Ask Your Question
0

Two different nodes getting odometry messages

asked 2019-07-22 02:07:26 -0500

Elric gravatar image

updated 2019-07-22 02:19:34 -0500

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-07-22 02:25:35 -0500

Junskter gravatar image

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.

edit flag offensive delete link more

Comments

Great!!! Thanks a lot.

Elric gravatar imageElric ( 2019-07-22 02:29:15 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-07-22 02:07:26 -0500

Seen: 26 times

Last updated: Jul 22