Slamtec / rplidar_ros

BSD 2-Clause "Simplified" License
497 stars 532 forks source link

Can't build on Raspberry Pi 4 #85

Closed fennma67764 closed 1 year ago

fennma67764 commented 2 years ago

catkin build and catkin_make lead to the following Error Message:

/home/pi/catkin_ws/src/rplidar_ros/sdk/src/sl_serial_channel.cpp:33:9: warning: #pragma once in main file
   33 | #pragma once
      |         ^~~~
/home/pi/catkin_ws/src/rplidar_ros/sdk/src/sl_lidar_driver.cpp: In member function ‘virtual sl_result sl::SlamtecLidarDriver::grabScanDataHq(sl_lidar_response_measurement_node_hq_t*, size_t&, sl_u32)’:
/home/pi/catkin_ws/src/rplidar_ros/sdk/src/sl_lidar_driver.cpp:556:34: error: narrowing conversion of ‘rp::hal::Event::EVENT_TIMEOUT’ from ‘int’ to ‘long unsigned int’ [-Wnarrowing]
  556 |             case rp::hal::Event::EVENT_TIMEOUT:
      |                                  ^~~~~~~~~~~~~
/home/pi/catkin_ws/src/rplidar_ros/sdk/src/sl_tcp_channel.cpp:33:9: warning: #pragma once in main file
   33 | #pragma once
      |         ^~~~
make[2]: *** [CMakeFiles/rplidarNode.dir/build.make:173: CMakeFiles/rplidarNode.dir/sdk/src/sl_lidar_driver.cpp.o] Fehler 1
make[2]: *** Es wird auf noch nicht beendete Prozesse gewartet....
/home/pi/catkin_ws/src/rplidar_ros/src/node.cpp: In function ‘bool checkRPLIDARHealth(sl::ILidarDriver*)’:
/home/pi/catkin_ws/src/rplidar_ros/src/node.cpp:156:1: warning: control reaches end of non-void function [-Wreturn-type]
  156 | }

What is the issue here?

MAVProxyUser commented 1 year ago

bump

sergiocastrogom commented 1 year ago

bump

jdesbonnet commented 1 year ago

I'm not familiar with this code base or the finer points of C++ , but changing make_def.inc line 129 to read:

CWARN = -Wall -Wno-narrowing

seems to fix the issue (tested against master branch at 2022-11-13 commit babe753f39f16f4c6a6dec2c33b4ed541ca0e502)

ronaldluc commented 1 year ago

I was able to compile after adding -Wno-narrowing to add_compile_options(-Wall -Wextra -Wpedantic -Wno-narrowing) and changing declare_parameters to new ROS Humble spec. After compilation, the library still does not connect to the RPLidar, so I had to stick using https://github.com/babakhani/rplidar_ros2/tree/master

Babak-SSH commented 1 year ago

I solved it by changing the return type of the wait function to int in rplidar_ros/sdk/src/hal/event.h because unsigned long has a conflict with EVENT_TIMEOUT type which is of Event enum and is equal to -1, therefore, we should remove the unsigned and also there is no need to define it as long too and int is adequate for our need. I created a PR to fix this : #101

ajuton-ens commented 1 year ago

2 problems of data types : src/sl_lidar_driver.cpp:556:34: error: narrowing conversion of ‘rp::hal::Event::EVENT_TIMEOUT’ from ‘int’ to ‘long unsigned int’ [-Wnarrowing] is solved by adding an explicit cast in the file sl_lidar_driver.cpp line 556 :

case (long unsigned int)rp::hal::Event::EVENT_TIMEOUT: case (long unsigned int)rp::hal::Event::EVENT_OK:

src/arch/linux/net_socket.cpp:170:15: error: ordered comparison of pointer with integer zero (‘const char*’ and ‘int’) is solved by adding an explicit cast in the file net_socket.cpp line 170 :

return (ans<=(const char *)0)?RESULT_OPERATION_FAIL:RESULT_OK;

deyouslamtec commented 1 year ago

A PR that fixes this has been merged. #101