update actions & plotting + add plotting examples

This commit is contained in:
Brian Delhaisse
2019-07-23 02:37:46 +02:00
parent 309c4712af
commit 9cc34b6508
28 changed files with 1401 additions and 307 deletions
+14
View File
@@ -0,0 +1,14 @@
Plotting examples
=================
In this folder, you will find examples where we use the plotting tools provided in PRL.
Warnings: Currently, you have to close the figure before closing the simulator. If you close the simulator first,
you might still have the process responsible to draw the figure running.
- ``joints.py``: plot in real-time the joint positions (in blue), velocities (in green), accelerations (in red),
and/or torques (in purple).
- ``link_frames.py``: plot in real-time the frames of the specified links.
To test these classes, you can run the corresponding python file, and move the manipulator with the mouse and check the
real-time plots.
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env python
"""Provide the joint real-time plotting example.
Try to move the Kuka manipulator with your mouse, and check the joint values. Note that it can take few seconds to
load the plot.
Warnings: don't forget to close FIRST the figure, THEN the simulator otherwise you will have the plotting process still
running.
"""
from itertools import count
import pyrobolearn as prl
# create the simulator
sim = prl.simulators.Bullet()
# create the world
world = prl.worlds.BasicWorld(sim)
# load the robot
robot = world.load_robot('kuka_iiwa')
# create the joint real-time plotting tool
plot = prl.utils.plotting.JointRealTimePlot(robot, joint_ids=None, position=True, velocity=False,
acceleration=False, torque=False, ticks=24)
# run the simulation
for t in count():
# update the plot
plot.update()
# perform a step in the world
world.step(sim.dt)
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python
"""Provide the link frame real-time plotting example.
Try to move the Kuka manipulator and / or the box with your mouse. Note that it can take few seconds to load the plot.
Warnings: don't forget to close FIRST the figure, THEN the simulator otherwise you will have the plotting process still
running.
"""
import pyrobolearn as prl
# create the simulator
sim = prl.simulators.Bullet()
# create the world
world = prl.worlds.BasicWorld(sim)
# load the robot and a box
robot = world.load_robot('kuka_iiwa')
box = world.load_box([0.7, 0., 0.2], dimensions=(0.2, 0.2, 0.2), color=(0.2, 0.2, 0.8, 1.), return_body=True)
# create the link frame real-time plotting tool
plot = prl.utils.plotting.LinkFrameRealTimePlot(bodies=[robot, box], link_ids=None, ticks=24)
# run the simulation
for t in prl.count():
# update the plot
plot.update()
# perform a step in the world
world.step(sim.dt)