added restart to autopilot menu and
disable autopilot by pressing the actionbutton
This commit is contained in:
@@ -86,13 +86,21 @@ void MenuAutopilot::printPage() const {
|
|||||||
lineTwo.concat(correction.correction);
|
lineTwo.concat(correction.correction);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2: {
|
||||||
|
uint16_t currentPoint = this->autopilot->getRouteInfo().currentPoint;
|
||||||
|
uint16_t totalPoints = this->autopilot->getRouteInfo().totalPoints;
|
||||||
|
if (currentPoint > totalPoints) {
|
||||||
|
lineOne = "Target reached";
|
||||||
|
lineTwo = "";
|
||||||
|
} else {
|
||||||
lineOne = "Target waypoint";
|
lineOne = "Target waypoint";
|
||||||
lineTwo = "";
|
lineTwo = "";
|
||||||
lineTwo.concat(this->autopilot->getRouteInfo().currentPoint);
|
lineTwo.concat(currentPoint);
|
||||||
lineTwo.concat(" from ");
|
lineTwo.concat(" from ");
|
||||||
lineTwo.concat(this->autopilot->getRouteInfo().totalPoints);
|
lineTwo.concat(totalPoints);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 3: {
|
case 3: {
|
||||||
NTRIPClientStates status = this->driveManager->getNavigation()->getNTRIPClient()->getClientState();
|
NTRIPClientStates status = this->driveManager->getNavigation()->getNTRIPClient()->getClientState();
|
||||||
@@ -131,6 +139,12 @@ void MenuAutopilot::printPage() const {
|
|||||||
lineOne.concat("0");
|
lineOne.concat("0");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 6:
|
||||||
|
lineOne = "Restart the";
|
||||||
|
lineTwo = "Autopilot";
|
||||||
|
this->autopilot->restart();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->printDefault();
|
this->printDefault();
|
||||||
return;
|
return;
|
||||||
@@ -139,6 +153,17 @@ void MenuAutopilot::printPage() const {
|
|||||||
this->print(lineOne, lineTwo);
|
this->print(lineOne, lineTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuAutopilot::runCommand() const {
|
||||||
|
switch (this->getCountPages()) {
|
||||||
|
case 6:
|
||||||
|
this->autopilot->restart();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuAutopilot::update() {
|
void MenuAutopilot::update() {
|
||||||
if (!this->autopilot->shouldUpdate())
|
if (!this->autopilot->shouldUpdate())
|
||||||
return;
|
return;
|
||||||
@@ -148,7 +173,7 @@ void MenuAutopilot::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuAutopilot::init() {
|
void MenuAutopilot::init() {
|
||||||
this->setCountPages(6);
|
this->setCountPages(7);
|
||||||
this->driveManager->changeModus(Modi::Autopilot);
|
this->driveManager->changeModus(Modi::Autopilot);
|
||||||
this->autopilot = (Autopilot*) this->driveManager->getDriveModiPtr();
|
this->autopilot = (Autopilot*) this->driveManager->getDriveModiPtr();
|
||||||
this->routeInfo = this->autopilot->getRouteInfo();
|
this->routeInfo = this->autopilot->getRouteInfo();
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class MenuAutopilot : public MenuDriveMode {
|
|||||||
* and save the Autopilot object.
|
* and save the Autopilot object.
|
||||||
*/
|
*/
|
||||||
void printPage() const override;
|
void printPage() const override;
|
||||||
|
void runCommand() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief can be called to update shown data
|
* @brief can be called to update shown data
|
||||||
|
|||||||
@@ -14,17 +14,7 @@
|
|||||||
Autopilot::Autopilot(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation)
|
Autopilot::Autopilot(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation)
|
||||||
: ManualControl(moveControl, input) {
|
: ManualControl(moveControl, input) {
|
||||||
this->navigation = navigation;
|
this->navigation = navigation;
|
||||||
if (this->navigation->startNavigation())
|
this->init();
|
||||||
this->state = State::NavigationStarted;
|
|
||||||
else
|
|
||||||
this->state = State::NoRoute;
|
|
||||||
this->routeInfo = this->navigation->getRouteInfo();
|
|
||||||
|
|
||||||
this->lastState = this->navigation->getNTRIPClient()->getClientState();
|
|
||||||
|
|
||||||
this->courseCorrection.correction = 0;
|
|
||||||
this->courseCorrection.distance = 0;
|
|
||||||
this->updateDisplay = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Autopilot::~Autopilot() {
|
Autopilot::~Autopilot() {
|
||||||
@@ -51,6 +41,7 @@ void Autopilot::runAutopilot() {
|
|||||||
this->moveControl->setSpeed(0);
|
this->moveControl->setSpeed(0);
|
||||||
this->moveControl->setRotationSpeed(0);
|
this->moveControl->setRotationSpeed(0);
|
||||||
this->updateDisplay = true;
|
this->updateDisplay = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->routeInfo = this->navigation->getRouteInfo();
|
this->routeInfo = this->navigation->getRouteInfo();
|
||||||
@@ -72,12 +63,22 @@ void Autopilot::runAutopilot() {
|
|||||||
this->updateDisplay = true;
|
this->updateDisplay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->state == State::SelfDriving
|
||||||
|
&& ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
|
||||||
|
this->state = State::SelfDrivingAvailable;
|
||||||
|
this->updateDisplay = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (this->state == State::SelfDriving) {
|
if (this->state == State::SelfDriving) {
|
||||||
this->setSpeedInRelToDistance(this->courseCorrection.distance);
|
this->setSpeedInRelToDistance(this->courseCorrection.distance);
|
||||||
this->setRotInRelToDistance(this->courseCorrection.correction);
|
this->setRotInRelToDistance(this->courseCorrection.correction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Autopilot::restart() {
|
||||||
|
this->init();
|
||||||
|
}
|
||||||
|
|
||||||
bool Autopilot::shouldUpdate() {
|
bool Autopilot::shouldUpdate() {
|
||||||
if (this->updateDisplay) {
|
if (this->updateDisplay) {
|
||||||
this->updateDisplay = false;
|
this->updateDisplay = false;
|
||||||
@@ -86,6 +87,20 @@ bool Autopilot::shouldUpdate() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Autopilot::init() {
|
||||||
|
if (this->navigation->startNavigation())
|
||||||
|
this->state = State::NavigationStarted;
|
||||||
|
else
|
||||||
|
this->state = State::NoRoute;
|
||||||
|
this->routeInfo = this->navigation->getRouteInfo();
|
||||||
|
|
||||||
|
this->lastState = this->navigation->getNTRIPClient()->getClientState();
|
||||||
|
|
||||||
|
this->courseCorrection.correction = 0;
|
||||||
|
this->courseCorrection.distance = 0;
|
||||||
|
this->updateDisplay = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Autopilot::checkNtrip() {
|
void Autopilot::checkNtrip() {
|
||||||
NTRIPClient* client = this->navigation->getNTRIPClient();
|
NTRIPClient* client = this->navigation->getNTRIPClient();
|
||||||
NTRIPClientStates state = client->getClientState();
|
NTRIPClientStates state = client->getClientState();
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ class Autopilot : public ManualControl {
|
|||||||
*/
|
*/
|
||||||
void runAutopilot();
|
void runAutopilot();
|
||||||
|
|
||||||
|
void restart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Route Info object
|
* @brief Get the Route Info object
|
||||||
*
|
*
|
||||||
@@ -106,6 +108,7 @@ class Autopilot : public ManualControl {
|
|||||||
bool shouldUpdate();
|
bool shouldUpdate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void init();
|
||||||
void checkNtrip();
|
void checkNtrip();
|
||||||
void setSpeedInRelToDistance(double distance);
|
void setSpeedInRelToDistance(double distance);
|
||||||
void setRotInRelToDistance(int16_t course);
|
void setRotInRelToDistance(int16_t course);
|
||||||
|
|||||||
Reference in New Issue
Block a user