Livox-SDK / livox_ros2_driver

Livox device driver under Ros2, support Lidar Mid-40, Mid-70, Tele-15, Horizon, Avia.
Other
77 stars 84 forks source link

Fix issues to allow build with ros humble #20

Open Scout22 opened 2 years ago

Scout22 commented 2 years ago

The SDK need also to be fixed and include the following PR https://github.com/Livox-SDK/Livox-SDK/pull/163

adamsj-ros commented 1 year ago

Appears to also need a fix to add an include to the thread_base.h in the SDK.

AnrewLIU commented 1 year ago

I did exactly the same changes to be able to compile. Works for Foxy and Galactic as well.

My branch @Marcus-D-Forte When using your branch with ROS2 Humble and Ubuntu 20.04, it failed with livox_ros2_driver when colcon build. How to fix this, thanks!


andrew@ros2:~/ws_livox$ colcon build
Starting >>> livox_interfaces
Starting >>> livox_sdk_vendor
Finished <<< livox_sdk_vendor [0.68s]                                
Finished <<< livox_interfaces [4.41s]                     
Starting >>> livox_ros2_driver
--- stderr: livox_ros2_driver                                
** WARNING ** io features related to pcap will be disabled
/usr/bin/ld: /usr/local/lib/liblivox_sdk_static.a(device_discovery.cpp.o): relocation R_X86_64_TPOFF32 against symbol `_ZGVZN6spdlog7details2os9thread_idEvE3tid' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/livox_ros2_driver.dir/build.make:508:liblivox_ros2_driver.so] 错误 1
gmake[1]: *** [CMakeFiles/Makefile2:139:CMakeFiles/livox_ros2_driver.dir/all] 错误 2
gmake: *** [Makefile:146:all] 错误 2
---
Failed   <<< livox_ros2_driver [13.0s, exited with code 2]

Summary: 2 packages finished [17.6s] 1 package failed: livox_ros2_driver 1 package had stderr output: livox_ros2_driver

Genozen commented 1 year ago

@Marcus-D-Forte Hello, thank you for updating your branch. I was able to clone it but got a build error:

Device: Jetson Xavier NX devkit Version: Jetpack 5.1

colcon build
Starting >>> livox_interfaces
Starting >>> livox_sdk_vendor                  
Finished <<< livox_sdk_vendor [1.86s]                                                                   
Starting >>> livox_sdk
Finished <<< livox_sdk [1.47s]                                                                      
Finished <<< livox_interfaces [4.50s]                  
Starting >>> livox_ros2_driver
[Processing: livox_ros2_driver]                             
--- stderr: livox_ros2_driver                               
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp: In member function ‘uint32_t livox_ros::Lddc::PublishPointcloudData(livox_ros::LidarDataQueue*, uint32_t, uint8_t)’:
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:328:34: error: no matching function for call to ‘toROSMsg(livox_ros::PointCloud&, sensor_msgs::msg::PointCloud2&)’
  328 |     pcl::toROSMsg(cloud,cloud_ros);
      |                                  ^
In file included from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.h:33,
                 from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:25:
/usr/include/pcl_conversions/pcl_conversions.h:487:8: note: candidate: ‘void pcl::toROSMsg(const PointCloud2&, sensor_msgs::Image&)’
  487 |   void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
      |        ^~~~~~~~
/usr/include/pcl_conversions/pcl_conversions.h:487:49: note:   no known conversion for argument 1 from ‘livox_ros::PointCloud’ {aka ‘pcl::PointCloud<pcl::PointXYZI>’} to ‘const PointCloud2&’ {aka ‘const sensor_msgs::PointCloud2_<std::allocator<void> >&’}
  487 |   void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:507:3: note: candidate: ‘template<class T> void pcl::toROSMsg(const pcl::PointCloud<PointT>&, sensor_msgs::Image&)’
  507 |   toROSMsg (const pcl::PointCloud<T> &cloud, sensor_msgs::Image& msg)
      |   ^~~~~~~~
/usr/include/pcl_conversions/pcl_conversions.h:507:3: note:   template argument deduction/substitution failed:
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:328:25: note:   cannot convert ‘cloud_ros’ (type ‘sensor_msgs::msg::PointCloud2’ {aka ‘sensor_msgs::msg::PointCloud2_<std::allocator<void> >’}) to type ‘sensor_msgs::Image&’ {aka ‘sensor_msgs::Image_<std::allocator<void> >&’}
  328 |     pcl::toROSMsg(cloud,cloud_ros);
      |                         ^~~~~~~~~
In file included from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.h:33,
                 from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:25:
/usr/include/pcl_conversions/pcl_conversions.h:539:8: note: candidate: ‘template<class T> void pcl::toROSMsg(const pcl::PointCloud<PointT>&, sensor_msgs::PointCloud2&)’
  539 |   void toROSMsg(const pcl::PointCloud<T> &pcl_cloud, sensor_msgs::PointCloud2 &cloud)
      |        ^~~~~~~~
/usr/include/pcl_conversions/pcl_conversions.h:539:8: note:   template argument deduction/substitution failed:
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:328:25: note:   cannot convert ‘cloud_ros’ (type ‘sensor_msgs::msg::PointCloud2’ {aka ‘sensor_msgs::msg::PointCloud2_<std::allocator<void> >’}) to type ‘sensor_msgs::PointCloud2&’ {aka ‘sensor_msgs::PointCloud2_<std::allocator<void> >&’}
  328 |     pcl::toROSMsg(cloud,cloud_ros);
      |                         ^~~~~~~~~
make[2]: *** [CMakeFiles/livox_ros2_driver.dir/build.make:160: CMakeFiles/livox_ros2_driver.dir/livox_ros2_driver/lddc.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:301: CMakeFiles/livox_ros2_driver.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
---
Failed   <<< livox_ros2_driver [44.5s, exited with code 2]

Summary: 3 packages finished [49.7s]
  1 package failed: livox_ros2_driver
  1 package had stderr output: livox_ros2_driver

and here is a list of pcl libraries we have:

libdapclient6v5/focal,now 3.20.5-1 arm64 [installed,automatic]
libpcl-apps1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-common1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-conversions-dev/focal,now 0.2.1-6build1 arm64 [installed]
libpcl-dev/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed]
libpcl-features1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-filters1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-io1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-kdtree1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-keypoints1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-ml1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-msgs-dev/focal,now 0.2.0-10 arm64 [installed,automatic]
libpcl-octree1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-outofcore1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-people1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-recognition1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-registration1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-sample-consensus1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-search1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-segmentation1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-stereo1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-surface1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-tracking1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-visualization1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
pcl-tools/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]

Do you have any encounter to this? or mind sharing details of the library versions/environment you built on?

yuchenlogin commented 9 months ago

i have the same trouble too! please help me qwq!

xiangheyenai commented 8 months ago

@AnrewLIU I have the same problem. Have you resolved it now?

zjmsyx commented 7 months ago

I have the same problem.

--- stderr: livox_ros2_driver
WARNING io features related to pcap will be disabled /usr/bin/ld: /usr/local/lib/liblivox_sdk_static.a(device_discovery.cpp.o): relocation R_X86_64_TPOFF32 against symbol `_ZGVZN6spdlog7details2os9thread_idEvE3tid' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status gmake[2]: [CMakeFiles/livox_ros2_driver.dir/build.make:508:liblivox_ros2_driver.so] 错误 1 gmake[1]: [CMakeFiles/Makefile2:139:CMakeFiles/livox_ros2_driver.dir/all] 错误 2 gmake: *** [Makefile:146:all] 错误 2

