Skip to content

Commit

Permalink
Use mock_hardware and mock_sensor_commands instead of fake (#739)
Browse files Browse the repository at this point in the history
* Use mock_hardware and mock_sensor_commands instead of fake

This has been deprecated a while back and was never adapted.

* Update documentation to mock_hardware
  • Loading branch information
fmauch authored Jul 13, 2023
1 parent d2599ec commit 333d0bc
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 100 deletions.
2 changes: 1 addition & 1 deletion ur_calibration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,5 @@ Then, anybody cloning this repository can startup the robot simply by launching
$ cd <colcon_ws>
$ colcon build --packages-select <organization_name>_ur_launch
$ ros2 launch <organization_name>_ur_launch ex-ur10-1.launch.py
robot_ip:=xxx.yyy.zzz.www ur_type:=ur5e use_fake_hardware:=false launch_rviz:=true
robot_ip:=xxx.yyy.zzz.www ur_type:=ur5e use_mock_hardware:=false launch_rviz:=true
```
10 changes: 5 additions & 5 deletions ur_moveit_config/launch/ur_moveit.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
def launch_setup(context, *args, **kwargs):
# Initialize Arguments
ur_type = LaunchConfiguration("ur_type")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
use_mock_hardware = LaunchConfiguration("use_mock_hardware")
safety_limits = LaunchConfiguration("safety_limits")
safety_pos_margin = LaunchConfiguration("safety_pos_margin")
safety_k_position = LaunchConfiguration("safety_k_position")
Expand Down Expand Up @@ -166,8 +166,8 @@ def launch_setup(context, *args, **kwargs):

# Trajectory Execution Configuration
controllers_yaml = load_yaml("ur_moveit_config", "config/controllers.yaml")
# the scaled_joint_trajectory_controller does not work on fake hardware
change_controllers = context.perform_substitution(use_fake_hardware)
# the scaled_joint_trajectory_controller does not work on mock hardware
change_controllers = context.perform_substitution(use_mock_hardware)
if change_controllers == "true":
controllers_yaml["scaled_joint_trajectory_controller"]["default"] = False
controllers_yaml["joint_trajectory_controller"]["default"] = True
Expand Down Expand Up @@ -268,9 +268,9 @@ def generate_launch_description():
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
"use_mock_hardware",
default_value="false",
description="Indicate whether robot is running with fake hardware mirroring command to its states.",
description="Indicate whether robot is running with mock hardware mirroring command to its states.",
)
)
declared_arguments.append(
Expand Down
2 changes: 1 addition & 1 deletion ur_robot_driver/doc/setup_tool_communication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ launch files:

.. code-block:: bash
$ ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_tool_communication:=true use_fake_hardware:=false launch_rviz:=false
$ ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_tool_communication:=true use_mock_hardware:=false launch_rviz:=false
# remember that your user needs to have the rights to write that file handle to /tmp/ttyUR
Following parameters can be set `ur.ros2_control.xacro <https://github.com/UniversalRobots/Universal_Robots_ROS2_Description/blob/ros2/urdf/ur.ros2_control.xacro>`_\ :
Expand Down
30 changes: 15 additions & 15 deletions ur_robot_driver/doc/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ The most relevant arguments are the following:

* ``ur_type`` (\ *mandatory* ) - a type of used UR robot (\ *ur3*\ , *ur3e*\ , *ur5*\ , *ur5e*\ , *ur10*\ , *ur10e*\ , or *ur16e*\ ).
* ``robot_ip`` (\ *mandatory* ) - IP address by which the root can be reached.
* ``use_fake_hardware`` (default: *false* ) - use simple hardware emulator from ros2_control.
* ``use_mock_hardware`` (default: *false* ) - use simple hardware emulator from ros2_control.
Useful for testing launch files, descriptions, etc. See explanation below.
* ``initial_positions`` (default: dictionary with all joint values set to 0) - Allows passing a dictionary to set the initial joint values for the fake hardware from `ros2_control <http://control.ros.org/>`_. It can also be set from a yaml file with the ``load_yaml`` commands as follows:
* ``initial_positions`` (default: dictionary with all joint values set to 0) - Allows passing a dictionary to set the initial joint values for the mock hardware from `ros2_control <http://control.ros.org/>`_. It can also be set from a yaml file with the ``load_yaml`` commands as follows:

.. code-block::
Expand All @@ -41,7 +41,7 @@ The most relevant arguments are the following:
wrist_2_joint: -1.765
wrist_3_joint: 0.0
* ``fake_sensor_commands`` (default: *false* ) - enables setting sensor values for the hardware emulators.
* ``mock_sensor_commands`` (default: *false* ) - enables setting sensor values for the hardware emulators.
Useful for offline testing of controllers.

* ``robot_controller`` (default: *joint_trajectory_controller* ) - controller for robot joints to be started.
Expand All @@ -55,12 +55,12 @@ The most relevant arguments are the following:

*HINT* : list all loaded controllers using ``ros2 control list_controllers`` command.

**NOTE**\ : The package can simulate hardware with the ros2_control ``FakeSystem``. This emulator enables an environment for testing of "piping" of hardware and controllers, as well as testing robot's descriptions. For more details see `ros2_control documentation <https://ros-controls.github.io/control.ros.org/>`_ for more details.
**NOTE**\ : The package can simulate hardware with the ros2_control ``MockSystem``. This emulator enables an environment for testing of "piping" of hardware and controllers, as well as testing robot's descriptions. For more details see `ros2_control documentation <https://ros-controls.github.io/control.ros.org/>`_ for more details.

Modes of operation
------------------

As mentioned in the last section the driver has two basic modes of operation: Using fake hardware or
As mentioned in the last section the driver has two basic modes of operation: Using mock hardware or
using real hardware(Or the URSim simulator, which is equivalent from the driver's perspective).
Additionally, the robot can be simulated using
`Gazebo <https://github.com/UniversalRobots/Universal_Robots_ROS2_Gazebo_Simulation>`_ or
Expand All @@ -72,7 +72,7 @@ outside of this driver's scope.

* - mode
- available controllers
* - fake_hardware
* - mock_hardware
- :raw-html-m2r:`<ul><li>joint_trajectory_controller</li><li>forward_velocity_controller</li><li>forward_position_controller</li></ul>`
* - real hardware / URSim
- :raw-html-m2r:`<ul><li>joint_trajectory_controller</li><li>scaled_joint_trajectory_controller </li><li>forward_velocity_controller</li><li>forward_position_controller</li></ul>`
Expand Down Expand Up @@ -124,11 +124,11 @@ Allowed UR - Type strings: ``ur3``\ , ``ur3e``\ , ``ur5``\ , ``ur5e``\ , ``ur10`

* To do an offline test with URSim check details about it in `this section <#usage-with-official-ur-simulator>`_

* To use mocked hardware(capability of ros2_control), use ``use_fake_hardware`` argument, like:
* To use mocked hardware(capability of ros2_control), use ``use_mock_hardware`` argument, like:

.. code-block::
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_fake_hardware:=true launch_rviz:=true
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_mock_hardware:=true launch_rviz:=true
**NOTE**\ : Instead of using the global launch file for control stack, there are also prepeared launch files for each type of UR robots named. They accept the same arguments are the global one and are used by:

Expand All @@ -150,11 +150,11 @@ Before running any commands, first check the controllers' state using ``ros2 con
After a few seconds the robot should move.

* To test another controller, simply define it using ``initial_joint_controller`` argument, for example when using fake hardware:
* To test another controller, simply define it using ``initial_joint_controller`` argument, for example when using mock hardware:

.. code-block::
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy initial_joint_controller:=joint_trajectory_controller use_fake_hardware:=true launch_rviz:=true
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy initial_joint_controller:=joint_trajectory_controller use_mock_hardware:=true launch_rviz:=true
And send the command using demo node:

Expand Down Expand Up @@ -191,17 +191,17 @@ To test the driver with the example MoveIt-setup, first start the driver as desc
Now you should be able to use the MoveIt Plugin in rviz2 to plan and execute trajectories with the
robot as explained `here <https://moveit.picknik.ai/galactic/doc/tutorials/quickstart_in_rviz/quickstart_in_rviz_tutorial.html>`_.

Fake hardware
Mock hardware
^^^^^^^^^^^^^

Currently, the ``scaled_joint_trajectory_controller`` does not work with ros2_control fake_hardware. There is an
`upstream Merge-Request <https://github.com/ros-controls/ros2_control/pull/822>`_ pending to fix that. Until this is merged and released, you'll have to fallback to the ``joint_trajectory_controller`` by passing ``initial_controller:=joint_trajectory_controller`` to the driver's startup. Also, you'll have to tell MoveIt! that you're using fake_hardware as it then has to map to the other controller:
Currently, the ``scaled_joint_trajectory_controller`` does not work with ros2_control mock_hardware. There is an
`upstream Merge-Request <https://github.com/ros-controls/ros2_control/pull/822>`_ pending to fix that. Until this is merged and released, you'll have to fallback to the ``joint_trajectory_controller`` by passing ``initial_controller:=joint_trajectory_controller`` to the driver's startup. Also, you'll have to tell MoveIt! that you're using mock_hardware as it then has to map to the other controller:

.. code-block::
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_fake_hardware:=true launch_rviz:=false initial_joint_controller:=joint_trajectory_controller
ros2 launch ur_robot_driver ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_mock_hardware:=true launch_rviz:=false initial_joint_controller:=joint_trajectory_controller
# and in another shell
ros2 launch ur_moveit_config ur_moveit.launch.py ur_type:=ur5e launch_rviz:=true use_fake_hardware:=true
ros2 launch ur_moveit_config ur_moveit.launch.py ur_type:=ur5e launch_rviz:=true use_mock_hardware:=true
Robot frames
------------
Expand Down
18 changes: 9 additions & 9 deletions ur_robot_driver/launch/ur10.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ def generate_launch_description():
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
"use_mock_hardware",
default_value="false",
description="Start robot with fake hardware mirroring command to its states.",
description="Start robot with mock hardware mirroring command to its states.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"fake_sensor_commands",
"mock_sensor_commands",
default_value="false",
description="Enable fake command interfaces for sensors used for simple simulations. \
Used only if 'use_fake_hardware' parameter is true.",
description="Enable mock command interfaces for sensors used for simple simulations. \
Used only if 'use_mock_hardware' parameter is true.",
)
)
declared_arguments.append(
Expand All @@ -82,8 +82,8 @@ def generate_launch_description():

# Initialize Arguments
robot_ip = LaunchConfiguration("robot_ip")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
use_mock_hardware = LaunchConfiguration("use_mock_hardware")
mock_sensor_commands = LaunchConfiguration("mock_sensor_commands")
initial_joint_controller = LaunchConfiguration("initial_joint_controller")
activate_joint_controller = LaunchConfiguration("activate_joint_controller")

Expand All @@ -92,8 +92,8 @@ def generate_launch_description():
launch_arguments={
"ur_type": "ur10",
"robot_ip": robot_ip,
"use_fake_hardware": use_fake_hardware,
"fake_sensor_commands": fake_sensor_commands,
"use_mock_hardware": use_mock_hardware,
"mock_sensor_commands": mock_sensor_commands,
"initial_joint_controller": initial_joint_controller,
"activate_joint_controller": activate_joint_controller,
}.items(),
Expand Down
18 changes: 9 additions & 9 deletions ur_robot_driver/launch/ur10e.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ def generate_launch_description():
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
"use_mock_hardware",
default_value="false",
description="Start robot with fake hardware mirroring command to its states.",
description="Start robot with mock hardware mirroring command to its states.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"fake_sensor_commands",
"mock_sensor_commands",
default_value="false",
description="Enable fake command interfaces for sensors used for simple simulations. \
Used only if 'use_fake_hardware' parameter is true.",
description="Enable mock command interfaces for sensors used for simple simulations. \
Used only if 'use_mock_hardware' parameter is true.",
)
)
declared_arguments.append(
Expand All @@ -82,8 +82,8 @@ def generate_launch_description():

# Initialize Arguments
robot_ip = LaunchConfiguration("robot_ip")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
use_mock_hardware = LaunchConfiguration("use_mock_hardware")
mock_sensor_commands = LaunchConfiguration("mock_sensor_commands")
initial_joint_controller = LaunchConfiguration("initial_joint_controller")
activate_joint_controller = LaunchConfiguration("activate_joint_controller")

Expand All @@ -92,8 +92,8 @@ def generate_launch_description():
launch_arguments={
"ur_type": "ur10e",
"robot_ip": robot_ip,
"use_fake_hardware": use_fake_hardware,
"fake_sensor_commands": fake_sensor_commands,
"use_mock_hardware": use_mock_hardware,
"mock_sensor_commands": mock_sensor_commands,
"initial_joint_controller": initial_joint_controller,
"activate_joint_controller": activate_joint_controller,
}.items(),
Expand Down
18 changes: 9 additions & 9 deletions ur_robot_driver/launch/ur16e.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ def generate_launch_description():
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
"use_mock_hardware",
default_value="false",
description="Start robot with fake hardware mirroring command to its states.",
description="Start robot with mock hardware mirroring command to its states.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"fake_sensor_commands",
"mock_sensor_commands",
default_value="false",
description="Enable fake command interfaces for sensors used for simple simulations. \
Used only if 'use_fake_hardware' parameter is true.",
description="Enable mock command interfaces for sensors used for simple simulations. \
Used only if 'use_mock_hardware' parameter is true.",
)
)
declared_arguments.append(
Expand All @@ -82,8 +82,8 @@ def generate_launch_description():

# Initialize Arguments
robot_ip = LaunchConfiguration("robot_ip")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
use_mock_hardware = LaunchConfiguration("use_mock_hardware")
mock_sensor_commands = LaunchConfiguration("mock_sensor_commands")
initial_joint_controller = LaunchConfiguration("initial_joint_controller")
activate_joint_controller = LaunchConfiguration("activate_joint_controller")

Expand All @@ -92,8 +92,8 @@ def generate_launch_description():
launch_arguments={
"ur_type": "ur16e",
"robot_ip": robot_ip,
"use_fake_hardware": use_fake_hardware,
"fake_sensor_commands": fake_sensor_commands,
"use_mock_hardware": use_mock_hardware,
"mock_sensor_commands": mock_sensor_commands,
"initial_joint_controller": initial_joint_controller,
"activate_joint_controller": activate_joint_controller,
}.items(),
Expand Down
18 changes: 9 additions & 9 deletions ur_robot_driver/launch/ur3.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ def generate_launch_description():
)
declared_arguments.append(
DeclareLaunchArgument(
"use_fake_hardware",
"use_mock_hardware",
default_value="false",
description="Start robot with fake hardware mirroring command to its states.",
description="Start robot with mock hardware mirroring command to its states.",
)
)
declared_arguments.append(
DeclareLaunchArgument(
"fake_sensor_commands",
"mock_sensor_commands",
default_value="false",
description="Enable fake command interfaces for sensors used for simple simulations. \
Used only if 'use_fake_hardware' parameter is true.",
description="Enable mock command interfaces for sensors used for simple simulations. \
Used only if 'use_mock_hardware' parameter is true.",
)
)
declared_arguments.append(
Expand All @@ -82,8 +82,8 @@ def generate_launch_description():

# Initialize Arguments
robot_ip = LaunchConfiguration("robot_ip")
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
use_mock_hardware = LaunchConfiguration("use_mock_hardware")
mock_sensor_commands = LaunchConfiguration("mock_sensor_commands")
initial_joint_controller = LaunchConfiguration("initial_joint_controller")
activate_joint_controller = LaunchConfiguration("activate_joint_controller")

Expand All @@ -92,8 +92,8 @@ def generate_launch_description():
launch_arguments={
"ur_type": "ur3",
"robot_ip": robot_ip,
"use_fake_hardware": use_fake_hardware,
"fake_sensor_commands": fake_sensor_commands,
"use_mock_hardware": use_mock_hardware,
"mock_sensor_commands": mock_sensor_commands,
"initial_joint_controller": initial_joint_controller,
"activate_joint_controller": activate_joint_controller,
}.items(),
Expand Down
Loading

0 comments on commit 333d0bc

Please sign in to comment.