Ask Your Question
0

Multiple subscribers in ROS

asked 2020-11-05 10:54:13 -0600

Abhinavgandhi09 gravatar image

I understand it is okay to have multiple subscribers in the same ROS Node. However I am not sure how this works. My ROS Node with multiple subscribers would be running on an ArduinoMega 2560 and would have 4 subscribers that are subscribing to velocity messages on 4 separate topics.

How would the subscribers and their callbacks respond to the msgs. Would they run in parallel or one after the other? And if they run one after the other would this depend on the order of the messages received or would it depend on where I call the subscribers themselves?

Thanks!

edit retag flag offensive close merge delete

Comments

1

Please note: the OP is using rosserial, not roscpp. Answers will be different for rosserial and roscpp.

gvdhoorn gravatar image gvdhoorn  ( 2020-11-05 11:43:51 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-11-05 12:29:39 -0600

electrophod gravatar image

I dont know a perfect answer to this question, but this is how I'd like to put it. Cpp codes by default are single threaded and don't use multiple threads unless the multithreading library is used. Arduino itself is a single threaded microcontroller, so there's no question of subscribers running in parallely I guess. I think the subscriber callbacks would get executed in a serial fashion maybe in the form of a queue. ros::spinOnce() will make the code look for callbacks if any and execute them and the proceed with its function after callbacks are executed.

edit flag offensive delete link more

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: 2020-11-05 10:54:13 -0600

Seen: 85 times

Last updated: Nov 05 '20