|
| 1 | +.. _pybullet_examples: |
| 2 | + |
| 3 | +******************************************************************************* |
| 4 | +Using PyBullet |
| 5 | +******************************************************************************* |
| 6 | + |
| 7 | +First Step |
| 8 | +========== |
| 9 | + |
| 10 | +The first step is to connect to PyBullet and verify that the system is working. |
| 11 | + |
| 12 | +Copy and paste the following example into a Python script or REPL. If, when run, |
| 13 | +you see the output ``Connected: True``, then everything is working properly. |
| 14 | + |
| 15 | +.. code-block:: python |
| 16 | +
|
| 17 | + from compas_fab.backends import PyBulletClient |
| 18 | + with PyBulletClient(connection_type='direct') as client: |
| 19 | + print('Connected:', client.is_connected) |
| 20 | +
|
| 21 | +.. note:: |
| 22 | + |
| 23 | + From the PyBullet user manual: |
| 24 | + The GUI connection will create a new graphical user interface (GUI) with 3D OpenGL |
| 25 | + rendering, within the same process space as PyBullet. On Linux and Windows this GUI |
| 26 | + runs in a separate thread, while on OSX it runs in the same thread due to operating |
| 27 | + system limitations. On Mac OSX you may see a spinning wheel in the OpenGL Window, |
| 28 | + until you run a 'stepSimulation' or other PyBullet command. |
| 29 | + |
| 30 | +Our first example loads the UR5 robot from a URDF and then adds, then removes, a |
| 31 | +floor as a collision mesh. The calls to ``sleep`` are only necessary to prevent the |
| 32 | +gui from closing this example too quickly. |
| 33 | + |
| 34 | +.. literalinclude :: files/01_add_collision_mesh.py |
| 35 | + :language: python |
| 36 | +
|
| 37 | +.. raw:: html |
| 38 | + |
| 39 | + <div class="card bg-light"> |
| 40 | + <div class="card-body"> |
| 41 | + <div class="card-title">Downloads</div> |
| 42 | + |
| 43 | +* :download:`Add Collision Mesh (.PY) <files/01_add_collision_mesh.py>` |
| 44 | + |
| 45 | +.. raw:: html |
| 46 | + |
| 47 | + </div> |
| 48 | + </div> |
| 49 | + |
| 50 | +Adding and removing a collision mesh attached to the end effector link of the |
| 51 | +robot is similar. Again, the calls to ``sleep`` and ``step_simulation`` exist only |
| 52 | +to make the GUI rendering smoother. |
| 53 | + |
| 54 | +.. literalinclude :: files/02_add_attached_collision_mesh.py |
| 55 | + :language: python |
| 56 | +
|
| 57 | +.. raw:: html |
| 58 | + |
| 59 | + <div class="card bg-light"> |
| 60 | + <div class="card-body"> |
| 61 | + <div class="card-title">Downloads</div> |
| 62 | + |
| 63 | +* :download:`Add Attached Collision Mesh (.PY) <files/02_add_attached_collision_mesh.py>` |
| 64 | + |
| 65 | +.. raw:: html |
| 66 | + |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + |
0 commit comments