ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Within the file rplidar_driver.cpp, there is an error concerning the message type. The error compile error with the data type of the message within the rplidar_driver.cpp file.

error: narrowing conversion of ‘rp::hal::Event::EVENT_TIMEOUT’ from ‘int’ to ‘long unsigned int’

The error states that the conversion from int, which is declared as a 8-bit unsigned integer (UInt8) by default, to long unsigned int. Correct me if I'm wrong, the error manifested probably because of data being exchanged in between CPP and Python and the number initialized/inputted.

Solution #1: Ensure that the integer inputted/initialized is within the scope of UInt8, ranging from 0 to 256 (2^8). If it's not within that range, ROS message will compute an unpredictable value and end up being a hard-to-find value after compiling.

Solution #2: Ensure that the serialization of the data type matches ROS and the corresponding programming language. Scroll down to Section 2.1.1: Field Types @ http://wiki.ros.org/msg

Solution #3: If self-implemented message types are included in your build, ensure that you have run catkin_make prior to building your project with catkin_make since the self-implemented message types have to be compiled to a language-specific implementation. Otherwise, CPP won't know where to locate the file, let alone compile it.

Solution #4: A classic mistake is that the bash isn't source properly. Ensure that you have "source /opt/ros/noetic/setup.bash" as your pathway. You can check this by typing .nano ~/bash. If it's not, rewrite it to it. An alternative way is to type gedit ~/.bashrc instead. Scroll all the way down and edit the line that has the starting word "source .... ". Save and Exit!

~FIN!