Skip to content

Commit

Permalink
Adds ROS 2 Launch file support to examples with visualizations
Browse files Browse the repository at this point in the history
Launch files were added to the following examples.
	- `multirobot`
	- `hydroelastic`
	- `iiwa_manipulator`
  • Loading branch information
adeeb10abbas committed Aug 8, 2023
1 parent 2d252c3 commit 2ff591e
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bazel-*
**/__pycache__/

# User-specified configuration
/bazel_ros2_rules/user.bazelrc
Expand Down
6 changes: 6 additions & 0 deletions drake_ros_examples/examples/hydroelastic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ install(FILES
hydroelastic.rviz
DESTINATION share/${PROJECT_NAME}/hydroelastic/
)

install(
DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
FILES_MATCHING PATTERN "*_launch.py"
)
7 changes: 6 additions & 1 deletion drake_ros_examples/examples/hydroelastic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ bazel run @ros2//:rviz2 -- -d `pwd`/examples/hydroelastic/hydroelastic.rviz
# Using Colcon/CMake
rviz2 -d `ros2 pkg prefix --share drake_ros_examples`/hydroelastic/hydroelastic.rviz
```
Or use ROS 2 Launch:
```sh
# Using ROS 2 Launch (C++)
ros2 launch drake_ros_examples hydroelastic_cc_launch.py
```

You can optionall enable visualizng the simulation with Meshcat.
You can optionally enable visualizng the simulation with Meshcat.

```bash
# Using bazel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os

from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess


def generate_launch_description():
rviz_config_file = os.path.join(get_package_share_directory('drake_ros_examples'), 'hydroelastic/hydroelastic.rviz')

rviz_node = ExecuteProcess(
cmd=['rviz2', '-d', rviz_config_file],
output='screen'
)

hydroelastic_cpp_node = ExecuteProcess(
cmd=[os.path.join(get_package_prefix('drake_ros_examples'), 'lib', 'drake_ros_examples', 'hydroelastic')],
)
return LaunchDescription([
rviz_node,
hydroelastic_cpp_node,
])
6 changes: 6 additions & 0 deletions drake_ros_examples/examples/iiwa_manipulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ install(
FILES iiwa_manipulator.rviz
DESTINATION share/${PROJECT_NAME}
)

install(
DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
FILES_MATCHING PATTERN "*_launch.py"
)
8 changes: 7 additions & 1 deletion drake_ros_examples/examples/iiwa_manipulator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ bazel run //examples/iiwa_manipulator:iiwa_manipulator
# Python
bazel run //examples/iiwa_manipulator:iiwa_manipulator_py
```

Or
```sh
# Using ROS 2 Launch (C++)
ros2 launch drake_ros_examples iiwa_manipulator_cc_launch.py
# or (Python)
ros2 launch drake_ros_examples iiwa_manipulator_py_launch.py
```
You should see the manipulation station with simple sinusoidal motion.

**Note***: If you restart the simulation but not RViz, you should click RViz's
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os

from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess


def generate_launch_description():
rviz_config_file = os.path.join(get_package_share_directory('drake_ros_examples'), 'iiwa_manipulator.rviz')

rviz_node = ExecuteProcess(
cmd=['rviz2', '-d', rviz_config_file],
output='screen'
)

iiwa_manipulator_cpp_node = ExecuteProcess(
cmd=[os.path.join(get_package_prefix('drake_ros_examples'), 'lib', 'drake_ros_examples', 'iiwa_manipulator')],
)
return LaunchDescription([
rviz_node,
iiwa_manipulator_cpp_node,
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os

from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess


def generate_launch_description():
rviz_config_file = os.path.join(get_package_share_directory('drake_ros_examples'), 'iiwa_manipulator.rviz')

rviz_node = ExecuteProcess(
cmd=['rviz2', '-d', rviz_config_file],
output='screen'
)

iiwa_manipulator_py_node = ExecuteProcess(
cmd=[os.path.join(get_package_prefix('drake_ros_examples'), 'lib', 'drake_ros_examples', 'iiwa_manipulator.py')],
)
return LaunchDescription([
rviz_node,
iiwa_manipulator_py_node,
])
6 changes: 6 additions & 0 deletions drake_ros_examples/examples/multirobot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ install(
FILES multirobot.rviz
DESTINATION share/${PROJECT_NAME}
)

install(
DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
FILES_MATCHING PATTERN "*_launch.py"
)
7 changes: 7 additions & 0 deletions drake_ros_examples/examples/multirobot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ bazel run //examples/multirobot:multirobot
# Python
bazel run //examples/multirobot:multirobot_py
```
Or use ROS 2 Launch:
```sh
# Using ROS 2 Launch (C++)
ros2 launch drake_ros_examples multirobot_cc_launch.py
# or (Python)
ros2 launch drake_ros_examples multirobot_py_launch.py
```

You should observe a 5 x 5 array of manipulators flopping about under the influence of gravity.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os

from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess


def generate_launch_description():
rviz_config_file = os.path.join(get_package_share_directory('drake_ros_examples'), 'multirobot.rviz')

rviz_node = ExecuteProcess(
cmd=['rviz2', '-d', rviz_config_file],
output='screen'
)

multirobot_cpp_node = ExecuteProcess(
cmd=[os.path.join(get_package_prefix('drake_ros_examples'), 'lib', 'drake_ros_examples', 'multirobot')],
)

return LaunchDescription([
rviz_node,
multirobot_cpp_node,
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os

from ament_index_python.packages import get_package_prefix
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import ExecuteProcess


def generate_launch_description():
rviz_config_file = os.path.join(get_package_share_directory('drake_ros_examples'), 'multirobot.rviz')

rviz_node = ExecuteProcess(
cmd=['rviz2', '-d', rviz_config_file],
output='screen'
)

multirobot_py_node = ExecuteProcess(
cmd=[os.path.join(get_package_prefix('drake_ros_examples'), 'lib', 'drake_ros_examples', 'multirobot.py')],
)

return LaunchDescription([
rviz_node,
multirobot_py_node,
])

0 comments on commit 2ff591e

Please sign in to comment.