diff --git a/src/driveModi/Modi/ManualControl/manualControl.cpp b/src/driveModi/Modi/ManualControl/manualControl.cpp index bae63a4..8a34db1 100644 --- a/src/driveModi/Modi/ManualControl/manualControl.cpp +++ b/src/driveModi/Modi/ManualControl/manualControl.cpp @@ -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); } diff --git a/src/driveModi/Modi/TestMode/testMode.cpp b/src/driveModi/Modi/TestMode/testMode.cpp index 4a44f31..86480c1 100644 --- a/src/driveModi/Modi/TestMode/testMode.cpp +++ b/src/driveModi/Modi/TestMode/testMode.cpp @@ -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;