-
Notifications
You must be signed in to change notification settings - Fork 10
Add realsense docker module and include examples #99
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
Open
yuhsiang1117
wants to merge
10
commits into
j3soon:main
Choose a base branch
from
yuhsiang1117:feat/realsense
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b85d8a
feat: create a new docker module for realsense
yuhsiang1117 f97799c
feat: create realsense example package and create realsense_desp work…
yuhsiang1117 8142b2b
feat: add realsense gazebo simulation package
yuhsiang1117 2f4f670
feat: add realsense related packages to template_ws
yuhsiang1117 ff4ac96
feat: add RealSense documentation and fix permissions of install script
yuhsiang1117 2344eeb
fix: rename realsense_example to realsense_examples
yuhsiang1117 034c48a
fix: add rviz config path in realsense_gazebo launch file
yuhsiang1117 a3d0c02
fix: adjust realsense d435 pose and mesh path for turtlebot3 burger
yuhsiang1117 09717b7
fix: add dependent package installation in docker
yuhsiang1117 db72697
fix: parameterize RealSense package installation
yuhsiang1117 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| if [ -z "$REALSENSE" ]; then | ||
| echo "Skipping RealSense installation as REALSENSE is not set" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Install RealSense, TurtleBot3 packages and rqt steering | ||
| # This script is intended to be run inside the Dockerfile during build. | ||
| if [ "$REALSENSE" = "YES" ]; then | ||
| echo "Installing RealSense ros packages for ROS distro: ${ROS_DISTRO:-humble}" | ||
|
|
||
| sudo apt-get update && sudo apt-get install -y \ | ||
| ros-${ROS_DISTRO}-point-cloud-transport \ | ||
| ros-${ROS_DISTRO}-librealsense2* \ | ||
| ros-${ROS_DISTRO}-realsense2-* \ | ||
| ros-${ROS_DISTRO}-turtlebot3* \ | ||
| ros-${ROS_DISTRO}-rqt-robot-steering \ | ||
| ros-${ROS_DISTRO}-launch-pytest \ | ||
| python3-tqdm \ | ||
| && sudo rm -rf /var/lib/apt/lists/* | ||
| fi | ||
|
|
||
| echo "RealSense installation completed successfully!" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # Realsense | ||
|
|
||
| [](https://github.com/j3soon/ros2-essentials/blob/main/docker_modules/install_cartographer.sh) | ||
|
|
||
| ROS2 Realsense. (Only installed by default for the template workspace.) | ||
|
|
||
| To enable Realsense, set the `REALSENSE` argument to `YES` in the `compose.yaml` file of your desired workspace (e.g., `husky_ws/docker/compose.yaml`). After making these changes, rebuild the Docker image. | ||
|
|
||
| > TODO: Remove duplicate content from the template workspace below. | ||
yuhsiang1117 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## 🐳 Start Container | ||
|
|
||
| > Make sure your system meets the [system requirements](https://j3soon.github.io/ros2-essentials/#system-requirements) and have followed the [setup instructions](https://j3soon.github.io/ros2-essentials/#setup) before using this workspace. | ||
| Run the following commands in a Ubuntu desktop environment. If you are using a remote server, make sure you're using a terminal within a remote desktop session (e.g., VNC) instead of SSH (i.e., don't use `ssh -X` or `ssh -Y`). | ||
|
|
||
| ```sh | ||
| cd ~/ros2-essentials/template_ws/docker | ||
| docker compose build | ||
| xhost +local:docker | ||
| docker compose up -d | ||
| # The initial build will take a while, please wait patiently. | ||
| ``` | ||
|
|
||
| > If your user's UID is `1000`, you may replace the `docker compose build` command with `docker compose pull`. | ||
| The commands in the following sections assume that you are inside the Docker container: | ||
|
|
||
| ```sh | ||
| # in a new terminal | ||
| docker exec -it ros2-template-ws bash | ||
| ``` | ||
|
|
||
| If the initial build somehow failed, run: | ||
|
|
||
| ```sh | ||
| rm -r build install | ||
| colcon build --symlink-install | ||
| ``` | ||
|
|
||
| Once you have finished testing, you can stop and remove the container with: | ||
|
|
||
| ```sh | ||
| docker compose down | ||
| ``` | ||
|
|
||
| ## Realsense test with gazebo | ||
|
|
||
| - realsense_desp package: Description of a robot with realsense D435 camera. | ||
| - realsense_gazebo package: Gazebo simulation of the robot with robot state publisher. | ||
| - Launch Gazebo with turtlebot3 in `tmux` | ||
| ```bash | ||
| ros2 launch realsense_gazebo realsense_gazebo.launch.py | ||
| ``` | ||
|
|
||
| - Run the control tool in new window of `tmux` | ||
| ```bash | ||
| ros2 run rqt_robot_steering rqt_robot_steering | ||
| ``` | ||
|
|
||
| ## Realsense test in realworld | ||
|
|
||
| - Launch Realsense camera node in `tmux` | ||
| ```bash | ||
| # add pointcloud.enable:=true to enable pointcloud | ||
| ros2 launch realsense2_camera rs_launch.py | ||
| ``` | ||
|
|
||
| - Open RViz to verify the camera topics in `tmux` | ||
| ```bash | ||
| ros2 run rviz2 rviz2 | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| - [Realsense ROS Wrapper](https://github.com/IntelRealSense/realsense-ros) | ||
| - [RealSense Gazebo ROS Plugin](https://github.com/pal-robotics/realsense_gazebo_plugin) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,8 @@ services: | |
| CARTOGRAPHER: "YES" | ||
| # TODO: Set to "YES" if using RTAB-Map or set to "" if not using RTAB-Map | ||
| RTABMAP: "YES" | ||
| # TODO: Set to "YES" if using RealSense or set to "" if not using RealSense | ||
| REALSENSE: "YES" | ||
| cache_from: | ||
| - j3soon/ros2-template-ws:buildcache-amd64 | ||
| - j3soon/ros2-template-ws:buildcache-arm64 | ||
|
|
@@ -109,7 +111,7 @@ services: | |
| # Mount shared memory for ROS2 communication. | ||
| - /dev/shm:/dev/shm | ||
| # TODO: Uncomment the line below and comment out the three entries above to enable USB support. | ||
| # - /dev:/dev | ||
| - /dev:/dev | ||
| # Mount Gazebo models directory to reuse models downloaded during first launch. | ||
| # Reference: https://answers.ros.org/question/365658 | ||
| # Note that this volume is shared among all workspaces. | ||
|
|
@@ -179,6 +181,11 @@ services: | |
| # TODO: Add more volume mounts here. | ||
| # Mount root workspace to allow easy access to all workspaces. | ||
| - ../..:/home/ros2-essentials | ||
| # Add device cgroup rules to allow access to specific devices (like realsense). | ||
| # Ref: https://github.com/2b-t/realsense-ros2-docker | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding reference docs here feels a bit out of place. It might be better to make this a standalone commit or include it in another one. |
||
| device_cgroup_rules: | ||
| - 'c 81:* rmw' | ||
| - 'c 189:* rmw' | ||
| volumes: | ||
| gazebo-cache: | ||
| name: ros2-gazebo-cache | ||
|
|
||
30 changes: 30 additions & 0 deletions
30
template_ws/src/realsense_examples/realsense_desp/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| cmake_minimum_required(VERSION 3.8) | ||
| project(realsense_desp) | ||
|
|
||
| if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
| add_compile_options(-Wall -Wextra -Wpedantic) | ||
| endif() | ||
|
|
||
| # find dependencies | ||
| find_package(ament_cmake REQUIRED) | ||
| # uncomment the following section in order to fill in | ||
| # further dependencies manually. | ||
| # find_package(<dependency> REQUIRED) | ||
|
|
||
| if(BUILD_TESTING) | ||
| find_package(ament_lint_auto REQUIRED) | ||
| # the following line skips the linter which checks for copyrights | ||
| # comment the line when a copyright and license is added to all source files | ||
| set(ament_cmake_copyright_FOUND TRUE) | ||
| # the following line skips cpplint (only works in a git repo) | ||
| # comment the line when this package is in a git repo and when | ||
| # a copyright and license is added to all source files | ||
| set(ament_cmake_cpplint_FOUND TRUE) | ||
| ament_lint_auto_find_test_dependencies() | ||
| endif() | ||
|
|
||
| install(DIRECTORY launch models urdf | ||
| DESTINATION share/${PROJECT_NAME}/ | ||
| ) | ||
|
|
||
| ament_package() |
71 changes: 71 additions & 0 deletions
71
template_ws/src/realsense_examples/realsense_desp/launch/realsense_desp.launch.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import os | ||
|
|
||
| from ament_index_python.packages import get_package_share_directory | ||
|
|
||
| from launch import LaunchDescription | ||
| from launch.actions import DeclareLaunchArgument | ||
| from launch.substitutions import PathJoinSubstitution, LaunchConfiguration | ||
|
|
||
| from launch_ros.substitutions import FindPackageShare | ||
| from launch_ros.actions import Node | ||
|
|
||
| def generate_launch_description(): | ||
|
|
||
| # Declare the robot position argument | ||
| robot_px = LaunchConfiguration('robot_px') | ||
| robot_px_arg = DeclareLaunchArgument('robot_px', default_value='0.5') | ||
|
|
||
| robot_py = LaunchConfiguration('robot_py') | ||
| robot_py_arg = DeclareLaunchArgument('robot_py', default_value='0.5') | ||
|
|
||
| robot_pz = LaunchConfiguration('robot_pz') | ||
| robot_pz_arg = DeclareLaunchArgument('robot_pz', default_value='0.0') | ||
|
|
||
| # Define the path to the model | ||
| burger_model_path = PathJoinSubstitution([ | ||
| FindPackageShare("realsense_desp"), | ||
| "models/turtlebot3_burger/model.sdf" | ||
| ]) | ||
|
|
||
| # Add robot description | ||
| # Ref: https://github.com/ROBOTIS-GIT/turtlebot3_simulations/blob/98a27b20952b11047f454d7ec751f8c742862713/turtlebot3_gazebo/launch/robot_state_publisher.launch.py | ||
| urdf_path = os.path.join( | ||
| get_package_share_directory('realsense_desp'), | ||
| 'urdf', | ||
| 'turtlebot3_burger.urdf' | ||
| ) | ||
|
|
||
| with open(urdf_path, 'r') as infp: | ||
| robot_desc = infp.read() | ||
|
|
||
| robot_description = Node( | ||
| package='robot_state_publisher', | ||
| executable='robot_state_publisher', | ||
| parameters=[{ | ||
| 'use_sim_time': True, | ||
| 'robot_description': robot_desc | ||
| }], | ||
| ) | ||
|
|
||
| # Spawn the robot in Gazebo | ||
| # Ref: https://github.com/ros-simulation/gazebo_ros_pkgs/blob/d52f7c471d1d2fd9425bf8621290bc4831be8dea/gazebo_ros/launch/spawn_entity_demo.launch.py | ||
| spawn_entity = Node( | ||
| package='gazebo_ros', | ||
| executable='spawn_entity.py', | ||
| arguments=[ | ||
| '-entity', 'burger', | ||
| '-file', burger_model_path, | ||
| '-x', robot_px, | ||
| '-y', robot_py, | ||
| '-z', robot_pz | ||
| ], | ||
| parameters=[{'use_sim_time': True}] | ||
| ) | ||
|
|
||
| return LaunchDescription([ | ||
| # Argument | ||
| robot_pz_arg, robot_px_arg, robot_py_arg, | ||
|
|
||
| # Nodes | ||
| robot_description, spawn_entity | ||
| ]) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure what's going wrong, but adding this line seems to break the Docker build (it says the package can't be found). Theoretically, it should be able to locate it, so I'm a bit puzzled here. Ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, could you clarify why these files need to be installed? I tried removing them locally, and the workspace seems to work just fine without them.