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

Added live camera tests #2865

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
c785bf5
support color and depth/ir formats
SamerKhshiboun Aug 8, 2023
e05a75b
remove unsupported models
SamerKhshiboun Aug 10, 2023
f2a389e
Merge branch 'ros2-development' into remove_l500_sr300
SamerKhshiboun Aug 16, 2023
00621dc
Get the topic to subscribe from user
Arun-Prasad-V Aug 22, 2023
8405872
merge
SamerKhshiboun Aug 29, 2023
66ba4ee
Added live camera tests
PrasRsRos Aug 30, 2023
6922d4d
Updated readme and imu tests
PrasRsRos Aug 31, 2023
a20eb25
static_tf fix
PrasRsRos Sep 1, 2023
c80e471
Added tf and tf_static tests
PrasRsRos Sep 5, 2023
adc75d7
Added pointcloud tests for live camera
PrasRsRos Sep 5, 2023
1634444
Add aligned tests
PrasRsRos Sep 8, 2023
d5b42b8
Merge branch 'IntelRealSense:ros2-development' into add-live-camera-t…
PrasRsRos Sep 8, 2023
af646fb
Modified the imu test to remove workaround for RS550
PrasRsRos Sep 8, 2023
139acde
removed failing_test file, was covered in all_profile_tests anyway
PrasRsRos Sep 8, 2023
7064b9b
Merge branch 'IntelRealSense:ros2-development' into add-live-camera-t…
PrasRsRos Sep 11, 2023
642236c
Merge branch 'IntelRealSense:ros2-development' into frame_latency
Arun-Prasad-V Sep 11, 2023
e4fd495
Merge branch 'IntelRealSense:ros2-development' into remove_l500_sr300
SamerKhshiboun Sep 2, 2023
4ed7a9f
rebase from ros2-development
SamerKhshiboun Sep 11, 2023
4412cdc
rebase from ros2-development
SamerKhshiboun Sep 11, 2023
348dec3
All topics may need more time in CI
PrasRsRos Sep 11, 2023
0446d7c
All topics testing
PrasRsRos Sep 11, 2023
5f7ec20
All topics testing1
PrasRsRos Sep 11, 2023
426776b
All topics testing2
PrasRsRos Sep 11, 2023
015bd4a
All topics testing3
PrasRsRos Sep 11, 2023
7235d99
All topics testing4
PrasRsRos Sep 11, 2023
e2cd241
All topics added to regression only, excluded from CI
PrasRsRos Sep 11, 2023
b958ca1
getting camera_name dynamically in ROS2 wrapper
Arun-Prasad-V Sep 11, 2023
aef2951
updated tests for the failures in CI
PrasRsRos Sep 14, 2023
e861b35
correct the d435 marker
PrasRsRos Sep 14, 2023
de01005
added markers for d415 d455 specific tests
PrasRsRos Sep 15, 2023
241961e
updated examples and readme
Arun-Prasad-V Sep 18, 2023
df411b1
[Frame Latency] Support for all topics
Arun-Prasad-V Sep 26, 2023
9dae8bd
PR #2841 from SamerKhshiboun: Remove Dashing, Eloquent, Foxy, L500 an…
SamerKhshiboun Sep 26, 2023
16721e1
Merge branch 'IntelRealSense:ros2-development' into frame_latency
Arun-Prasad-V Sep 27, 2023
0e47ef9
Merge branch 'ros2-development' into ros2_examples_readme
Arun-Prasad-V Sep 27, 2023
6f87960
PR #2878 from Arun-Prasad-V: Updated ros2 examples and readme
SamerKhshiboun Sep 27, 2023
1cd8f27
Merge branch 'ros2-development' into camera_name
Arun-Prasad-V Sep 27, 2023
5c1aaaa
Merge PR #2872 from Arun-Prasad-V: Updating _camera_name with RS node…
SamerKhshiboun Sep 27, 2023
9679a9b
[Frame latency Tool] Added description
Arun-Prasad-V Sep 27, 2023
6947e13
Merge PR #2853 from Arun-Prasad-V: Frame latency for the '/topic' pro…
SamerKhshiboun Sep 27, 2023
d2549b1
Revert 'Updating _camera_name with RS node's name'
Arun-Prasad-V Oct 4, 2023
6305b1c
Merge PR #2891 from Arun-Prasad-V: revert PR2872
SamerKhshiboun Oct 4, 2023
7762d8d
Update README.md
SamerKhshiboun Oct 4, 2023
b66a252
Added live camera tests
PrasRsRos Aug 30, 2023
dc12788
Updated readme and imu tests
PrasRsRos Aug 31, 2023
6d34932
static_tf fix
PrasRsRos Sep 1, 2023
295f08d
Added tf and tf_static tests
PrasRsRos Sep 5, 2023
1ff67d4
Added pointcloud tests for live camera
PrasRsRos Sep 5, 2023
4f5c34d
Add aligned tests
PrasRsRos Sep 8, 2023
726dbd2
Modified the imu test to remove workaround for RS550
PrasRsRos Sep 8, 2023
7a525a7
removed failing_test file, was covered in all_profile_tests anyway
PrasRsRos Sep 8, 2023
2c8a39b
All topics may need more time in CI
PrasRsRos Sep 11, 2023
5adccee
All topics testing
PrasRsRos Sep 11, 2023
a8225d1
All topics testing1
PrasRsRos Sep 11, 2023
be59d2e
All topics testing2
PrasRsRos Sep 11, 2023
ac6301e
All topics testing3
PrasRsRos Sep 11, 2023
53e39e7
All topics testing4
PrasRsRos Sep 11, 2023
7777ae7
All topics added to regression only, excluded from CI
PrasRsRos Sep 11, 2023
31b7a80
updated tests for the failures in CI
PrasRsRos Sep 14, 2023
b0d14bf
correct the d435 marker
PrasRsRos Sep 14, 2023
1376bb7
added markers for d415 d455 specific tests
PrasRsRos Sep 15, 2023
b150072
Merge branch 'add-live-camera-tests' of https://github.com/PrasRsRos/…
PrasRsRos Oct 5, 2023
8e499f1
fixed live camera connection checking
PrasRsRos Oct 5, 2023
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
71 changes: 0 additions & 71 deletions .travis.yml

This file was deleted.

17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
- Install dependencies
```bash
sudo apt-get install python3-rosdep -y
sudo rosdep init # "sudo rosdep init --include-eol-distros" for Eloquent and earlier
rosdep update # "sudo rosdep update --include-eol-distros" for Eloquent and earlier
sudo rosdep init # "sudo rosdep init --include-eol-distros" for Foxy and earlier
rosdep update # "sudo rosdep update --include-eol-distros" for Foxy and earlier
rosdep install -i --from-path src --rosdistro $ROS_DISTRO --skip-keys=librealsense2 -y
```

Expand Down Expand Up @@ -203,7 +203,7 @@ User can set the camera name and camera namespace, to distinguish between camera

```ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=D455_1```

- With ros2 run (using remapping mechanisim [Reference](https://docs.ros.org/en/foxy/How-To-Guides/Node-arguments.html)):
- With ros2 run (using remapping mechanisim [Reference](https://docs.ros.org/en/humble/How-To-Guides/Node-arguments.html)):

```ros2 run realsense2_camera realsense2_camera_node --ros-args -r __node:=D455_1 -r __ns:=robot1```

Expand Down Expand Up @@ -269,13 +269,13 @@ User can set the camera name and camera namespace, to distinguish between camera
- They have, at least, the **profile** parameter.
- The profile parameter is a string of the following format: \<width>X\<height>X\<fps> (The dividing character can be X, x or ",". Spaces are ignored.)
- For example: ```depth_module.profile:=640x480x30 rgb_camera.profile:=1280x720x30```
- Since infra, infra1, infra2, fisheye, fisheye1, fisheye2 and depth are all streams of the depth_module, their width, height and fps are defined by the same param **depth_module.profile**
- Since infra, infra1, infra2 and depth are all streams of the depth_module, their width, height and fps are defined by the same param **depth_module.profile**
- If the specified combination of parameters is not available by the device, the default or previously set configuration will be used.
- Run ```ros2 param describe <your_node_name> <param_name>``` to get the list of supported profiles.
- Note: Should re-enable the stream for the change to take effect.
- ***<stream_name>*_format**
- This parameter is a string used to select the stream format.
- <stream_name> can be any of *infra, infra1, infra2, color, depth, fisheye, fisheye1, fisheye2*.
- <stream_name> can be any of *infra, infra1, infra2, color, depth*.
- For example: ```depth_module.depth_format:=Z16 depth_module.infra1_format:=y8 rgb_camera.color_format:=RGB8```
- This parameter supports both lower case and upper case letters.
- If the specified parameter is not available by the stream, the default or previously set configuration will be used.
Expand All @@ -286,14 +286,14 @@ User can set the camera name and camera namespace, to distinguish between camera
- Run ```rs-enumerate-devices``` command to know the list of profiles supported by the connected sensors.
- **enable_*<stream_name>***:
- Choose whether to enable a specified stream or not. Default is true for images and false for orientation streams.
- <stream_name> can be any of *infra, infra1, infra2, color, depth, fisheye, fisheye1, fisheye2, gyro, accel, pose*.
- <stream_name> can be any of *infra, infra1, infra2, color, depth, gyro, accel*.
- For example: ```enable_infra1:=true enable_color:=false```
- **enable_sync**:
- gathers closest frames of different sensors, infra red, color and depth, to be sent with the same timetag.
- This happens automatically when such filters as pointcloud are enabled.
- ***<stream_type>*_qos**:
- Sets the QoS by which the topic is published.
- <stream_type> can be any of *infra, infra1, infra2, color, depth, fisheye, fisheye1, fisheye2, gyro, accel, pose*.
- <stream_type> can be any of *infra, infra1, infra2, color, depth, gyro, accel*.
- Available values are the following strings: `SYSTEM_DEFAULT`, `DEFAULT`, `PARAMETER_EVENTS`, `SERVICES_DEFAULT`, `PARAMETERS`, `SENSOR_DATA`.
- For example: ```depth_qos:=SENSOR_DATA```
- Reference: [ROS2 QoS profiles formal documentation](https://docs.ros.org/en/rolling/Concepts/About-Quality-of-Service-Settings.html#qos-profiles)
Expand Down Expand Up @@ -354,7 +354,6 @@ User can set the camera name and camera namespace, to distinguish between camera
- If set to true, the device will reset prior to usage.
- For example: `initial_reset:=true`
- **base_frame_id**: defines the frame_id all static transformations refers to.
- **odom_frame_id**: defines the origin coordinate system in ROS convention (X-Forward, Y-Left, Z-Up). pose topic defines the pose relative to that system.
- **clip_distance**:
- Remove from the depth image all values above a given value (meters). Disable by giving negative value (default)
- For example: `clip_distance:=1.5`
Expand All @@ -371,8 +370,6 @@ User can set the camera name and camera namespace, to distinguish between camera
- 0 or negative values mean no diagnostics topic is published. Defaults to 0.</br>
The `/diagnostics` topic includes information regarding the device temperatures and actual frequency of the enabled streams.

- **publish_odom_tf**: If True (default) publish TF from odom_frame to pose_frame.

<hr>

<h3 id="coordination">
Expand Down
54 changes: 34 additions & 20 deletions realsense2_camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,34 +144,18 @@ set(SOURCES
if(NOT DEFINED ENV{ROS_DISTRO})
message(FATAL_ERROR "ROS_DISTRO is not defined." )
endif()
if("$ENV{ROS_DISTRO}" STREQUAL "dashing")
message(STATUS "Build for ROS2 Dashing")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDASHING")
set(SOURCES "${SOURCES}" src/ros_param_backend_dashing.cpp)
elseif("$ENV{ROS_DISTRO}" STREQUAL "eloquent")
message(STATUS "Build for ROS2 eloquent")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DELOQUENT")
set(SOURCES "${SOURCES}" src/ros_param_backend_foxy.cpp)
elseif("$ENV{ROS_DISTRO}" STREQUAL "foxy")
message(STATUS "Build for ROS2 Foxy")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFOXY")
set(SOURCES "${SOURCES}" src/ros_param_backend_foxy.cpp)
elseif("$ENV{ROS_DISTRO}" STREQUAL "galactic")
message(STATUS "Build for ROS2 Galactic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGALACTIC")
set(SOURCES "${SOURCES}" src/ros_param_backend_foxy.cpp)
elseif("$ENV{ROS_DISTRO}" STREQUAL "humble")
if("$ENV{ROS_DISTRO}" STREQUAL "humble")
message(STATUS "Build for ROS2 Humble")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHUMBLE")
set(SOURCES "${SOURCES}" src/ros_param_backend_foxy.cpp)
set(SOURCES "${SOURCES}" src/ros_param_backend.cpp)
elseif("$ENV{ROS_DISTRO}" STREQUAL "iron")
message(STATUS "Build for ROS2 Iron")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIRON")
set(SOURCES "${SOURCES}" src/ros_param_backend_foxy.cpp)
set(SOURCES "${SOURCES}" src/ros_param_backend.cpp)
elseif("$ENV{ROS_DISTRO}" STREQUAL "rolling")
message(STATUS "Build for ROS2 Rolling")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DROLLING")
set(SOURCES "${SOURCES}" src/ros_param_backend_rolling.cpp)
set(SOURCES "${SOURCES}" src/ros_param_backend.cpp)
else()
message(FATAL_ERROR "Unsupported ROS Distribution: " "$ENV{ROS_DISTRO}")
endif()
Expand Down Expand Up @@ -320,6 +304,36 @@ if(BUILD_TESTING)
)
endforeach()
endforeach()

unset(_pytest_folders)

set(rs_query_cmd "rs-enumerate-devices -s")
execute_process(COMMAND bash -c ${rs_query_cmd}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE rs_result
OUTPUT_VARIABLE RS_DEVICE_INFO)
message(STATUS "rs_device_info:")
message(STATUS "${RS_DEVICE_INFO}")
if((RS_DEVICE_INFO MATCHES "D455") OR (RS_DEVICE_INFO MATCHES "D415") OR (RS_DEVICE_INFO MATCHES "D435"))
message(STATUS "D455 device found")
set(_pytest_live_folders
test/live_camera
)
endif()

foreach(test_folder ${_pytest_live_folders})
file(GLOB files "${test_folder}/test_*.py")
foreach(file ${files})

get_filename_component(_test_name ${file} NAME_WE)
ament_add_pytest_test(${_test_name} ${file}
APPEND_ENV PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_SOURCE_DIR}/test/utils:${CMAKE_SOURCE_DIR}/launch:${CMAKE_SOURCE_DIR}/scripts
TIMEOUT 500
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endforeach()
endforeach()

endif()

# Ament exports
Expand Down
12 changes: 12 additions & 0 deletions realsense2_camera/examples/align_depth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Align Depth to Color
This example shows how to start the camera node and align depth stream to color stream.
```
ros2 launch realsense2_camera rs_align_depth_launch.py
```

The aligned image will be published to the topic "/aligned_depth_to_color/image_raw"

Also, align depth to color can enabled by following cmd:
```
ros2 launch realsense2_camera rs_launch.py align_depth.enable:=true
```
123 changes: 123 additions & 0 deletions realsense2_camera/examples/dual_camera/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Launching Dual RS ROS2 nodes
The following example lanches two RS ROS2 nodes.
```
ros2 launch realsense2_camera rs_dual_camera_launch.py serial_no1:=<serial number of the first camera> serial_no2:=<serial number of the second camera>
```

## Example:
Let's say the serial numbers of two RS cameras are 207322251310 and 234422060144.
```
ros2 launch realsense2_camera rs_dual_camera_launch.py serial_no1:="'207322251310'" serial_no2:="'234422060144'"
```
or
```
ros2 launch realsense2_camera rs_dual_camera_launch.py serial_no1:=_207322251310 serial_no2:=_234422060144
```

## How to know the serial number?
Method 1: Using the rs-enumerate-devices tool
```
rs-enumerate-devices | grep "Serial Number"
```

Method 2: Connect single camera and run
```
ros2 launch realsense2_camera rs_launch.py
```
and look for the serial number in the log printed to screen under "[INFO][...] Device Serial No:".

# Using Multiple RS camera by launching each in differnet terminals
Make sure you set a different name and namespace for each camera.

Terminal 1:
```
ros2 launch realsense2_camera rs_launch.py serial_no:="'207322251310'" camera_name:='camera1' camera_namespace:='camera1'
```
Terminal 2:
```
ros2 launch realsense2_camera rs_launch.py serial_no:="'234422060144'" camera_name:='camera2' camera_namespace:='camera2'
```

# Multiple cameras showing a semi-unified pointcloud
The D430 series of RealSense cameras use stereo based algorithm to calculate depth. This mean, a couple of cameras can operate on the same scene. For the purpose of this demonstration, let's say 2 cameras can be coupled to look at the same scene from 2 different points of view. See image:

![multi_cameras](https://user-images.githubusercontent.com/127019120/268692789-1b3d5d8b-a41f-4a97-995d-81d44b4bcacb.jpg)

The schematic settings could be described as:
X--------------------------------->cam_2
|&emsp;&emsp;&emsp;&emsp;(70 cm)
|
|
|&ensp;(60 cm)
|
|
/
cam_1

The cameras have no data regarding their relative position. That’s up to a third party program to set. To simplify things, the coordinate system of cam_1 can be considered as the refernce coordinate system for the whole scene.

The estimated translation of cam_2 from cam_1 is 70(cm) on X-axis and 60(cm) on Y-axis. Also, the estimated yaw angle of cam_2 relative to cam_1 as 90(degrees) clockwise. These are the initial parameters to be set for setting the transformation between the 2 cameras as follows:

```
ros2 launch realsense2_camera rs_dual_camera_launch.py serial_no1:=_207322251310 serial_no2:=_234422060144 tf.translation.x:=0.7 tf.translation.y:=0.6 tf.translation.z:=0.0 tf.rotation.yaw:=-90.0 tf.rotation.pitch:=0.0 tf.rotation.roll:=0.0
```

If the unified pointcloud result is not good, follow the below steps to fine-tune the calibaration.

## Visualizing the pointclouds and fine-tune the camera calibration
Launch 2 cameras in separate terminals:

**Terminal 1:**
```
ros2 launch realsense2_camera rs_launch.py serial_no:="'207322251310'" camera_name:='camera1' camera_namespace:='camera1'
```
**Terminal 2:**
```
ros2 launch realsense2_camera rs_launch.py serial_no:="'234422060144'" camera_name:='camera2' camera_namespace:='camera2'
```
**Terminal 3:**
```
rviz2
```
Open rviz and set '“Fixed Frame'” to “camera1_link”
Add Pointcloud2-> By topic -> /camera1/camera1/depth/color/points
Add Pointcloud2 -> By topic -> /camera2/camera2/depth/color/points

**Terminal 4:**
Run the 'set_cams_transforms.py' tool. It can be used to fine-tune the calibaration.
```
python src/realsense-ros/realsense2_camera/scripts/set_cams_transforms.py camera1_link camera2_link 0.7 0.6 0 -90 0 0
```

**Instructions printed by the tool:**
```
Using default file /home/user_name/ros2_ws/src/realsense-ros/realsense2_camera/scripts/_set_cams_info_file.txt

Use given initial values.

Press the following keys to change mode: x, y, z, (a)zimuth, (p)itch, (r)oll

For each mode, press 6 to increase by step and 4 to decrease

Press + to multiply step by 2 or - to divide

Press Q to quit
```

Note that the tool prints the path of the current configuration file. It saves its last configuration automatically, all the time, to be used on the next run.

After a lot of fiddling around, unified pointcloud looked better with the following calibaration:
```
x = 0.75
y = 0.575
z = 0
azimuth = -91.25
pitch = 0.75
roll = 0
```

Now, use the above results in the launch file:
```
ros2 launch realsense2_camera rs_dual_camera_launch.py serial_no1:=_207322251310 serial_no2:=_234422060144 tf.translation.x:=0.75 tf.translation.y:=0.575 tf.translation.z:=0.0 tf.rotation.yaw:=-91.25 tf.rotation.pitch:=0.75 tf.rotation.roll:=0.0
```

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# For each device, the parameter name was changed to include an index.
# For example: to set camera_name for device1 set parameter camera_name1.
# command line example:
# ros2 launch realsense2_camera rs_dual_camera_launch.py camera_name1:=D400 device_type2:=l5. device_type1:=d4..
# ros2 launch realsense2_camera rs_dual_camera_launch.py serial_no1:=<serial number of 1st camera> serial_no2:=<serial number of 2nd camera>

"""Launch realsense2_camera node."""
import copy
Expand Down Expand Up @@ -68,7 +68,7 @@ def duplicate_params(general_params, posix):
return local_params

def launch_static_transform_publisher_node(context : LaunchContext):
# dummy static transformation from camera1 to camera2
# Static transformation from camera1 to camera2
node = launch_ros.actions.Node(
name = "my_static_transform_publisher",
package = "tf2_ros",
Expand Down Expand Up @@ -104,6 +104,6 @@ def generate_launch_description():
namespace='',
executable='rviz2',
name='rviz2',
arguments=['-d', [ThisLaunchFileDir(), '/dual_camera_pointcloud.rviz']]
arguments=['-d', [ThisLaunchFileDir(), '/rviz/dual_camera_pointcloud.rviz']]
)
])
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Visualization Manager:
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: /camera1/depth/color/points
Value: /camera1/camera1/depth/color/points
Use Fixed Frame: true
Use rainbow: true
Value: true
Expand Down Expand Up @@ -108,7 +108,7 @@ Visualization Manager:
Filter size: 10
History Policy: Keep Last
Reliability Policy: Reliable
Value: /camera2/depth/color/points
Value: /camera2/camera2/depth/color/points
Use Fixed Frame: true
Use rainbow: true
Value: true
Expand Down
Loading