Async/await and events executor in animation server
Summary
Use events executor in animation server. Due to the complex nature of an action server that is able to reject/cancel actions as well as the close communication with the hcm via service rpc calls this was not possible in a single threaded manner without the use of async and await. Which actually works great with ROS 2. Why is this not the default in the tutorials?????
This change brings the resource utilization from 30% (idle) to 2-6% (while playing animations ). Also the latency when calling animations (e.g. during falling) seems much lower.
Somehow ROS2 async does not has a async sleep function (using ros time), so I needed to build my own based on https://github.com/ros2/rclpy/issues/1234. I also added a wrapper for blocking functions that was not needed in the end.
I tested many scenarios where e.g. the hcm cancels an animation in simulation and it seems to work without deadlocks.
Minor Updates:
-
bitbots_motion/bitbots_hcm/bitbots_hcm/hcm_dsd/actions/change_motor_power.py: Updated the motor switch service call to use the asynchronouscall_asyncas a blocking method is not needed and might be risky.
Related issues
#682
Checklist
- [x] Run
colcon build - [x] Write documentation
- [x] Test on your machine
- [ ] Test on the robot
- [x] Create issues for future work
- [x] Triage this PR and label it