make all possible functions const
This commit is contained in:
@@ -125,7 +125,7 @@ class MoveControl : public Component {
|
|||||||
* @param side 0 -> left, 1 -> right
|
* @param side 0 -> left, 1 -> right
|
||||||
* @return PID*
|
* @return PID*
|
||||||
*/
|
*/
|
||||||
PID* getPID(uint8_t side);
|
PID* getPID(uint8_t side) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the Speedometer Left object
|
* @brief Get the Speedometer Left object
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ void Battery::run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Battery::getBatteryVoltage() {
|
double Battery::getBatteryVoltage() const {
|
||||||
double res = this->batteryVoltage;
|
double res = this->batteryVoltage;
|
||||||
return (int)(res*100+0.5)/100.0;
|
return (int)(res*100+0.5)/100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Battery::isBatteryLow(double voltage) {
|
bool Battery::isBatteryLow(double voltage) const {
|
||||||
if (this->getBatteryVoltage() <= voltage && this->batteryVoltage > this->absurdLowVoltage)
|
if (this->getBatteryVoltage() <= voltage && this->batteryVoltage > this->absurdLowVoltage)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@@ -136,7 +136,7 @@ void Battery::initBuffer() {
|
|||||||
this->adcBuffer[i] = 0;
|
this->adcBuffer[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Battery::getBufAvg() {
|
uint16_t Battery::getBufAvg() const {
|
||||||
uint32_t res = 0;
|
uint32_t res = 0;
|
||||||
uint8_t emptyPos = 0;
|
uint8_t emptyPos = 0;
|
||||||
for (uint8_t i = 0; i < Battery::bufferSize; i++) {
|
for (uint8_t i = 0; i < Battery::bufferSize; i++) {
|
||||||
|
|||||||
@@ -48,14 +48,14 @@ class Battery : public Component {
|
|||||||
*
|
*
|
||||||
* @return double in Volt
|
* @return double in Volt
|
||||||
*/
|
*/
|
||||||
double getBatteryVoltage();
|
double getBatteryVoltage() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the charge level of the battery
|
* @brief Get the charge level of the battery
|
||||||
*
|
*
|
||||||
* @return uint8_t charge level in percent
|
* @return uint8_t charge level in percent
|
||||||
*/
|
*/
|
||||||
uint8_t getBatteryPercent() { return this->batteryPercent; }
|
uint8_t getBatteryPercent() const { return this->batteryPercent; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks if the battery is low.
|
* @brief Checks if the battery is low.
|
||||||
@@ -68,7 +68,7 @@ class Battery : public Component {
|
|||||||
* @return true if the battery is low
|
* @return true if the battery is low
|
||||||
* @return false if the battery is high
|
* @return false if the battery is high
|
||||||
*/
|
*/
|
||||||
bool isBatteryLow(double voltage);
|
bool isBatteryLow(double voltage) const;
|
||||||
|
|
||||||
bool isNewValue();
|
bool isNewValue();
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class Battery : public Component {
|
|||||||
void calculateBatteryPercent();
|
void calculateBatteryPercent();
|
||||||
void readAdcToBuf();
|
void readAdcToBuf();
|
||||||
void initBuffer();
|
void initBuffer();
|
||||||
uint16_t getBufAvg();
|
uint16_t getBufAvg() const;
|
||||||
|
|
||||||
static const uint8_t bufferSize = 30;
|
static const uint8_t bufferSize = 30;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ void Counter::clear() {
|
|||||||
pcnt_counter_clear(this->unit);
|
pcnt_counter_clear(this->unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t Counter::getValue() {
|
int16_t Counter::getValue() const {
|
||||||
int16_t res;
|
int16_t res;
|
||||||
pcnt_get_counter_value(this->unit, &res);
|
pcnt_get_counter_value(this->unit, &res);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Counter {
|
|||||||
void resume();
|
void resume();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
int16_t getValue();
|
int16_t getValue() const;
|
||||||
|
|
||||||
void setFilterValue(uint16_t value);
|
void setFilterValue(uint16_t value);
|
||||||
void filterEnable();
|
void filterEnable();
|
||||||
|
|||||||
@@ -114,27 +114,19 @@ void MotorControl::emergencyStop() {
|
|||||||
setRealPower(0);
|
setRealPower(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t MotorControl::getPower() {
|
bool MotorControl::isTargetPowerReached() const {
|
||||||
return this->power;
|
|
||||||
}
|
|
||||||
|
|
||||||
int8_t MotorControl::getTargetPower() {
|
|
||||||
return this->targetPower;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MotorControl::isTargetPowerReached() {
|
|
||||||
if (this->targetPower == this->power)
|
if (this->targetPower == this->power)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MotorControl::isAccelerationPositive() {
|
bool MotorControl::isAccelerationPositive() const {
|
||||||
if (power < targetPower)
|
if (power < targetPower)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MotorControl::isAccelerationNegative() {
|
bool MotorControl::isAccelerationNegative() const {
|
||||||
if (power > targetPower)
|
if (power > targetPower)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -103,19 +103,19 @@ class MotorControl : public Component {
|
|||||||
*
|
*
|
||||||
* @return int8_t percent of power (-100 to 100)
|
* @return int8_t percent of power (-100 to 100)
|
||||||
*/
|
*/
|
||||||
int8_t getPower();
|
int8_t getPower() const { return this->power; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the target power
|
* @brief Get the target power
|
||||||
*
|
*
|
||||||
* @return int8_t percent of power (-100 to 100)
|
* @return int8_t percent of power (-100 to 100)
|
||||||
*/
|
*/
|
||||||
int8_t getTargetPower();
|
int8_t getTargetPower() const { return this->targetPower; };
|
||||||
|
|
||||||
uint16_t getDutycycle() const { return this->dutycycle; }
|
uint16_t getDutycycle() const { return this->dutycycle; }
|
||||||
bool isTargetPowerReached();
|
bool isTargetPowerReached() const;
|
||||||
bool isAccelerationPositive();
|
bool isAccelerationPositive() const;
|
||||||
bool isAccelerationNegative();
|
bool isAccelerationNegative() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|||||||
+1
-1
@@ -128,7 +128,7 @@ class Point{
|
|||||||
*
|
*
|
||||||
* @return Accuracy
|
* @return Accuracy
|
||||||
*/
|
*/
|
||||||
Accuracy getAccuracy() { return this->accuracy; }
|
Accuracy getAccuracy() const { return this->accuracy; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(uint32_t horizontalAccuracy, uint32_t creationTime);
|
void init(uint32_t horizontalAccuracy, uint32_t creationTime);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class Speedometer : public Component {
|
|||||||
*
|
*
|
||||||
* @return Direction
|
* @return Direction
|
||||||
*/
|
*/
|
||||||
Direction getDirection() { return this->currentDirection; }
|
Direction getDirection() const { return this->currentDirection; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the calculated speed of the Wheel
|
* @brief Get the calculated speed of the Wheel
|
||||||
|
|||||||
@@ -65,18 +65,6 @@ class Autopilot : public ManualControl {
|
|||||||
*/
|
*/
|
||||||
~Autopilot();
|
~Autopilot();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Calls runAutopilot or ManualControl loop
|
|
||||||
*
|
|
||||||
* This function should be called every main loop. If self
|
|
||||||
* driving is activated the function call run Autopilot. If
|
|
||||||
* the loopDelayMillis is not reached the function returns immediately.
|
|
||||||
*
|
|
||||||
* If self driving is not activated this functions calls the
|
|
||||||
* ManualControl loop additionally.
|
|
||||||
*/
|
|
||||||
void loop();
|
|
||||||
|
|
||||||
void restart();
|
void restart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void CaptureRoute::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double CaptureRoute::getDistanceToLastPoint() {
|
double CaptureRoute::getDistanceToLastPoint() const {
|
||||||
if (!this->lastSavedPoint.isInit())
|
if (!this->lastSavedPoint.isInit())
|
||||||
return 0;
|
return 0;
|
||||||
return this->lastSavedPoint.distanceTo(this->navigation->getCurrentPosition());
|
return this->lastSavedPoint.distanceTo(this->navigation->getCurrentPosition());
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class CaptureRoute : public ManualControl {
|
|||||||
*
|
*
|
||||||
* @return double in meters
|
* @return double in meters
|
||||||
*/
|
*/
|
||||||
double getDistanceToLastPoint();
|
double getDistanceToLastPoint() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Tells if there are new informations to display
|
* @brief Tells if there are new informations to display
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ void TestMode::abortManeuver() {
|
|||||||
this->abort = true;
|
this->abort = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t TestMode::getRemainingManeuverTime() {
|
uint8_t TestMode::getRemainingManeuverTime() const {
|
||||||
if (busy)
|
if (busy)
|
||||||
return (uint8_t) ((this->maneuverTime - (millis() - this->actionStart)) / 1000);
|
return (uint8_t) ((this->maneuverTime - (millis() - this->actionStart)) / 1000);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class TestMode : public DriveModi {
|
|||||||
*/
|
*/
|
||||||
void abortManeuver();
|
void abortManeuver();
|
||||||
|
|
||||||
uint8_t getRemainingManeuverTime();
|
uint8_t getRemainingManeuverTime() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns true if a maneuver is running
|
* @brief Returns true if a maneuver is running
|
||||||
@@ -99,8 +99,8 @@ class TestMode : public DriveModi {
|
|||||||
*/
|
*/
|
||||||
bool getBusy() const { return this->busy; }
|
bool getBusy() const { return this->busy; }
|
||||||
Maneuver getManeuver() const { return this->maneuver; }
|
Maneuver getManeuver() const { return this->maneuver; }
|
||||||
Speedometer* getSpeedometerLeft() { return this->moveControl->getSpeedometerLeft(); }
|
Speedometer* getSpeedometerLeft() const { return this->moveControl->getSpeedometerLeft(); }
|
||||||
Speedometer* getSpeedometerRight() { return this->moveControl->getSpeedometerRight(); }
|
Speedometer* getSpeedometerRight() const { return this->moveControl->getSpeedometerRight(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class DriveManager : public Component {
|
|||||||
*
|
*
|
||||||
* @return Navigation*
|
* @return Navigation*
|
||||||
*/
|
*/
|
||||||
Navigation* getNavigation() {return this->navigation;}
|
Navigation* getNavigation() const {return this->navigation;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the DriveModi Ptr object
|
* @brief Get the DriveModi Ptr object
|
||||||
@@ -96,14 +96,14 @@ class DriveManager : public Component {
|
|||||||
* @see getDriveModi
|
* @see getDriveModi
|
||||||
* @return DriveModi*
|
* @return DriveModi*
|
||||||
*/
|
*/
|
||||||
DriveModi* getDriveModiPtr() { return this->currentModusPtr; }
|
DriveModi* getDriveModiPtr() const { return this->currentModusPtr; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the DriveModi enum
|
* @brief Get the DriveModi enum
|
||||||
*
|
*
|
||||||
* @return Modi
|
* @return Modi
|
||||||
*/
|
*/
|
||||||
Modi getDriveModi() { return this->currentModus; }
|
Modi getDriveModi() const { return this->currentModus; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class DriveModi : public Component {
|
|||||||
void setMaxSpeed(double maxForwardSpeed) { maxForwardSpeed = maxForwardSpeed; }
|
void setMaxSpeed(double maxForwardSpeed) { maxForwardSpeed = maxForwardSpeed; }
|
||||||
void increaseMaxSpeed(double increase = 0.1) { maxForwardSpeed += increase; }
|
void increaseMaxSpeed(double increase = 0.1) { maxForwardSpeed += increase; }
|
||||||
void decreaseMaxSpeed(double increase = 0.1) { maxForwardSpeed -= increase; }
|
void decreaseMaxSpeed(double increase = 0.1) { maxForwardSpeed -= increase; }
|
||||||
double getMaxSpeed() { return this->maxForwardSpeed; }
|
double getMaxSpeed() const { return this->maxForwardSpeed; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the max rotation
|
* @brief Set the max rotation
|
||||||
@@ -44,7 +44,7 @@ class DriveModi : public Component {
|
|||||||
void setMaxRotation(double maxRotation) { maxRotationSpeed = maxRotation; }
|
void setMaxRotation(double maxRotation) { maxRotationSpeed = maxRotation; }
|
||||||
void increaseMaxRotation(double increase = 0.1) { maxRotationSpeed += increase; }
|
void increaseMaxRotation(double increase = 0.1) { maxRotationSpeed += increase; }
|
||||||
void decreaseMaxRotation(double increase = 0.1) { maxRotationSpeed -= increase; }
|
void decreaseMaxRotation(double increase = 0.1) { maxRotationSpeed -= increase; }
|
||||||
double getMaxRotation() { return this->maxRotationSpeed; }
|
double getMaxRotation() const { return this->maxRotationSpeed; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MoveControl *moveControl;
|
MoveControl *moveControl;
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ void makeMenu() {
|
|||||||
man_m->setLcd(lcdWrapper);
|
man_m->setLcd(lcdWrapper);
|
||||||
cap_m->setLcd(lcdWrapper);
|
cap_m->setLcd(lcdWrapper);
|
||||||
auto_m->setLcd(lcdWrapper);
|
auto_m->setLcd(lcdWrapper);
|
||||||
|
auto_m->setUpdateDelay(1000);
|
||||||
testM_m->setLcd(lcdWrapper);
|
testM_m->setLcd(lcdWrapper);
|
||||||
comp_m->setLcd(lcdWrapper);
|
comp_m->setLcd(lcdWrapper);
|
||||||
gps_m->setLcd(lcdWrapper);
|
gps_m->setLcd(lcdWrapper);
|
||||||
|
|||||||
+1
-1
@@ -137,7 +137,7 @@ void MoveControl::setPidTunings(uint8_t side, double p, double i, double d) {
|
|||||||
selectedPID->SetTunings(p, i, d);
|
selectedPID->SetTunings(p, i, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
PID* MoveControl::getPID(uint8_t side) {
|
PID* MoveControl::getPID(uint8_t side) const {
|
||||||
if (side == 0)
|
if (side == 0)
|
||||||
return this->left_pid;
|
return this->left_pid;
|
||||||
else if (side == 1)
|
else if (side == 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user