-
Notifications
You must be signed in to change notification settings - Fork 1
Description
It should be possible to control both simulation and real robot asynchronously, which means that the python call should directly return and the action should be executed in the background. Furthermore, if an action is executed and a python caller issues a new action, the movement of the robot should be updated.
Requirements
- It should be possible to communicate with the thread in a thread safe manner e.g. by using signals or certain shared states (it would be better if the implementation already comes with that to avoid that the user forgets to use semaphores)
- Should be joinable and waitable
- Hold the return type of the async executed function (not a strict requirement for robot control)
std::async and std::future seem to fulfill these requirements. However, they cannot be used as a thread pool, thus they will spawn a new thread every time. It would be faster to keep a thread constantly waiting until a command is issued, similar to thread pools work.
Implementation
-> The best solution seems to me to write a dispatcher class, which takes any function signature and arguments and lets the function run async. It should support interrupt and join methods as well as checking for python errors.