WPILibC++  2018.4.1-20180821013237-1172-g8d8f120
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
MecanumDrive.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 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 
16 namespace frc {
17 
18 class SpeedController;
19 
65 class MecanumDrive : public RobotDriveBase {
66  public:
72  MecanumDrive(SpeedController& frontLeftMotor, SpeedController& rearLeftMotor,
73  SpeedController& frontRightMotor,
74  SpeedController& rearRightMotor);
75 
76  ~MecanumDrive() override = default;
77 
78  MecanumDrive(const MecanumDrive&) = delete;
79  MecanumDrive& operator=(const MecanumDrive&) = delete;
80 
96  void DriveCartesian(double ySpeed, double xSpeed, double zRotation,
97  double gyroAngle = 0.0);
98 
112  void DrivePolar(double magnitude, double angle, double zRotation);
113 
120  bool IsRightSideInverted() const;
121 
128  void SetRightSideInverted(bool rightSideInverted);
129 
130  void StopMotor() override;
131  void GetDescription(wpi::raw_ostream& desc) const override;
132 
133  void InitSendable(SendableBuilder& builder) override;
134 
135  private:
136  SpeedController& m_frontLeftMotor;
137  SpeedController& m_rearLeftMotor;
138  SpeedController& m_frontRightMotor;
139  SpeedController& m_rearRightMotor;
140 
141  double m_rightSideInvertMultiplier = -1.0;
142 
143  bool reported = false;
144 };
145 
146 } // namespace frc
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
Interface for speed controlling devices.
Definition: SpeedController.h:17
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
void DriveCartesian(double ySpeed, double xSpeed, double zRotation, double gyroAngle=0.0)
Drive method for Mecanum platform.
MecanumDrive(SpeedController &frontLeftMotor, SpeedController &rearLeftMotor, SpeedController &frontRightMotor, SpeedController &rearRightMotor)
Construct a MecanumDrive.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
A class for driving Mecanum drive platforms.
Definition: MecanumDrive.h:65
bool IsRightSideInverted() const
Gets if the power sent to the right side of the drivetrain is multipled by -1.
Definition: SendableBuilder.h:23
void SetRightSideInverted(bool rightSideInverted)
Sets if the power sent to the right side of the drivetrain should be multipled by -1...
void DrivePolar(double magnitude, double angle, double zRotation)
Drive method for Mecanum platform.
Common base class for drive platforms.
Definition: RobotDriveBase.h:26