How to call node publisher from C function

asked 2021-06-22 01:23:02 -0500

bojankoce gravatar image

Hello, guys!

I'm using ROS2 Foxy with Ubuntu 18.04. I successfully integrated my C application code into ROS2 node but there is one single thing left to be done. Namely, I have an asynchronous C callback function that is called every time I receive new data over USB. I need to use Node publisher to publish those data through the topic to other subscriber nodes.

How can I do it from my callback function located in C file? How can I call my node's publisher from there? Is this a question of mixing C and C++? Any experience to share with me?

Thanks in advance for your time and efforts. Sincerely, Bojan.

edit retag flag offensive close merge delete

Comments

You might want to look into using rclc instead of rclcpp: https://github.com/ros2/rclc

christophebedard gravatar image christophebedard  ( 2021-06-23 19:04:06 -0500 )edit