Failed <<< livox_ros2_driver [8.58s, exited with code 2]

KenN7 commented 7 months ago

@Marcus-D-Forte Hello, thank you for updating your branch. I was able to clone it but got a build error:

Device: Jetson Xavier NX devkit Version: Jetpack 5.1

colcon build
Starting >>> livox_interfaces
Starting >>> livox_sdk_vendor                  
Finished <<< livox_sdk_vendor [1.86s]                                                                   
Starting >>> livox_sdk
Finished <<< livox_sdk [1.47s]                                                                      
Finished <<< livox_interfaces [4.50s]                  
Starting >>> livox_ros2_driver
[Processing: livox_ros2_driver]                             
--- stderr: livox_ros2_driver                               
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp: In member function ‘uint32_t livox_ros::Lddc::PublishPointcloudData(livox_ros::LidarDataQueue*, uint32_t, uint8_t)’:
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:328:34: error: no matching function for call to ‘toROSMsg(livox_ros::PointCloud&, sensor_msgs::msg::PointCloud2&)’
  328 |     pcl::toROSMsg(cloud,cloud_ros);
      |                                  ^
In file included from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.h:33,
                 from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:25:
/usr/include/pcl_conversions/pcl_conversions.h:487:8: note: candidate: ‘void pcl::toROSMsg(const PointCloud2&, sensor_msgs::Image&)’
  487 |   void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
      |        ^~~~~~~~
