WPILibC++  2020.3.2
KilloughDrive.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-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/drive/Vector2d.h"
16 #include "frc/smartdashboard/Sendable.h"
17 #include "frc/smartdashboard/SendableHelper.h"
18 
19 namespace frc {
20 
21 class SpeedController;
22 
50  public Sendable,
51  public SendableHelper<KilloughDrive> {
52  public:
53  static constexpr double kDefaultLeftMotorAngle = 60.0;
54  static constexpr double kDefaultRightMotorAngle = 120.0;
55  static constexpr double kDefaultBackMotorAngle = 270.0;
56 
69  KilloughDrive(SpeedController& leftMotor, SpeedController& rightMotor,
70  SpeedController& backMotor);
71 
87  KilloughDrive(SpeedController& leftMotor, SpeedController& rightMotor,
88  SpeedController& backMotor, double leftMotorAngle,
89  double rightMotorAngle, double backMotorAngle);
90 
91  ~KilloughDrive() override = default;
92 
93  KilloughDrive(KilloughDrive&&) = default;
94  KilloughDrive& operator=(KilloughDrive&&) = default;
95 
111  void DriveCartesian(double ySpeed, double xSpeed, double zRotation,
112  double gyroAngle = 0.0);
113 
127  void DrivePolar(double magnitude, double angle, double zRotation);
128 
129  void StopMotor() override;
130  void GetDescription(wpi::raw_ostream& desc) const override;
131 
132  void InitSendable(SendableBuilder& builder) override;
133 
134  private:
135  SpeedController* m_leftMotor;
136  SpeedController* m_rightMotor;
137  SpeedController* m_backMotor;
138 
139  Vector2d m_leftVec;
140  Vector2d m_rightVec;
141  Vector2d m_backVec;
142 
143  bool reported = false;
144 };
145 
146 } // namespace frc
frc::KilloughDrive::KilloughDrive
KilloughDrive(SpeedController &leftMotor, SpeedController &rightMotor, SpeedController &backMotor)
Construct a Killough drive with the given motors and default motor angles.
frc::RobotDriveBase
Common base class for drive platforms.
Definition: RobotDriveBase.h:24
frc::KilloughDrive
A class for driving Killough drive platforms.
Definition: KilloughDrive.h:49
frc::KilloughDrive::DriveCartesian
void DriveCartesian(double ySpeed, double xSpeed, double zRotation, double gyroAngle=0.0)
Drive method for Killough platform.
frc::Vector2d
This is a 2D vector struct that supports basic vector operations.
Definition: Vector2d.h:15
frc::Sendable
Interface for Sendable objects.
Definition: Sendable.h:17
frc::KilloughDrive::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
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::SendableHelper
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
frc::KilloughDrive::DrivePolar
void DrivePolar(double magnitude, double angle, double zRotation)
Drive method for Killough platform.
frc::SendableBuilder
Definition: SendableBuilder.h:23