Actions

# SoftMotion¶

## In construction...¶

### Using jupyter to plot trajectories¶

First you need to install jupyter, you can do it from here:

```http://jupyter.org/install.html
```

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

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

Then go to src/swig/ to compile the code and generate the files _softMotion.so and softMotion.py
Now jupyter notebook can be run from a terminal:

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

This opens a tab in your favorite browser. 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).
That's all you need to define a point to point trajectory with softMotion.

The phase diagram

To plot The phase diagram, use the function myplotter.drawAV().
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 vary the length of the trajectory, the plot is updated dynamically.

The optimal time solutions versus the trajectory length

To plot the optimal time solutions against the trajectory length, just 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 cheak if you closed the previous plot.

Position, velocity, acceleration, jerk plot

To plot the evolution of position, velocity, acceleration and jerk and observe the number of segment of cubic polynomial functions used to represent the whole trajectory, use drawVT() instead of drawAV() or drawTX().

Video examples

You can find a video "shortcut_traj.mp4" illustrating the presence of shorcut trajectories in the phase diagram in this Wiki. The associated code to plot is the following one :

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

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

ic.a = 10
ic.v = 4
ic.x = 0.
fc.a = 10
fc.v = 6
fc.x = 10.

#vmin vmax amin amax jmin jmax
limits = softMotion.Sm_Limits(-20, 20, -20, 20, -30, 30)
myplotter = SmPlotter(limits,ic,fc)
myplotter.drawAV()
``````

Minimal example

## More material¶

Updated by Daniel Sidobre about 5 years ago · 18 revisions