WPILibC++  2018.4.1-1228-gb9fa3a4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
KilloughDrive.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-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 #include "frc/drive/Vector2d.h"
16 
17 namespace frc {
18 
19 class SpeedController;
20 
47 class KilloughDrive : public RobotDriveBase {
48  public:
49  static constexpr double kDefaultLeftMotorAngle = 60.0;
50  static constexpr double kDefaultRightMotorAngle = 120.0;
51  static constexpr double kDefaultBackMotorAngle = 270.0;
52 
65  KilloughDrive(SpeedController& leftMotor, SpeedController& rightMotor,
66  SpeedController& backMotor);
67 
83  KilloughDrive(SpeedController& leftMotor, SpeedController& rightMotor,
84  SpeedController& backMotor, double leftMotorAngle,
85  double rightMotorAngle, double backMotorAngle);
86 
87  ~KilloughDrive() override = default;
88 
89  KilloughDrive(KilloughDrive&&) = default;
90  KilloughDrive& operator=(KilloughDrive&&) = default;
91 
107  void DriveCartesian(double ySpeed, double xSpeed, double zRotation,
108  double gyroAngle = 0.0);
109 
123  void DrivePolar(double magnitude, double angle, double zRotation);
124 
125  void StopMotor() override;
126  void GetDescription(wpi::raw_ostream& desc) const override;
127 
128  void InitSendable(SendableBuilder& builder) override;
129 
130  private:
131  SpeedController& m_leftMotor;
132  SpeedController& m_rightMotor;
133  SpeedController& m_backMotor;
134 
135  Vector2d m_leftVec;
136  Vector2d m_rightVec;
137  Vector2d m_backVec;
138 
139  bool reported = false;
140 };
141 
142 } // 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 InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
KilloughDrive(SpeedController &leftMotor, SpeedController &rightMotor, SpeedController &backMotor)
Construct a Killough drive with the given motors and default motor angles.
void DrivePolar(double magnitude, double angle, double zRotation)
Drive method for Killough platform.
A class for driving Killough drive platforms.
Definition: KilloughDrive.h:47
Definition: SendableBuilder.h:23
void DriveCartesian(double ySpeed, double xSpeed, double zRotation, double gyroAngle=0.0)
Drive method for Killough platform.
This is a 2D vector struct that supports basic vector operations.
Definition: Vector2d.h:15
Common base class for drive platforms.
Definition: RobotDriveBase.h:26