Skip to content

Commit

Permalink
Merge PR #3066 from SamerKhshiboun: Revert Foxy Build Support (From S…
Browse files Browse the repository at this point in the history
…ource)
  • Loading branch information
SamerKhshiboun authored Apr 8, 2024
2 parents b69891b + a75c2e2 commit 34350e7
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 28 deletions.
36 changes: 29 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ jobs:
strategy:
fail-fast: false
matrix:
ros_distro: [rolling, iron, humble]
ros_distro: [rolling, iron, humble, foxy]
include:
- ros_distro: 'rolling'
os: ubuntu-22.04
- ros_distro: 'iron'
os: ubuntu-22.04
- ros_distro: 'humble'
os: ubuntu-22.04
- ros_distro: 'foxy'
os: ubuntu-20.04

steps:

Expand All @@ -50,13 +52,27 @@ jobs:
cd ${{github.workspace}}/ros2/src/realsense-ros/scripts
./pr_check.sh
- name: build ROS2
# setup-ros@v0.6 is the last version supporting foxy (EOL)
# setup-ros@v0.7 is needed to support humble/iron/rolling
# so, seperating steps with if conditions
- name: build ROS2 for foxy
if: ${{ matrix.ros_distro == 'foxy' }}
uses: ros-tooling/setup-ros@v0.6
with:
required-ros-distributions: ${{ matrix.ros_distro }}
- name: build ROS2 for humble/iron/rolling
if: ${{ matrix.ros_distro != 'foxy' }}
uses: ros-tooling/setup-ros@v0.7
with:
required-ros-distributions: ${{ matrix.ros_distro }}

- name: Build RealSense SDK 2.0 from source
- name: Build RealSense SDK 2.0 (development branch) from source
run: |
# libusb-1.0-0-dev is needed for librealsense build in ubuntu 20.04
# This apt install command will be ignored in ubuntu 22.04 as libusb-1.0-0-dev already installed there
sudo apt install -y libusb-1.0-0-dev
cd ${{github.workspace}}
git clone https://github.com/IntelRealSense/librealsense.git -b development
cd librealsense
Expand All @@ -68,13 +84,13 @@ jobs:
sudo make -j10
sudo make install
- name: Build RealSense ROS2 Wrapper
run: |
- name: Build RealSense ROS2 Wrapper from source
run: |
echo "source /opt/ros/${{ matrix.ros_distro }}/setup.bash" >> ${{github.workspace}}/.bashrc
source ${{github.workspace}}/.bashrc
cd ${{github.workspace}}/ros2
echo "================= ROSDEP UPDATE ====================="
rosdep update --rosdistro ${{ matrix.ros_distro }}
rosdep update --rosdistro ${{ matrix.ros_distro }} --include-eol-distros
echo "================= ROSDEP INSTALL ===================="
rosdep install -i --reinstall --from-path src --rosdistro ${{ matrix.ros_distro }} --skip-keys=librealsense2 -y
echo "================== COLCON BUILD ======================"
Expand Down Expand Up @@ -103,10 +119,16 @@ jobs:
cd ${{github.workspace}}/ros2
source ${{github.workspace}}/.bashrc
. install/local_setup.bash
# the next command might be needed for foxy distro, since this package is not installed
# by default in ubuntu 20.04. For other distro, the apt install command will be ignored.
sudo apt install -y ros-${{matrix.ros_distro}}-sensor-msgs-py
python3 src/realsense-ros/realsense2_camera/scripts/rs2_test.py non_existent_file
# don't run integration tests for foxy since some testing dependecies packages like
# tf_ros_py are not avaialble
# TODO: check when we can run integration tests on rolling
- name: Run integration tests
if: ${{ matrix.ros_distro != 'rolling'}}
if: ${{ matrix.ros_distro != 'rolling' && matrix.ros_distro != 'foxy' }}
run: |
cd ${{github.workspace}}/ros2
source ${{github.workspace}}/.bashrc
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
[![rolling][rolling-badge]][rolling]
[![iron][iron-badge]][iron]
[![humble][humble-badge]][humble]
[![foxy][foxy-badge]][foxy]
[![ubuntu22][ubuntu22-badge]][ubuntu22]
[![ubuntu20][ubuntu20-badge]][ubuntu20]

