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
+27 -12
View File
@@ -1,17 +1,22 @@
/**
* @file config.h
* @author Alexander Klein (alex@kleiax.de)
* @brief Some defines to configere the project.
* @brief Some defines to configure the project.
* @version 0.1
* @date 2022-02-15
*
*
* @copyright Copyright (c) 2022
*
*
*/
#pragma once
namespace PinNumbers {
/**
* @brief The numbers of pins to be used
*
*/
namespace PinNumbers
{
constexpr uint8_t spiCopi = 16;
constexpr uint8_t spiCipo = 4;
constexpr uint8_t spiSck = 5;
@@ -20,24 +25,31 @@ namespace PinNumbers {
constexpr uint8_t scl = 19;
constexpr uint8_t battery = 35;
namespace LeftMotor {
namespace LeftMotor
{
constexpr uint8_t dir1 = 27;
constexpr uint8_t dir2 = 12;
constexpr uint8_t pwm = 13;
constexpr uint8_t pwm = 13;
constexpr uint8_t encoder = 32;
constexpr uint8_t pmwChannel = 0;
}
namespace RightMotor {
namespace RightMotor
{
constexpr uint8_t dir1 = 14;
constexpr uint8_t dir2 = 23;
constexpr uint8_t pwm = 22;
constexpr uint8_t pwm = 22;
constexpr uint8_t encoder = 33;
constexpr uint8_t pmwChannel = 1;
}
}
namespace Settings {
/**
* @brief Default values for different components
*
*/
namespace Settings
{
constexpr uint32_t baudRate = 115200;
constexpr uint32_t i2cSpeed = 400000;
@@ -45,14 +57,17 @@ namespace Settings {
constexpr float wheelDistance = 0.255;
constexpr uint16_t encoderSteps = 384;
namespace Pid {
namespace Left {
namespace Pid
{
namespace Left
{
constexpr uint8_t P = 5;
constexpr uint8_t I = 0;
constexpr uint8_t D = 0;
}
namespace Right {
namespace Right
{
constexpr uint8_t P = 5;
constexpr uint8_t I = 0;
constexpr uint8_t D = 0;
+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;