refactore
all components now have a base class compnent for loop functions
This commit is contained in:
2023-08-18 10:47:35 +02:00
parent 25d37e3970
commit 11d21e2e89
35 changed files with 303 additions and 511 deletions
+27 -7
View File
@@ -12,24 +12,44 @@
#ifndef DRIVEMODI_H
#define DRIVEMODI_H
#include "component.h"
#include "moveControl.h"
/**
* @brief Baseclass to build DriveModi
*
* This class must be inherited by other classes which want to be
* act as a DriveModi, because the DriveModi structure uses polymorphism.
*/
class DriveModi {
class DriveModi : public Component {
public:
DriveModi(){}
virtual ~DriveModi(){}
DriveModi(MoveControl* moveControl);
virtual ~DriveModi();
/**
* @brief This function is called by the DriveManager
* @brief Set the max speed
*
* All actions from a DriveMode have to called from
* this function or the PS3-Controller
* @param maxSpeed in m/s
*/
virtual void loop() = 0;
void setMaxSpeed(double maxForwardSpeed) { maxForwardSpeed = maxForwardSpeed; }
void increaseMaxSpeed(double increase = 0.1) { maxForwardSpeed += increase; }
void decreaseMaxSpeed(double increase = 0.1) { maxForwardSpeed -= increase; }
double getMaxSpeed() { 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() { return this->maxRotationSpeed; }
protected:
MoveControl *moveControl;
double maxForwardSpeed = 1;
double maxRotationSpeed = 7;
};
#endif // DRIVEMODI_H