Message Boards Message Boards

0
|
13949 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
POSTED BY: novio8
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
POSTED BY: Updating Name
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
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

Hi mario,

It's its own plan. The long and short plans are just longer or shorter. Their structure is the same.

But the motionPlan I implemented doesn't use the Block[]. That was necessary for the substitutions of dx and dtheta.

Inside the Blocks[] you will see the basic structure; a List[] of List[]s.

Eric

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
POSTED BY: Eric Johnstone
Posted 9 years ago
POSTED BY: novio8

Hi Mario,

Coming to terms with the z,y and theta,phi interchanges requires some contemplation. It's like driving in England compared to the USA. You have to change the side of the road you call legal.

I tried the ExportMotionPlan[] with framerate=50 and it works OK. Don't forget that you have to re-compile it by hitting shift-enter after changing the framerate.

Eric

POSTED BY: Eric Johnstone
Posted 9 years ago
POSTED BY: novio8
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

yes Leg Lengths are what I'm looking for, but they are not calculated correctly. If you change Long Demonstration Motion Plan, just one Angle at a time to something like this

demoMotionPlan =
  Block[{dx = 0.05, d\[Theta] = 0.5},
   {
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, d\[Theta], 0, 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, -d\[Theta], 0, 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, d\[Theta], 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, -d\[Theta], 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, d\[Theta]},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, -d\[Theta]},
    {0, 0, 0, 0, 0, 0}
    }
   ];

Leg lengths are not calculated for [Phi]. Any Ideas Mario

POSTED BY: novio8
Posted 9 years ago

Hi Mario,

It took a while to go through the code, but I finally get the problem. I don't know what it is; you may have found a bug in Mathematica. But if you use separate RotationTrransforms like this:

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

the second angle calculates.

For a motion path of

testMotionPlan =
  Block[{dx = 0.05, d\[Theta] = 0.5},
   {
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, d\[Theta], 0},
    {0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, -d\[Theta], 0},
    {0, 0, 0, 0, 0, 0}
    }
   ];

the platform returns to its rest position at the {0, 0, 0, 0, 0, 0} points.

I used the ExportMotionPlan[] function with the last line commented out, as above.

Use MatrixPlot[] to see how the leg lengths change.

Eric

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

Hi Mario,

I downloaded SystemModeler onto my XP computer. Not compatible, it seems.

I see now that the problem I was having with the code you supplied is that the Y axis is the vertical. The PoseLegEndpoints[] function seems to work OK, but the range of values that it works for is hard to determine using Manipulate (especially when everything is turned 90 degrees).

Is the problem here:

ExportMotionPlan[demoMotionPlan];

*Export::nodir: Directory C:\Documents and Settings\Eric Johnstone\Local Settings\Temp\wz4602\StewartPlatform\DocumentationFiles\ does not exist. >>*

*OpenWrite::noopen: Cannot open C:\Documents and Settings\Eric Johnstone\Local Settings\Temp\wz4602\StewartPlatform\DocumentationFiles\PlatformPath.txt. >>*

?

Or is that because I don't have SystemModeler? Is this the problem you are referring to?

Eric

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

Hi Eric, I'm referring to https://www.wolfram.com/system-modeler/industry-examples/industrial-manufacturing/stewart-platform-parallel-manipulator.html Yes it uses System Modeller, but Mathematica generates Motion Data and thats what I'm after. If you look at above example you'll see where the problem is. Inverse Kinematics generates motion data from Long Demonstration Plan. Any help is appreciated especially yours as you already worked with Stewart Mechanism. Thanks Mario

POSTED BY: novio8
POSTED BY: Eric Johnstone

Maybe I should leave this to the experts, but I've dug my hole now.

As above,

platformHeight=1;
relativePlatformPoints := 
 Table[{Cos[\[Theta]], Sin[\[Theta]], 0}, {\[Theta],  Range[0, 5]/6 2 Pi}]

But the RotationTransform seems to be much simpler:

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

    ListPlot3D[PoseLegEndpoints[{0,0,0,0,0,0}]//N,PlotRange->{{-1.5,1.5},{-1.5,1.5},{-1,2}}]

    Manipulate[
     ListPlot3D[
      PoseLegEndpoints[{x, y, z, \[Theta], \[Phi], \[Tau]}] // N, 
      PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}, {-1, 2}}], 
        {{x, 0}, -1, 1}, {{y, 0}, -1, 1}, {{z, 0}, -1, 1}, 
        {{\[Theta], 0}, -1, 1}, {{\[Phi], 0}, -1, 1}, {{\[Tau], 0}, -1, 1}]
POSTED BY: Eric Johnstone
Posted 9 years ago

Thank you Eric. I'm a newbie, just downloaded Mathematica. My goal is to generate correct Motion data from this Stewart Platform Demo. Hence stupid questions. I pasted your Code to Demo file in the place of the original Code and the result is platform collapse. Any Ideas Your help is much appreciated Mario

POSTED BY: novio8
POSTED BY: Eric Johnstone
Posted 9 years ago
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