Python trajectory waiting

In simple motion control applications with moteus, a common request for the python library is “run a position command until it is complete”. moteus does track when the target position reaches the desired one and reports it in the “trajectory complete flag” (register 0x00b), however until now the application needed to poll that flag on a regular basis to see when the motion is done.

As of pypi moteus 0.3.59, there is now a new method on Controller which can be used to accomplish this, along with an example script. Basic usage is about as simple as one would expect:

c = moteus.Controller()
await c.set_position_wait_complete(position=0.5, accel_limit=2.0)

By default, it will poll the controller every 25ms, and when complete, will return the final status update it received. If you have more than one controller, you’ll still need do the polling by hand or use a multi-axis trajectory planner, but for simple cases this can make life a lot easier.