/usr/include/pcl_conversions/pcl_conversions.h:487:49: note:   no known conversion for argument 1 from ‘livox_ros::PointCloud’ {aka ‘pcl::PointCloud<pcl::PointXYZI>’} to ‘const PointCloud2&’ {aka ‘const sensor_msgs::PointCloud2_<std::allocator<void> >&’}
  487 |   void toROSMsg(const sensor_msgs::PointCloud2 &cloud, sensor_msgs::Image &image)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/pcl_conversions/pcl_conversions.h:507:3: note: candidate: ‘template<class T> void pcl::toROSMsg(const pcl::PointCloud<PointT>&, sensor_msgs::Image&)’
  507 |   toROSMsg (const pcl::PointCloud<T> &cloud, sensor_msgs::Image& msg)
      |   ^~~~~~~~
/usr/include/pcl_conversions/pcl_conversions.h:507:3: note:   template argument deduction/substitution failed:
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:328:25: note:   cannot convert ‘cloud_ros’ (type ‘sensor_msgs::msg::PointCloud2’ {aka ‘sensor_msgs::msg::PointCloud2_<std::allocator<void> >’}) to type ‘sensor_msgs::Image&’ {aka ‘sensor_msgs::Image_<std::allocator<void> >&’}
  328 |     pcl::toROSMsg(cloud,cloud_ros);
      |                         ^~~~~~~~~
In file included from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.h:33,
                 from /home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:25:
/usr/include/pcl_conversions/pcl_conversions.h:539:8: note: candidate: ‘template<class T> void pcl::toROSMsg(const pcl::PointCloud<PointT>&, sensor_msgs::PointCloud2&)’
  539 |   void toROSMsg(const pcl::PointCloud<T> &pcl_cloud, sensor_msgs::PointCloud2 &cloud)
      |        ^~~~~~~~
/usr/include/pcl_conversions/pcl_conversions.h:539:8: note:   template argument deduction/substitution failed:
/home/workspace/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:328:25: note:   cannot convert ‘cloud_ros’ (type ‘sensor_msgs::msg::PointCloud2’ {aka ‘sensor_msgs::msg::PointCloud2_<std::allocator<void> >’}) to type ‘sensor_msgs::PointCloud2&’ {aka ‘sensor_msgs::PointCloud2_<std::allocator<void> >&’}
  328 |     pcl::toROSMsg(cloud,cloud_ros);
      |                         ^~~~~~~~~
make[2]: *** [CMakeFiles/livox_ros2_driver.dir/build.make:160: CMakeFiles/livox_ros2_driver.dir/livox_ros2_driver/lddc.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:301: CMakeFiles/livox_ros2_driver.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
---
Failed   <<< livox_ros2_driver [44.5s, exited with code 2]

Summary: 3 packages finished [49.7s]
  1 package failed: livox_ros2_driver
  1 package had stderr output: livox_ros2_driver

and here is a list of pcl libraries we have:

libdapclient6v5/focal,now 3.20.5-1 arm64 [installed,automatic]
libpcl-apps1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-common1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-conversions-dev/focal,now 0.2.1-6build1 arm64 [installed]
libpcl-dev/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed]
libpcl-features1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-filters1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-io1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-kdtree1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-keypoints1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-ml1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-msgs-dev/focal,now 0.2.0-10 arm64 [installed,automatic]
libpcl-octree1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-outofcore1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-people1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-recognition1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-registration1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-sample-consensus1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-search1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-segmentation1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-stereo1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-surface1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-tracking1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
libpcl-visualization1.10/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]
pcl-tools/focal,now 1.10.0+dfsg-5ubuntu1 arm64 [installed,automatic]

Do you have any encounter to this? or mind sharing details of the library versions/environment you built on?

Same problem here, did you find a workaround ?