Skip to content

Commit 19afec1

Browse files
author
rostest
committed
ROS-2 Humble support
1 parent ce69c42 commit 19afec1

13 files changed

+83
-23
lines changed

CMakeLists.txt

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@ project(sick_lidar_localization)
55
## Compile options ##
66
#####################
77

8+
if(ROS_VERSION EQUAL 2)
9+
set(ROS2_HUMBLE 1)
10+
if(WIN32 OR EXISTS "/opt/ros/eloquent" OR EXISTS "/opt/ros/foxy" OR EXISTS "/opt/ros/galactic") # rosidl_typesupport for ROS2 eloquent, foxy, galaxy # use $ENV{ROS_DISTRO} instead
11+
set(ROS2_HUMBLE 0)
12+
endif()
13+
endif()
14+
815
## Compile as C++14
916
set(CMAKE_CXX_STANDARD 14)
1017
if(WIN32)
1118
add_compile_options(-D_CRT_SECURE_NO_WARNINGS)
1219
set(WIN_LIBRARIES Ws2_32)
1320
else()
14-
add_compile_options(-std=c++14 -g -Wall -Wno-reorder -Wno-sign-compare -Wno-unused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result)
21+
if(ROS2_HUMBLE) # ROS2 humble or later require C++17
22+
add_compile_options(-std=c++17)
23+
else()
24+
add_compile_options(-std=c++14)
25+
endif()
26+
add_compile_options(-g -Wall -Wno-reorder -Wno-sign-compare -Wno-unused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result)
1527
# add_compile_options(-Wshadow) # Note: compiler option -Wshadow generates a lot of warnings in ros header files. Therefore it's deactivated by default, but can be usefull for development and testing.
1628
set(LINUX_LIBRARIES pthread) # gcc maps std::thread to pthread, using std::thread requires linking with pthread
1729
endif()
@@ -41,7 +53,8 @@ elseif(ROS_VERSION EQUAL 2)
4153
find_package(sensor_msgs REQUIRED)
4254
find_package(std_msgs REQUIRED)
4355
find_package(tf2 REQUIRED)
44-
find_package(tf2_ros REQUIRED)
56+
find_package(tf2_ros REQUIRED)
57+
find_package(visualization_msgs REQUIRED)
4558
endif()
4659

