0
$\begingroup$

Rosanswers logo

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.


Originally posted by IFLORbot on ROS Answers with karma: 33 on 2012-07-13

Post score: 0


Original comments

Comment by Mac on 2012-07-13:
[edit: should have been an answer, not a comment.]

Comment by IFLORbot on 2012-07-16:
Ok cool. I'm also new to Python, so that could explain my problem as well. Thanks.

Comment by IFLORbot on 2012-07-16:
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....

Comment by Mac on 2012-07-17:
@IFORbot: sounds to me like you should start a new question.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Mac with karma: 4119 on 2012-07-13

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.