Group Abstract Group Abstract

Message Boards Message Boards

0
|
13.2K Views
|
7 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Newbie Kinematics question

Posted 10 years ago

Hi, I'm calculating motion data from list of poses

 motionPlan = {
       {0, 0, 0, 0, 0, 0, 0},
       {3.4, 0, 0.08, 0, 0, 0, 0},
       {3.5, 0, 0.077, 0, 0, 0, 0},
       {4, 0, 0.08, 0, 0, 0, 0},
       {4.1, 0, 0.077, 0, 0, 0, 0},
       {4.2, 0, 0.08, 0, 0, 0, 0},
       {4.3, 0, 0.083, 0, 0, 0, 0},
       {4.4, 0, 0.08, 0, 0, 0, 0},
       {5, 0, 0.1, 0, 0, 0, 0}   };

Utility function for generating a sequence of steps between two poses:

PoseRange[{pose1_, pose2_}, steps_, time1_, time2_] := 
 Table[pose1 + t/(time2 - time1) (pose2 - pose1), {t, 
   Range[0, time2 - time1, 1/steps]}]

This generates a list of numbers between two pose divided into the number of frames per second. I would like to smooth out the motion data and change Acceleration.

Please help Mario

POSTED BY: novio8
7 Replies

Hi Mario,

I've used the original dimensions of the platform because I don't know what your base is.

I've also changed the rotation from radians to degrees.

So, here is the interpolation function:

splinedMotionPlan[motionPlan_, 
  frameRate_] := (fn2 = 
   Interpolation[
    Transpose[{motionPlan[[All, 1]], motionPlan[[All, 2 ;; 7]]}], 
    Method -> "Spline", InterpolationOrder -> 2];
  fn2[Range[0, motionPlan[[-1, 1]], 1/frameRate]][[All]])

fn2 is the second order interpolation function. Note that if you change the interpolation order to 1, the motion will be the same as the original linear motion. motionPlan[[-1, 1]] is the last time in the motion plan, so the Range function will generate a series of time slots from 0 to the maximum time in 1/frameRate periods.

this makes the ExportMotionPlan function much simpler:

ExportMotionPlan[poses_List, legoffsets_: {0, 0, 0, 0, 0, 0}] := 
 Module[{framerate = 10, lengths, tabledata1, tabledata2, 
   splinedPoses},
  lengths = Map[PoseLegLengths, splinedMotionPlan[poses, framerate]];
  tabledata1 = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];

  {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath.txt"}], {{"LegLengths", tabledata1}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata1]]};

  lengths = Map[# - legoffsets &, lengths];
  tabledata2 = 
   MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];

  {Export[
    FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath2.txt"}], {{"LegLengths", tabledata2}}, 
    "ModelicaCombiTimeTable"], First[Last[tabledata2]]};
  ]

A notebook is attached. As an exercise, you might try to make the interpolation order one of the arguments. Be careful of the splines; they could sent you into wild overshoots.

Eric

Attachments:
POSTED BY: Eric Johnstone
Posted 10 years ago
POSTED BY: novio8

Hi Mario,

Here is what happens when you use the spline interpolation on your motionPlan:

    fn1=Interpolation[Transpose[{motionPlan[[All,1]],motionPlan[[All,2;;7]]}],Method->"Spline",InterpolationOrder->1];
    fn2=Interpolation[Transpose[{motionPlan[[All,1]],motionPlan[[All,2;;7]]}],Method->"Spline",InterpolationOrder->2];

    Show[ListLinePlot[fn1[Range[0,10.5,.1]][[All,2]],PlotRange->{-.5,1.7}],
         ListLinePlot[fn2[Range[0,10.5,.1]][[All,2]],PlotRange->{-.5,1.7}]]

overshoot

The overshoot is unacceptable. In the first part of the motion, the spline even goes in the opposite direction. We need to find a way to stay in the linear motionPlan but use computed acceleration and deceleration as the plan points are left and approached.

Unless you have changed the dimensions of the Stewart platform in the demo, the range of values in your motion plan exceed the dimensions of the actuators.

If we assume that the time intervals must be constant, we will have to change the distance intervals to get acceleration and deceleration. That will require some thought.

Eric

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

Hi John, thank you for your answer, but I just can't figure it out. I have the following code

to generate motion data:

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}]

Function giving the lengths of each leg as a function of the pose coordinates:

PoseLegLengths[pose_] := Map[Norm, PoseLegEndpoints[N[pose]] - basePoints]



{PoseLegLengths[{0, 0, 0, 0, 0, 0}], PoseLegLengths[{0, 0.01, 0, 0, 0, 0}]}

{{1.13137, 1.13137, 1.13137, 1.13137, 1.13137, 1.13137}, {1.13793, 1.13793, 
  1.13793, 1.13793, 1.13793, 1.13793}}

Utility function for generating a sequence of steps between two poses:

PoseRange[{pose1_, pose2_}, steps_, time1_, time2_] := 
 Table[pose1 + t/(time2 - time1) (pose2 - pose1), {t, 
   Range[0, time2 - time1, 1/steps]}]
fn = Interpolation[Transpose[{Range[Length[motionPlan]], motionPlan}]];

Function to tabulate and export a sequence of leg lengths corresponding to a platform shifting between a list of poses at the rate of one pose per second, with a specified fixed offset applied to the length each leg:

ExportMotionPlan[poses_List, 
  legoffsets_: {1.1313669977935081`, 1.1313669977935081`, 1.1313669977935084`,
     1.131366997793508`, 1.1313669977935086`, 1.131366997793508`}] := 
 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[# &, lengths];
  tabledata = MapIndexed[Prepend[#, (First[#2] - 1)/framerate] &, lengths];
  {Export[FileNameJoin[{NotebookDirectory[], "DocumentationFiles", 
      "PlatformPath.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]]}
  ]

motionPlan = {
   {0, 0, 0, 0, 0, 0, 0},
   {3.4, 0, 0.40, 0, 0, 0, 0},
   {3.5, 0, 0.47, 0, 0, 0, 0},
   {4, 0, 0.48, 0, 0, 0, 0},
   {4.1, 0, 0.477, 0, 0, 0, 0},
   {4.2, 0, 0.48, 0, 0, 0, 0},
   {4.3, 0, 0.483, 0, 0, 0, 0},
   {4.4, 0, 0.48, 0, 0, 0, 0},
   {5, 0, 0.5, 0, 0, 0, 0}, {
    7, 0, 0.5, 0, 10, 0, 0},
   {7.1, 0, 0.197, 0, 0, 0, 0},
   {7.3, 0, 0.2, 0, 0, 10, 0},
   {7.4, 0, 0.197, 0, 0, 0, 10},
   {8, 0, 0.205, 0, 0, 0, 0},
   {8.1, 0, 0.2, 0, 0, 0, 0},
   {8.3, 0, 0.205, 0, 0, 0, 0},
   {8.4, 0, 0.2, 0, 0, 0, 0},
   {9, 0.05, 0.205, 0, 0, 0, 0},
   {9.3, 0, 0.205, 0, 0, 0, 0},
   {10.1, -0.05, 0.205, 0, 0, 0, 0},
   {10.5, 0.05, 0.21, 0, 0, 0, 0}
   };
ExportMotionPlan[motionPlan];

Any suggestion is much appreciated.

Mario

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