Hi, thanks for the suggestions. I have created a segment named ContactLeftNode, then defined AnyKinLinear and AnyKinRotational to measure the relative distance between the frame of the segment and the global frame (act as constraints), and finally used AnyKinEqInterPolDriver. However, i found that the position of the segment is always constant (all the data follow the data in the first row in the CSV file). May I know why this happened?
Below are the details of the coding and the picture showing an overview of the environment model:
Main.EnvironmentModel ={
AnyFolder modelbedReac={
AnyInputFile readcsv =
{
FileName = BedReac_DATA +"/"+ Main.ModelSetup.TrialSpecificData.TrialFileName + ".csv"; //add the extension to the file name here
};
AnyFloat LBedReacX= readcsv.Data[0];
AnyFloat LBedReacY= readcsv.Data[1];
AnyFloat LBedReacZ= readcsv.Data[2];
AnyFloat RBedReacX= readcsv.Data[3];
AnyFloat RBedReacY= readcsv.Data[4];
AnyFloat RBedReacZ= readcsv.Data[5];
AnyFloat Dx_global_Left= readcsv.Data[6];
AnyFloat Dy_global_Left=readcsv.Data[7];
AnyFloat Dz_global_Left=readcsv.Data[8];
AnyFloat Rot1=readcsv.Data[9];
AnyFloat Rot2=readcsv.Data[10];
AnyFloat Rot3=readcsv.Data[11];
AnyFloat time=readcsv.T;
AnySeg Bed={
r0={ 0.5, 0.55, 2.38};
Mass=0;
Jii={0,0,0};
AnyDrawSurf DrwBox = {
FileName = "..\..\..\CAD-Files\box";
RGB = {0,0,1};
ScaleXYZ={4,0.27,2};
Opacity =0.5;
Face=-1;
};
};
AnyKinEqSimpleDriver beddriver={
AnyKinLinear trans={
AnyRefFrame &ref0= Main.EnvironmentModel.GlobalRef;
AnyRefFrame &ref1= Main.EnvironmentModel.modelbedReac.Bed;
};
AnyKinRotational rot={
AnyRefFrame &ref0= Main.EnvironmentModel.GlobalRef;
AnyRefFrame &ref1= Main.EnvironmentModel.modelbedReac.Bed;
Type=RotAxesAngles;
};
DriverPos={ 0.500, 0.55, 2.35,0,0,0};
DriverVel={0,0,0,0,0,0};
};
AnySeg ContactLeftNode = {
Mass = 0;
Jii = {0,0,0};
r0={ 0.8, 0.55, 2.08};
};
AnyKinLinear Left_Trans={
AnyRefFrame &ref0=Main.EnvironmentModel.GlobalRef;
AnyRefFrame &ref1=Main.EnvironmentModel.modelbedReac.ContactLeftNode;
Ref = 0;
};
AnyKinRotational Left_Rot={
AnyRefFrame &ref0=Main.EnvironmentModel.GlobalRef;
AnyRefFrame &ref1=Main.EnvironmentModel.modelbedReac.ContactLeftNode;
Type=RotAxesAngles;
};
AnyKinEqInterPolDriver Left_Motion = {
AnyKinLinear &ref0=.Left_Trans;
AnyKinRotational &ref1=.Left_Rot;
Type = PiecewiseLinear;
T = .time;
Data = {.Dx_global_Left, .Dy_global_Left, .Dz_global_Left, .Rot1, .Rot2, .Rot3};
};
AnyFunInterpol ForceFun = {
Data = {.LBedReacX,.LBedReacY,.LBedReacZ,.RBedReacX,.RBedReacY,.RBedReacZ};
T = .time;
Type=PiecewiseLinear;
};
AnyForce3D LeftBedReac= {
AnyRefFrame &ref=Main.EnvironmentModel.modelbedReac.ContactLeftNode;
F={.ForceFun(Main.Studies.InverseDynamicStudy.t)[0],.ForceFun(Main.Studies.InverseDynamicStudy.t)[1], -.ForceFun(Main.Studies.InverseDynamicStudy.t)[2]};
AnyDrawVector drF = {
Vec = .RefFrameOutput.F[0]/100; // Scale the length down
Line = {
Style = Line3DStyleFull;
Thickness = 0.01;
RGB = {1, 0, 0};
End = {
Style = Line3DCapStyleArrow; // This specifies the end to be an arrowhead
RGB = {1, 0, 0};
Thickness = 0.02; // The head begins with twice the thickness of the shaft
Length = 0.05;
};
};
// attach the arrow to the bed
AnyRefFrame &bedpoint = Main.EnvironmentModel.modelbedReac.ContactLeftNode;
};
};
};
};