ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Almost certainly the issue has to do with scoping in Python. In your callbacks you likely have some line looking approximately like gps_xy = msg.data.something
. This is creating a new variable local to the callback that goes out of scope as soon as the callback is done running. Here are several ways you could fix this:
global
keyword in your callbacks.self
as its first argument, and you'll be able to access self.gps_xy
callback_args
argument in the Subscriber instantiation method to pass additional arguments to your callback. In this case, it would be the variables that you would want updated within the callbacks.