Pas vraiment, c'est sur la théorie des autopilotes. j'ai pas de question sur le matos.
Le fait que ca soit sur un arduino c'est un detail
Le fait que ca soit sur un arduino c'est un detail
class LinearServo { public: LinearServo(float); void SetTarget(float); void SetActual(float); float GetOutput(); float Com****(); private: float actual; float target; float step; unsigned long lastTime; };
LinearServo::LinearServo(float s) { actual = 0.0f; target = 0.0f; step = s; //lastTime = millis(); } void LinearServo::SetTarget(float t) { target = t; } void LinearServo::SetActual(float a) { actual = a; } float LinearServo::GetOutput() { return actual; } float LinearServo::Com****() { float diff = target - actual; if(abs(diff) < step) { // Last step, just set to target and the job is done actual = target; return target; } if(diff > 0.0f) { // We're going positive : actual += step; // Increment actual by step } else { // Negative : actual -= step; // Decrement actual by step } return actual; }
Commentaire