Skip to content

Commit faabb33

Browse files
AndyZedestogl
andauthored
Make an optional launch arg for RViz, document it in README (#82)
* Avoid launching two RViz instances when MoveIt is launched Co-authored-by: Denis Stogl <[email protected]>
1 parent 76a4029 commit faabb33

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ The most relevant arguments are the following:
6565

6666
### Example Commands for Testing the Driver
6767

68-
1. To start the robot driver and controllers, use:
68+
- To start the robot driver and controllers, use:
6969
```
70-
ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_fake_hardware:=true
70+
ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_fake_hardware:=true launch_rviz:=true
7171
```
7272
For an offline test with the emulated hardware you can just copy-paste this line.
7373
To run on the hardware, write the IP address of your robot and omit the `use_fake_hardware` argument.
@@ -80,13 +80,13 @@ The most relevant arguments are the following:
8080

8181
To check the controllers' state use `ros2 control list_controllers` command.
8282

83-
2. Send some goal to the Joint Trajectory Controller by using a demo node from [ros2_control_demos](https://github.com/ros-controls/ros2_control_demos) package by starting the following command in another terminal:
83+
- Send some goal to the Joint Trajectory Controller by using a demo node from [ros2_control_demos](https://github.com/ros-controls/ros2_control_demos) package by starting the following command in another terminal:
8484
```
8585
ros2 launch ur_bringup test_joint_trajectory_controller.launch.py
8686
```
8787
After a few seconds the robot should move.
8888

89-
3. To test another controller, simply define it using `robot_controller` argument:
89+
- To test another controller, simply define it using `robot_controller` argument:
9090
```
9191
ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy robot_controller:=scaled_joint_trajectory_controller use_fake_hardware:=true
9292
```
@@ -96,9 +96,11 @@ The most relevant arguments are the following:
9696
```
9797
After a few seconds the robot should move (or jump when using emulation).
9898

99-
4. To test the driver with example MoveIt-setup, start `ur_control` launch file and then start MoveIt using the following command:
99+
- To test the driver with example MoveIt-setup, first start the controllers then start MoveIt:
100100
```
101-
ros2 launch ur_bringup ur_moveit.launch.py ur_type:=ur5e robot_ip:="xxx.xxx" use_fake_hardware:=true
101+
ros2 launch ur_bringup ur_control.launch.py ur_type:=ur5e robot_ip:=yyy.yyy.yyy.yyy use_fake_hardware:=true launch_rviz:=false
102+
103+
ros2 launch ur_bringup ur_moveit.launch.py ur_type:=ur5e robot_ip:="xxx.xxx" use_fake_hardware:=true launch_rviz:=true
102104
```
103105
Now you should be able to use MoveIt Plugin in rviz2 to plan and execute trajectories with the robot.
104106
**NOTE**: This results in two instances of rviz2. You can safely close the one without *MotionPlanning* panel.

ur_bringup/launch/ur_control.launch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def generate_launch_description():
118118
description="Robot controller to start.",
119119
)
120120
)
121+
declared_arguments.append(
122+
DeclareLaunchArgument("launch_rviz", default_value="true", description="Launch RViz?")
123+
)
121124

122125
# Initialize Arguments
123126
ur_type = LaunchConfiguration("ur_type")
@@ -134,6 +137,7 @@ def generate_launch_description():
134137
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
135138
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
136139
robot_controller = LaunchConfiguration("robot_controller")
140+
launch_rviz = LaunchConfiguration("launch_rviz")
137141

138142
joint_limit_params = PathJoinSubstitution(
139143
[FindPackageShare(description_package), "config", ur_type, "joint_limits.yaml"]
@@ -236,8 +240,10 @@ def generate_launch_description():
236240
output="both",
237241
parameters=[robot_description],
238242
)
243+
239244
rviz_node = Node(
240245
package="rviz2",
246+
condition=IfCondition(LaunchConfiguration("launch_rviz")),
241247
executable="rviz2",
242248
name="rviz2",
243249
output="log",

ur_bringup/launch/ur_moveit.launch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ def generate_launch_description():
148148
description="Robot controller to start.",
149149
)
150150
)
151+
declared_arguments.append(
152+
DeclareLaunchArgument("launch_rviz", default_value="true", description="Launch RViz?")
153+
)
151154

152155
# Initialize Arguments
153156
ur_type = LaunchConfiguration("ur_type")
@@ -166,6 +169,7 @@ def generate_launch_description():
166169
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
167170
fake_sensor_commands = LaunchConfiguration("fake_sensor_commands")
168171
robot_controller = LaunchConfiguration("robot_controller")
172+
launch_rviz = LaunchConfiguration("launch_rviz")
169173

170174
joint_limit_params = PathJoinSubstitution(
171175
[FindPackageShare(description_package), "config", ur_type, "joint_limits.yaml"]
@@ -345,6 +349,7 @@ def generate_launch_description():
345349
)
346350
rviz_node = Node(
347351
package="rviz2",
352+
condition=IfCondition(LaunchConfiguration("launch_rviz")),
348353
executable="rviz2",
349354
name="rviz2_moveit",
350355
output="log",

0 commit comments

Comments
 (0)