2017-10-17 21:37:58 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:20:21 -08:00
|
|
|
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
2017-10-17 21:37:58 -07:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include <frc/AnalogGyro.h>
|
|
|
|
|
#include <frc/Encoder.h>
|
2018-12-31 13:45:09 -08:00
|
|
|
#include <frc/PWMVictorSPX.h>
|
2018-07-20 00:03:45 -07:00
|
|
|
#include <frc/SpeedControllerGroup.h>
|
|
|
|
|
#include <frc/commands/Subsystem.h>
|
|
|
|
|
#include <frc/drive/DifferentialDrive.h>
|
2017-10-17 21:37:58 -07:00
|
|
|
|
|
|
|
|
namespace frc {
|
|
|
|
|
class Joystick;
|
2017-10-26 19:28:59 -07:00
|
|
|
} // namespace frc
|
2017-10-17 21:37:58 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The DriveTrain subsystem controls the robot's chassis and reads in
|
|
|
|
|
* information about it's speed and position.
|
|
|
|
|
*/
|
|
|
|
|
class DriveTrain : public frc::Subsystem {
|
2018-05-13 17:09:56 -07:00
|
|
|
public:
|
|
|
|
|
DriveTrain();
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/**
|
|
|
|
|
* When other commands aren't using the drivetrain, allow tank drive
|
|
|
|
|
* with
|
|
|
|
|
* the joystick.
|
|
|
|
|
*/
|
|
|
|
|
void InitDefaultCommand();
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/**
|
|
|
|
|
* @param leftAxis Left sides value
|
|
|
|
|
* @param rightAxis Right sides value
|
|
|
|
|
*/
|
|
|
|
|
void TankDrive(double leftAxis, double rightAxis);
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/**
|
|
|
|
|
* Stop the drivetrain from moving.
|
|
|
|
|
*/
|
|
|
|
|
void Stop();
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/**
|
|
|
|
|
* @return The encoder getting the distance and speed of left side of
|
|
|
|
|
* the drivetrain.
|
|
|
|
|
*/
|
2018-05-22 23:33:50 -07:00
|
|
|
frc::Encoder& GetLeftEncoder();
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/**
|
|
|
|
|
* @return The encoder getting the distance and speed of right side of
|
|
|
|
|
* the drivetrain.
|
|
|
|
|
*/
|
2018-05-22 23:33:50 -07:00
|
|
|
frc::Encoder& GetRightEncoder();
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
/**
|
|
|
|
|
* @return The current angle of the drivetrain.
|
|
|
|
|
*/
|
|
|
|
|
double GetAngle();
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
private:
|
|
|
|
|
// Subsystem devices
|
2018-12-31 13:45:09 -08:00
|
|
|
frc::PWMVictorSPX m_frontLeftCIM{1};
|
|
|
|
|
frc::PWMVictorSPX m_rearLeftCIM{2};
|
2018-05-13 17:09:56 -07:00
|
|
|
frc::SpeedControllerGroup m_leftCIMs{m_frontLeftCIM, m_rearLeftCIM};
|
2017-11-03 13:22:56 -07:00
|
|
|
|
2018-12-31 13:45:09 -08:00
|
|
|
frc::PWMVictorSPX m_frontRightCIM{3};
|
|
|
|
|
frc::PWMVictorSPX m_rearRightCIM{4};
|
2018-05-13 17:09:56 -07:00
|
|
|
frc::SpeedControllerGroup m_rightCIMs{m_frontRightCIM, m_rearRightCIM};
|
2017-11-03 13:22:56 -07:00
|
|
|
|
2018-05-13 17:09:56 -07:00
|
|
|
frc::DifferentialDrive m_robotDrive{m_leftCIMs, m_rightCIMs};
|
2017-11-03 13:22:56 -07:00
|
|
|
|
2018-05-22 23:33:50 -07:00
|
|
|
frc::Encoder m_rightEncoder{1, 2, true, frc::Encoder::k4X};
|
|
|
|
|
frc::Encoder m_leftEncoder{3, 4, false, frc::Encoder::k4X};
|
2018-05-13 17:09:56 -07:00
|
|
|
frc::AnalogGyro m_gyro{0};
|
2017-10-17 21:37:58 -07:00
|
|
|
};
|