edit manualControl for new ControlPad

This commit is contained in:
2023-04-20 12:34:45 +02:00
parent ef451a75fd
commit 5081290164
2 changed files with 11 additions and 5 deletions
@@ -31,12 +31,18 @@ void ManualControl::loop() {
}
void ManualControl::runManualControl() {
int8_t x = this->input->x;
int8_t y = this->input->y;
// Have to be int16_t to avoid overflow (int8_t = 255 - 127 = -128)
int16_t y = this->input->x - 127;
int16_t x = this->input->y - 127;
// if (x || y) {
// std::cout << "x: " << (int) this->input->x << " y: " << (int) this->input->y << std::endl;
// std::cout << "x: " << (int) x << " y: " << (int) y << std::endl;
// }
double value_per_step = this->max_speed * 2 / 256;
this->moveControl->setSpeed((y * -1) * value_per_step);
this->moveControl->setSpeed(-y * value_per_step);
value_per_step = this->max_rotation * 2 / 256;
this->moveControl->setRotationSpeed(-x * value_per_step);
this->moveControl->setRotationSpeed(x * value_per_step);
}
+1 -1
View File
@@ -79,7 +79,7 @@ bool TestMode::drive(int16_t cm, int16_t degree) {
else if (cm > 0)
this->moveControl->setSpeed(this->speed);
this->maneuverTime = (uint32_t) (((double) cm / 100.0) / this->speed) * 1000;
this->maneuverTime = (uint32_t) (((double) abs(cm) / 100.0) / this->speed) * 1000;
this->busy = true;
this->maneuver = Maneuver::Drive;
return true;