Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
DriveBoard.h
Go to the documentation of this file.
1
12#ifndef DRIVEBOARD_H
13#define DRIVEBOARD_H
14
15#include "../algorithms/DifferentialDrive.hpp"
16
18#include <RoveComm/RoveComm.h>
19#include <RoveComm/RoveCommManifest.h>
20#include <array>
21#include <shared_mutex>
22
24
25
34{
35 private:
37 // Declare private member variables.
39
40 diffdrive::DrivePowers m_stDrivePowers; // Struct used to store the left and right drive powers of the robot.
41 controllers::PIDController* m_pPID; // The PID controller used for drive towards a heading.
42 float m_fMinDriveEffort; // The min power limit of the drive. This can be adjusted through RoveComm.
43 float m_fMaxDriveEffort; // The max power limit of the drive. This can be adjusted through RoveComm.
44 std::shared_mutex m_muDriveEffortMutex; // Mutex used for changing the drive efforts.
45
47 // Declare private methods.
49
50
57 const std::function<void(const rovecomm::RoveCommPacket<float>&, const sockaddr_in&)> SetMaxSpeedCallback =
58 [this](const rovecomm::RoveCommPacket<float>& stPacket, const sockaddr_in& stdAddr)
59 {
60 // Not using this.
61 (void) stdAddr;
62
63 // Call class method to update max speed.
64 this->SetMaxDriveEffort(stPacket.vData[0]);
65
66 // Submit logger message.
67 LOG_INFO(logging::g_qSharedLogger, "Incoming SETMAXSPEED: {}", stPacket.vData[0]);
68 };
69
70 public:
72 // Declare public enums that are specific to and used within this class.
74
76 // Declare public methods and member variables.
78
79 DriveBoard();
81 diffdrive::DrivePowers CalculateMove(const double dGoalSpeed,
82 const double dGoalHeading,
83 const double dActualHeading,
84 const diffdrive::DifferentialControlMethod eKinematicsMethod);
85 void SendDrive(diffdrive::DrivePowers& stDrivePowers);
86 void SendStop();
87
89 // Setters
91 void SetMaxDriveEffort(const float fMaxDriveEffortMultiplier);
92
94 // Getters
96
98};
99#endif
This class handles communication with the drive board on the rover by sending RoveComm packets over t...
Definition DriveBoard.h:34
~DriveBoard()
Destroy the Drive Board::DriveBoard object.
Definition DriveBoard.cpp:67
DriveBoard()
Construct a new Drive Board::DriveBoard object.
Definition DriveBoard.cpp:31
diffdrive::DrivePowers CalculateMove(const double dGoalSpeed, const double dGoalHeading, const double dActualHeading, const diffdrive::DifferentialControlMethod eKinematicsMethod)
This method determines drive powers to make the Rover drive towards a given heading at a given speed.
Definition DriveBoard.cpp:92
diffdrive::DrivePowers GetDrivePowers() const
Accessor for the current drive powers of the robot.
Definition DriveBoard.cpp:213
void SetMaxDriveEffort(const float fMaxDriveEffortMultiplier)
Set the max power limits of the drive.
Definition DriveBoard.cpp:195
const std::function< void(const rovecomm::RoveCommPacket< float > &, const sockaddr_in &)> SetMaxSpeedCallback
Callback function that is called whenever RoveComm receives a new SETMAXSPEED packet.
Definition DriveBoard.h:57
void SendStop()
Stop the drivetrain of the Rover.
Definition DriveBoard.cpp:162
void SendDrive(diffdrive::DrivePowers &stDrivePowers)
Sets the left and right drive powers of the drive board.
Definition DriveBoard.cpp:120
This class encapsulates the fundamental principles of Proportional-Integral-Derivative (PID) control ...
Definition PIDController.h:50
This struct is used to store the left and right drive powers for the robot. Storing these values in a...
Definition DifferentialDrive.hpp:73