WPILibC++  2020.3.2
MecanumDrive.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <memory>
11 
12 #include <wpi/raw_ostream.h>
13 
14 #include "frc/drive/RobotDriveBase.h"
15 #include "frc/smartdashboard/Sendable.h"
16 #include "frc/smartdashboard/SendableHelper.h"
17 
18 namespace frc {
19 
20 class SpeedController;
21 
68  public Sendable,
69  public SendableHelper<MecanumDrive> {
70  public:
76  MecanumDrive(SpeedController& frontLeftMotor, SpeedController& rearLeftMotor,
77  SpeedController& frontRightMotor,
78  SpeedController& rearRightMotor);
79 
80  ~MecanumDrive() override = default;
81 
82  MecanumDrive(MecanumDrive&&) = default;
83  MecanumDrive& operator=(MecanumDrive&&) = default;
84 
100  void DriveCartesian(double ySpeed, double xSpeed, double zRotation,
101  double gyroAngle = 0.0);
102 
116  void DrivePolar(double magnitude, double angle, double zRotation);
117 
124  bool IsRightSideInverted() const;
125 
132  void SetRightSideInverted(bool rightSideInverted);
133 
134  void StopMotor() override;
135  void GetDescription(wpi::raw_ostream& desc) const override;
136 
137  void InitSendable(SendableBuilder& builder) override;
138 
139  private:
140  SpeedController* m_frontLeftMotor;
141  SpeedController* m_rearLeftMotor;
142  SpeedController* m_frontRightMotor;
143  SpeedController* m_rearRightMotor;
144 
145  double m_rightSideInvertMultiplier = -1.0;
146 
147  bool reported = false;
148 };
149 
150 } // namespace frc
frc::RobotDriveBase
Common base class for drive platforms.
Definition: RobotDriveBase.h:24
frc::MecanumDrive::IsRightSideInverted
bool IsRightSideInverted() const
Gets if the power sent to the right side of the drivetrain is multipled by -1.
frc::MecanumDrive::DriveCartesian
void DriveCartesian(double ySpeed, double xSpeed, double zRotation, double gyroAngle=0.0)
Drive method for Mecanum platform.
frc::MecanumDrive::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::MecanumDrive::SetRightSideInverted
void SetRightSideInverted(bool rightSideInverted)
Sets if the power sent to the right side of the drivetrain should be multipled by -1.
frc::MecanumDrive::MecanumDrive
MecanumDrive(SpeedController &frontLeftMotor, SpeedController &rearLeftMotor, SpeedController &frontRightMotor, SpeedController &rearRightMotor)
Construct a MecanumDrive.
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::MecanumDrive::DrivePolar
void DrivePolar(double magnitude, double angle, double zRotation)
Drive method for Mecanum platform.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::SpeedController
Interface for speed controlling devices.
Definition: SpeedController.h:19
wpi::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:47
frc::MecanumDrive
A class for driving Mecanum drive platforms.
Definition: MecanumDrive.h:67
frc::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::SendableBuilder
Definition: SendableBuilder.h:23