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 bDriveBackwards =
false,
52 const bool bAlwaysProgressForward =
false,
53 const bool bSquareControlInput =
false,
54 const bool bCurvatureDriveAllowTurningWhileStopped =
true);
78 std::unique_ptr<controllers::PIDController> m_pPID;
79 float m_fDriveEffortMultiplier;
80 mutable std::shared_mutex m_muDriveEffortMutex;
81 const float m_fMinSlope = constants::DRIVE_BOARD_MIN_SLOPE;
82 const float m_fMaxSlope = constants::DRIVE_BOARD_MAX_SLOPE;
83 const float m_fMinDamp = constants::DRIVE_BOARD_MIN_DAMP;
84 const float m_fMaxDamp = constants::DRIVE_BOARD_MAX_DAMP;
85 const float m_fRoll_w = constants::DRIVE_BOARD_ROLL_WEIGHT;
86 const float m_fPitch_w = constants::DRIVE_BOARD_PITCH_WEIGHT;
87 const float m_fYaw_w = constants::DRIVE_BOARD_YAW_WEIGHT;
100 const std::function<void(
const rovecomm::RoveCommPacket<float>&,
const sockaddr_in&)>
SetMaxSpeedCallback =
101 [
this](
const rovecomm::RoveCommPacket<float>& stPacket,
const sockaddr_in& stdAddr)
107 float fClampedMultiplier = std::clamp(std::fabs(stPacket.vData[0]), 0.0f, 1.0f);
110 std::unique_lock<std::shared_mutex> lkDriveEffortLock(m_muDriveEffortMutex);
111 m_fDriveEffortMultiplier = fClampedMultiplier;
115 LOG_NOTICE(logging::g_qSharedLogger,
"Incoming SETMAXSPEED: {}", fClampedMultiplier);
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:66
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:166
diffdrive::DrivePowers GetDrivePowers() const
Accessor for the current drive powers of the robot.
Definition DriveBoard.cpp:346
void SetMaxDriveEffort(const float fMaxDriveEffortMultiplier)
Set the max power limits of the drive.
Definition DriveBoard.cpp:328
diffdrive::DrivePowers CalculateMove(const double dGoalSpeed, const double dGoalHeading, const double dActualHeading, const diffdrive::DifferentialControlMethod eKinematicsMethod=diffdrive::DifferentialControlMethod::eArcadeDrive, const bool bDriveBackwards=false, const bool bAlwaysProgressForward=false, const bool bSquareControlInput=false, const bool bCurvatureDriveAllowTurningWhileStopped=true)
This method determines drive powers to make the Rover drive towards a given heading at a given speed.
Definition DriveBoard.cpp:89
float GetMaxDriveEffort() const
Accessor for the current max drive effort multiplier.
Definition DriveBoard.cpp:361
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:100
float VariableDriveEffort()
This method calculates a multiplier that is applied to SetMaxDriveEffort() to adjust the speed of the...
Definition DriveBoard.cpp:280
void SendStop()
Stop the drivetrain of the Rover.
Definition DriveBoard.cpp:246
This struct is used to store the left and right drive powers for the robot. Storing these values in a...
Definition DifferentialDrive.hpp:73