Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ROS2 Launch Files to all relevant examples #289

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
])
Loading