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

How do I use a subscriber callback to change a global variable?

asked 2012-07-13 09:53:23 -0600

IFLORbot gravatar image

I'm trying to use a callback for the current location to update a global variable I have that's just a tuple. However, the callback is working fine, but the global variable is never updated.

I normally use a callback as a loop to run whatever it is I want to do, but in this case I have a separate loop choosing locations to navigate too. I want this loop to gain access to the current location.

Also, I'm not sure I understand exactly how callbacks work, and this may be me problem.

edit retag flag offensive close merge delete

Comments

[edit: should have been an answer, not a comment.]

Mac gravatar image Mac  ( 2012-07-13 09:57:04 -0600 )edit

Ok cool. I'm also new to Python, so that could explain my problem as well. Thanks.

IFLORbot gravatar image IFLORbot  ( 2012-07-16 02:56:39 -0600 )edit

Also, while we're here, is there a good thread/site for understanding callbacks? I think I get them now, but it took me a while as it was new and at first seemed like magic....

IFLORbot gravatar image IFLORbot  ( 2012-07-16 03:11:08 -0600 )edit
1

@IFORbot: sounds to me like you should start a new question.

Mac gravatar image Mac  ( 2012-07-17 09:58:35 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2012-07-13 09:57:19 -0600

Mac gravatar image

If you're in python, take a look at the "global" keyword. If you're in C++, we're going to need a code snippet.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-07-13 09:53:23 -0600

Seen: 1,593 times

Last updated: Jul 13 '12