finished speed and sensor menu in modes
This commit is contained in:
@@ -42,10 +42,8 @@ Do later:
|
|||||||
Do now:
|
Do now:
|
||||||
Code:
|
Code:
|
||||||
Doxygen Kommentare aktualisieren
|
Doxygen Kommentare aktualisieren
|
||||||
sensor data gnss daten aktualisieren
|
|
||||||
Menübaum korrigieren, Verlinkung Sensor in Mode etc.
|
|
||||||
esp und sensoren in den deepsleep
|
esp und sensoren in den deepsleep
|
||||||
battery Prozent ausgabe wirkt komisch
|
magic numbers etc
|
||||||
|
|
||||||
Latex:
|
Latex:
|
||||||
Anhang: Liste mit allen Komponenten und Kurzbeschreibung
|
Anhang: Liste mit allen Komponenten und Kurzbeschreibung
|
||||||
@@ -57,4 +55,3 @@ Latex:
|
|||||||
3D:
|
3D:
|
||||||
|
|
||||||
Rover:
|
Rover:
|
||||||
Spannungsteiler neu kalibrieren.
|
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
#include "debugTimes.h"
|
#include "debugTimes.h"
|
||||||
#include "component.h"
|
#include "component.h"
|
||||||
|
|
||||||
|
struct DrivingSpeeds {
|
||||||
|
double x;
|
||||||
|
double rot;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class manages the motors and the encoders
|
* @brief This class manages the motors and the encoders
|
||||||
@@ -91,6 +95,8 @@ class MoveControl : public Component {
|
|||||||
*/
|
*/
|
||||||
void setRotationSpeed(double speed);
|
void setRotationSpeed(double speed);
|
||||||
|
|
||||||
|
void setSpeeds(DrivingSpeeds drivingSpeeds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set Raw Power Left
|
* @brief Set Raw Power Left
|
||||||
*
|
*
|
||||||
@@ -159,9 +165,7 @@ class MoveControl : public Component {
|
|||||||
PID *right_pid;
|
PID *right_pid;
|
||||||
|
|
||||||
Status driving_status = Status::Stop;
|
Status driving_status = Status::Stop;
|
||||||
|
DrivingSpeeds drivingSpeeds = {0, 0};
|
||||||
double x_speed = 0;
|
|
||||||
double rotation_speed = 0;
|
|
||||||
|
|
||||||
double wheelspeed_left_target = 0;
|
double wheelspeed_left_target = 0;
|
||||||
double wheelspeed_right_target = 0;
|
double wheelspeed_right_target = 0;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class MenuPidSettings : public MenuIntInputWrapper {
|
|||||||
*/
|
*/
|
||||||
MenuPidSettings(PID* pid);
|
MenuPidSettings(PID* pid);
|
||||||
|
|
||||||
void action(int16_t* values, uint8_t length);
|
void action(int16_t* values, uint8_t length) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PID* pid;
|
PID* pid;
|
||||||
|
|||||||
@@ -11,3 +11,9 @@
|
|||||||
|
|
||||||
#include "menuSpeed.h"
|
#include "menuSpeed.h"
|
||||||
|
|
||||||
|
void MenuSpeed::action(int16_t* values, uint8_t length) {
|
||||||
|
if (length != 2)
|
||||||
|
return;
|
||||||
|
this->speeds.x = (double) values[0] / 10.0;
|
||||||
|
this->speeds.rot = (double) values[1] / 10.0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,8 +13,16 @@
|
|||||||
#define MENU_SPEED_H
|
#define MENU_SPEED_H
|
||||||
|
|
||||||
#include <menuIntInput.h>
|
#include <menuIntInput.h>
|
||||||
|
#include "moveControl.h"
|
||||||
|
|
||||||
class MenuSpeed : public MenuIntInput {
|
class MenuSpeed : public MenuIntInputWrapper {
|
||||||
|
public:
|
||||||
|
MenuSpeed(DrivingSpeeds& speeds) : speeds(speeds){};
|
||||||
|
|
||||||
|
void action(int16_t* values, uint8_t length) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DrivingSpeeds& speeds;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ void MenuManualControl::init() {
|
|||||||
this->driveManager->changeModus(this->manualControl);
|
this->driveManager->changeModus(this->manualControl);
|
||||||
this->setCountPages(4);
|
this->setCountPages(4);
|
||||||
this->updateDelay = 500;
|
this->updateDelay = 500;
|
||||||
|
this->activateSpeedMenu();
|
||||||
MenuDriveMode::init();
|
MenuDriveMode::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ void MenuTestMode::init() {
|
|||||||
this->testMode = new TestMode();
|
this->testMode = new TestMode();
|
||||||
this->driveManager->changeModus(this->testMode);
|
this->driveManager->changeModus(this->testMode);
|
||||||
|
|
||||||
testMode->setMaxSpeed(1);
|
this->testMode->setSpeeds(DrivingSpeeds{1, 8});
|
||||||
testMode->setMaxRotation(8);
|
|
||||||
|
|
||||||
auto dummy = []() {
|
auto dummy = []() {
|
||||||
std::cout << "Dummy in Action" <<std::endl;
|
std::cout << "Dummy in Action" <<std::endl;
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ void MenuDriveMode::left() {
|
|||||||
|
|
||||||
this->firstPrint = true;
|
this->firstPrint = true;
|
||||||
this->configureOnLeave();
|
this->configureOnLeave();
|
||||||
|
if (this->menuSpeed)
|
||||||
|
delete this->menuSpeed;
|
||||||
this->driveManager->changeModus();
|
this->driveManager->changeModus();
|
||||||
MenuInformationSites::left();
|
MenuInformationSites::left();
|
||||||
}
|
}
|
||||||
@@ -85,6 +87,20 @@ void MenuDriveMode::init() {
|
|||||||
this->activeMenu = nullptr;
|
this->activeMenu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuDriveMode::activateSpeedMenu() {
|
||||||
|
if (!this->driveManager->isActive())
|
||||||
|
return;
|
||||||
|
|
||||||
|
DrivingSpeeds& speeds = this->driveManager->getDriveModiPtr()->getSpeedsRef();
|
||||||
|
MenuIntInput* menu = new MenuIntInput(2, new MenuSpeed(speeds));
|
||||||
|
|
||||||
|
menu->setMinMax(5, UINT8_MAX);
|
||||||
|
menu->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10);
|
||||||
|
menu->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10);
|
||||||
|
|
||||||
|
this->addSpeedMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
void MenuDriveMode::enterSpeedMenu() {
|
void MenuDriveMode::enterSpeedMenu() {
|
||||||
this->activeMenu = this->menuSpeed;
|
this->activeMenu = this->menuSpeed;
|
||||||
this->enterMenu();
|
this->enterMenu();
|
||||||
@@ -97,9 +113,8 @@ void MenuDriveMode::enterSensorMenu() {
|
|||||||
|
|
||||||
void MenuDriveMode::enterMenu() {
|
void MenuDriveMode::enterMenu() {
|
||||||
if (!this->activeMenu)
|
if (!this->activeMenu)
|
||||||
return
|
return;
|
||||||
|
|
||||||
this->activeMenu->printMenu();
|
this->activeMenu->printMenu();
|
||||||
std::cout << "Sensor Menu was theretically printed" << std::endl;
|
|
||||||
this->activeMenu->setParentMenu(this);
|
this->activeMenu->setParentMenu(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class MenuDriveMode : public MenuInformationSites {
|
|||||||
MenuDriveMode(DriveManager* driveManager);
|
MenuDriveMode(DriveManager* driveManager);
|
||||||
|
|
||||||
void addSensorMenu(MenuSensorData* menuSensor) { this->menuSensor = menuSensor; }
|
void addSensorMenu(MenuSensorData* menuSensor) { this->menuSensor = menuSensor; }
|
||||||
void addSpeedMenu(MenuSpeed* menuSpeed) { this->menuSpeed = menuSpeed; }
|
void addSpeedMenu(MenuIntInput* menuSpeed) { this->menuSpeed = menuSpeed; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Goes back to the parentMenu.
|
* @brief Goes back to the parentMenu.
|
||||||
@@ -48,6 +48,7 @@ class MenuDriveMode : public MenuInformationSites {
|
|||||||
protected:
|
protected:
|
||||||
void init() override;
|
void init() override;
|
||||||
virtual void configureOnLeave() {}
|
virtual void configureOnLeave() {}
|
||||||
|
void activateSpeedMenu();
|
||||||
void enterSpeedMenu();
|
void enterSpeedMenu();
|
||||||
void enterSensorMenu();
|
void enterSensorMenu();
|
||||||
|
|
||||||
@@ -60,6 +61,6 @@ class MenuDriveMode : public MenuInformationSites {
|
|||||||
|
|
||||||
MenuControl* activeMenu = nullptr;
|
MenuControl* activeMenu = nullptr;
|
||||||
MenuSensorData* menuSensor = nullptr;
|
MenuSensorData* menuSensor = nullptr;
|
||||||
MenuSpeed* menuSpeed = nullptr;
|
MenuIntInput* menuSpeed = nullptr;
|
||||||
};
|
};
|
||||||
#endif // MENU_DRIVE_MODI_H
|
#endif // MENU_DRIVE_MODI_H
|
||||||
|
|||||||
@@ -125,17 +125,13 @@ void Autopilot::init() {
|
|||||||
this->courseCorrection.correction = 0;
|
this->courseCorrection.correction = 0;
|
||||||
this->courseCorrection.distance = 0;
|
this->courseCorrection.distance = 0;
|
||||||
this->updateDisplay = true;
|
this->updateDisplay = true;
|
||||||
|
|
||||||
this->maxRotationSpeed = 7;
|
|
||||||
this->maxForwardSpeed = 1.5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Autopilot::drive() {
|
void Autopilot::drive() {
|
||||||
this->moveControl->setRotationSpeed(0);
|
DrivingSpeeds speeds = {0, 0};
|
||||||
if (this->courseCorrection.distance >= this->minRemainingDistance)
|
if (this->courseCorrection.distance >= this->minRemainingDistance)
|
||||||
this->moveControl->setSpeed(this->maxForwardSpeed);
|
speeds.x = this->maxSpeeds.x;
|
||||||
else
|
this->moveControl->setSpeeds(speeds);
|
||||||
this,moveControl->setSpeed(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Autopilot::beginRotate() {
|
void Autopilot::beginRotate() {
|
||||||
@@ -145,11 +141,13 @@ void Autopilot::beginRotate() {
|
|||||||
this->rotationAimAzimuth = this->getSensorData()->getRealAzimuth() + this->courseCorrection.correction;
|
this->rotationAimAzimuth = this->getSensorData()->getRealAzimuth() + this->courseCorrection.correction;
|
||||||
this->rotationAimAzimuth = Navigation::fixDegree(this->rotationAimAzimuth);
|
this->rotationAimAzimuth = Navigation::fixDegree(this->rotationAimAzimuth);
|
||||||
|
|
||||||
this->moveControl->setSpeed(0);
|
DrivingSpeeds speeds = {0, 0};
|
||||||
if (this->courseCorrection.correction > 0)
|
if (this->courseCorrection.correction > 0)
|
||||||
this->moveControl->setRotationSpeed(-this->maxRotationSpeed);
|
speeds.rot = -this->maxSpeeds.rot;
|
||||||
else
|
else
|
||||||
this->moveControl->setRotationSpeed(this->maxRotationSpeed);
|
speeds.rot = this->maxSpeeds.rot;
|
||||||
|
|
||||||
|
this->moveControl->setSpeeds(speeds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,17 +34,11 @@ void ManualControl::analogControl() {
|
|||||||
int16_t x = this->input->x - 127;
|
int16_t x = this->input->x - 127;
|
||||||
int16_t y = this->input->y - 127;
|
int16_t y = this->input->y - 127;
|
||||||
|
|
||||||
// static int counter = 0;
|
|
||||||
// if (counter % 60 == 0) {
|
|
||||||
// std::cout << "Input: x: " << (int) this->input->x << " y: " << (int) this->input->y << std::endl;
|
|
||||||
// std::cout << "Output: x: " << (int) x << " y: " << (int) y << std::endl;
|
|
||||||
// }
|
|
||||||
// counter++;
|
|
||||||
|
|
||||||
double value_per_step = this->maxForwardSpeed * 2 / UINT8_MAX;
|
double value_per_step = this->maxSpeeds.x * 2 / UINT8_MAX;
|
||||||
this->moveControl->setSpeed(-x * value_per_step);
|
this->moveControl->setSpeed(-x * value_per_step);
|
||||||
|
|
||||||
value_per_step = this->maxRotationSpeed * 2 / UINT8_MAX;
|
value_per_step = this->maxSpeeds.rot * 2 / UINT8_MAX;
|
||||||
this->moveControl->setRotationSpeed(y * value_per_step);
|
this->moveControl->setRotationSpeed(y * value_per_step);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,16 +47,16 @@ void ManualControl::digitalControl() {
|
|||||||
int16_t x = this->input->y - 127;
|
int16_t x = this->input->y - 127;
|
||||||
|
|
||||||
if (y > 120)
|
if (y > 120)
|
||||||
this->moveControl->setSpeed(-this->maxForwardSpeed);
|
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
||||||
else if (y < -120)
|
else if (y < -120)
|
||||||
this->moveControl->setSpeed(this->maxForwardSpeed);
|
this->moveControl->setSpeed(this->maxSpeeds.rot);
|
||||||
else
|
else
|
||||||
this->moveControl->setSpeed(0);
|
this->moveControl->setSpeed(0);
|
||||||
|
|
||||||
if (x > 120)
|
if (x > 120)
|
||||||
this->moveControl->setRotationSpeed(this->maxRotationSpeed);
|
this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
|
||||||
else if (x < -120)
|
else if (x < -120)
|
||||||
this->moveControl->setRotationSpeed(-this->maxRotationSpeed);
|
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
|
||||||
else
|
else
|
||||||
this->moveControl->setRotationSpeed(0);
|
this->moveControl->setRotationSpeed(0);
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,9 @@ bool TestMode::drive(int16_t cm, int16_t degree) {
|
|||||||
this->moveControl->setSpeed(0);
|
this->moveControl->setSpeed(0);
|
||||||
|
|
||||||
if (degree < 0)
|
if (degree < 0)
|
||||||
this->moveControl->setRotationSpeed(-this->maxRotationSpeed);
|
this->moveControl->setRotationSpeed(-this->maxSpeeds.rot);
|
||||||
else if (degree > 0)
|
else if (degree > 0)
|
||||||
this->moveControl->setRotationSpeed(this->maxRotationSpeed);
|
this->moveControl->setRotationSpeed(this->maxSpeeds.rot);
|
||||||
|
|
||||||
this->azimuth = this->getSensorData()->getRealAzimuth();
|
this->azimuth = this->getSensorData()->getRealAzimuth();
|
||||||
this->degree = degree;
|
this->degree = degree;
|
||||||
@@ -53,11 +53,11 @@ bool TestMode::drive(int16_t cm, int16_t degree) {
|
|||||||
this->moveControl->setRotationSpeed(0);
|
this->moveControl->setRotationSpeed(0);
|
||||||
|
|
||||||
if (cm < 0)
|
if (cm < 0)
|
||||||
this->moveControl->setSpeed(-this->maxForwardSpeed);
|
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
||||||
else if (cm > 0)
|
else if (cm > 0)
|
||||||
this->moveControl->setSpeed(this->maxForwardSpeed);
|
this->moveControl->setSpeed(this->maxSpeeds.x);
|
||||||
|
|
||||||
this->maneuverTime = (uint32_t) (((double) abs(cm) / 100.0) / this->maxForwardSpeed) * 1000;
|
this->maneuverTime = (uint32_t) (((double) abs(cm) / 100.0) / this->maxSpeeds.x) * 1000;
|
||||||
this->busy = true;
|
this->busy = true;
|
||||||
this->maneuver = Maneuver::Drive;
|
this->maneuver = Maneuver::Drive;
|
||||||
return true;
|
return true;
|
||||||
@@ -65,11 +65,11 @@ bool TestMode::drive(int16_t cm, int16_t degree) {
|
|||||||
//forward or backward and left or right
|
//forward or backward and left or right
|
||||||
// TODO: Calculate roationspeed
|
// TODO: Calculate roationspeed
|
||||||
if (cm < 0)
|
if (cm < 0)
|
||||||
this->moveControl->setSpeed(-this->maxForwardSpeed);
|
this->moveControl->setSpeed(-this->maxSpeeds.x);
|
||||||
else if (cm > 0)
|
else if (cm > 0)
|
||||||
this->moveControl->setSpeed(this->maxForwardSpeed);
|
this->moveControl->setSpeed(this->maxSpeeds.x);
|
||||||
|
|
||||||
this->maneuverTime = (uint32_t) (((double) cm / 100.0) / this->maxForwardSpeed) * 1000;
|
this->maneuverTime = (uint32_t) (((double) cm / 100.0) / this->maxSpeeds.x) * 1000;
|
||||||
this->busy = true;
|
this->busy = true;
|
||||||
this->maneuver = Maneuver::Drive;
|
this->maneuver = Maneuver::Drive;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ void DriveManager::changeModus(DriveModi* modus) {
|
|||||||
|
|
||||||
if (this->currentModusPtr) {
|
if (this->currentModusPtr) {
|
||||||
this->currentModusPtr->activate(this->driveModiParams);
|
this->currentModusPtr->activate(this->driveModiParams);
|
||||||
|
this->currentModusPtr->setSpeeds(this->drivingSpeeds);
|
||||||
this->addChildComponent(this->currentModusPtr);
|
this->addChildComponent(this->currentModusPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class DriveManager : public Component {
|
|||||||
* @return DriveModi*
|
* @return DriveModi*
|
||||||
*/
|
*/
|
||||||
DriveModi* getDriveModiPtr() const { return this->currentModusPtr; }
|
DriveModi* getDriveModiPtr() const { return this->currentModusPtr; }
|
||||||
|
DrivingSpeeds& getDrivingSpeedsRef() { return this->drivingSpeeds; }
|
||||||
|
|
||||||
bool isActive() const { return this->currentModusPtr; }
|
bool isActive() const { return this->currentModusPtr; }
|
||||||
|
|
||||||
@@ -63,6 +63,7 @@ class DriveManager : public Component {
|
|||||||
|
|
||||||
DriveModi *currentModusPtr = nullptr;
|
DriveModi *currentModusPtr = nullptr;
|
||||||
DriveModiParams driveModiParams;
|
DriveModiParams driveModiParams;
|
||||||
|
DrivingSpeeds drivingSpeeds = {1, 7};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,34 +39,17 @@ class DriveModi : public Component {
|
|||||||
void activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData);
|
void activate(MoveControl* moveControl, ControlPadInput* input, SensorData* sensorData);
|
||||||
void activate(DriveModiParams params);
|
void activate(DriveModiParams params);
|
||||||
|
|
||||||
/**
|
void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; }
|
||||||
* @brief Set the max speed
|
DrivingSpeeds getSpeeds() const { return this->maxSpeeds; }
|
||||||
*
|
DrivingSpeeds& getSpeedsRef() { return this->maxSpeeds; }
|
||||||
* @param maxSpeed in m/s
|
|
||||||
*/
|
|
||||||
void setMaxSpeed(double maxForwardSpeed) { maxForwardSpeed = maxForwardSpeed; }
|
|
||||||
void increaseMaxSpeed(double increase = 0.1) { maxForwardSpeed += increase; }
|
|
||||||
void decreaseMaxSpeed(double increase = 0.1) { maxForwardSpeed -= increase; }
|
|
||||||
double getMaxSpeed() const { return this->maxForwardSpeed; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the max rotation
|
|
||||||
*
|
|
||||||
* @param maxRotation in rad/s (maybe)
|
|
||||||
*/
|
|
||||||
void setMaxRotation(double maxRotation) { maxRotationSpeed = maxRotation; }
|
|
||||||
void increaseMaxRotation(double increase = 0.1) { maxRotationSpeed += increase; }
|
|
||||||
void decreaseMaxRotation(double increase = 0.1) { maxRotationSpeed -= increase; }
|
|
||||||
double getMaxRotation() const { return this->maxRotationSpeed; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void afterActivate() {}
|
virtual void afterActivate() {}
|
||||||
|
|
||||||
MoveControl *moveControl;
|
MoveControl *moveControl;
|
||||||
|
DrivingSpeeds maxSpeeds = {1, 7};
|
||||||
const ControlPadInput* input;
|
const ControlPadInput* input;
|
||||||
const SensorData* sensorData;
|
const SensorData* sensorData;
|
||||||
double maxForwardSpeed = 1;
|
|
||||||
double maxRotationSpeed = 7;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|||||||
+8
-3
@@ -208,6 +208,7 @@ void makeMenu() {
|
|||||||
Menu* pid_m = new Menu();
|
Menu* pid_m = new Menu();
|
||||||
MenuIntInput* pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0)));
|
MenuIntInput* pidl_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(0)));
|
||||||
MenuIntInput* pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1)));
|
MenuIntInput* pidr_m = new MenuIntInput(3, new MenuPidSettings(moveController.getPID(1)));
|
||||||
|
MenuIntInput* speed_m = new MenuIntInput(2, new MenuSpeed(driveManager->getDrivingSpeedsRef()));
|
||||||
MenuManualControl* man_m = new MenuManualControl(driveManager);
|
MenuManualControl* man_m = new MenuManualControl(driveManager);
|
||||||
MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager);
|
MenuCaptureRoute* cap_m = new MenuCaptureRoute(driveManager);
|
||||||
MenuAutopilot* auto_m = new MenuAutopilot(driveManager);
|
MenuAutopilot* auto_m = new MenuAutopilot(driveManager);
|
||||||
@@ -223,8 +224,6 @@ void makeMenu() {
|
|||||||
sys_m->setUpdateDelay(1500);
|
sys_m->setUpdateDelay(1500);
|
||||||
sen_m->setUpdateDelay(500);
|
sen_m->setUpdateDelay(500);
|
||||||
|
|
||||||
man_m->addSensorMenu(sen_m);
|
|
||||||
|
|
||||||
// Entry for the main menu
|
// Entry for the main menu
|
||||||
main_m->addEntry(new MenuAction("Mode", mode_m));
|
main_m->addEntry(new MenuAction("Mode", mode_m));
|
||||||
main_m->addEntry(new MenuAction("Sensor", sen_m));
|
main_m->addEntry(new MenuAction("Sensor", sen_m));
|
||||||
@@ -243,7 +242,7 @@ void makeMenu() {
|
|||||||
|
|
||||||
// Entry for the setting menu
|
// Entry for the setting menu
|
||||||
set_m->addEntry(new MenuAction("PID", pid_m));
|
set_m->addEntry(new MenuAction("PID", pid_m));
|
||||||
set_m->addEntry(new MenuAction("Speed", dummy));
|
set_m->addEntry(new MenuAction("Speed", speed_m));
|
||||||
set_m->addEntry(new MenuAction("Distance", dummy));
|
set_m->addEntry(new MenuAction("Distance", dummy));
|
||||||
set_m->addEntry(new MenuAction("WiFi", dummy));
|
set_m->addEntry(new MenuAction("WiFi", dummy));
|
||||||
set_m->addEntry(new MenuAction("Battery", bat_m));
|
set_m->addEntry(new MenuAction("Battery", bat_m));
|
||||||
@@ -263,6 +262,12 @@ void makeMenu() {
|
|||||||
pidr_m->setEntry(1, "I-Part", (uint8_t) moveController.getPID(1)->GetKi());
|
pidr_m->setEntry(1, "I-Part", (uint8_t) moveController.getPID(1)->GetKi());
|
||||||
pidr_m->setEntry(2, "D-Part", (uint8_t) moveController.getPID(1)->GetKd());
|
pidr_m->setEntry(2, "D-Part", (uint8_t) moveController.getPID(1)->GetKd());
|
||||||
|
|
||||||
|
speed_m->setMinMax(5, UINT8_MAX);
|
||||||
|
speed_m->setEntry(0, "x m/s e-1", driveManager->getDrivingSpeedsRef().x * 10);
|
||||||
|
speed_m->setEntry(1, "z rad/s e-1", driveManager->getDrivingSpeedsRef().rot * 10);
|
||||||
|
|
||||||
|
man_m->addSensorMenu(sen_m);
|
||||||
|
|
||||||
controlPad->setMenuControl(main_m);
|
controlPad->setMenuControl(main_m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+11
-6
@@ -105,20 +105,25 @@ void MoveControl::emergencyStop() {
|
|||||||
|
|
||||||
void MoveControl::setSpeed(double speed) {
|
void MoveControl::setSpeed(double speed) {
|
||||||
if (speed < 0.2 && speed > -0.2) {
|
if (speed < 0.2 && speed > -0.2) {
|
||||||
this->x_speed = 0;
|
this->drivingSpeeds.x = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->x_speed = speed;
|
this->drivingSpeeds.x = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveControl::setRotationSpeed(double speed) {
|
void MoveControl::setRotationSpeed(double speed) {
|
||||||
if (speed < 0.1 && speed > -0.1){
|
if (speed < 0.1 && speed > -0.1){
|
||||||
this->rotation_speed = 0;
|
this->drivingSpeeds.rot = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->rotation_speed = speed;
|
this->drivingSpeeds.rot = speed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MoveControl::setSpeeds(DrivingSpeeds drivingSpeeds) {
|
||||||
|
this->setSpeed(drivingSpeeds.x);
|
||||||
|
this->setRotationSpeed(drivingSpeeds.rot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveControl::setRawPowerLeft(int16_t power) {
|
void MoveControl::setRawPowerLeft(int16_t power) {
|
||||||
@@ -169,8 +174,8 @@ void MoveControl::calcTargetWheelSpeed() {
|
|||||||
// (1 / r) * b
|
// (1 / r) * b
|
||||||
constexpr double B = 2.096518987;
|
constexpr double B = 2.096518987;
|
||||||
|
|
||||||
this->wheelspeed_right_target = (A * this->x_speed + B * this->rotation_speed) * (Settings::wheelDiameter / 2);
|
this->wheelspeed_right_target = (A * this->drivingSpeeds.x + B * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2);
|
||||||
this->wheelspeed_left_target = (A * this->x_speed + (-B) * this->rotation_speed) * (Settings::wheelDiameter / 2);
|
this->wheelspeed_left_target = (A * this->drivingSpeeds.x + (-B) * this->drivingSpeeds.rot) * (Settings::wheelDiameter / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveControl::regulateMotors() {
|
void MoveControl::regulateMotors() {
|
||||||
|
|||||||
Reference in New Issue
Block a user