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/kinematics/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 std::unique_ptr<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 = diffdrive::DifferentialControlMethod::eArcadeDrive,
85 const bool bAlwaysProgressForward = false);
86 void SendDrive(const diffdrive::DrivePowers& stDrivePowers);
87 void SendStop();
88
90 // Setters
92 void SetMaxDriveEffort(const float fMaxDriveEffortMultiplier);
93
95 // Getters
97
99};
100#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 GetDrivePowers() const
Accessor for the current drive powers of the robot.
Definition DriveBoard.cpp:217
void SendDrive(const diffdrive::DrivePowers &stDrivePowers)
Sets the left and right drive powers of the drive board.
Definition DriveBoard.cpp:117
void SetMaxDriveEffort(const float fMaxDriveEffortMultiplier)
Set the max power limits of the drive.
Definition DriveBoard.cpp:196
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:163
diffdrive::DrivePowers CalculateMove(const double dGoalSpeed, const double dGoalHeading, const double dActualHeading, const diffdrive::DifferentialControlMethod eKinematicsMethod=diffdrive::DifferentialControlMethod::eArcadeDrive, const bool bAlwaysProgressForward=false)
This method determines drive powers to make the Rover drive towards a given heading at a given speed.
Definition DriveBoard.cpp:87
This struct is used to store the left and right drive powers for the robot. Storing these values in a...
Definition DifferentialDrive.hpp:73