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

ROS2 Humble build error #23

Closed TZECHIN6 closed 1 year ago

TZECHIN6 commented 1 year ago

Same error here, below is the environment setup and error reproduce procedures:

Environment:

I have also followed the suggsetion above to fix the Livox_sdk build, there is no issue about compling Livox_sdk; however when I colcon build the livox_ros2_driver from this repo, below error occurs:

/opt/ros/humble/install/include/rclcpp/rclcpp/publisher.hpp:81:47: error: static assertion failed: given message type is not compatible with ROS and cannot be used with a Publisher
   81 |     rclcpp::is_ros_compatible_type<MessageT>::value,
/workspace/ROS2/ws_livox/src/livox_ros2_driver/livox_ros2_driver/lddc.cpp:323:29: error: no matching function for call to ‘rclcpp::Publisher<pcl::PointCloud<pcl::PointXYZI> >::publish(livox_ros::PointCloud&)’
  323 |     publisher->publish(cloud);
/usr/include/c++/9/type_traits:2378:11: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
 2378 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
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:139: CMakeFiles/livox_ros2_driver.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
---
Failed   <<< livox_ros2_driver [31.4s, exited with code 2]

Summary: 2 packages finished [34.8s]
  1 package failed: livox_ros2_driver
  1 package had stderr output: livox_ros2_driver
root@ubuntu:/workspace/ROS2/ws_livox# 

Any solution for this issue?

_Originally posted by @TZECHIN6 in https://github.com/Livox-SDK/livox_ros2_driver/issues/19#issuecomment-1254469491_

Marcus-D-Forte commented 1 year ago

Try using this suggestion: https://github.com/Livox-SDK/livox_ros2_driver/pull/20

It worked for me

TZECHIN6 commented 1 year ago

So do you mean it also requires the Livox_SDK to make the livox_ros2_driver works? As I saw there is no comment saying that....

MerdanBay commented 1 year ago

i had same error, and the suggestion from @Marcus-D-Forte is right. btw, the [livox_sdk_vendor] pkg will download sdk, so once you compiled it even with error, you will find the sdk in install folder. anyway, the easy way before officially merged, you can just use https://github.com/Marcus-D-Forte/livox_ros2_driver version.

Marcus-D-Forte commented 1 year ago

Yeah, feel free to use my branch. I implemented the fix in both repositories and reference a working livox-sdk branch from livox_ros2_driver.

TZECHIN6 commented 1 year ago

hi @Marcus-D-Forte, I saw your commit on the lddc.cpp file. Why you override the timestamp definition and also using cloud_ros instead of cloud?

TZECHIN6 commented 1 year ago

The colcon build is successful by making below changes:

timesync.h

#include <memory>

lddc.cpp, line: 319

rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr publisher =
      std::dynamic_pointer_cast<rclcpp::Publisher<sensor_msgs::msg::PointCloud2>>
      (GetCurrentPublisher(handle));
  if (kOutputToRos == output_type_) {
    sensor_msgs::msg::PointCloud2 msg;
    pcl::toROSMsg(cloud, msg);
    publisher->publish(msg);
  } else {

I am wondering will the commit you made will affect the using experience in ROS2?

Marcus-D-Forte commented 1 year ago

hi @Marcus-D-Forte, I saw your commit on the lddc.cpp file. Why you override the timestamp definition and also using cloud_ros instead of cloud?

So this is definetly not required. It helps me synchronize timestamps incoming from external sensors (not from Livox)

Regarding using cloud_ros insteand of cloud. In this section of the code, cloud is of type PointCloud, so a conversion to sensor_msgs::msg::PointCloud2> is required. At least, as far as I have tried, I could not publish a PointCloud directly as I would in ros1. I think pcl_ros (http://wiki.ros.org/pcl_ros) allowed it.

Marcus-D-Forte commented 1 year ago

The colcon build is successful by making below changes:

timesync.h

#include <memory>

lddc.cpp, line: 319

rclcpp::Publisher<sensor_msgs::msg::PointCloud2>::SharedPtr publisher =
      std::dynamic_pointer_cast<rclcpp::Publisher<sensor_msgs::msg::PointCloud2>>
      (GetCurrentPublisher(handle));
  if (kOutputToRos == output_type_) {
    sensor_msgs::msg::PointCloud2 msg;
    pcl::toROSMsg(cloud, msg);
    publisher->publish(msg);
  } else {

I am wondering will the commit you made will affect the using experience in ROS2?

All I can say is that I was able to successfully publish Livox data :). As far as performance goes, it does deserve a comparison investigation.. Maybe https://github.com/ros-perception/perception_pcl/pull/368 has some insight to it.