WPILibC++  unspecified
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 <llvm/raw_ostream.h>
13 
14 #include "Drive/RobotDriveBase.h"
15 #include "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 
53  KilloughDrive(SpeedController& leftMotor, SpeedController& rightMotor,
54  SpeedController& backMotor);
55  KilloughDrive(SpeedController& leftMotor, SpeedController& rightMotor,
56  SpeedController& backMotor, double leftMotorAngle,
57  double rightMotorAngle, double backMotorAngle);
58  ~KilloughDrive() override = default;
59 
60  KilloughDrive(const KilloughDrive&) = delete;
61  KilloughDrive& operator=(const KilloughDrive&) = delete;
62 
63  void DriveCartesian(double ySpeed, double xSpeed, double zRotation,
64  double gyroAngle = 0.0);
65  void DrivePolar(double magnitude, double angle, double zRotation);
66 
67  void StopMotor() override;
68  void GetDescription(llvm::raw_ostream& desc) const override;
69 
70  void InitSendable(SendableBuilder& builder) override;
71 
72  private:
73  SpeedController& m_leftMotor;
74  SpeedController& m_rightMotor;
75  SpeedController& m_backMotor;
76 
77  Vector2d m_leftVec;
78  Vector2d m_rightVec;
79  Vector2d m_backVec;
80 
81  bool reported = false;
82 };
83 
84 } // namespace frc
void DriveCartesian(double ySpeed, double xSpeed, double zRotation, double gyroAngle=0.0)
Drive method for Killough platform.
Definition: KilloughDrive.cpp:89
Interface for speed controlling devices.
Definition: SpeedController.h:17
Definition: RobotController.cpp:14
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
Definition: KilloughDrive.cpp:157
void DrivePolar(double magnitude, double angle, double zRotation)
Drive method for Killough platform.
Definition: KilloughDrive.cpp:134
A class for driving Killough drive platforms.
Definition: KilloughDrive.h:47
KilloughDrive(SpeedController &leftMotor, SpeedController &rightMotor, SpeedController &backMotor)
Construct a Killough drive with the given motors and default motor angles.
Definition: KilloughDrive.cpp:34
Definition: SendableBuilder.h:23
This is a 2D vector struct that supports basic vector operations.
Definition: Vector2d.h:15
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:33
Common base class for drive platforms.
Definition: RobotDriveBase.h:26