Translation + Rotation of a segment by motion-capturing data

Hello everyone,

First of all I’d like to introduce myself. My name is Dieter and I’m
a student of medical engineering working at the Uni Ulm.
Then I would like to apologize about my poor knowledge on anybody-
script-language but I just started using the software and I worked
through most of the tutorials available on anybodytech.com.
Unfortunately, I’m not allowed to tell you too much about my project:

We have motion capturing data of an animal received by computer
tomographic imaging. At the moment, I’m trying to drive just one
segment by this data (highest located segment). These contain
informations about the x,y,z-translations and one rotation per
timestep. I found an example somewhere here in the group:


Main = {

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

     //Points used for defining the line
     AnyVec3  p1={0,0,0};
     AnyVec3  p2={0.2,0.2,0.4};
     AnyVec3  p3={0.4,0.3,0.3};
     AnyVec3  p4={0.7,0.4,0.1};
     AnyVec3  p5={0.9,0.5,0.1};
     AnyVec3  p6={0.95,-0.2,0.3};
     AnyVec3  p7={1.2,-0.3,0.6};
     AnyVec3  p8={1.5,-0.1,0.8};
     AnyVec3  p9={2,0.2,0.9};
     AnyVec3  p10={2.4,0.5,1};

     // Global Reference Frame
     AnyFixedRefFrame GlobalRef = {

       //Create some controlpoints

       AnyRefNode p1={sRel=..p1;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p2={sRel=..p2;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p3={sRel=..p3;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p4={sRel=..p4;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p5={sRel=..p5;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p6={sRel=..p6;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p7={sRel=..p7;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p8={sRel=..p8;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p9={sRel=..p9;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };
       AnyRefNode p10={sRel=..p10;
         AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
       };

     };  // Global reference frame

     AnySeg  Seg={
       Mass=0;Jii={0,0,0};
       AnySurfSphere  Sphere= {
         Radius=0.21;
         AnyDrawParamSurf drw={};
       };
     };

     AnyKinLinear lin={
       AnyFixedRefFrame  &ref1=.GlobalRef ;
       AnySeg  &ref2=.Seg;
     };
     AnyKinEq RotDrv={
       AnyKinRotational rot={
         AnyFixedRefFrame  &ref1=..GlobalRef ;
         AnySeg  &ref2=..Seg;
         Type=RotAxesAngles;
       };
     };
     //Interpolation driver
     AnyKinEqInterPolDriver Driver =  {
       Type = Bspline ;  //try to swicth between the different types
       BsplineOrder = 4;
       //      Type = Bezier ;   //try to swicth between the different
types
       //       Type = PiecewiseLinear ;//try to swicth between the
different types
       //FileName = "knecht.txt";
       T =({0,1,2,3,4,5,6,7,8,9}/9)*Main.MyStudy.tEnd ;
       //use the control points as data in the interpoaltion function
       Data ={
         {.p1[0],.p2[0],.p3[0],.p4[0],.p5[0],.p6[0],.p7[0],.p8[0],.p9
[0],.p10[0]},
         {.p1[1],.p2[1],.p3[1],.p4[1],.p5[1],.p6[1],.p7[1],.p8[1],.p9
[1],.p10[1]},
         {.p1[2],.p2[2],.p3[2],.p4[2],.p5[2],.p6[2],.p7[2],.p8[2],.p9
[2],.p10[2]}};

       AnyKinMeasure &ref = .lin;  //reference to the measue being
driven
     };

     //This section is just made in order to draw the trajectory
     AnyFixedRefFrame Chart1Ref ={

       Origin = -{5,5,5};
       AnyChart Chart1 =  {
         Style = {
           Sizes = {10,10,10};
           Axes = { Style = 0; };
         };

         Series =
         {
           AnyChartSerie series0 =           {
             Lines.RGB = {0,0,1};
             Abscissa = "Main.MyStudy.Output.Model.Seg.r[0]";
             Abscissa2 = "Main.MyStudy.Output.Model.Seg.r[1]";
             Value  = "Main.MyStudy.Output.Model.Seg.r[2]";
             Lines = {  Thickness = 1.5; };
           };
         };

         AbsAxis = {
           Visible = Off;
           Min = -5;
           Max = 5;
           AutoMin = Off;
           AutoMax = Off;
         };

         AbsAxis2 =
         {
           Visible = Off;
           Min = -5;
           Max = 5;
           AutoMin = Off;
           AutoMax = Off;
         };

         ValueAxis =
         {
           Visible = Off;
           Min = -5;
           Max = 5;
           AutoMin = Off;
           AutoMax = Off;
         };
       };
     };  //chart
   }; // MyModel

   // The study: Operations to be performed on the model
   AnyBodyStudy MyStudy = {
     AnyFolder &Model = .Model;
     RecruitmentSolver = MinMaxSimplex;
     Gravity = {0.0, -9.81, 0.0};
     nStep=1000;
   };
};  // Main

Actually it pretty much works fine but I additionally would like to
rotate the segment. How can I achieve that?

Regards

Dieter

Hi Dieter

Welcome to the group

If you have xyz rotations for each segment in each time step you can drive
these rotations in the very same way as done in the code you listed, the
only difference will be that instead of driving the lin mearsure you will
driver the rotational measure, so something like this

AnyKinRotational rot={
AnyFixedRefFrame &ref1=…GlobalRef ;
AnySeg &ref2=…Seg;
Type=RotAxesAngles;
};

AnyKinEqInterPolDriver DriverRot = {
Type = Bspline ; //try to swicth Rotbetween the different types
BsplineOrder = 4;
// Type = Bezier ; //try to swicth between the different types
// Type = PiecewiseLinear ;//try to swicth between the different types
FileName = “knechtrotations???.txt”;
T =({0,1,2,3,4,5,6,7,8,9}/9)*Main.MyStudy.tEnd ;
//use the control points as data in the interpoaltion function

AnyKinMeasure &ref = .rot; //reference to the measue being driven
};

The RotDrv object in the code should be removed since the driver above will
drive the same dof.

Before using this setup you need to make sure about the sequence of the
rotation in the measured data, this must be matched by the sequence and type
of rotations in the rotational measure above.

This setup will in principle allow you to drive all the segments in the
model one by one, but it will not you apply joints between the segments if
they are already fully kinematically determined. So if you plan to
introduce joints you will need not to drive 6 dof of each of the segments.

I you plan to introduce joints I think you should try to look at the Gait3D
model in the repository. In this model the segments are driven by recorded
markers, it is not exactly the same but the principles are, you have to use
only a selected amount of you data not all of it.

There is a webcast about this model please see

Gait Modeling (Dr. John Rasmussen, 31. August, 2006)

http://www.anybodytech.com/196.html

The gait model is driven by driving selected dof. of a number of markers.
The lower extremity model has 18 dof. so only this amount of dof can be
driven no more no less.

So in your model you need to find out how many dof you have, and then
carefully select the dof to drive from each of the markers and which
rotations to drive. Please have a look in the JointandDrivers.any file of
the Gait3D model, here you can see how selected dof of each of the markers
are used for driving the model. In the linear measures used in this file the
local reference system of the segments are used as the basis for the
measurements. This is done by setting the line Ref=0, it is important to
understand this concept, if needed please refer to manual.

I hope this helps you move on, otherwise please write again

Best regards

Søren, AnyBody Support


From: anyscript@yahoogroups.com [mailto:anyscript@yahoogroups.com] On Behalf
Of dieterkassgim
Sent: 20 November 2007 14:10
To: anyscript@yahoogroups.com
Subject: [AnyScript] Translation + Rotation of a segment by motion-capturing
data

Hello everyone,

First of all I’d like to introduce myself. My name is Dieter and I’m
a student of medical engineering working at the Uni Ulm.
Then I would like to apologize about my poor knowledge on anybody-
script-language but I just started using the software and I worked
through most of the tutorials available on anybodytech.com.
Unfortunately, I’m not allowed to tell you too much about my project:

We have motion capturing data of an animal received by computer
tomographic imaging. At the moment, I’m trying to drive just one
segment by this data (highest located segment). These contain
informations about the x,y,z-translations and one rotation per
timestep. I found an example somewhere here in the group:


Main = {

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

//Points used for defining the line
AnyVec3 p1={0,0,0};
AnyVec3 p2={0.2,0.2,0.4};
AnyVec3 p3={0.4,0.3,0.3};
AnyVec3 p4={0.7,0.4,0.1};
AnyVec3 p5={0.9,0.5,0.1};
AnyVec3 p6={0.95,-0.2,0.3};
AnyVec3 p7={1.2,-0.3,0.6};
AnyVec3 p8={1.5,-0.1,0.8};
AnyVec3 p9={2,0.2,0.9};
AnyVec3 p10={2.4,0.5,1};

// Global Reference Frame
AnyFixedRefFrame GlobalRef = {

//Create some controlpoints

AnyRefNode p1={sRel=..p1;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p2={sRel=..p2;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p3={sRel=..p3;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p4={sRel=..p4;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p5={sRel=..p5;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p6={sRel=..p6;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p7={sRel=..p7;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p8={sRel=..p8;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p9={sRel=..p9;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};
AnyRefNode p10={sRel=..p10;
AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
};

}; // Global reference frame

AnySeg Seg={
Mass=0;Jii={0,0,0};
AnySurfSphere Sphere= {
Radius=0.21;
AnyDrawParamSurf drw={};
};
};

AnyKinLinear lin={
AnyFixedRefFrame &ref1=.GlobalRef ;
AnySeg &ref2=.Seg;
};
AnyKinEq RotDrv={
AnyKinRotational rot={
AnyFixedRefFrame &ref1=..GlobalRef ;
AnySeg &ref2=..Seg;
Type=RotAxesAngles;
};
};
//Interpolation driver
AnyKinEqInterPolDriver Driver = {
Type = Bspline ; //try to swicth between the different types
BsplineOrder = 4;
// Type = Bezier ; //try to swicth between the different
types
// Type = PiecewiseLinear ;//try to swicth between the
different types
//FileName = "knecht.txt";
T =({0,1,2,3,4,5,6,7,8,9}/9)*Main.MyStudy.tEnd ;
//use the control points as data in the interpoaltion function
Data ={
{.p1[0],.p2[0],.p3[0],.p4[0],.p5[0],.p6[0],.p7[0],.p8[0],.p9
[0],.p10[0]},
{.p1[1],.p2[1],.p3[1],.p4[1],.p5[1],.p6[1],.p7[1],.p8[1],.p9
[1],.p10[1]},
{.p1[2],.p2[2],.p3[2],.p4[2],.p5[2],.p6[2],.p7[2],.p8[2],.p9
[2],.p10[2]}};

AnyKinMeasure &ref = .lin; //reference to the measue being
driven
};

//This section is just made in order to draw the trajectory
AnyFixedRefFrame Chart1Ref ={

Origin = -{5,5,5};
AnyChart Chart1 = {
Style = {
Sizes = {10,10,10};
Axes = { Style = 0; };
};

Series =
{
AnyChartSerie series0 = {
Lines.RGB = {0,0,1};
Abscissa = "Main.MyStudy.Output.Model.Seg.r[0]";
Abscissa2 = "Main.MyStudy.Output.Model.Seg.r[1]";
Value = "Main.MyStudy.Output.Model.Seg.r[2]";
Lines = { Thickness = 1.5; };
};
};

AbsAxis = {
Visible = Off;
Min = -5;
Max = 5;
AutoMin = Off;
AutoMax = Off;
};

AbsAxis2 =
{
Visible = Off;
Min = -5;
Max = 5;
AutoMin = Off;
AutoMax = Off;
};

ValueAxis =
{
Visible = Off;
Min = -5;
Max = 5;
AutoMin = Off;
AutoMax = Off;
};
};
}; //chart
}; // MyModel

// The study: Operations to be performed on the model
AnyBodyStudy MyStudy = {
AnyFolder &Model = .Model;
RecruitmentSolver = MinMaxSimplex;
Gravity = {0.0, -9.81, 0.0};
nStep=1000;
};
}; // Main

Actually it pretty much works fine but I additionally would like to
rotate the segment. How can I achieve that?

Regards

Dieter

[Non-text portions of this message have been removed]

Thanks for the very detailed answer Søren. I will try your
suggestions.

Regards

Dieter

— In anyscript@yahoogroups.com, “AnyBody Support” <support@…>
wrote:
>
> Hi Dieter
>
>
>
> Welcome to the group
>
>
>
> If you have xyz rotations for each segment in each time step you
can drive
> these rotations in the very same way as done in the code you
listed, the
> only difference will be that instead of driving the lin mearsure
you will
> driver the rotational measure, so something like this
>
>
>
>
>
> AnyKinRotational rot={
> AnyFixedRefFrame &ref1=…GlobalRef ;
> AnySeg &ref2=…Seg;
> Type=RotAxesAngles;
> };
>
>
>
>
>
> AnyKinEqInterPolDriver DriverRot = {
> Type = Bspline ; //try to swicth Rotbetween the different types
> BsplineOrder = 4;
> // Type = Bezier ; //try to swicth between the different types
> // Type = PiecewiseLinear ;//try to swicth between the different
types
> FileName = “knechtrotations???.txt”;
> T =({0,1,2,3,4,5,6,7,8,9}/9)*Main.MyStudy.tEnd ;
> //use the control points as data in the interpoaltion function
>
> AnyKinMeasure &ref = .rot; //reference to the measue being driven
> };
>
>
>
> The RotDrv object in the code should be removed since the driver
above will
> drive the same dof.
>
> Before using this setup you need to make sure about the sequence of
the
> rotation in the measured data, this must be matched by the sequence
and type
> of rotations in the rotational measure above.
>
>
>
> This setup will in principle allow you to drive all the segments in
the
> model one by one, but it will not you apply joints between the
segments if
> they are already fully kinematically determined. So if you plan to
> introduce joints you will need not to drive 6 dof of each of the
segments.
>
>
>
> I you plan to introduce joints I think you should try to look at
the Gait3D
> model in the repository. In this model the segments are driven by
recorded
> markers, it is not exactly the same but the principles are, you
have to use
> only a selected amount of you data not all of it.
>
>
>
> There is a webcast about this model please see
>
>
>
> Gait Modeling (Dr. John Rasmussen, 31. August, 2006)
>
> http://www.anybodytech.com/196.html
>
>
>
> The gait model is driven by driving selected dof. of a number of
markers.
> The lower extremity model has 18 dof. so only this amount of dof
can be
> driven no more no less.
>
>
>
> So in your model you need to find out how many dof you have, and
then
> carefully select the dof to drive from each of the markers and which
> rotations to drive. Please have a look in the JointandDrivers.any
file of
> the Gait3D model, here you can see how selected dof of each of the
markers
> are used for driving the model. In the linear measures used in this
file the
> local reference system of the segments are used as the basis for the
> measurements. This is done by setting the line Ref=0, it is
important to
> understand this concept, if needed please refer to manual.
>
>
>
> I hope this helps you move on, otherwise please write again
>
>
>
> Best regards
>
> Søren, AnyBody Support
>
>
>
>
>
>
>
>
>
> _____
>
> From: anyscript@yahoogroups.com [mailto:anyscript@yahoogroups.com]
On Behalf
> Of dieterkassgim
> Sent: 20 November 2007 14:10
> To: anyscript@yahoogroups.com
> Subject: [AnyScript] Translation + Rotation of a segment by motion-
capturing
> data
>
>
>
> Hello everyone,
>
> First of all I’d like to introduce myself. My name is Dieter and
I’m
> a student of medical engineering working at the Uni Ulm.
> Then I would like to apologize about my poor knowledge on anybody-
> script-language but I just started using the software and I worked
> through most of the tutorials available on anybodytech.com.
> Unfortunately, I’m not allowed to tell you too much about my
project:
>
> We have motion capturing data of an animal received by computer
> tomographic imaging. At the moment, I’m trying to drive just one
> segment by this data (highest located segment). These contain
> informations about the x,y,z-translations and one rotation per
> timestep. I found an example somewhere here in the group:
>
>


> Main = {
>
> // The actual body model goes in this folder
> AnyFolder Model = {
>
> //Points used for defining the line
> AnyVec3 p1={0,0,0};
> AnyVec3 p2={0.2,0.2,0.4};
> AnyVec3 p3={0.4,0.3,0.3};
> AnyVec3 p4={0.7,0.4,0.1};
> AnyVec3 p5={0.9,0.5,0.1};
> AnyVec3 p6={0.95,-0.2,0.3};
> AnyVec3 p7={1.2,-0.3,0.6};
> AnyVec3 p8={1.5,-0.1,0.8};
> AnyVec3 p9={2,0.2,0.9};
> AnyVec3 p10={2.4,0.5,1};
>
> // Global Reference Frame
> AnyFixedRefFrame GlobalRef = {
>
> //Create some controlpoints
>
> AnyRefNode p1={sRel=..p1;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p2={sRel=..p2;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p3={sRel=..p3;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p4={sRel=..p4;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p5={sRel=..p5;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p6={sRel=..p6;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p7={sRel=..p7;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p8={sRel=..p8;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p9={sRel=..p9;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
> AnyRefNode p10={sRel=..p10;
> AnyDrawRefFrame drw={ScaleXYZ={0.01,0.01,0.01};};
> };
>
> }; // Global reference frame
>
> AnySeg Seg={
> Mass=0;Jii={0,0,0};
> AnySurfSphere Sphere= {
> Radius=0.21;
> AnyDrawParamSurf drw={};
> };
> };
>
> AnyKinLinear lin={
> AnyFixedRefFrame &ref1=.GlobalRef ;
> AnySeg &ref2=.Seg;
> };
> AnyKinEq RotDrv={
> AnyKinRotational rot={
> AnyFixedRefFrame &ref1=..GlobalRef ;
> AnySeg &ref2=..Seg;
> Type=RotAxesAngles;
> };
> };
> //Interpolation driver
> AnyKinEqInterPolDriver Driver = {
> Type = Bspline ; //try to swicth between the different types
> BsplineOrder = 4;
> // Type = Bezier ; //try to swicth between the different
> types
> // Type = PiecewiseLinear ;//try to swicth between the
> different types
> //FileName = "knecht.txt";
> T =({0,1,2,3,4,5,6,7,8,9}/9)*Main.MyStudy.tEnd ;
> //use the control points as data in the interpoaltion function
> Data ={
> {.p1[0],.p2[0],.p3[0],.p4[0],.p5[0],.p6[0],.p7[0],.p8[0],.p9
> [0],.p10[0]},
> {.p1[1],.p2[1],.p3[1],.p4[1],.p5[1],.p6[1],.p7[1],.p8[1],.p9
> [1],.p10[1]},
> {.p1[2],.p2[2],.p3[2],.p4[2],.p5[2],.p6[2],.p7[2],.p8[2],.p9
> [2],.p10[2]}};
>
> AnyKinMeasure &ref = .lin; //reference to the measue being
> driven
> };
>
> //This section is just made in order to draw the trajectory
> AnyFixedRefFrame Chart1Ref ={
>
> Origin = -{5,5,5};
> AnyChart Chart1 = {
> Style = {
> Sizes = {10,10,10};
> Axes = { Style = 0; };
> };
>
> Series =
> {
> AnyChartSerie series0 = {
> Lines.RGB = {0,0,1};
> Abscissa = "Main.MyStudy.Output.Model.Seg.r[0]";
> Abscissa2 = "Main.MyStudy.Output.Model.Seg.r[1]";
> Value = "Main.MyStudy.Output.Model.Seg.r[2]";
> Lines = { Thickness = 1.5; };
> };
> };
>
> AbsAxis = {
> Visible = Off;
> Min = -5;
> Max = 5;
> AutoMin = Off;
> AutoMax = Off;
> };
>
> AbsAxis2 =
> {
> Visible = Off;
> Min = -5;
> Max = 5;
> AutoMin = Off;
> AutoMax = Off;
> };
>
> ValueAxis =
> {
> Visible = Off;
> Min = -5;
> Max = 5;
> AutoMin = Off;
> AutoMax = Off;
> };
> };
> }; //chart
> }; // MyModel
>
> // The study: Operations to be performed on the model
> AnyBodyStudy MyStudy = {
> AnyFolder &Model = .Model;
> RecruitmentSolver = MinMaxSimplex;
> Gravity = {0.0, -9.81, 0.0};
> nStep=1000;
> };
> }; // Main
> 

>
> Actually it pretty much works fine but I additionally would like to
> rotate the segment. How can I achieve that?
>
> Regards
>
> Dieter
> –
>
>
>
>
>
> [Non-text portions of this message have been removed]
>