Async Robots
- Level:
- beginner
- Room:
- south hall 2b
- Start:
- Duration:
- 30 minutes
Abstract
Interactive control of robots can be a challenge, as it requires a lot of things to happen in parallel while at the same time reacting to data from sensors and control signals. Using python's async facilities may greatly simplify this task, allowing us to write code that is similar to the non-parallel version, but that is at the same time easy to compose into bigger program doing many things at once. I will talk about my own experiences programming the Fluffbug robot with CircuitPython, point out the problems and the solutions I found.
Description
Fluffbug is a small, affordable walking robot programmed with CircuitPython. The way it moves and reacts to sensors and control signals requires code that seemingly does a lot of things all at once, but we don't have direct access to mechanisms like threads or interrupts. What we use instead is Python's async syntax and the minimal version of asyncio library available in CircuitPython. This makes an interesting use case for asynchronous programming that is different from the usual web servers and API frontends. The resulting code is much shorter and easier to maintain than similar code written in a traditional, linear way.