Wiki » History » Version 4
Anonymous, 2018-01-07 18:27
1 | 1 | Daniel Sidobre | h1. SoftMotion |
---|---|---|---|
2 | |||
3 | h2. In construction... |
||
4 | 2 | Anonymous | |
5 | h3. Using jupyter to plot trajectories |
||
6 | |||
7 | Once in the softMotion-libs repository go to the devel3j branch : |
||
8 | |||
9 | <pre><code class="text"> |
||
10 | git checkout devel3j |
||
11 | </code></pre> |
||
12 | |||
13 | Then go to /src/swig/ and in a terminal enter |
||
14 | |||
15 | <pre><code class="text"> |
||
16 | jupyter notebook |
||
17 | </code></pre> |
||
18 | |||
19 | this will open a browser tab. On the button on the right "New" select "Python 2". |
||
20 | This action will open another tab inside which you will find a block you can fill with text. |
||
21 | Inside that block we can enter some python code to define and plot our trajectories. |
||
22 | To execute this code you have to press shift + enter with the cursor inside the block. |
||
23 | You can have multiple blocks but only one plot open at once. |
||
24 | |||
25 | The code used for the plotting can be found inside the file Sm_Plotter.py still in /src/swig/. |
||
26 | 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. |
27 | 2 | Anonymous | <pre><code class="python"> |
28 | execfile('./Sm_Plotter.py', globals(), locals()) |
||
29 | |||
30 | ic = softMotion.Sm_Condition() |
||
31 | fc = softMotion.Sm_Condition() |
||
32 | |||
33 | ic.a = 5 |
||
34 | ic.v = -10 |
||
35 | ic.x = 10. |
||
36 | fc.a = 8 |
||
37 | fc.v = 8 |
||
38 | fc.x = 10 |
||
39 | |||
40 | limits = softMotion.Sm_Limits(-30, 30, -20, 20, -10, 10) |
||
41 | myplotter = SmPlotter(limits,ic,fc) |
||
42 | myplotter.drawAV() |
||
43 | </code></pre> |
||
44 | |||
45 | IC and FC are respectively the initial and final conditions. So you can define their acceleration, velocity and position. |
||
46 | The bounds are defined in the variable limits in this order : (Vmin, Vmax, Amin, Amax, Jmin, Jmax). |
||
47 | Thats everything that is needed to define a point to point trajectory with our method. |
||
48 | |||
49 | |||
50 | 4 | Anonymous | ===The phase diagram=== |
51 | 2 | Anonymous | |
52 | Now to plot it, in this example we call the function myplotter.drawAV() that plot the phase diagram. |
||
53 | 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. |
||
54 | |||
55 | *The optimal time solutions versus the trajectory length* |
||
56 | |||
57 | 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(). |
||
58 | 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. |
||
59 | |||
60 | *Position, velocity, acceleration, jerk plot* |
||
61 | |||
62 | 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. |
||
63 | Here instead of drawAV() or drawTX() we call drawVT(). |