Message Boards Message Boards

0
|
16055 Views
|
35 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Stewart Platform

Posted 9 years ago
Attachments:
POSTED BY: novio8
35 Replies
Posted 9 years ago

Hi Eric, I'v found the solution to the problem: So your Code:

ExportMotionPlan[poses_List, legoffsets_: {0, 0, 0, 0, 0, 0}] :=
 Module[{framerate = 10, lengths, tabledata, time1, time2},
  lengths = {poses[[1, 2 ;; 7]]};
  time1 := poses[[1, 1]];

  Do[
   (
    time2 := wp[[1]];
    lengths = 
     Join[lengths, 
      Rest@PoseRange[{Last[lengths], wp[[2 ;; 7]]}, framerate, time1, 
        time2]];
    time1 = time2;
    ),
   {wp, Rest[poses]}];

  AppendTo[lengths, Last[lengths]];
  lengths = Map[PoseLegLengths, lengths];
  tabledata = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];
  {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath1.txt"}], {{"LegLengths", tabledata}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata]]};

  lengths = Map[# + legoffsets &, lengths];
  tabledata = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];
  {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath2.txt"}], {{"LegLengths", tabledata}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata]]}
  ]

is correct and the error I was getting: Syntax::sntxf: "legoffsets_:" cannot be followed by "{1.1313669977935081,1.1313669977935081,1.1313669977935081,1.1313669977935081,1.1313669977935081,1.131366997793508 can be avoided just by deleting the colon in egoffsets_: and retyping it again.

I don't know why, but it works.

I wonder if you have any suggestion for my next question:

In Motion plan one can enter platform positions at certain time, then the positions (frames) are calculated in linear way. I wold like to change that by using for instance logaritmic or any other curve.

Any Ideas how.

Regards

Mario

POSTED BY: novio8

Hi Mario,

Did you use something like:

ExportMotionPlan[motionPlan,legoffsets_: -{0.17035,0.17035,0.17035,0.17035,0.17035,0.17035}]?

The legoffsets_:{...} idiom is only used in the definition of the function. When you call the function, use:

ExportMotionPlan[ motionPlan, -{0.17035,0.17035,0.17035,0.17035,0.17035,0.17035} ]

Note that using an offset of 1.1313669977935081 is not realistic because the platform height is only 0.15 units. You will get leg lengths, but they won't be very meaningful. The purpose of subtracting the offsets is to get control values for the servo actuators.

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, I copied your Code at the end of the Notebook. Replaced Zeroes with Offset Value and I'v received the following error: Syntax::sntxf: "legoffsets_:" cannot be followed by "{1.1313669977935081,1.1313669977935081,1.1313669977935081,1.1313669977935081,1.1313669977935081,1.1313669977935081}". Mario

POSTED BY: novio8

Hi Mario,

You can try this:

ExportMotionPlan[poses_List, legoffsets_: {0, 0, 0, 0, 0, 0}] :=
 Module[{framerate = 10, lengths, tabledata, time1, time2},
  lengths = {poses[[1, 2 ;; 7]]};
  time1 := poses[[1, 1]];

  Do[
   (
    time2 := wp[[1]];
    lengths = 
     Join[lengths, 
      Rest@PoseRange[{Last[lengths], wp[[2 ;; 7]]}, framerate, time1, 
        time2]];
    time1 = time2;
    ),
   {wp, Rest[poses]}];

  AppendTo[lengths, Last[lengths]];
  lengths = Map[PoseLegLengths, lengths];
  tabledata = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];
  {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath1.txt"}], {{"LegLengths", tabledata}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata]]};

  lengths = Map[# + legoffsets &, lengths];
  tabledata = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];
  {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath2.txt"}], {{"LegLengths", tabledata}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata]]}
  ]

I haven't tested this code, of course, because I don't have SystemModeler.

A good value to test the offsets would be -0.17035, the zero-position leg length.

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, yes that is correct. I would like to Export two Motion Plans, one

as it is and the other one with Leg Offsets, but I was not successful

by copying ExportMotionPlan Cell and Entering Values in Offset Field.

Any suggestions?

Regards Mario

POSTED BY: Updating Name

Hi Mario,

Here is what the legoffsets are about:

Suppose you are using hydraulic actuators for the legs. The control signal tells the actuator to extend so many meters from the retracted position. The retracted position is the "legoffset". The distance that you want the actuator to extend is the calculated length minus the retracted length.

So, the legoffset could have been called "retracted length" and the code could have subtracted the legoffset instead of adding it. That would have been a little clearer.

On the other hand, the neutral position might be the reference length, depending on the way the software is arranged, so this could be the offset.

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, yes that's what I had in mind to import path file back at the end of this Notebook or even a new one.

Mario

POSTED BY: novio8

Hi Mario,

I haven't been able to install SystemModeler on my old XP computer, so I don't have the elements needed to do the export. You'll have to stick to the notebook output for this discussion.

Can you re-phase your problem? Note that subtracting leg lengths will not give the motion that was originally calculated. Why do you want to do this? Or are you just verifying that the path will be different?

Generating a path from the leg lengths is called the forward kinematics. It was this problem that was difficult to solve in 1999 when I discovered that the path of the intended Stewart platform could hit the walls of the pit it was to be housed in.

Maybe you could import the path file back into Mathematica and we could work on it.

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, I'm also confused about leg offsets purpose.

What I would like to do is to read PlatformPath.txt that was generated by ExportMotionPlan....

and substract initial leg length or any other arbitrary number from all of leg lengths written in file PlatformPath.txt and save it as PlatformPath 2.txt

Mario

POSTED BY: novio8
POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric,

of course you are right.

I added the following to the end of NoteBook to generate another file PlatformPath 2.txt wit leg offsets

ExportMotionPlan[poses_List, legoffsets_: {-1.13137, -1.13137, -1.13137, -1.13137, -1.13137, -1.13137}] := 
 Module[{framerate = 50, lengths, tabledata, time1, time2}, 
  lengths = {poses[[1, 2 ;; 7]]};
  time1 := poses[[1, 1]];
  Do[(time2 := wp[[1]];
    lengths = 
     Join[lengths, 
      Rest@PoseRange[{Last[lengths], wp[[2 ;; 7]]}, framerate, time1, 
        time2]];
    time1 = time2;), {wp, Rest[poses]}];
  AppendTo[lengths, Last[lengths]];
  lengths = Map[PoseLegLengths, lengths];
  lengths = Map[# + legoffsets &, lengths];
  tabledata = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];
  {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath 2.txt"}], {{"LegLengths", tabledata}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata]]}
  ]
motionPlan = {
   {0, 0, 0, 0, 0, 0, 0},
   {1, 0, 0.01, 0, 0, 0, 0},
   {3, 0, -0.03, 0, 0, 0, 0},
   {4, 0, 0.04, 0, 0, 0, 0},
   {4.5, 0, -0.045, 0, 0, 0, 0},
   {8.5, 0, 0.3, 0, 0, 0, 0},
   {10.5, 0, 0.3, 0, 0, 10 \[Degree], 0},
   {16, 0, 0, 0, 0, 0, 0}
   };
ExportMotionPlan[motionPlan];

Unfortunately the result is not what I expected. What am I doing wrong this time? Mario

POSTED BY: novio8
POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric , thank you again.

I replaced original code with yours, what is confusing me is whether

motionPlan = {
   {0, 0, 0.00, 0, 0, 0, 0},
   {1, 0, 0.01, 0, 0, 0, 0},
   {3, 0, -0.03, 0, 0, 0, 0},
   {4, 0, 0.04, 0, 0, 0, 0},
   {4.5, 0, -0.045, 0, 0, 0, 0}
   };

is Short test motion plan or Long demonstration motion plan?

Regards

Mario

POSTED BY: Updating Name
POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, yeah me too. I would like to modify the code so that I can enter pose data in Long demonstration motion plan but every second as it is now, but instead only at certain time positions: like the following example:

pose 1 at 1sec,

pose 2 at 4sec,

pose 3 at 4,5sec,

etc. Any suggestions ? Mario

POSTED BY: novio8

Hi Mario,

I learned a lot from this discussion. Please keep asking.

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, yes you are right, one has to follow certain rules like shift_enter.

You are a great help. I have many questions but I don't want to bother you

too much ...with all of them.

Thanks

Mario

POSTED BY: novio8
POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, I watched Wolfram Video ScreenCast at http://www.wolfram.com/broadcast/video.php?c=202&v=835

and I'm still confused about double flip y,z and Phi.

I also want to change the number of poses per second, originally 10 to 50.

I'v changed frame rate from 10 to 50, but I get the same amount of lines in file PlatformPath.txt.

ExportMotionPlan[poses_List, legoffsets_: {0, 0, 0, 0, 0, 0}] :=

 Module[{framerate = 50, lengths, tabledata},
  lengths = {First[poses]};
  Do[lengths = 
    Join[lengths, 
     Rest@PoseRange[{Last[lengths], wp}, framerate]], {wp, 
    Rest[poses]}]; AppendTo[lengths, Last[lengths]];
  lengths = Map[PoseLegLengths, lengths];
  lengths = Map[# + legoffsets &, lengths];
  tabledata = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, 
    lengths]; {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath.txt"}], {{"LegLengths", tabledata}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata]]}

Mario

POSTED BY: novio8

Edwards & Penny p840

This is the way spherical coordinates are usually presented, but Mathematica interchanges theta and phi. When theta is zero in PoseLegEndpoints[], (phi in the diagram), the vector is pointing straight up, right at the north pole.

This vector is the normal to the platform surface; that is, the platform surface has to move so that its surface is normal to the vector OP in the diagram.

This is what the line of code

RotationTransform[{{0,1,0},{Sin[\[Theta]]Cos[\[Phi]],Cos[\[Theta]],Sin[\[Theta]]Sin[\[Phi]]}}]

does. It takes the vector {0,1,0} (the vertical) and transforms it to {Sin[\[Theta]]Cos[\[Phi]],Cos[\[Theta]],Sin[\[Theta]]Sin[\[Phi]]}.

The {0,1,0} vector is the z axis in the diagram and the OP vector is {Sin[\[Theta]]Cos[\[Phi]],Cos[\[Theta]],Sin[\[Theta]]Sin[\[Phi]]}.

But the author has thrown a double whammy by making the y axis the vertical and interchanging theta and phi.

Now look at the z axis in the diagram. If the OP vector is on the z axis, any value of theta (in the diagram) will not change the vertical position of the vector OP.

So the PoseLegEndpoints[] is correct in not changing the leg lengths if theta is zero and phi is any other value.

Does that make sense?

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago

yes this is true for SphericalPlot3D. But original Inverse Kinematics Calculations are wrong. If you enter 5cm change in x,y z or correctly x,z,y direction you get the following results :

{PoseLegLengths[{0, 0, 0, 0, 0, 0}], PoseLegLengths[{0.05, 0, 0, 0, 0, 0}]}

{{0.17035, 0.17035, 0.17035, 0.17035, 0.17035, 0.17035}, {0.155246, 0.19491, 0.180185, 0.180185, 0.19491, 0.155246}}

{PoseLegLengths[{0, 0, 0, 0, 0, 0}], PoseLegLengths[{0, 0.05, 0, 0, 0, 0}]}

{{0.17035, 0.17035, 0.17035, 0.17035, 0.17035, 0.17035}, {0.215683, 0.215683, 0.215683, 0.215683, 0.215683, 0.215683}}

{PoseLegLengths[{0, 0, 0, 0, 0, 0}],  PoseLegLengths[{0, 0, 0.05, 0, 0, 0}]}

{0.17035, 0.17035, 0.17035, 0.17035, 0.17035, 0.17035}, {0.186301, 0.16337, 0.1533, 0.198841, 0.190654, 0.168317}} and changing [Theta], [Phi], [Tau]_} angels 10 degree

{PoseLegLengths[{0, 0, 0, 0, 0, 0}],  PoseLegLengths[{0, 0, 0, 10 \[Degree], 0, 0}]}

{{0.17035, 0.17035, 0.17035, 0.17035, 0.17035, 0.17035}, {0.160146, 0.166254, 0.185371, 0.185371, 0.166254, 0.160146}}

{PoseLegLengths[{0, 0, 0, 0, 0, 0}],   PoseLegLengths[{0, 0, 0, 0, 10 \[Degree], 0}]}

{{0.17035, 0.17035, 0.17035, 0.17035, 0.17035, 0.17035}, {0.17035, 0.17035, 0.17035, 0.17035, 0.17035, 0.17035}} CALCULATION ERROR

{PoseLegLengths[{0, 0, 0, 0, 0, 0}],  PoseLegLengths[{0, 0, 0, 0, 0, 10 \[Degree]}]}

As one can immediately notice, only [Phi] calculation gives the result for Zero Degree.

Any Ideas Mario

POSTED BY: novio8

Hi Mario,

Mathematica seems to flip the meanings of theta and phi. According to the documentation for SphericalPlot3D:

(Pi/2 - theta) corresponds to "latitude"; theta is 0 at the "north pole", and Pi at the "south pole".

Phi corresponds to "longitude", varying from 0 to 2 Pi counterclockwise looking from the north pole.

My text books reverse the definitions of theta and phi.

So, with this in mind, there is nothing wrong with the PoseLegEndpoints[] function. If theta is zero, the vector is pointing towards the north pole, so the value of phi is immaterial.

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago

Hi Eric, I tested your workaround and it works. It is also unusual that z vertical is in second position,

so instead x,y,z it is x,z,y. You are right phi get's calculated only if theta is not 0.

Mario

POSTED BY: novio8

Hi Mario,

I've been playing around with the RotationTransform. Using it in the form that the author does, where he is transforming the vertical vector, {0, 1, 0}, by another vector {Sin[\[Theta]] Cos[\[Phi]], Cos[\[Theta]], Sin[\[Theta]] Sin[\[Phi]]} cannot be generated by successive theta and phi transformations.

So, although my workaround seems to work, it doesn't give the behaviour that the author intended.

RotationTransform[{{0,1,0},{Sin[\[Theta]]Cos[\[Phi]],Cos[\[Theta]],Sin[\[Theta]]Sin[\[Phi]]}}]

seems to work.

Hey, but, in looking at it, if theta is 0, {Sin[\[Theta]]Cos[\[Phi]],Cos[\[Theta]],Sin[\[Theta]]Sin[\[Phi]]} evaluates to {0,Cos[theta],0}, so the phi value doesn't get through.

Could this be the problem?

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago
POSTED BY: novio8
Posted 9 years ago
POSTED BY: Updating Name
POSTED BY: Eric Johnstone
Posted 9 years ago
POSTED BY: Updating Name
Posted 9 years ago
POSTED BY: novio8
Posted 9 years ago
POSTED BY: novio8
POSTED BY: Eric Johnstone
POSTED BY: Eric Johnstone
Posted 9 years ago
POSTED BY: novio8
POSTED BY: Eric Johnstone
Posted 9 years ago

maybe inverse kinematics formula is not correct:

The "pose" of the moveable platform is defined by 6 coordinates {x,y,z,[Theta],[Phi],[Tau]}. The position of the center of the platform is {x,y,z}. The normal vector pointing upwards out of the platform points in the direction {[Theta],[Phi]} in spherical coordinates. The rotation of the platform about the normal vector is the angle [Tau].

PoseLegEndpoints[{x_, y_, z_, \[Theta]_, \[Phi]_, \[Tau]_}] := 
 Table[Composition[
    TranslationTransform[{x, y, z} + {0, platformHeight, 0}], 
    RotationTransform[{{0, 1, 0}, {Sin[\[Theta]] Cos[\[Phi]], 
       Cos[\[Theta]], Sin[\[Theta]] Sin[\[Phi]]}}], 
    RotationTransform[\[Tau], {0, 1, 0}]][p], {p, 
   relativePlatformPoints}]

please help

POSTED BY: novio8
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract