YDLIDAR / YDLidar-SDK

Driver for receiving YD LiDAR data and more...
Other
119 stars 221 forks source link

ROS2 TG50 Health Issue #39

Closed farhangnaderi closed 2 months ago

farhangnaderi commented 1 year ago

Based on random health issue not retrieved from the sensor randomly, I am proposing this temporary hard-coded workaround

This is happening on ROS Foxy!

Before:

image

And after the changes:

image

srujanpanuganti commented 3 months ago

@farhangnaderi I got here trying to fix the healthcheck issue. I'm only getting this issue on a Raspberry Pi 4 Mod B. The SDK works perfectly fine on a PC. I tried you solution and it throws an error during cmake .. Here is the error report

xairo@xairo:~/ydlidar_ws/src/YDLidar-SDK/build$ cmake ..
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Current platform: Linux
CMake Deprecation Warning at CMakeLists.txt:50 (cmake_policy):
  The OLD behavior for policy CMP0053 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

CMake Deprecation Warning at CMakeLists.txt:53 (cmake_policy):
  The OLD behavior for policy CMP0037 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

CMake Deprecation Warning at CMakeLists.txt:56 (cmake_policy):
  The OLD behavior for policy CMP0043 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.

-- Found SWIG: /usr/bin/swig4.0 (found version "4.0.2")  
-- Found PythonInterp: /usr/bin/python3.10 (found version "3.10.12") 
-- Found PythonLibs: /usr/lib/aarch64-linux-gnu/libpython3.10.so (found version "3.10.12") 
-- Found GTest: /usr/lib/aarch64-linux-gnu/cmake/GTest/GTestConfig.cmake (found version "1.11.0")  
CMake Deprecation Warning at core/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

CMake Deprecation Warning at samples/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- build python API....
CMake Warning (dev) at /usr/share/cmake-3.22/Modules/UseSWIG.cmake:775 (message):
  Policy CMP0078 is not set: UseSWIG generates standard target names.  Run
  "cmake --help-policy CMP0078" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

