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
|
|
Hi Mario, I learned a lot from this discussion. Please keep asking. Eric
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
Hi Mario, If you comment out the last line:
ExportMotionPlan[poses_List,legoffsets_:{0,0,0,0,0,0}]:=
Module[{framerate=10,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]]}*)
]
and run
ExportMotionPlan[demoMotionPlan]
without a semicolon, you get {{0,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{1/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{1/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{3/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{2/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{1/2,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{3/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{7/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{4/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{9/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{1,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{11/10,0.177146,0.172484,0.179639,0.171251,0.18149,0.168899},{6/5,0.184186,0.175092,0.189321,0.173459,0.193351,0.168897},{13/10,0.191352,0.178177,0.199365,0.177031,0.205731,0.170305},{7/5,0.198544,0.181744,0.209743,0.181978,0.218455,0.173031},{3/2,0.20568,0.185795,0.220421,0.188265,0.231373,0.176951},{8/5,0.212696,0.190332,0.231367,0.195819,0.244357,0.18191},{17/10,0.219538,0.195353,0.242545,0.204538,0.257296,0.187744},{9/5,0.226167,0.200858,0.25392,0.214302,0.270095,0.194285},{19/10,0.232553,0.206839,0.265457,0.224982,0.282669,0.201373},{2,0.238676,0.213291,0.277118,0.236445,0.294946,0.208859},{21/10,0.230679,0.210296,0.269809,0.229228,0.282619,0.196616},{11/5,0.221762,0.207329,0.263004,0.223376,0.270155,0.184527},{23/10,0.211962,0.204354,0.256696,0.218952,0.257687,0.172825},{12/5,0.201327,0.201351,0.250866,0.215975,0.245361,0.16177},{5/2,0.189923,0.198317,0.245485,0.21441,0.23333,0.151648},{13/5,0.177829,0.195261,0.240512,0.21418,0.221758,0.142763},{27/10,0.165141,0.192212,0.235902,0.215159,0.21082,0.135414},{14/5,0.151974,0.189211,0.231602,0.217194,0.200694,0.129866},{29/10,0.138468,0.186313,0.22756,0.220108,0.191559,0.126306},{3,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{31/10,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{16/5,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{33/10,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{17/5,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{7/2,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{18/5,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{37/10,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{19/5,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{39/10,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{4,0.124796,0.183587,0.223719,0.223719,0.183587,0.124796},{41/10,0.137276,0.184049,0.21631,0.21631,0.184049,0.137276},{21/5,0.150357,0.185189,0.209514,0.209514,0.185189,0.150357},{43/10,0.163992,0.187016,0.203326,0.203326,0.187016,0.163992},{22/5,0.178131,0.189531,0.197736,0.197736,0.189531,0.178131},{9/2,0.192728,0.192728,0.192728,0.192728,0.192728,0.192728},{23/5,0.207734,0.196591,0.188284,0.188284,0.196591,0.207734},{47/10,0.223101,0.201095,0.184381,0.184381,0.201095,0.223101},{24/5,0.238779,0.206211,0.180997,0.180997,0.206211,0.238779},{49/10,0.254719,0.211904,0.178112,0.178112,0.211904,0.254719},{5,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{51/10,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{26/5,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{53/10,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{27/5,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{11/2,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{28/5,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{57/10,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{29/5,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{59/10,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{6,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{61/10,0.270072,0.223851,0.17247,0.179826,0.212818,0.271964},{31/5,0.269577,0.229882,0.170187,0.184719,0.207987,0.273337},{63/10,0.269394,0.236145,0.168924,0.190282,0.203724,0.274971},{32/5,0.269524,0.242563,0.168717,0.196405,0.200112,0.276846},{13/2,0.269966,0.249062,0.169572,0.202979,0.197221,0.278939},{33/5,0.270714,0.255573,0.171463,0.2099,0.195114,0.281224},{67/10,0.271758,0.262033,0.17434,0.217068,0.193838,0.283674},{34/5,0.273084,0.268384,0.178126,0.224392,0.193422,0.28626},{69/10,0.274675,0.27457,0.182729,0.231787,0.193875,0.288953},{7,0.27651,0.280545,0.188044,0.239176,0.195188,0.291724},{71/10,0.274675,0.27457,0.182729,0.231787,0.193875,0.288953},{36/5,0.273084,0.268384,0.178126,0.224392,0.193422,0.28626},{73/10,0.271758,0.262033,0.17434,0.217068,0.193838,0.283674},{37/5,0.270714,0.255573,0.171463,0.2099,0.195114,0.281224},{15/2,0.269966,0.249062,0.169572,0.202979,0.197221,0.278939},{38/5,0.269524,0.242563,0.168717,0.196405,0.200112,0.276846},{77/10,0.269394,0.236145,0.168924,0.190282,0.203724,0.274971},{39/5,0.269577,0.229882,0.170187,0.184719,0.207987,0.273337},{79/10,0.270072,0.223851,0.17247,0.179826,0.212818,0.271964},{8,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{81/10,0.271505,0.217083,0.173486,0.178048,0.219296,0.270328},{41/5,0.27223,0.216141,0.171378,0.180494,0.220565,0.269877},{83/10,0.273044,0.215312,0.169392,0.183043,0.221939,0.269517},{42/5,0.273947,0.214595,0.167532,0.185692,0.223416,0.26925},{17/2,0.274938,0.213993,0.165801,0.188437,0.224995,0.269076},{43/5,0.276015,0.213507,0.164205,0.191273,0.226673,0.268994},{87/10,0.277179,0.213137,0.162746,0.194196,0.228448,0.269006},{44/5,0.278428,0.212883,0.16143,0.197203,0.230319,0.26911},{89/10,0.279761,0.212747,0.160258,0.200289,0.232281,0.269307},{9,0.281176,0.212728,0.159235,0.203452,0.234334,0.269597},{91/10,0.276592,0.213504,0.15774,0.202283,0.235039,0.264813},{46/5,0.272299,0.214744,0.156869,0.201605,0.236165,0.260325},{93/10,0.268309,0.216438,0.156632,0.201421,0.237707,0.256149},{47/5,0.264638,0.218578,0.157034,0.201734,0.239657,0.252301},{19/2,0.261298,0.221149,0.158068,0.20254,0.242005,0.248795},{48/5,0.258302,0.224138,0.159723,0.203834,0.244739,0.245647},{97/10,0.255662,0.227527,0.16198,0.205607,0.247846,0.24287},{49/5,0.25339,0.231299,0.164814,0.207847,0.251313,0.240477},{99/10,0.251495,0.235436,0.168195,0.210538,0.255126,0.238479},{10,0.249986,0.239918,0.172091,0.213664,0.259268,0.236887},{101/10,0.246891,0.240055,0.174124,0.207722,0.255644,0.236333},{51/5,0.244167,0.240609,0.1767,0.202101,0.252365,0.236201},{103/10,0.241826,0.241575,0.179796,0.196828,0.249444,0.236493},{52/5,0.239879,0.242949,0.183385,0.191931,0.246893,0.237206},{21/2,0.238337,0.244725,0.18744,0.18744,0.244725,0.238337},{53/5,0.237206,0.246893,0.191931,0.183385,0.242949,0.239879},{107/10,0.236493,0.249444,0.196828,0.179796,0.241575,0.241826},{54/5,0.236201,0.252365,0.202101,0.1767,0.240609,0.244167},{109/10,0.236333,0.255644,0.207722,0.174124,0.240055,0.246891},{11,0.236887,0.259268,0.213664,0.172091,0.239918,0.249986},{111/10,0.238479,0.255126,0.210538,0.168195,0.235436,0.251495},{56/5,0.240477,0.251313,0.207847,0.164814,0.231299,0.25339},{113/10,0.24287,0.247846,0.205607,0.16198,0.227527,0.255662},{57/5,0.245647,0.244739,0.203834,0.159723,0.224138,0.258302},{23/2,0.248795,0.242005,0.20254,0.158068,0.221149,0.261298},{58/5,0.252301,0.239657,0.201734,0.157034,0.218578,0.264638},{117/10,0.256149,0.237707,0.201421,0.156632,0.216438,0.268309},{59/5,0.260325,0.236165,0.201605,0.156869,0.214744,0.272299},{119/10,0.264813,0.235039,0.202283,0.15774,0.213504,0.276592},{12,0.269597,0.234334,0.203452,0.159235,0.212728,0.281176},{121/10,0.26911,0.230319,0.197203,0.16143,0.212883,0.278428},{61/5,0.268994,0.226673,0.191273,0.164205,0.213507,0.276015},{123/10,0.26925,0.223416,0.185692,0.167532,0.214595,0.273947},{62/5,0.269877,0.220565,0.180494,0.171378,0.216141,0.27223},{25/2,0.270871,0.218135,0.175711,0.175711,0.218135,0.270871},{63/5,0.27223,0.216141,0.171378,0.180494,0.220565,0.269877},{127/10,0.273947,0.214595,0.167532,0.185692,0.223416,0.26925},{64/5,0.276015,0.213507,0.164205,0.191273,0.226673,0.268994},{129/10,0.278428,0.212883,0.16143,0.197203,0.230319,0.26911},{13,0.281176,0.212728,0.159235,0.203452,0.234334,0.269597},{131/10,0.26751,0.212055,0.158143,0.205212,0.221794,0.259272},{66/5,0.253696,0.211706,0.157477,0.207555,0.210425,0.25043},{133/10,0.239942,0.211794,0.157219,0.210316,0.20034,0.24316},{67/5,0.226483,0.212425,0.157368,0.213346,0.191629,0.237498},{27/2,0.213586,0.213693,0.157939,0.216518,0.184349,0.233413},{68/5,0.201547,0.215677,0.15896,0.219725,0.178515,0.230809},{137/10,0.190685,0.218431,0.160466,0.222882,0.174095,0.229532},{69/5,0.181329,0.221986,0.162503,0.225923,0.171012,0.229378},{139/10,0.173794,0.226345,0.165115,0.228801,0.169146,0.230112},{14,0.168346,0.231483,0.168346,0.231483,0.168346,0.231483},{141/10,0.164621,0.224944,0.164621,0.224944,0.164621,0.224944},{71/5,0.161675,0.21831,0.161675,0.21831,0.161675,0.21831},{143/10,0.159579,0.211641,0.159579,0.211641,0.159579,0.211641},{72/5,0.15839,0.205004,0.15839,0.205004,0.15839,0.205004},{29/2,0.15814,0.198472,0.15814,0.198472,0.15814,0.198472},{73/5,0.158836,0.192123,0.158836,0.192123,0.158836,0.192123},{147/10,0.160458,0.186044,0.160458,0.186044,0.160458,0.186044},{74/5,0.162963,0.180325,0.162963,0.180325,0.162963,0.180325},{149/10,0.166287,0.175062,0.166287,0.175062,0.166287,0.175062},{15,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{151/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{76/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{153/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{77/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{31/2,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{78/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{157/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{79/5,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{159/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{16,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035},{161/10,0.17035,0.17035,0.17035,0.17035,0.17035,0.17035}} Is this the text you are looking for? Eric
|
|
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
|
|
Hi,
yes it seems that Y is the vertical, which is weird and I can't figure it why.
I'v run Evaluate Notebook in Mathematica only, without System Modeler running
and it seems OK It looks like PlatformPath.txt is saved in folder DocumentationFiles that has to be
on the same root as Mathematica file StewartPlatform.nb As I can see you'v saved Mathematica file in to Temp Folder C:\Documents and Settings\Eric Johnstone\Local Settings\Temp\wz4602\StewartPlatform\DocumentationFiles\PlatformPath.txt. >>
ExportMotionPlan[poses_List, legoffsets_: {0, 0, 0, 0, 0, 0}] :=
Module[{framerate = 10, 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
|
|
Hi Mario, Which demo are you referring to? If you are using System Modeler, I won't be of much help; I've never used it. If you are interested in the Stewart Platform itself, I can be of help. (But, be warned. I'm 68 years old and took up Mathematica as a retirement project. 35 years of programming microcontrollers in C is a lot procedural thinking to get over!) Back in 1999, I was tasked with the job of putting a Stewart mechanism in a pit in a new Posture and Gait lab. The professor insisted on buying the hydraulic actuators before the platform was designed. Using Working Model 3D, a new program that could model parallel mechanisms, I found that the Stewart Platform could hit the sides of the pit if it were to satisfy the range of motions required. So I had to invent a new mechanism. That required learning about parallel mechanisms, and the key to understanding them is degrees of freedom. The symmetrical design of the Stewart mechanism is not at all necessary. The actuators can be placed any-which-way as long as they aren't parallel at some point. And other degrees of freedom can be used, too. For another project, I invented a 2-degree of freedom motion base keeping x,y,z,and tau fixed. Eric
|
|
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}]
|
|
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
|
|
If we give some values to platformHeight and relativePlatformPoints , and change the {0, platformHeight, 0} to {0, 0,platformHeight}
platformHeight=1;
relativePlatformPoints:=Table[{Cos[\[Theta]],Sin[\[Theta]],0},{\[Theta],Range[0,5]/6 2Pi}]
PoseLegEndpoints[{x_,y_,z_,\[Theta]_,\[Phi]_,\[Tau]_}]:=
Table[
Composition[
TranslationTransform[{x,y,z}+{0,0,platformHeight}],
RotationTransform[{{0,1,0},
{Sin[\[Theta]] Cos[\[Phi]],
Cos[\[Theta]],Sin[\[Theta]] Sin[\[Phi]]}}],
RotationTransform[\[Tau],{0,1,0}]][p],
{p,relativePlatformPoints}
]
ListPlot3D[PoseLegEndpoints[{0, 0, 0, 0, 0, 0}] // N,
PlotRange -> {{-1, 1}, {-1, 1}, {-1, 2}}]
This appears to work. But it needs thorough checking. EDIT: After playing around with this, later on, it seems to still need some work. Theta and phi were not working in the above, so I put them in separate RotationTransforms. The plot looks OK now. But it still needs checking. I'm not very experienced with these transformations, although I have had a lot of experience with Stewart platforms.
PoseLegEndpoints[{x_,y_,z_,\[Theta]_,\[Phi]_,\[Tau]_}]:=
Table[
Composition[
TranslationTransform[{x,y,z}+{0,0,platformHeight}],
RotationTransform[\[Theta],{Sin[\[Theta]] Cos[\[Phi]],Cos[\[Theta]],Sin[\[Theta]] Sin[\[Phi]]}],
RotationTransform[\[Phi],{Sin[\[Theta]] Cos[\[Phi]],Cos[\[Theta]],Sin[\[Theta]] Sin[\[Phi]]}],
RotationTransform[\[Tau],{0,0,1}]][p],
{p,relativePlatformPoints}
]
ListPlot3D[PoseLegEndpoints[{0,0,0,0,0,0}]//N,PlotRange->{{-1,1},{-1,1},{-1,2}}]
|
|
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
|
|
Reply to this discussion
in reply to
Group Abstract
|