ROS subscriber callback in cpp

asked 2022-09-28 15:10:48 -0600

Kostas Tzias gravatar image

I have some data coming from my arduino publisher (for example x and y ). And i want to write a subscriber which takes these data and transforms them and publishes them again in odom .

Soo my problem is that i dont know how to write a callback without using ROS_INFO( as all of the tutorials show) . I just need to store these data in new variables and nothing more . Is there anyone who could help me with that ?

edit retag flag offensive close merge delete

Comments

1

... how to write a callback without using ROS_INFO ...

Here you go. Please note that ROS_INFO is not doing any magic. Just, assume ROS_INFO( ... ) equivalent of printf( ... ). If you do not need any printing/logging, do not use ROS_INFO.

I just need to store these data in new variables and nothing more ...

Create 2 global/class variables, say x and y, and then assign x and y to the values received inside the callback.

ravijoshi gravatar image ravijoshi  ( 2022-09-29 02:58:34 -0600 )edit