Call Stack (most recent call first):
  python/CMakeLists.txt:35 (swig_add_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at /usr/share/cmake-3.22/Modules/UseSWIG.cmake:617 (message):
  Policy CMP0086 is not set: UseSWIG honors SWIG_MODULE_NAME via -module
  flag.  Run "cmake --help-policy CMP0086" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/UseSWIG.cmake:888 (SWIG_ADD_SOURCE_TO_MODULE)
  python/CMakeLists.txt:35 (swig_add_library)
This warning is for project developers.  Use -Wno-dev to suppress it.

<string>:2: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
<string>:2: DeprecationWarning: The distutils.sysconfig module is deprecated, use sysconfig instead
-- build test is ON.....
CMake Deprecation Warning at cmake/install_package.cmake:101 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:168 (install_package)

CMake Warning (dev) at cmake/install_package.cmake:191 (install):
  Policy CMP0062 is not set: Disallow install() of export() result.  Run
  "cmake --help-policy CMP0062" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The file

    /home/xairo/ydlidar_ws/src/YDLidar-SDK/build/ydlidar_sdkTargets.cmake

  was generated by the export() command.  It should not be installed with the
  install() command.  Use the install(EXPORT) mechanism instead.  See the
  cmake-packages(7) manual for more.

Call Stack (most recent call first):
  CMakeLists.txt:168 (install_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- 
-- +===========================================================================+
-- |         Resulting configuration for                             |
-- +===========================================================================+
--  _________________________ PLATFORM _____________________________
--  Host                        : Linux5.15.0-1048-raspiaarch64
--  Is the system big endian?   :  No 
--  Word size (32/64 bit)       : 64
--  CMake version               : 3.22.1
--  CMake generator             : Unix Makefiles
--  CMake build tool            : /usr/bin/gmake
--  Compiler                    : GNU
--  Configuration               : 
-- 
--  __________________________ OPTIONS _____________________________
--  Build YDLidar-SDK as a shared library?   :  No 
--  Build Examples?               : Yes 
--  Build C Sharp API?             :  No 
--  Build TEST?                 : Yes 
-- 
--  _________________________ INSTALL _____________________
--  Install prefix                    : /usr/local
-- 
--  _______________________ WRAPPERS/BINDINGS ______________________
--  Python bindings (pyydlidar)   : Yes 
--   - dep: Swig found?       : Yes [Version: 4.0.2]
--   - dep: PythonLibs found?  : Yes [Version: 3.10.12]
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/xairo/ydlidar_ws/src/YDLidar-SDK/build
xairo@xairo:~/ydlidar_ws/src/YDLidar-SDK/build$ make
[  2%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/base/timer.cpp.o
[  4%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/common/ydlidar_def.cpp.o
[  6%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/network/ActiveSocket.cpp.o
[  9%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/network/PassiveSocket.cpp.o
[ 11%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/network/SimpleSocket.cpp.o
[ 13%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/serial/serial.cpp.o
In file included from /home/xairo/ydlidar_ws/src/YDLidar-SDK/core/serial/common.h:45,
                 from /home/xairo/ydlidar_ws/src/YDLidar-SDK/core/serial/serial.cpp:12:
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h: In member function ‘int ydlidar::core::base::Thread::join(long unsigned int)’:
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:136:46: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  136 |           printf("[YDLIDAR DEBUG] Thread [0x%X] ready to cancel[%d]\n", _handle, s);
      |                                             ~^                          ~~~~~~~
      |                                              |                          |
      |                                              unsigned int               _size_t {aka long unsigned int}
      |                                             %lX
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:138:46: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  138 |           printf("[YDLIDAR DEBUG] Thread [0x%X] ready to cancel[%d] time[%u]\n",
      |                                             ~^
      |                                              |
      |                                              unsigned int
      |                                             %lX
  139 |             _handle, s, getms() - t);
      |             ~~~~~~~                           
      |             |
      |             _size_t {aka long unsigned int}
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:142:42: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  142 |             printf("[YDLIDAR] Thread [0x%X] has been canceled in other thread\n", _handle);
      |                                         ~^                                        ~~~~~~~
      |                                          |                                        |
      |                                          unsigned int                             _size_t {aka long unsigned int}
      |                                         %lX
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:147:74: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  147 |             fprintf(stderr, "[YDLIDAR] An error occurred while thread[0x%X] cancelled!\n", _handle);
      |                                                                         ~^                 ~~~~~~~
      |                                                                          |                 |
      |                                                                          unsigned int      _size_t {aka long unsigned int}
      |                                                                         %lX
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:151:40: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  151 |           printf("[YDLIDAR] Thread [0x%X] has been canceled\n", _handle);
      |                                       ~^                        ~~~~~~~
      |                                        |                        |
      |                                        unsigned int             _size_t {aka long unsigned int}
      |                                       %lX
[ 16%] Building C object CMakeFiles/ydlidar_sdk.dir/core/serial/impl/unix/lock.c.o
[ 18%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/serial/impl/unix/list_ports_linux.cpp.o
[ 20%] Building CXX object CMakeFiles/ydlidar_sdk.dir/core/serial/impl/unix/unix_serial.cpp.o
[ 23%] Building CXX object CMakeFiles/ydlidar_sdk.dir/src/CYdLidar.cpp.o
In file included from /home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/common/DriverInterface.h:3,
                 from /home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.h:48,
                 from /home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:29:
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h: In member function ‘int ydlidar::core::base::Thread::join(long unsigned int)’:
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:136:46: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  136 |           printf("[YDLIDAR DEBUG] Thread [0x%X] ready to cancel[%d]\n", _handle, s);
      |                                             ~^                          ~~~~~~~
      |                                              |                          |
      |                                              unsigned int               _size_t {aka long unsigned int}
      |                                             %lX
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:138:46: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  138 |           printf("[YDLIDAR DEBUG] Thread [0x%X] ready to cancel[%d] time[%u]\n",
      |                                             ~^
      |                                              |
      |                                              unsigned int
      |                                             %lX
  139 |             _handle, s, getms() - t);
      |             ~~~~~~~                           
      |             |
      |             _size_t {aka long unsigned int}
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:142:42: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  142 |             printf("[YDLIDAR] Thread [0x%X] has been canceled in other thread\n", _handle);
      |                                         ~^                                        ~~~~~~~
      |                                          |                                        |
      |                                          unsigned int                             _size_t {aka long unsigned int}
      |                                         %lX
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:147:74: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 3 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  147 |             fprintf(stderr, "[YDLIDAR] An error occurred while thread[0x%X] cancelled!\n", _handle);
      |                                                                         ~^                 ~~~~~~~
      |                                                                          |                 |
      |                                                                          unsigned int      _size_t {aka long unsigned int}
      |                                                                         %lX
/home/xairo/ydlidar_ws/src/YDLidar-SDK/./core/base/thread.h:151:40: warning: format ‘%X’ expects argument of type ‘unsigned int’, but argument 2 has type ‘_size_t’ {aka ‘long unsigned int’} [-Wformat=]
  151 |           printf("[YDLIDAR] Thread [0x%X] has been canceled\n", _handle);
      |                                       ~^                        ~~~~~~~
      |                                        |                        |
      |                                        unsigned int             _size_t {aka long unsigned int}
      |                                       %lX
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp: In member function ‘bool CYdLidar::getDeviceHealth()’:
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1332:42: error: ‘YDlidarDriver’ has not been declared
 1332 |   printf("[YDLIDAR]: SDK Version: %s\n", YDlidarDriver::getSDKVersion().c_str());
      |                                          ^~~~~~~~~~~~~
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1367:17: error: ‘class ydlidar::core::common::DriverInterface’ has no member named ‘startMotor’
 1367 |       lidarPtr->startMotor();
      |                 ^~~~~~~~~~
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1377:29: error: qualified-id in declaration before ‘(’ token
 1377 | bool CYdLidar::getDeviceInfo()
      |                             ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1500:41: error: qualified-id in declaration before ‘(’ token
 1500 | void CYdLidar::handleSingleChannelDevice()
      |                                         ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1537:31: error: qualified-id in declaration before ‘(’ token
 1537 | void CYdLidar::checkSampleRate()
      |                               ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1585:34: error: qualified-id in declaration before ‘(’ token
 1585 | bool CYdLidar::checkScanFrequency()
      |                                  ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1665:30: error: qualified-id in declaration before ‘(’ token
 1665 | bool CYdLidar::checkHeartBeat()
      |                              ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1697:37: error: qualified-id in declaration before ‘(’ token
 1697 | bool CYdLidar::checkCalibrationAngle(const std::string &serialNumber)
      |                                     ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1743:26: error: qualified-id in declaration before ‘(’ token
 1743 | bool CYdLidar::checkCOMMs()
      |                          ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1824:27: error: qualified-id in declaration before ‘(’ token
 1824 | bool CYdLidar::checkStatus()
      |                           ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1836:29: error: qualified-id in declaration before ‘(’ token
 1836 | bool CYdLidar::checkHardware()
      |                             ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1851:1: error: ‘namespace’ definition is not allowed here
 1851 | namespace ydlidar
      | ^~~~~~~~~
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1873:2: error: expected ‘}’ at end of input
 1873 | }
      |  ^
/home/xairo/ydlidar_ws/src/YDLidar-SDK/src/CYdLidar.cpp:1323:1: note: to match this ‘{’
 1323 | {
      | ^
make[2]: *** [CMakeFiles/ydlidar_sdk.dir/build.make:202: CMakeFiles/ydlidar_sdk.dir/src/CYdLidar.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:342: CMakeFiles/ydlidar_sdk.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

I'm using ROS2 humble on Ubuntu 22.04 on a Raspberry Pi 4 model B and YDLidar X4

farhangnaderi commented 3 months ago

@srujanpanuganti I guess the issue is fixed on Humble, isn't it? I am not sure how son I can reproduce it. So far tested on Jetson Jetpack 5.1.1 with Isaac Buildfarm and seems it is fixed.

srujanpanuganti commented 3 months ago

@farhangnaderi I still get the error somehow. I think it could be a power issue. Because when I changed the power source the issue disappeared. The lidar consumes it's peak current during the startup and I think initially the USB port on Raspi 4 was not able to supply enough current causing a failure of device health check and device info check. I have an onboard 11.1v lipo battery. I'm going to step it down to produce a clean 5v-2amp current and see whether that fixes my issue reliably. I'll post an update about it ones I get a chance to test it.

Also meanwhile for the ydlidar-x4 model, Changing the isSingleChannel param to true also fixed the health check issue, however it did not fix the device info issue (failed to get the baseplate info) and still caused failure in starting the scan.

farhangnaderi commented 2 months ago

Am closing this for now!