4760
## packages required by sick_lidar_localization
@@ -112,10 +125,16 @@ if(ROS_VERSION EQUAL 1)
112125
add_dependencies(sick_lidar_localization_main sick_localization_lib ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
113126
add_dependencies(pointcloud_converter sick_localization_lib ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
114127
elseif(ROS_VERSION EQUAL 2)
115-
ament_target_dependencies(sick_localization_lib rclcpp geometry_msgs nav_msgs sensor_msgs std_msgs tf2_ros)
116-
rosidl_target_interfaces(sick_localization_lib ${PROJECT_NAME} "rosidl_typesupport_cpp")
117-
ament_target_dependencies(pointcloud_converter rclcpp geometry_msgs nav_msgs sensor_msgs std_msgs tf2_ros)
118-
rosidl_target_interfaces(pointcloud_converter ${PROJECT_NAME} "rosidl_typesupport_cpp")
128+
ament_target_dependencies(sick_localization_lib rclcpp geometry_msgs nav_msgs sensor_msgs std_msgs tf2_ros visualization_msgs)
129+
ament_target_dependencies(pointcloud_converter rclcpp geometry_msgs nav_msgs sensor_msgs std_msgs tf2_ros visualization_msgs)
130+
if(ROS2_HUMBLE) # rosidl_typesupport for ROS2 humble or later
131+
rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
132+
target_link_libraries(sick_localization_lib "${cpp_typesupport_target}")
133+
target_link_libraries(pointcloud_converter "${cpp_typesupport_target}")
134+
else()
135+
rosidl_target_interfaces(sick_localization_lib ${PROJECT_NAME} "rosidl_typesupport_cpp")
136+
rosidl_target_interfaces(pointcloud_converter ${PROJECT_NAME} "rosidl_typesupport_cpp")
137+
endif()
119138
else()
120139
add_dependencies(sick_lidar_localization_main sick_localization_lib)
121140
endif()

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,24 +343,36 @@ pip install scapy
343343
pip install pypcapfile
344344
pip install python-pcapng
345345
```
346+
If you're still getting `ModuleNotFoundError` messages, try `sudo pip install` resp. `sudo pip3 install` instead of `pip install`.
346347
347348
:question: UDP messages have CRC checksum error in wireshark or tcpdump
348349
349350
:white_check_mark: Excerpt from https://docs.gz.ro/tuning-network-cards-on-linux.html : "If you have offload features enabled and you see chksum incorrect in tcpdump output, without any packet errors and your network is working properly: it is nothing to worry about because the checksum is actually calculated on the network adapter and the tcpdump is showing the checksum calculated on kernel level."
350351
351352
:question: Error MSB3491 on Windows: "Could not write lines to file. The fully qualified file name must be less than 260 characters"
352353
353-
:white_check_mark: Possible solutions are f.e.
354+
:white_check_mark: Possible solutions are e.g.:
354355
* Just clone repository https://github.com/SICKAG/sick_lidar_localization into a short path, f.e. directly to `C:\`:
355356
```
356357
cd c:\
357358
git clone https://github.com/SICKAG/sick_lidar_localization.git
358359
```
359-
* Use subst to shorten long paths, f.e.:
360+
This is the recommended solution. Working on shared folder might cause errors using ROS-2 on Windows.
361+
* Alternatively, use subst to shorten long paths, f.e.:
360362
```
361363
subst <long_path_to_sick_lidar_localization> s:
362364
cd /d s:\
363365
```
364-
* See https://docs.ros.org/en/foxy/Guides/Installation-Troubleshooting.html:
366+
* Alternatively, See https://docs.ros.org/en/foxy/Guides/Installation-Troubleshooting.html:
365367
* Run regedit.exe, navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem, and set LongPathsEnabled to 0x00000001 (1).
366-
* Hit the windows key and type Edit Group Policy. Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem. Right click Enable Win32 long paths, click Edit. In the dialog, select Enabled and click OK.
368+
* Hit the windows key and type Edit Group Policy (gpedit.msc). Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem. Right click Enable Win32 long paths, click Edit. In the dialog, select Enabled and click OK.
369+
370+
:question: `rivz2` does not work on Windows
371+
372+
:white_check_mark: Start rviz2 with
373+
```
374+
call C:\dev\ros2_foxy\local_setup.bat
375+
call c:\opt\ros\foxy\x64\setup.bat
376+
call .\install\setup.bat
377+
ros2 run rviz2 rviz2
378+
```

package_ros2.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<depend>std_msgs</depend>
3232
<depend>tf2</depend>
3333
<depend>tf2_ros</depend>
34+
<depend>visualization_msgs</depend>
3435

3536
<exec_depend>rosidl_default_runtime</exec_depend>
3637

src/udp_message_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,10 @@ static std::string printHex(const std::vector<uint8_t>& data)
739739
template<class T> static void decodeAndPrint(std::vector<uint8_t>& reference_bin)
740740
{
741741
sick_lidar_localization::UDPMessage::HeaderData msg_header = { 0 };
742-
sick_lidar_localization::UDPMessage::decodeHeader(&reference_bin[0], reference_bin.size(), msg_header);
742+
sick_lidar_localization::UDPMessage::decodeHeader(&reference_bin[0], (int)reference_bin.size(), msg_header);
743743
bool payload_is_big_endian = (msg_header.payloadtype == 0x0642);
744744
uint8_t* udp_payload_buffer = &reference_bin[0] + sizeof(sick_lidar_localization::UDPMessage::HeaderData);
745-
int udp_payload_len = reference_bin.size() - sizeof(sick_lidar_localization::UDPMessage::HeaderData);
745+
int udp_payload_len = (int)reference_bin.size() - (int)sizeof(sick_lidar_localization::UDPMessage::HeaderData);
746746
sick_lidar_localization::UDPMessage::Payload<T> reference_payload;
747747
reference_payload.decodePayload(udp_payload_buffer, udp_payload_len, payload_is_big_endian);
748748
ROS_INFO_STREAM("UDPMessage::unittest: payload_reference = " << reference_payload.toString(false) << ", payload_big_endian = " << payload_is_big_endian << ", source_id = " << msg_header.sourceid);

test/scripts/make_ros1.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
pushd ../../../..
3-
source /opt/ros/melodic/setup.bash
3+
source /opt/ros/noetic/setup.bash
44
rm -f ./build/catkin_make_install.log
55

66
#

test/scripts/make_ros2.bash

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ pushd ../../../..
1010
# BUILDTYPE=Debug
1111
BUILDTYPE=Release
1212

13-
source /opt/ros/eloquent/setup.bash
13+
if [ -f /opt/ros/humble/setup.bash ] ; then
14+
source /opt/ros/humble/setup.bash
15+
elif [ -f /opt/ros/foxy/setup.bash ] ; then
16+
source /opt/ros/foxy/setup.bash
17+
fi
1418
colcon build --cmake-args " -DROS_VERSION=2" " -DCMAKE_BUILD_TYPE=$BUILDTYPE" --event-handlers console_direct+
1519
source ./install/setup.bash
1620

test/scripts/make_ros2.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ REM Build sick_lidar_localization on Windows ROS-2
33
REM
44

55
pushd ..\..\..\..
6+
rem Workaround for "The fully qualified file name must be less than 260 characters" errors:
7+
rem Copy folder sick_lidar_localization2_pretest to c:\<short_folder_name> and run in that directory...
8+
rem if not exist r:\sick_lidar_localization2_pretest subst r: ..
9+
rem pushd r:\sick_lidar_localization2_pretest
10+
rem Cleanup
611
rmdir /s/q .\log
712
for %%i in ( .\install\sick_lidar_localization\lib .\install\sick_lidar_localization\lib\sick_lidar_localization .\build\sick_lidar_localization\Debug .\build\sick_lidar_localization\Release ) do (
813
if exist %%i\gen_service_call.exe del /f/q %%i\gen_service_call.exe
@@ -31,6 +36,7 @@ if not exist .\build\sick_lidar_localization\Release\gen_service_call.exe
3136
if not exist .\build\sick_lidar_localization\Release\sick_lidar_localization.exe ( @echo colcon build sick_lidar_localization.exe failed & @pause ) else ( @echo Successfully build sick_lidar_localization.exe for ROS-2 Windows )
3237
if not exist .\build\sick_lidar_localization\Release\pointcloud_converter.exe ( @echo colcon build pointcloud_converter.exe failed & @pause ) else ( @echo Successfully build pointcloud_converter.exe for ROS-2 Windows )
3338

39+
popd
3440
popd
3541
@pause
3642
rem @timeout /t 10

test/scripts/makeall_ros1.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
pushd ../../../..
3-
source /opt/ros/melodic/setup.bash
3+
source /opt/ros/noetic/setup.bash
44

55
#
66
# cleanup

test/scripts/makeall_ros2.bash

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# cleanup
55
#
66

7+
printf "\033c"
78
pushd ../../../..
89
if [ -d ./src/sick_lidar_localization2_pretest ] ; then
910
cp -f ./src/sick_lidar_localization2_pretest/package_ros2.xml ./src/sick_lidar_localization2_pretest/package.xml

test/scripts/run_linux_ros1_simu.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ sleep 3
6868
#
6969

7070
pushd ../../../..
71-
source /opt/ros/melodic/setup.bash
71+
source /opt/ros/noetic/setup.bash
7272
source ./install/setup.bash
7373
SICK_LIDAR_LOCALIZATION_ROOT=./src/sick_lidar_localization
7474
if [ -d ./src/sick_lidar_localization2_pretest ] ; then SICK_LIDAR_LOCALIZATION_ROOT=./src/sick_lidar_localization2_pretest ; fi

0 commit comments

Comments
 (0)