-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: More concise sim/real-interface description
- Loading branch information
Showing
5 changed files
with
82 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,63 @@ | ||
************************************************ | ||
Simulation vs Real Robot in trifinger_simulation | ||
************************************************ | ||
******************** | ||
Real Robot Interface | ||
******************** | ||
|
||
We have designed the entire `trifinger_simulation` package with the | ||
aim of making it possible to seamlessly transition to our software for | ||
interfacing with these robots in the real world, to the extent of making | ||
this transition pretty much plug and play: depending on whether you want | ||
to create an instance of a simulated robot or a | ||
real robot, which you would like to use in a gym environment for learning, or for | ||
optimal control, or just to play around in by sending some crazy random commands. | ||
The simulation API is designed with the aim of making it easy to transition to the | ||
interface of the real robots. | ||
Below, we describe two different ways of switching between simulated and real robot: | ||
|
||
To give a very simple example of this, consider sending some control commands to | ||
the TriFinger, | ||
1. Switching between :class:`~trifinger_simulation.sim_finger.SimFinger` and | ||
:class:`~trifinger_simulation.real_finger.RealFinger` | ||
2. Using the real-robot interface and replacing the hardware back end with the | ||
simulation. | ||
|
||
Note also, that the interface of :class:`~trifinger_simulation.sim_finger.SimFinger` is | ||
designed to be as similar as possible to the real-robot front end, so even switching | ||
between the two should be relatively easy. | ||
|
||
|
||
RealRobot Wrapper | ||
================= | ||
|
||
The :class:`~trifinger_simulation.real_finger.RealFinger` class provides a wrapper | ||
around the real-robot interface which can be used as a drop-in replacement for | ||
:class:`~trifinger_simulation.sim_finger.SimFinger`. | ||
|
||
Simple example, sending control commands to the TriFinger: | ||
|
||
.. code-block:: python | ||
from trifinger_simulation import sim_finger, real_finger | ||
if use_real == True: | ||
# to know what this robot is, look at the example below | ||
robot = sim_finger.RealFinger(finger_type) | ||
robot = real_finger.RealFinger(finger_type) | ||
else: | ||
robot = real_finger.SimFinger(finger_type) | ||
robot = sim_finger.SimFinger(finger_type) | ||
def step(action): | ||
for _ in range(steps_per_control): | ||
t = robot.append_desired_action(action) | ||
observation = robot.get_observation() | ||
As you can see from the example above, you can control the TriFinger in the | ||
same way irrespective of whether its a simulated or real. You can see an example | ||
of this usage in our `TriFingerReach environment <https://github.com/open-dynamic-robot-initiative/trifinger_simulation/blob/master/trifinger_simulation/gym_wrapper/envs/trifinger_reach.py>`_. | ||
|
||
The ``RealFinger`` class exposes analogous methods to interact with the real robot as the ones | ||
for ``SimFinger``. Inside ``RealFinger``, the robot actually gets created like this: | ||
|
||
.. code-block:: python | ||
import robot_interfaces | ||
import robot_fingers | ||
robot_config_path = "path_to_the_config_yml_of_the_desired_robot_type" | ||
robot_data = robot_interfaces.trifinger.SingleProcessData() | ||
You can see an example of this usage in our :doc:`TriFingerReach environment | ||
<src_trifinger_reach-py>`. | ||
|
||
robot_backend = robot_fingers.create_trifinger_backend( | ||
robot_data, robot_config_path) | ||
robot = robot_interfaces.trifinger.Frontend(robot_data) | ||
|
||
.. note:: | ||
|
||
In order to use the ``RealFinger`` class, you would need to install additional packages like | ||
`robot_interfaces`_ and `robot_fingers`_ as you can see in the example above. These packages are | ||
not a part of the `trifinger_simulation conda environment`_. Instructions on how to install | ||
these packages will follow soon in the :ref:`colcon` section. | ||
In order to use the ``RealFinger`` class, you would need additional packages from | ||
the TriFinger software bundle. See :ref:`colcon`. | ||
|
||
.. note:: | ||
|
||
If at this point, you are interested in exploring our software interface for the | ||
real robot, you can head over to the frontend of this interface to check out | ||
the exposed methods in the `RobotFrontend`_, | ||
and check out some demos for controlling a real robot in `here <https://github.com/open-dynamic-robot-initiative/robot_fingers/tree/master/demos>`_. | ||
|
||
In addition, you can also access the complete API of interacting with the real robot (the `RobotFrontend`_ mentioned | ||
in the note above) with this simulation. Head over to the next section, :ref:`robot_interfaces with Simulation` to know how to do this. | ||
Real Robot Front End with Simulation Back End | ||
============================================= | ||
|
||
The :doc:`robot_fingers <robot_fingers:index>` package provides an | ||
:doc:`robot_interfaces <robot_interfaces:index>`-based interface to the hardware of the | ||
real TriFinger robots. | ||
|
||
.. _`RobotFrontend`: https://github.com/open-dynamic-robot-initiative/robot_interfaces/blob/master/include/robot_interfaces/robot_frontend.hpp | ||
.. _`robot_interfaces`: https://github.com/open-dynamic-robot-initiative/robot_interfaces/blob/master/ | ||
.. _`robot_fingers`: https://github.com/open-dynamic-robot-initiative/robot_fingers | ||
.. _`trifinger_simulation conda environment`: https://github.com/open-dynamic-robot-initiative/trifinger_simulation/blob/master/environment.yml | ||
It is possible to use the front end of the real-robot interface but with the simulation | ||
plugged in as back end. This allows using the exact same code for simulation and real | ||
robot. For more information on this, see :ref:`robot_fingers:simulation_backend` in the | ||
``robot_fingers`` documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
:orphan: | ||
|
||
*************************************** | ||
Example: TriFingerReach Gym Environment | ||
*************************************** | ||
|
||
.. literalinclude:: ../../trifinger_simulation/gym_wrapper/envs/trifinger_reach.py |