Actions

## Wiki » History » Revision 6

« Previous | Revision 6/18 (diff) | Next »
Anonymous, 2018-01-07 18:30

# SoftMotion¶

## In construction...¶

### Using jupyter to plot trajectories¶

Once in the softMotion-libs repository go to the devel3j branch :

``````git checkout devel3j
``````

Then go to /src/swig/ and in a terminal enter

``````jupyter notebook
``````

this will open a browser tab. On the button on the right "New" select "Python 2".
This action will open another tab inside which you will find a block you can fill with text.
Inside that block we can enter some python code to define and plot our trajectories.
To execute this code you have to press shift + enter with the cursor inside the block.
You can have multiple blocks but only one plot open at once.

The code used for the plotting can be found inside the file Sm_Plotter.py still in /src/swig/.
You can find the code used to plot the figures that illustrate our paper in article_plots_values.txt. It is attached to this Wiki page.

``````execfile('./Sm_Plotter.py', globals(), locals())

ic = softMotion.Sm_Condition()
fc = softMotion.Sm_Condition()

ic.a = 5
ic.v = -10
ic.x = 10.
fc.a = 8
fc.v = 8
fc.x = 10

limits = softMotion.Sm_Limits(-30, 30, -20, 20, -10, 10)
myplotter = SmPlotter(limits,ic,fc)
myplotter.drawAV()
``````

IC and FC are respectively the initial and final conditions. So you can define their acceleration, velocity and position.
The bounds are defined in the variable limits in this order : (Vmin, Vmax, Amin, Amax, Jmin, Jmax).
Thats everything that is needed to define a point to point trajectory with our method.

The phase diagram
<br/>

Now to plot it, in this example we call the function myplotter.drawAV() that plot the phase diagram.
On the right you will find various buttons. By clicking on them you can add parabolas defined by IC and FC, plot the limit trajectory for each type of solution available etc. The time-optimal trajectory is plotted by using the button "Traj(x)". You can use the slider to make the length of the trajectory vary, and see the plot being updated dynamically.

The optimal time solutions versus the trajectory length

If we now want to plot the optimal time solutions against the trajectory length we only have to replace the call to drawAV() by drawTX().
Remember that only one instance of a plot can be open at once, so if the plot doesn't appear after you execute the code just look if you have already one active and close it if that's the case.

Position, velocity, acceleration, jerk plot

This plot draws the evolution of position, velocity, acceleration and jerk. You can easily observe the number of cubics used to represent the whole trajectory by looking at the number of jerk segments.
Here instead of drawAV() or drawTX() we call drawVT().

Updated by Anonymous over 6 years ago · 6 revisions