autopilot inherits speed from manualControl

spelling
refactor
This commit is contained in:
2023-08-14 15:28:21 +02:00
parent 99dc1709d8
commit c7a19163ff
4 changed files with 22 additions and 21 deletions
@@ -59,10 +59,10 @@ void ManualControl::analogControl() {
// std::cout << "x: " << (int) x << " y: " << (int) y << std::endl;
// }
double value_per_step = this->max_speed * 2 / UINT8_MAX;
double value_per_step = this->maxForwardSpeed * 2 / UINT8_MAX;
this->moveControl->setSpeed(-y * value_per_step);
value_per_step = this->max_rotation * 2 / UINT8_MAX;
value_per_step = this->maxRotationSpeed * 2 / UINT8_MAX;
this->moveControl->setRotationSpeed(x * value_per_step);
}
@@ -71,16 +71,16 @@ void ManualControl::digitalControl() {
int16_t x = this->input->y - 127;
if (y > 120)
this->moveControl->setSpeed(-this->max_speed);
this->moveControl->setSpeed(-this->maxForwardSpeed);
else if (y < -120)
this->moveControl->setSpeed(this->max_speed);
this->moveControl->setSpeed(this->maxForwardSpeed);
else
this->moveControl->setSpeed(0);
if (x > 120)
this->moveControl->setRotationSpeed(this->max_rotation);
this->moveControl->setRotationSpeed(this->maxRotationSpeed);
else if (x < -120)
this->moveControl->setRotationSpeed(-this->max_rotation);
this->moveControl->setRotationSpeed(-this->maxRotationSpeed);
else
this->moveControl->setRotationSpeed(0);