ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
But it seems the subscribers callbacks don't work.
The callbacks are probably fine, and this is not a ROS problem (so there's nothing wrong with the publishers, subscribers or dyn re_cfg here), but most likely a Python scoping problem: you're trying to use variables (in1
, in2
, gain1
and gain2
) in the body of your while
-loop that are out of scope at that point (ie: they do not 'exist' there). See random tutorial about Python variable scopes for some explanation.
A quick work-around could be to put in1
, in2
, gain1
and gain2
in the global scope. Using a class and making those variables members would probably be nicer.
Edit: note that besides the scoping issue your current implementation also has some other issues:
while-loop
(see wiki/rospy/Overview/Time - Sleeping and Rates)pub1
and pub2
publishers don't republish old data)The first can lead to starvation of other tasks/nodes, while the second can lead to missed updates and publishing stale data (among other things).