0
$\begingroup$

Rosanswers logo

I'm using C++ to program two nodes on ROS melodic with Gazebo 9.9.0 running on an Ubuntu 18.04.2 LTS.

I'm learning ROS and I have to do the same: move a robot, Pioneer 2DX, to make a map using Odometry.

Yes, I know, there are a lot of better ways to do a map, but I'm learning and this is an exercise that I have to do at the university.

I've thought to use two nodes:

  • One to store odometry data.
  • Other to move the robot using keyboard.

My problem, or doubt, is that I need to use Odometry data on both. In the second one, because if I have to rotate the robot, I need to know robot's heading.

I'm using ros::spinOnce(); to process callbacks waiting.

My question is: if one node read a Odometry message, that message read from one node, will it be available for the other node? Or maybe, I will lose that message.

I've also thought to use one node to store odometry data and also to move the robot if calling ros::spinOnce(); will make me to lose the message.


Originally posted by Elric on ROS Answers with karma: 71 on 2019-07-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Yes, the same message will be available to all nodes which have subscribed to that message topic.

In your case, for the second node, you can read the odometry message whenever it is received and store it in a variable for later use.


Originally posted by Junskter with karma: 41 on 2019-07-22

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Elric on 2019-07-22:
Great!!! Thanks a lot.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.