Data fusion

I prepared an example on how you can access rplidar data on CORE2.

In web IDE create new project, then add three files:

  • main.cpp
  • ros.h
  • ros/node_handle.h

Please note, that file node_handle.h is in folder named ros.

Files content:
main.cpp (1.2 KB)
ros.h (162 Bytes)
node_handle.h (16.4 KB)

In file main.cpp method scanCallback is where data from rplidar comes, here you can process it.
Data is structured as ROS message of type sensor_msgs/LaserScan, you can read more about data structure at http://docs.ros.org/api/sensor_msgs/html/msg/LaserScan.html

Two other files are for increasing CORE2 buffer size, because default is too small to handle rplidar message. Buffer size is defined in node_handle.h in lines 96 and 97.

Save these files, build project and upload it to your device.

Then you need to run nodes on linux:

/opt/husarion/tools/rpi-linux/ros-core2-client /dev/ttyCORE2

This one is bridge between linux and CORE2.

rosrun rplidar_ros rplidarNode

This one is rplidar driver.

rosrun topic_tools throttle messages /scan 1.0 /scan_throttle

This one is lowering rate of incoming scans. It is required because rplidar scans are quite a big amount of data and bandwidth between linux and CORE2 is limited. Above example throttles scans to one per second, you can increase these values to your needs. Nevertheless, keep in mind that if you increase it too much, CORE2 can become unstable.

I tested it on fresh image without any problems.