Project

General

Profile

Wiki » History » Version 14

Daniel Sidobre, 2018-01-10 10:14

1 1 Daniel Sidobre
h1. SoftMotion
2
3
h2. In construction...
4 2 Anonymous
5
h3. Using jupyter to plot trajectories 
6
7 13 Daniel Sidobre
First you need to install jupyter, you can do it from here:
8 10 Anonymous
9
<pre>
10
http://jupyter.org/install.html
11
</pre>
12
13 13 Daniel Sidobre
Once in the softMotion-libs repository go to the devel3j branch:
14 2 Anonymous
15
<pre><code class="text">
16
git checkout devel3j
17 1 Daniel Sidobre
</code></pre>
18 2 Anonymous
19 14 Daniel Sidobre
Then go to src/swig/ to compile the code and generate the files _softMotion.so and softMotion.py 
20 13 Daniel Sidobre
Now jupyter notebook can be run from a terminal:
21 2 Anonymous
22
<pre><code class="text">
23
jupyter notebook
24
</code></pre>
25
 
26
this will open a browser tab. On the button on the right "New" select "Python 2". 
27
This action will open another tab inside which you will find a block you can fill with text.
28
Inside that block we can enter some python code to define and plot our trajectories.
29
To execute this code you have to press shift + enter with the cursor inside the block.
30
You can have multiple blocks but only one plot open at once.
31
32
The code used for the plotting can be found inside the file Sm_Plotter.py still in /src/swig/.
33 3 Anonymous
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.
34 2 Anonymous
<pre><code class="python">
35
execfile('./Sm_Plotter.py', globals(), locals())
36
37
ic = softMotion.Sm_Condition()
38
fc = softMotion.Sm_Condition()
39
40
ic.a = 5
41
ic.v = -10
42
ic.x = 10.
43
fc.a = 8
44
fc.v = 8
45
fc.x = 10
46
47
limits = softMotion.Sm_Limits(-30, 30, -20, 20, -10, 10)
48
myplotter = SmPlotter(limits,ic,fc)
49
myplotter.drawAV()
50
</code></pre>
51
52
IC and FC are respectively the initial and final conditions. So you can define their acceleration, velocity and position.
53
The bounds are defined in the variable limits in this order : (Vmin, Vmax, Amin, Amax, Jmin, Jmax).
54 8 Daniel Sidobre
That's all you need to define a point to point trajectory with softMotion.
55 2 Anonymous
56
57 5 Anonymous
*The phase diagram*
58 2 Anonymous
59 9 Daniel Sidobre
To plot The phase diagram, use the function myplotter.drawAV().
60
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. 
61 2 Anonymous
 
62
*The optimal time solutions versus the trajectory length*
63
64 9 Daniel Sidobre
To plot the optimal time solutions against the trajectory length, just replace the call to drawAV() by drawTX().
65
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.
66 2 Anonymous
67
*Position, velocity, acceleration, jerk plot*
68
69 9 Daniel Sidobre
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().
70 11 Anonymous
71
72
*Video examples*
73
74
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 :
75
76
<pre><code class="python">
77
execfile('./Sm_Plotter.py', globals(), locals())
78
79
ic = softMotion.Sm_Condition()
80
fc = softMotion.Sm_Condition()
81
82
ic.a = 10
83
ic.v = 4
84
ic.x = 0.
85
fc.a = 10
86
fc.v = 6
87
fc.x = 10.
88
89
#vmin vmax amin amax jmin jmax
90
limits = softMotion.Sm_Limits(-20, 20, -20, 20, -30, 30)
91
myplotter = SmPlotter(limits,ic,fc)
92
myplotter.drawAV()
93
</code></pre>