15#include "../algorithms/kinematics/DifferentialDrive.hpp"
18#include "../AutonomyConstants.h"
19#include <RoveComm/RoveComm.h>
20#include <RoveComm/RoveCommManifest.h>
22#include <shared_mutex>
48 const double dGoalHeading,
49 const double dActualHeading,
50 const diffdrive::DifferentialControlMethod eKinematicsMethod = diffdrive::DifferentialControlMethod::eArcadeDrive,
51 const bool bAlwaysProgressForward =
false);
74 std::unique_ptr<controllers::PIDController> m_pPID;
75 float m_fMinDriveEffort;
76 float m_fMaxDriveEffort;
77 float m_fDriveEffortMultiplier;
78 std::shared_mutex m_muDriveEffortMutex;
79 const float m_fMinSlope = constants::DRIVE_BOARD_MIN_SLOPE;
80 const float m_fMaxSlope = constants::DRIVE_BOARD_MAX_SLOPE;
81 const float m_fMinDamp = constants::DRIVE_BOARD_MIN_DAMP;
82 const float m_fMaxDamp = constants::DRIVE_BOARD_MAX_DAMP;
83 const float m_fRoll_w = constants::DRIVE_BOARD_ROLL_WEIGHT;
84 const float m_fPitch_w = constants::DRIVE_BOARD_PITCH_WEIGHT;
85 const float m_fYaw_w = constants::DRIVE_BOARD_YAW_WEIGHT;
98 const std::function<void(
const rovecomm::RoveCommPacket<float>&,
const sockaddr_in&)>
SetMaxSpeedCallback =
99 [
this](
const rovecomm::RoveCommPacket<float>& stPacket,
const sockaddr_in& stdAddr)
105 float fClampedMultiplier = std::clamp(std::fabs(stPacket.vData[0]), 0.0f, 1.0f);
108 std::unique_lock<std::shared_mutex> lkDriveEffortLock(m_muDriveEffortMutex);
109 m_fDriveEffortMultiplier = fClampedMultiplier;
113 LOG_NOTICE(logging::g_qSharedLogger,
"Incoming SETMAXSPEED: {}", stPacket.vData[0]);
This class handles communication with the drive board on the rover by sending RoveComm packets over t...
Definition DriveBoard.h:35
~DriveBoard()
Destroy the Drive Board::DriveBoard object.
Definition DriveBoard.cpp:68
DriveBoard()
Construct a new Drive Board::DriveBoard object.
Definition DriveBoard.cpp:31
void SendDrive(const diffdrive::DrivePowers &stDrivePowers, const bool bEnableVariableDriveEffort=true)
Sets the left and right drive powers of the drive board.
Definition DriveBoard.cpp:118
diffdrive::DrivePowers GetDrivePowers() const
Accessor for the current drive powers of the robot.
Definition DriveBoard.cpp:295
void SetMaxDriveEffort(const float fMaxDriveEffortMultiplier)
Set the max power limits of the drive.
Definition DriveBoard.cpp:277
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:98
float VariableDriveEffort()
This method calculates a multiplier that is applied to SetMaxDriveEffort() to adjust the speed of the...
Definition DriveBoard.cpp:229
void SendStop()
Stop the drivetrain of the Rover.
Definition DriveBoard.cpp:195
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:88
This struct is used to store the left and right drive powers for the robot. Storing these values in a...
Definition DifferentialDrive.hpp:73