update comments 1

This commit is contained in:
2023-10-12 08:43:33 +02:00
parent a43e2db92b
commit 61a95e4601
5 changed files with 133 additions and 105 deletions
+50 -38
View File
@@ -22,6 +22,11 @@
#include "debugTimes.h"
#include "component.h"
/**
* @brief A struct to easy set the speed
*
*/
struct DrivingSpeeds {
double x;
double rot;
@@ -41,6 +46,11 @@ class MoveControl : public Component {
* @brief used to set driving status
*
* When set to stop all motors are set to halt
* When set to Raw the PIDs are not used. The target
* values must be given withe @see setRawPowerLeft and
* @see setRawPowerRight.
*
* Drive is the normal working mode.
*
*/
enum Status {Stop,
@@ -52,7 +62,7 @@ class MoveControl : public Component {
* @brief Construct a new Move Control object
*
* Initialize the motors, encoders and PIDs with given
* values in moveControlConfig.h
* values in config.h
*/
MoveControl();
@@ -66,6 +76,9 @@ class MoveControl : public Component {
/**
* @brief Set the Status
*
* Control if this component should work normally or with
* raw values for the motors.
*
* @see Status
* @param status
*/
@@ -87,29 +100,39 @@ class MoveControl : public Component {
void setSpeed(double speed);
/**
* @brief Set the rotationspeed
* @brief Set the rotationSpeed
*
* If the given rotationspeed is close to zero, then the
* target rotationspeed is set to zero.
* If the given rotationSpeed is close to zero, then the
* target rotationSpeed is set to zero.
* @param speed rad/s
*/
void setRotationSpeed(double speed);
/**
* @brief Set the speeds
*
* This function is a combination of @see setSpeed and
* @see setRotationSpeed. The struct @see DrivingSpeeds
* is used for this.
*
* @param drivingSpeeds
*/
void setSpeeds(DrivingSpeeds drivingSpeeds);
/**
* @brief Set Raw Power Left
* @brief Set raw power left
*
* This value has only an effect if Status is raw.
* This value has only an effect if the status is raw.
* @see setDrivingStatus
*
* @param power between -100 and 100
*/
void setRawPowerLeft(int16_t power);
/**
* @brief Set the Raw Power Right
* @brief Set the raw power right
*
* This value has only an effect if Status is raw.
* This value has only an effect if status is raw.
*
* @param power between -100 and 100
*/
@@ -119,9 +142,9 @@ class MoveControl : public Component {
* @brief Set the pid tunings
*
* @param side 0 -> left, 1 -> right
* @param p
* @param i
* @param d
* @param pPart
* @param iPart
* @param dPart
*/
void setPidTunings(uint8_t side, double pPart, double iPart, double dPart);
@@ -133,22 +156,11 @@ class MoveControl : public Component {
*/
PID* getPID(uint8_t side) const;
/**
* @brief Get the Speedometer Left object
*
* @return Speedometer*
*/
Speedometer* getSpeedometerLeft() const { return this->left_speedometer; }
Speedometer* getSpeedometerLeft() const { return this->leftSpeedometer; }
Speedometer* getSpeedometerRight() const { return this->rightSpeedometer; }
/**
* @brief Get the Speedometer Right object
*
* @return Speedometer*
*/
Speedometer* getSpeedometerRight() const { return this->right_speedometer; }
uint16_t getDutycycleLeft() const { return this->left_motor->getDutycycle(); }
uint16_t getDutycycleRight() const { return this->right_motor->getDutycycle(); }
uint16_t getDutycycleLeft() const { return this->leftMotor->getDutycycle(); }
uint16_t getDutycycleRight() const { return this->rightMotor->getDutycycle(); }
private:
void run() override;
@@ -157,22 +169,22 @@ class MoveControl : public Component {
void regulateMotors();
void updateCurrentWheelSpeed();
MotorControl *left_motor;
MotorControl *right_motor;
Speedometer *left_speedometer;
Speedometer *right_speedometer;
PID *left_pid;
PID *right_pid;
MotorControl *leftMotor;
MotorControl *rightMotor;
Speedometer *leftSpeedometer;
Speedometer *rightSpeedometer;
PID *leftPid;
PID *rightPid;
Status driving_status = Status::Stop;
DrivingSpeeds drivingSpeeds = {0, 0};
double wheelspeed_left_target = 0;
double wheelspeed_right_target = 0;
double wheelspeed_left = 0;
double wheelspeed_right = 0;
double left_pid_out = 0;
double right_pid_out = 0;
double wheelspeedLeftTarget = 0;
double wheelspeedRightTarget = 0;
double wheelspeedLeft = 0;
double wheelspeedRight = 0;
double leftPidOut = 0;
double rightPidOut = 0;
uint8_t overTimeCounter = 0;
uint8_t overTimeMax = 100;