I was certain I'd posted this before, but I searched all my previous posts and couldn't find it, so *super* sorry if this is one of those common questions that comes up all the time!
Here's my issue:
I'm using webbotlib. The Axon is responsible for determining whether my robot should be working in "position" mode or "force" mode. The switch between these two modes is a threshold on the force sensor: the robot keeps moving to a certain position unless the force on the sensor exceeds a threshold, at which point it starts to regulate the force at some pre-set value.
That threshold is going to have to be variable, and what changes it is a message from the PC. So far, so good -- I can easily send data back and forth from the PC to the Axon.
However, since the threshold is just a variable that gets created each time the Axon goes into the "appControl" function, it also gets destroyed each time I exit that loop. If the threshold were never changing, I'd just #define it as something. I need to be able to set the threshold whenever I want, without having to re-set it each time I go through the appControl function.
So: PC sends a new threshold, Axon receives it, and should set that threshold and keep it, regardless of whether it exited appControl, until a new threshold is received.
How do I do that? :-P