ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

using the latest message in a service

asked 2017-08-02 01:39:11 -0500

huckl3b3rry87 gravatar image

I have looked at a bunch of tutorials and read a bunch of similar question about this but am still struggling to figure it out and I would appreciate some insight.

I am running a bunch of programs together and I would like to synchronize everything as best as I can. My application involves solving an optimization that takes about 0.5 seconds to solve and then using this data to guide finer control of the system during the 0.5 second intervals where I am waiting for the optimization to solve. I am also publishing data that informs the optimization much faster than this to a message. Just before I solve the optimization I want to grab the most recent data available, what I was thinking about doing was creating a service that basically echos the latest message that got published to my topic of interest. Are there any examples of something like this?

I also was thinking about making a subscriber node that has a callback function that is constantly updating ros parameters, but not only does this seem wasteful, it seems dangerous because I might try to use one of the parameters when they are being written to.

edit retag flag offensive close merge delete

Comments

Why do you want to echo the latest message published in your topic of interest instead of using that topic directly?

Procópio gravatar image Procópio  ( 2017-08-02 02:01:58 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2017-08-02 02:01:20 -0500

Procópio gravatar image

I would go with having a subscriber constantly updating a variable through a callback. You may see that as wasteful, but that is basically how ROS works. When you need them, you can make a copy of the the updatable vars, so they won't change on the fly.

edit flag offensive delete link more

Comments

Thank you for your quick response! So, should I use ROS parameters to do this? Also, the variables are the data about an obstacle, x and y position, radius and x and y velocity ( so they are related ). I can imagine that if I have them as separate variables that as I am actually copying them some

huckl3b3rry87 gravatar image huckl3b3rry87  ( 2017-08-02 10:42:35 -0500 )edit

Some of them may actually be overwritten. Should I try to put them into a single ros parameter?

huckl3b3rry87 gravatar image huckl3b3rry87  ( 2017-08-02 10:43:35 -0500 )edit

@huckl3b3rry87 do you mean message?

jayess gravatar image jayess  ( 2017-08-02 13:52:10 -0500 )edit

@jayess, yes. Sorry I just saw your comment

huckl3b3rry87 gravatar image huckl3b3rry87  ( 2017-08-06 14:38:29 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2017-08-02 01:39:11 -0500

Seen: 153 times

Last updated: Aug 02 '17