Skip to content

Commit

Permalink
[Templates] Optimize how MockHW usage and README is. (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
destogl authored Feb 26, 2024
1 parent bf4e7ca commit 1d3fe7c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
22 changes: 22 additions & 0 deletions templates/ros2_control/append_to_MAIN_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


## Running MockHW
> **NOTE:** If you are not familiar with ros2_control check the docs for some [useful examples](https://control.ros.org/master/doc/ros2_control_demos/doc/index.html) and [additional information](https://control.ros.org/master/doc/getting_started/getting_started.html).
To test the mock hardware with standard controllers we first start the bringup with the mock hardware enabled:
```
ros2 launch dte_ea_bringup dte_ea_1000.launch.xml use_mock_hardware:=true
```
In a second terminal we then publish goals for the jtc:
```
ros2 launch dte_ea_bringup test_joint_trajectory_controller.launch.xml
```

After stopping the goal publisher, you can deactivate `JointTrajectoryController`, and activate `ForwardPositionController`:
```
ros2 control switch_controllers --activate forward_position_controller --deactivate joint_trajectory_controller
```
After successful controller switch, start goal publisher for another controller:
```
ros2 launch dte_ea_bringup test_forward_position_controller.launch.xml
```
2 changes: 1 addition & 1 deletion templates/ros2_control/append_to_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Consult the repository and [ros2_control documentation](https://ros-controls.git

1. Start robot's hardware and load controllers (default configuration starts mock hardware)
```
ros2 launch $PKG_NAME$ $ROBOT_NAME$.launch.py
ros2 launch $PKG_NAME$ $ROBOT_NAME$.launch.xml
```

2. Open another terminal and check if your hardware is loaded properly:
Expand Down
6 changes: 6 additions & 0 deletions templates/ros2_control/robot_ros2_control.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Authors: Riyan Jose, Manuel Muth, Dr. Denis
<arg name="robot_controller"
default="forward_position_controller"
description="Robot controller to start. Choices are: [forward_position_controller, joint_trajectory_controller]."/>
<arg name="inactive_robot_controller"
default="forward_position_controller"
description="Robot controller to start inactive. Choices are: [forward_position_controller, joint_trajectory_controller]."/>

<let name="robot_description_content" value="$(command '$(find-exec xacro) $(find-pkg-share $(var description_package))/urdf/$(var description_file).urdf.xacro prefix:=$(var prefix) use_mock_hardware:=$(var use_mock_hardware) mock_sensor_commands:=$(var mock_sensor_commands)')"/>

Expand All @@ -69,4 +72,7 @@ Authors: Riyan Jose, Manuel Muth, Dr. Denis
<!--robot_controller_spawner-->
<node pkg="controller_manager" exec="spawner" args="$(var robot_controller)"/>

<!--robot_controller_spawner-->
<node pkg="controller_manager" exec="spawner" args="$(var inactive_robot_controller) --inactive"/>

</launch>

0 comments on commit 1d3fe7c

Please sign in to comment.