I want to have a controller that somehow runs 3 processes to run the robot's code.
I am trying to simulate a humanoid soccer robot in webots . To run our robot's code, we run 3 processes. One for the servomotors' power management , another one for image processing and communications and the last one for motion control.
Now I want to have a controller making me somehow able to simulate something like this or at least similar to it. Does anyone have any idea how I can do this?
Good news: the Webots API is thread safe :-)
Generally speaking, I would not recommend to use multi-threads, because programming threads is a big source of issues. So, if you have any possibility to merge your threads into a single-threaded application, it's the way to go!
If you would like to go in this direction, the best solution is certainly to create a single controller running your 3 threads, and synchronize them with the main thread (thread 0).
The tricky part is to deal correctly with the time management and the simulation steps. A solution could be to set the Robot.synchronization
field to FALSE and to use the main thread to call the wb_robot_step(duration)
function every duration
time (real time).