finished speed and sensor menu in modes

This commit is contained in:
2023-09-29 11:30:13 +02:00
parent d7357d4f95
commit 45264c6481
17 changed files with 96 additions and 78 deletions
@@ -34,17 +34,11 @@ void ManualControl::analogControl() {
int16_t x = this->input->x - 127;
int16_t y = this->input->y - 127;
// static int counter = 0;
// if (counter % 60 == 0) {
// std::cout << "Input: x: " << (int) this->input->x << " y: " << (int) this->input->y << std::endl;
// std::cout << "Output: x: " << (int) x << " y: " << (int) y << std::endl;
// }
// counter++;
double value_per_step = this->maxForwardSpeed * 2 / UINT8_MAX;
double value_per_step = this->maxSpeeds.x * 2 / UINT8_MAX;
this->moveControl->setSpeed(-x * value_per_step);
value_per_step = this->maxRotationSpeed * 2 / UINT8_MAX;
value_per_step = this->maxSpeeds.rot * 2 / UINT8_MAX;
this->moveControl->setRotationSpeed(y * value_per_step);
}
@@ -53,16 +47,16 @@ void ManualControl::digitalControl() {
int16_t x = this->input->y - 127;
if (y > 120)
this->moveControl->setSpeed(-this->maxForwardSpeed);
this->moveControl->setSpeed(-this->maxSpeeds.x);
else if (y < -120)
this->moveControl->setSpeed(this->maxForwardSpeed);
this->moveControl->setSpeed(this->maxSpeeds.rot);
else
this->moveControl->setSpeed(0);
if (x > 120)
this->moveControl->setRotationSpeed(this->maxRotationSpeed);
this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
else if (x < -120)
this->moveControl->setRotationSpeed(-this->maxRotationSpeed);
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
else
this->moveControl->setRotationSpeed(0);