Expand Down Expand Up @@ -90,20 +91,23 @@
- #### Ubuntu 22.04:
- [ROS2 Iron](https://docs.ros.org/en/iron/Installation/Ubuntu-Install-Debians.html)
- [ROS2 Humble](https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html)
#### Ubuntu 20.04
- [ROS2 Foxy](https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html)
</details>

<details>
<summary>
Step 2: Install latest Intel&reg; RealSense&trade; SDK 2.0
</summary>

**Please choose only one option from the 3 options below (in order to prevent multiple versions installation and workspace conflicts)**

- #### Option 1: Install librealsense2 debian package from Intel servers
- Jetson users - use the [Jetson Installation Guide](https://github.com/IntelRealSense/librealsense/blob/master/doc/installation_jetson.md)
- Otherwise, install from [Linux Debian Installation Guide](https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md#installing-the-packages)
- In this case treat yourself as a developer: make sure to follow the instructions to also install librealsense2-dev and librealsense2-dkms packages

- #### Option 2: Install librealsense2 (without graphical tools and examples) debian package from ROS servers:
- #### Option 2: Install librealsense2 (without graphical tools and examples) debian package from ROS servers (Foxy EOL distro is not supported by this option):
- [Configure](http://wiki.ros.org/Installation/Ubuntu/Sources) your Ubuntu repositories
- Install all realsense ROS packages by ```sudo apt install ros-<ROS_DISTRO>-librealsense2*```
- For example, for Humble distro: ```sudo apt install ros-humble-librealsense2*```
Expand All @@ -119,7 +123,7 @@
Step 3: Install Intel&reg; RealSense&trade; ROS2 wrapper
</summary>

#### Option 1: Install debian package from ROS servers
#### Option 1: Install debian package from ROS servers (Foxy EOL distro is not supported by this option):
- [Configure](http://wiki.ros.org/Installation/Ubuntu/Sources) your Ubuntu repositories
- Install all realsense ROS packages by ```sudo apt install ros-<ROS_DISTRO>-realsense2-*```
- For example, for Humble distro: ```sudo apt install ros-humble-realsense2-*```
Expand Down Expand Up @@ -153,7 +157,7 @@

- Source environment
```bash
ROS_DISTRO=<YOUR_SYSTEM_ROS_DISTRO> # set your ROS_DISTRO: iron, humble
ROS_DISTRO=<YOUR_SYSTEM_ROS_DISTRO> # set your ROS_DISTRO: iron, humble, foxy
source /opt/ros/$ROS_DISTRO/setup.bash
cd ~/ros2_ws
. install/local_setup.bash
Expand All @@ -172,14 +176,17 @@
</summary>

- #### Windows 10/11

**Please choose only one option from the two options below (in order to prevent multiple versions installation and workspace conflicts)**

- Manual install from ROS2 formal documentation:
- [ROS2 Iron](https://docs.ros.org/en/iron/Installation/Windows-Install-Binary.html)
- [ROS2 Humble](https://docs.ros.org/en/humble/Installation/Windows-Install-Binary.html)
- [ROS2 Foxy](https://docs.ros.org/en/foxy/Installation/Windows-Install-Binary.html)
- Microsoft IOT binary installation:
- https://ms-iot.github.io/ROSOnWindows/GettingStarted/SetupRos2.html
- Pay attention that the examples of install are for Foxy distro (which is not supported anymore by RealSense ROS2 Wrapper)
- Please replace the word "Foxy" with Humble or Iron, as you choose
- Please replace the word "Foxy" with Humble or Iron, depends on the chosen distro.
</details>

<details>
Expand Down Expand Up @@ -676,6 +683,8 @@ ros2 launch realsense2_camera rs_intra_process_demo_launch.py intra_process_comm

[rolling-badge]: https://img.shields.io/badge/-ROLLING-orange?style=flat-square&logo=ros
[rolling]: https://docs.ros.org/en/rolling/index.html
[foxy-badge]: https://img.shields.io/badge/-foxy-orange?style=flat-square&logo=ros
[foxy]: https://docs.ros.org/en/foxy/index.html
[humble-badge]: https://img.shields.io/badge/-HUMBLE-orange?style=flat-square&logo=ros
[humble]: https://docs.ros.org/en/humble/index.html
[iron-badge]: https://img.shields.io/badge/-IRON-orange?style=flat-square&logo=ros
Expand Down
6 changes: 5 additions & 1 deletion realsense2_camera/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ endif()
if(NOT DEFINED ENV{ROS_DISTRO})
message(FATAL_ERROR "ROS_DISTRO is not defined." )
endif()
if("$ENV{ROS_DISTRO}" STREQUAL "humble")
if("$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.cpp)
elseif("$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.cpp)
Expand Down
10 changes: 9 additions & 1 deletion realsense2_camera/launch/rs_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,22 @@ def yaml_to_dict(path_to_yaml):
def launch_setup(context, params, param_name_suffix=''):
_config_file = LaunchConfiguration('config_file' + param_name_suffix).perform(context)
params_from_file = {} if _config_file == "''" else yaml_to_dict(_config_file)

_output = LaunchConfiguration('output' + param_name_suffix)
if(os.getenv('ROS_DISTRO') == 'foxy'):
# Foxy doesn't support output as substitution object (LaunchConfiguration object)
# but supports it as string, so we fetch the string from this substitution object
# see related PR that was merged for humble, iron, rolling: https://github.com/ros2/launch/pull/577
_output = context.perform_substitution(_output)

return [
launch_ros.actions.Node(
package='realsense2_camera',
namespace=LaunchConfiguration('camera_namespace' + param_name_suffix),
name=LaunchConfiguration('camera_name' + param_name_suffix),
executable='realsense2_camera_node',
parameters=[params, params_from_file],
output=LaunchConfiguration('output' + param_name_suffix),
output=_output,
arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level' + param_name_suffix)],
emulate_tty=True,
)
Expand Down
22 changes: 11 additions & 11 deletions realsense2_camera/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
<depend>tf2</depend>
<depend>tf2_ros</depend>
<depend>diagnostic_updater</depend>
<test_depend>ament_cmake_gtest</test_depend>
<test_depend>launch_testing</test_depend>
<test_depend>ament_cmake_pytest</test_depend>
<test_depend>launch_pytest</test_depend>
<test_depend>sensor_msgs_py</test_depend>
<test_depend>python3-numpy</test_depend>
<test_depend>python3-tqdm</test_depend>
<test_depend>sensor_msgs_py</test_depend>
<test_depend>python3-requests</test_depend>
<test_depend>tf2_ros_py</test_depend>
<test_depend>ros2topic</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">ament_cmake_gtest</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">launch_testing</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">ament_cmake_pytest</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">launch_pytest</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">sensor_msgs_py</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">python3-numpy</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">python3-tqdm</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">sensor_msgs_py</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">python3-requests</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">tf2_ros_py</test_depend>
<test_depend condition="$ROS_DISTRO != foxy">ros2topic</test_depend>

<exec_depend>launch_ros</exec_depend>
<build_depend>ros_environment</build_depend>
Expand Down
7 changes: 7 additions & 0 deletions realsense2_camera/src/base_realsense_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,14 @@ rclcpp::Time BaseRealSenseNode::frameSystemTimeSec(rs2::frame frame)
{
double elapsed_camera_ns = millisecondsToNanoseconds(timestamp_ms - _camera_time_base);

/*
Fixing deprecated-declarations compilation error for EOL distro (foxy)
*/
#if defined(FOXY)
auto duration = rclcpp::Duration(elapsed_camera_ns);
#else
auto duration = rclcpp::Duration::from_nanoseconds(elapsed_camera_ns);
#endif

return rclcpp::Time(_ros_time_base + duration);
}
Expand Down
6 changes: 5 additions & 1 deletion realsense2_camera/src/dynamic_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ namespace realsense2_camera
try
{
ROS_DEBUG_STREAM("setParam::Setting parameter: " << param_name);
descriptor.dynamic_typing=true; // Without this, undeclare_parameter() throws error.
#if defined(FOXY)
//do nothing for old versions (foxy)
#else
descriptor.dynamic_typing=true;
#endif
if (!_node.get_parameter(param_name, result_value))
{
result_value = _node.declare_parameter(param_name, initial_value, descriptor);
Expand Down
9 changes: 6 additions & 3 deletions realsense2_camera/src/ros_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include <ros_sensor.h>
#include <assert.h>

using namespace realsense2_camera;
using namespace rs2;
Expand Down Expand Up @@ -409,7 +410,7 @@ void RosSensor::set_sensor_auto_exposure_roi()
{
try
{
rs2_stream stream_type;
rs2_stream stream_type = RS2_STREAM_ANY;
if (this->rs2::sensor::is<rs2::depth_sensor>())
{
stream_type = RS2_STREAM_DEPTH;
Expand All @@ -418,6 +419,7 @@ void RosSensor::set_sensor_auto_exposure_roi()
{
stream_type = RS2_STREAM_COLOR;
}
assert(stream_type != RS2_STREAM_ANY);

int width = std::dynamic_pointer_cast<VideoProfilesManager>(_profile_managers[0])->getWidth(stream_type);
int height = std::dynamic_pointer_cast<VideoProfilesManager>(_profile_managers[0])->getHeight(stream_type);
Expand Down Expand Up @@ -451,7 +453,7 @@ void RosSensor::registerAutoExposureROIOptions()

if (this->rs2::sensor::is<rs2::roi_sensor>())
{
rs2_stream stream_type;
rs2_stream stream_type = RS2_STREAM_ANY;
if (this->rs2::sensor::is<rs2::depth_sensor>())
{
stream_type = RS2_STREAM_DEPTH;
Expand All @@ -460,7 +462,8 @@ void RosSensor::registerAutoExposureROIOptions()
{
stream_type = RS2_STREAM_COLOR;
}

assert(stream_type != RS2_STREAM_ANY);

int width = std::dynamic_pointer_cast<VideoProfilesManager>(_profile_managers[0])->getWidth(stream_type);
int height = std::dynamic_pointer_cast<VideoProfilesManager>(_profile_managers[0])->getHeight(stream_type);

Expand Down

0 comments on commit 34350e7

Please sign in to comment.