Merge branch 'main' of git.kleiax.de:kleiax/Projektarbeit-Rover
This commit is contained in:
@@ -17,7 +17,7 @@ void TestMode::run() {
|
||||
this->abort = true;
|
||||
}
|
||||
|
||||
if (millis() - this->actionStart > this->maneuverTime || this->abort) {
|
||||
if (this->busy && millis() - this->actionStart > this->maneuverTime || this->abort) {
|
||||
this->busy = false;
|
||||
this->abort = false;
|
||||
this->moveControl->setDrivingStatus(MoveControl::Status::Stop);
|
||||
@@ -83,6 +83,7 @@ bool TestMode::leftEngine(int16_t powerPercentage, int16_t seconds) {
|
||||
if (this->engineInit(powerPercentage, seconds)) {
|
||||
this->moveControl->setRawPowerLeft(powerPercentage);
|
||||
this->maneuver = Maneuver::LeftEngine;
|
||||
std::cout << "TestMode::leftEngine" << std::endl;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -112,7 +113,7 @@ void TestMode::abortManeuver() {
|
||||
}
|
||||
|
||||
uint8_t TestMode::getRemainingManeuverTime() const {
|
||||
if (busy)
|
||||
if (this->busy)
|
||||
return (uint8_t) ((this->maneuverTime - (millis() - this->actionStart)) / 1000);
|
||||
return 0;
|
||||
}
|
||||
@@ -120,7 +121,7 @@ uint8_t TestMode::getRemainingManeuverTime() const {
|
||||
bool TestMode::engineInit(int16_t powerPercentage, int16_t seconds) {
|
||||
if (this->busy)
|
||||
return false;
|
||||
if (powerPercentage >= 100 || powerPercentage <= -100)
|
||||
if (powerPercentage > 100 || powerPercentage < -100)
|
||||
return false;
|
||||
if (seconds < 0)
|
||||
return false;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "moveControl.h"
|
||||
#include "navigation.h"
|
||||
#include "driveModi/driveModi.h"
|
||||
|
||||
|
||||
@@ -97,7 +96,6 @@ class TestMode : public DriveModi {
|
||||
void run() override;
|
||||
bool engineInit(int16_t powerPercentage, int16_t seconds);
|
||||
|
||||
Navigation* navigation;
|
||||
Maneuver maneuver = Maneuver::None;
|
||||
int16_t maneuverValueOne = 0;
|
||||
int16_t maneuverValueTwo = 0;
|
||||
|
||||
+13
-9
@@ -44,7 +44,7 @@ MoveControl::MoveControl() {
|
||||
this->right_motor->init(PinNumbers::RightMotor::pwm, PinNumbers::RightMotor::pmwChannel, PinNumbers::RightMotor::dir1, PinNumbers::RightMotor::dir2);
|
||||
|
||||
this->addChildComponent(this->left_motor);
|
||||
this->addChildComponent(this->right_motor);
|
||||
this->addChildComponent(this->right_motor);
|
||||
this->addChildComponent(this->left_speedometer);
|
||||
this->addChildComponent(this->right_speedometer);
|
||||
}
|
||||
@@ -80,11 +80,15 @@ void MoveControl::setDrivingStatus(Status status) {
|
||||
this->driving_status = status;
|
||||
// switch (this->driving_status) {
|
||||
// case Status::Stop :
|
||||
// Serial.println("New drivingState = Stop in MoveControl::setDrivingStatus");
|
||||
// std::cout << "New drivingState = Stop in MoveControl::setDrivingStatus" << std::endl;
|
||||
// break;
|
||||
|
||||
// case Status::Drive :
|
||||
// Serial.println("New drivingState = Drive in MoveControl::setDrivingStatus");
|
||||
// std::cout << "New drivingState = Drive in MoveControl::setDrivingStatus" << std::endl;
|
||||
// break;
|
||||
|
||||
// case Status::Raw :
|
||||
// std::cout << "New drivingState = Raw in MoveControl::setDrivingStatus" << std::endl;
|
||||
// break;
|
||||
|
||||
// default:
|
||||
@@ -169,12 +173,12 @@ void MoveControl::calcTargetWheelSpeed() {
|
||||
\ 1 -b / \ T / \ Xr / */
|
||||
|
||||
// (1 / r) * 1
|
||||
constexpr double A = 15.82278481;
|
||||
constexpr double A = 1.0 / (Settings::wheelDiameter / 2);
|
||||
// (1 / r) * b
|
||||
constexpr double B = 2.096518987;
|
||||
constexpr double B = (1.0 / (Settings::wheelDiameter / 2)) * (Settings::wheelDistance / 2);
|
||||
|
||||
this->wheelspeed_right_target = (A * this->drivingSpeeds.x + B * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2);
|
||||
this->wheelspeed_left_target = (A * this->drivingSpeeds.x + (-B) * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2);
|
||||
this->wheelspeed_right_target = (A * this->drivingSpeeds.x + B * this->drivingSpeeds.rot);
|
||||
this->wheelspeed_left_target = (A * this->drivingSpeeds.x + (-B) * this->drivingSpeeds.rot);
|
||||
}
|
||||
|
||||
void MoveControl::regulateMotors() {
|
||||
@@ -207,6 +211,6 @@ void MoveControl::regulateMotors() {
|
||||
}
|
||||
|
||||
void MoveControl::updateCurrentWheelSpeed() {
|
||||
this->wheelspeed_left = this->left_speedometer->getSpeed();
|
||||
this->wheelspeed_right = this->right_speedometer->getSpeed();
|
||||
this->wheelspeed_left = this->left_speedometer->getSpeedRad();
|
||||
this->wheelspeed_right = this->right_speedometer->getSpeedRad();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user