I am messing around in the firmware, trying to implement some custom behaviour in place of the usual Torque Control mode. This began as an attempt to work around a problem and is now just for seeing how far I can go with it.
To do this I am inserting code in Controller::update() and Motor::update(), just altering the values of torque and current_setpoint. (I am using fw-v0.5.1 - I think those names might have changed in more recent revisions.)
I cannot do too much in here without hitting ERROR_CONTROL_DEADLINE_MISSED - which I assume means the code I’ve added is taking too long to run.
Is it safe to comment out the bit in motor.cpp that raises this error? I’m assuming no.
Better question: is there somewhere else I can put my code, other than in Controller::update()? I still need it to run as fast as possible, but it can go a bit slower than every 125us (which is the value I get when printing current_meas_period, and therefore I’m taking to be the time between successive Controller::update() calls.)
EDIT: and it should be somewhere that still has access to the pos and vel estimates for the Axis as well as some other, custom values I’m remembering between updates. Currently I’ve added those as properties to the Controller class.
What’s probably happening is, because the control system thread priority is likely higher than the USB comms thread priority, an infinite loop without any delay to pass control to other threads will starve the communications thread of execution time.