Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions A_Getting_started_anyscript/lesson3.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
::: {rst-class} break
:::

(How_to_write_AnyScript_L3)=
# Lesson 3: Connecting Segments by Joints

:::{note}
Expand Down
2 changes: 1 addition & 1 deletion ForceDependentKinematics/Downloads/DemoSimpleKnee2.any
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Main = {
sRel = {0.0, 0.4, 0.0};
};
AnyRefNode Quadriceps = {
sRel={0.00, 0.3, 0.0};
sRel={0.05, 0.3, 0.0};
};
};

Expand Down
2 changes: 1 addition & 1 deletion ForceDependentKinematics/Downloads/DemoSimpleKnee3.any
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Main = {

// Origin of the quadriceps muscle.
AnyRefNode Quadriceps = {
sRel = {0.00, 0.3, 0.0};
sRel = {0.06, 0.0, 0.0};
};
AnyDrawSeg drw ={
Opacity = 0.5;
Expand Down
2 changes: 1 addition & 1 deletion ForceDependentKinematics/Downloads/DemoSimpleKnee4.any
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Main = {

// Origin of the quadriceps muscle.
AnyRefNode Quadriceps = {
sRel = {0.00, 0.3, 0.0};
sRel = {0.06, 0.0, 0.0};
};
AnyDrawSeg drw ={
Opacity = 0.5;
Expand Down
139 changes: 139 additions & 0 deletions ForceDependentKinematics/Snippets/lesson2/snip.SimpleKnee.main-1.any
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// This model is for the FDK tutorial. It is the starting point for the
//definition of a simple knee with force-dependent kinematics features.

Main = {

/// The actual body model goes in this folder
AnyFolder MyModel = {

// Global Reference Frame
AnyFixedRefFrame GlobalRef = {
}; // Global reference frame

// Definition of the thigh segment
AnySeg Thigh = {
r0 = {0.4, 0, 0};
Axes0 = RotMat(pi/2,z);
Mass = 5;
Jii = {0.3, 0.01, 0.3}*0.7;

// This is the center of the nominal knee joint. Notice that
// the actual knee center will vary when we use FDK.
AnyRefNode KneeCenter = {
sRel = {-0.03, -0.4, 0.0};

// Define a cylinder representing the femoral condyle. The quadriceps
// will wrap about this cylinder.
AnyRefNode SurfCenter = {
sRel = {0,0,-0.05};
AnySurfCylinder Condyle = {
Radius = 0.06;
Length = 0.1;
AnyDrawParamSurf drw = {
RGB = {0, 0, 1};
};
};
};
};
AnyRefNode HipCenter = {
sRel = {0.0, 0.4, 0.0};
};

// Origin of the quadriceps muscle.
AnyRefNode Quadriceps = {
sRel = {0.06, 0.0, 0.0};
};
AnyDrawSeg drw ={
Opacity = 0.5;
};
};

AnySeg Shank = {
r0 = {0.8, -0.4, 0.0};
Mass = 4;
Jii = {0.4, 0.01, 0.4}*0.4;
AnyDrawSeg drw ={
Opacity = 0.5;
RGB = {1,0,0};
};

AnyRefNode KneeCenter = {
sRel = {0.0, 0.4, 0.0};
};
AnyRefNode Quadriceps = {
sRel={0.05, 0.3, 0.0};
};
};

// Hip joint between the thigh and ground
AnyRevoluteJoint Hip = {
AnyRefFrame &ref1 = .GlobalRef;
AnyRefFrame &ref2 = .Thigh.HipCenter;
};

// Fix the hip joint at a constant angle
AnyKinEqSimpleDriver HipAngle = {
AnyRevoluteJoint &Hip = .Hip;
DriverPos = {pi/2};
DriverVel = {0};
};

// Knee joint. Notice that this is only going to be the nominal joint.
// The actual position of the knee joint center will depend on the forces
// acting upon it. Notice that we list the shank before the thigh. This
// defines the knee joint in the shank coordinate system and we can
// relate the reaction forces to the directon of the tibial plateau.
//# BEGIN SNIPPET 1
AnyRevoluteJoint KneeJoint = {
AnyRefFrame &Shank = .Shank.KneeCenter;
AnyRefFrame &Thigh = .Thigh.KneeCenter;

§// Prepare the joint for FDK: Define the reaction types in x and y
// directions to be FDK-dependent. These reaction forces must then
// be switched off and provided by some elastic element that we
// define explicitly below.
Constraints = {
CType = {ForceDep, ForceDep, Hard, Hard, Hard};
Reaction.Type={Off,Off,On,On,On};
};§
};
//# END SNIPPET 1

// Knee driver- just a simple knee extension.
AnyKinEqSimpleDriver KneeDriver = {
DriverPos = {pi/2};
DriverVel = {-pi/30};
AnyRevoluteJoint &KneeJoint = .KneeJoint;
Reaction.Type={Off}; // The muscles must carry this movement
};

// Muscle
AnyMuscleShortestPath Quadriceps = {
AnyMuscleModel MusMdl = {
F0 = 6000;
};
AnyRefFrame &org = .Thigh.Quadriceps;
AnyParamSurf &wrap = .Thigh.KneeCenter.SurfCenter.Condyle;
AnyRefFrame &ins = .Shank.Quadriceps;
SPLine = {
StringMesh = 50;
InitWrapPosVectors = {{0.1, 0.1, 0},{0.1, 0.2, 0}};
};
AnyDrawMuscle drw = {
Bulging = 1;
MaxStress = 2500;
};
};
}; // MyModel

AnyBodyStudy Study = {
AnyFolder &Model = .MyModel;
Gravity = {0.0, -9.81, 0.0};
tStart = 1;
tEnd = 10;
nStep = 100;
};

}; // Main


149 changes: 149 additions & 0 deletions ForceDependentKinematics/Snippets/lesson2/snip.SimpleKnee.main-2.any
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// This model is for the FDK tutorial. It is the starting point for the
//definition of a simple knee with force-dependent kinematics features.

Main = {

/// The actual body model goes in this folder
AnyFolder MyModel = {

// Global Reference Frame
AnyFixedRefFrame GlobalRef = {
}; // Global reference frame

// Definition of the thigh segment
AnySeg Thigh = {
r0 = {0.4, 0, 0};
Axes0 = RotMat(pi/2,z);
Mass = 5;
Jii = {0.3, 0.01, 0.3}*0.7;

// This is the center of the nominal knee joint. Notice that
// the actual knee center will vary when we use FDK.
AnyRefNode KneeCenter = {
sRel = {-0.03, -0.4, 0.0};

// Define a cylinder representing the femoral condyle. The quadriceps
// will wrap about this cylinder.
AnyRefNode SurfCenter = {
sRel = {0,0,-0.05};
AnySurfCylinder Condyle = {
Radius = 0.06;
Length = 0.1;
AnyDrawParamSurf drw = {
RGB = {0, 0, 1};
};
};
};
};
AnyRefNode HipCenter = {
sRel = {0.0, 0.4, 0.0};
};

// Origin of the quadriceps muscle.
AnyRefNode Quadriceps = {
sRel = {0.06, 0.0, 0.0};
};
AnyDrawSeg drw ={
Opacity = 0.5;
};
};

AnySeg Shank = {
r0 = {0.8, -0.4, 0.0};
Mass = 4;
Jii = {0.4, 0.01, 0.4}*0.4;
AnyDrawSeg drw ={
Opacity = 0.5;
RGB = {1,0,0};
};

AnyRefNode KneeCenter = {
sRel = {0.0, 0.4, 0.0};
};
AnyRefNode Quadriceps = {
sRel={0.05, 0.3, 0.0};
};
};

// Hip joint between the thigh and ground
AnyRevoluteJoint Hip = {
AnyRefFrame &ref1 = .GlobalRef;
AnyRefFrame &ref2 = .Thigh.HipCenter;
};

// Fix the hip joint at a constant angle
AnyKinEqSimpleDriver HipAngle = {
AnyRevoluteJoint &Hip = .Hip;
DriverPos = {pi/2};
DriverVel = {0};
};

// Knee joint. Notice that this is only going to be the nominal joint.
// The actual position of the knee joint center will depend on the forces
// acting upon it. Notice that we list the shank before the thigh. This
// defines the knee joint in the shank coordinate system and we can
// relate the reaction forces to the directon of the tibial plateau.
//# BEGIN SNIPPET 1
AnyRevoluteJoint KneeJoint = {
AnyRefFrame &Shank = .Shank.KneeCenter;
AnyRefFrame &Thigh = .Thigh.KneeCenter;

// Prepare the joint for FDK: Define the reaction types in x and y
// directions to be FDK-dependent. These reaction forces must then
// be switched off and provided by some elastic element that we
// define explicitly below.
Constraints = {
CType = {ForceDep, ForceDep, Hard, Hard, Hard};
Reaction.Type={Off,Off,On,On,On};
};
};
§// Define springs in the knee, simulating the effect of cartilage
// and ligaments.
AnyForce KneeStiffness = {
AnyKinLinear &lin = Main.MyModel.KneeJoint.Linear;
F = {-1000*lin.Pos[0], -5000*lin.Pos[1], 0};
};§

//# END SNIPPET 1

// Knee driver- just a simple knee extension.
AnyKinEqSimpleDriver KneeDriver = {
DriverPos = {pi/2};
DriverVel = {-pi/30};
AnyRevoluteJoint &KneeJoint = .KneeJoint;
Reaction.Type={Off}; // The muscles must carry this movement
};

// Muscle
AnyMuscleShortestPath Quadriceps = {
AnyMuscleModel MusMdl = {
F0 = 6000;
};
AnyRefFrame &org = .Thigh.Quadriceps;
AnyParamSurf &wrap = .Thigh.KneeCenter.SurfCenter.Condyle;
AnyRefFrame &ins = .Shank.Quadriceps;
SPLine = {
StringMesh = 50;
InitWrapPosVectors = {{0.1, 0.1, 0},{0.1, 0.2, 0}};
};
AnyDrawMuscle drw = {
Bulging = 1;
MaxStress = 2500;
};
};
}; // MyModel

//# BEGIN SNIPPET 2
AnyBodyStudy Study = {
AnyFolder &Model = .MyModel;
Gravity = {0.0, -9.81, 0.0};
tStart = 1;
tEnd = 10;
nStep = 100;
§InverseDynamics.ForceDepKinOnOff=On;§
};
//# END SNIPPET 2

}; // Main


Loading