Data fusion

Hello all,

I have worked with camera and lader on ROSbot. Now I need to access to data of both camera and lader. Previously I visual dates on Rviz.
Now I need to access raw data f both and implement some Kalman filter.
Would you please help me?

Hi Amin,

You can access raw data from both lidar and camera by building your own node. Process of building your own node is covered in tutorial 2 ‘Creating nodes’.
Inside node you will have this data as basic types - you can apply any sort of processing you wish.

Łukasz Mitka

Tank you for your answer.
Would you please help me more. I have no idea to start.
Would you please provide me an example.


1 Like

He told you how to do it. Now do you part.You need to study ROS and rostopic.

You need to build a foundation of knowledge before you take your project further. Its part of the learning process.

Amin, you can find the link to the tutorial mentioned by Łukasz here: Creating nodes | Husarion . We advice to go through the tutorials one by one as each one is based on the knowledge from the previous one.

If anything was unclear let us know.


OK, I want to implement the Kalman filter with core-2 board. How can I accesses the raw data from ROS in to core2 board.

I go through this tutorial, I know how to create my own node,
my question is how to access the raw data from Web IDE. Because I want to access a real time data (for processing) in Core2 board

Yep. Write the code on the Tinkerboard / pi. Access the Core2 io via ROS

That’s why I mentioned earlier study up on ROS and ROS topics

I’ve some experience with ROS and created the node for receiving the raw rgb-image data of the camera. I want to access the raw rgb-image data on the core2 board in the web IDE for further filtering/ processing.

I think I need to include the node (which I created in the Linux-environment) as a h.-file in the web IDE.

@Jerry_Normandin you stated that you should ‘access the core2 io via ROS’, but I don’t understand what you actually mean with that and how to do that. Could you or someone else please give me an explanation on how to do that?


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

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.

Thank you for the example, I think it is very clear!

Now, I want to call scanCallback() in the while loop of the void hMain() to access the data in the serial console of the web IDE:

while (true)

By building the code, an error occured:

error: too few arguments to function ‘void scanCallback(const sensor_msgs::LaserScan&)’

I already spent a lot of time trying to fix the error, but without result.

Does anybody know which arguments I should add between the brackets to function the method scanCallback (and eventually access the data in the serial console)?

Kind regards,

Hello Tino,

You do not call scanCallback() function.
You register it in ROS system by calling:

ros::Subscriber<sensor_msgs::LaserScan> scan_sub("/scan_throttle", &scanCallback);



These are already included in above example.

After registering in ROS, scanCallback() is called by the system every time, when new message is published.

Data is accessible under &scan pointer.

To print maximum range that can be detected by lidar in scan you can use:

Serial.printf("maximum lidar range is # %7d\r\n", scan.range_max);

If you modify scanCallback() to:

void scanCallback(const sensor_msgs::LaserScan &scan)
    	Serial.printf("lidar maximum range is # %7f, minimum is %7f\r\n", scan.range_max, scan.range_min);

You will get lidar range printed on serial port every second.

You can find more about data structure in scan message under: