circle mode for autopilot
menu entry for circle mode
This commit is contained in:
2023-08-14 08:25:24 +02:00
parent 9adbdece7f
commit 010544a35a
5 changed files with 97 additions and 67 deletions
+18 -8
View File
@@ -18,7 +18,7 @@ DirectionChangeSignal::DirectionChangeSignal(Navigation* navigation) {
}
DirectionChangeSignal::~DirectionChangeSignal() {
navigation->dissableCalcAzimuth();
navigation->disableCalcAzimuth();
}
void DirectionChangeSignal::action() {
@@ -59,7 +59,7 @@ void Autopilot::loop() {
void Autopilot::runAutopilot() {
switch (this->state) {
case State::InsufficientAccuarcy:
case State::InsufficientAccuracy:
this->askNavigationForOrder();
return;
@@ -97,6 +97,8 @@ void Autopilot::runAutopilot() {
break;
case State::TargetReached:
if (this->loopMode)
this->restartLoop();
break;
default:
@@ -163,12 +165,12 @@ void Autopilot::beginRotate() {
}
void Autopilot::rotate() {
if (abs(this->navigation->getAzimuth() - this->rotationAimAzimuth) < 5) {
if (abs(this->navigation->getAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct) {
this->endRotate();
return;
}
if ((abs(this->navigation->getAzimuth() - this->rotationAimAzimuth) < 15)
if ((abs(this->navigation->getAzimuth() - this->rotationAimAzimuth) < this->maxCourseDeviationBeforeAct * 3)
&&
((this->courseCorrection.correction > 0
&& this->rotationAimAzimuth < this->navigation->getAzimuth())
@@ -217,18 +219,18 @@ void Autopilot::askNavigationForOrder() {
case Navigation::Status::InsufficientAccuracy:
this->lastState = this->state;
this->state = State::InsufficientAccuarcy;
this->state = State::InsufficientAccuracy;
this->moveControl->setSpeed(0);
this->moveControl->setRotationSpeed(0);
break;
case Navigation::Status::Unchanged:
if (this->state == State::InsufficientAccuarcy)
if (this->state == State::InsufficientAccuracy)
this->state = this->lastState;
break;
case Navigation::Status::Updated:
if (this->state == State::InsufficientAccuarcy)
if (this->state == State::InsufficientAccuracy)
this->state = this->lastState;
break;
@@ -241,8 +243,16 @@ void Autopilot::selfDriving() {
if (this->state != State::SelfDriving)
return;
if (abs(this->courseCorrection.correction) >= this->maxCourseDeviationBerforeAct)
if (abs(this->courseCorrection.correction) >= this->maxCourseDeviationBeforeAct)
this->beginRotate();
else
this->drive();
}
void Autopilot::restartLoop() {
this->navigation->startNavigation();
this->state = State::SelfDriving;
this->routeInfo = this->navigation->getRouteInfo();
this->lastOrderStatus = this->navigation->getCourseCorrection(this->courseCorrection, true);
this->updateDisplay = true;
}