we would probably need then a scalable linearized list of motors and a motor structure providing a thread ID, eg.:
typedef struc {
pthread_t tid;
int rampupaccel;
int rampdndecel;
int32_t setpoint;
int maxspeed;
//...a.s.o.
} tEncMotor ;
tEncMotor motor[MAXMOTORS];
void * PID_ramp (void *arg) ; // (forward)
pthread_create( & motor[nr].tid, // store ID in the related Array-Element
0, // Default Attribute (threads to be canceled)
PID_ramp, // Name of the PID-calculation routine
(void *) nr); // Index of Array-Elements for a PID structure,
// identcal to Motorindex
// run pthread task in detached mode, then auto-cleanup
pthread_detach(motor[nr].tid);
Hell, that would end up in a source code long enough to sink the USS Nimitzā¦ :-/
Iām pretty sure you can do it all in one loop, and the loop doesnāt even need to be dedicated to updating the motors (as long as the loop runs maybe 25+ times per second). That means you donāt need multi-threading to control the motors similar to how I described, even if there are 10 motors that simultaneously need to be limited (ramp up/down).
tbh, that entire task with PID and ramp and multiple motor control is too complicated to me, I think Iāll wait until itās implemented to the SAMD firmware, something similar like EV3Basic or LeJOS do it or did it for Mindstorms.
There is no update on this. The feature might get implemented into the firmware at some point, but itās not a priority since the functionality can be achieved in user code.
no, it actually canāt be achieved - the only way I could imagine are complicated detached threads for each single motor, thatās way too cumbersome. In all Mindstorms firmwares for NXT and EV3 (even 3rd party OS like leJos or ev3dev) this feature is integrated from the start, it works out of the box, and is indispensible for BrickPi3, tooā¦