Files
allwpilib/wpilibcExamples/src/main/cpp/examples/PacGoat/include/Subsystems/DriveTrain.h

80 lines
2.1 KiB
C
Raw Normal View History

/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* 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
#include <AnalogGyro.h>
#include <Commands/Subsystem.h>
2017-11-03 13:22:56 -07:00
#include <Drive/DifferentialDrive.h>
#include <Encoder.h>
2017-11-03 13:22:56 -07:00
#include <Spark.h>
#include <SpeedControllerGroup.h>
namespace frc {
class Joystick;
2017-10-26 19:28:59 -07:00
} // namespace frc
/**
* 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();
2018-05-13 17:09:56 -07:00
/**
* When other commands aren't using the drivetrain, allow tank drive
* with
* the joystick.
*/
void InitDefaultCommand();
2018-05-13 17:09:56 -07:00
/**
* @param leftAxis Left sides value
* @param rightAxis Right sides value
*/
void TankDrive(double leftAxis, double rightAxis);
2018-05-13 17:09:56 -07:00
/**
* Stop the drivetrain from moving.
*/
void Stop();
2018-05-13 17:09:56 -07:00
/**
* @return The encoder getting the distance and speed of left side of
* the drivetrain.
*/
frc::Encoder& GetLeftEncoder();
2018-05-13 17:09:56 -07:00
/**
* @return The encoder getting the distance and speed of right side of
* the drivetrain.
*/
frc::Encoder& GetRightEncoder();
2018-05-13 17:09:56 -07:00
/**
* @return The current angle of the drivetrain.
*/
double GetAngle();
2018-05-13 17:09:56 -07:00
private:
// Subsystem devices
frc::Spark m_frontLeftCIM{1};
frc::Spark m_rearLeftCIM{2};
frc::SpeedControllerGroup m_leftCIMs{m_frontLeftCIM, m_rearLeftCIM};
2017-11-03 13:22:56 -07:00
2018-05-13 17:09:56 -07:00
frc::Spark m_frontRightCIM{3};
frc::Spark m_rearRightCIM{4};
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
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};
};