How to set a single index for ROS vector (C++) Parameter?

asked 2020-12-01 06:45:47 -0500

adi gravatar image

So I've got a yaml file with some parameters which get loaded into the parameter server when i launch the corresponding launch file. One of the parameters is a distance vector "dist" which has a length = number of drones spawned. For each drone I only need to update a particular index of the dist vector. The issue is that I don't know how to modify only the value at a certain index using nodehandle.setParam. Its easy to update the entire vector by doing nodehandle.setParam('/dist', dist_vector_inside_drone_i_node), but that would certainly overwrite the value that the other drones write to the same vector. This is why I need a way to update just the index for a certain global vector. How do I do a setParam on a single index of a vector?

edit retag flag offensive close merge delete

Comments

I don't know if you can easily. Will there be many updates? The parameter server isn't really meant for that. Either way, have you considered giving each drone its own parameter in a shared namespace? Something like /dist/drone_i. You could do this on the parameter server (or with topics if there will be many updates). If you explain a bit more about your use case, it may help determine the best course. In general, multiple independent agents accessing a global variable can create problems.

tryan gravatar image tryan  ( 2020-12-01 11:40:57 -0500 )edit