Skip to content

Commit

Permalink
Update XRPReference for parity with java
Browse files Browse the repository at this point in the history
  • Loading branch information
Advay17 committed Nov 13, 2024
1 parent c289562 commit 4213143
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ class AutonomousDistance
: public frc2::CommandHelper<frc2::SequentialCommandGroup,
AutonomousDistance> {
public:
/**
* Creates a new Autonomous Drive based on distance. This will drive out for a
* specified distance, turn around and drive back.
*
* @param drive The drivetrain subsystem on which this command will run
*/
explicit AutonomousDistance(Drivetrain* drive) {
AddCommands(
DriveDistance(-0.5, 10_in, drive), TurnDegrees(-0.5, 180_deg, drive),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
class AutonomousTime
: public frc2::CommandHelper<frc2::SequentialCommandGroup, AutonomousTime> {
public:
/**
* Creates a new Autonomous Drive based on time. This will drive out for a
* period of time, turn around for time (equivalent to time to turn around)
* and drive forward again. This should mimic driving out, turning around and
* driving back.
*
* @param drive The drive subsystem on which this command will run
*/
explicit AutonomousTime(Drivetrain* drive) {
AddCommands(DriveTime(-0.6, 2_s, drive), TurnTime(-0.5, 1.3_s, drive),
DriveTime(-0.6, 2_s, drive), TurnTime(0.5, 1.3_s, drive));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@

class DriveDistance : public frc2::CommandHelper<frc2::Command, DriveDistance> {
public:
/**
* Creates a new DriveDistance. This command will drive your your robot for a
* desired distance at a desired speed.
*
* @param speed The speed at which the robot will drive
* @param inches The number of inches the robot will drive
* @param drive The drivetrain subsystem on which this command will run
*/
DriveDistance(double speed, units::meter_t distance, Drivetrain* drive)
: m_speed(speed), m_distance(distance), m_drive(drive) {
AddRequirements(m_drive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

class DriveTime : public frc2::CommandHelper<frc2::Command, DriveTime> {
public:
/**
* Creates a new DriveTime. This command will drive your robot for a desired
* speed and time.
*
* @param speed The speed which the robot will drive. Negative is in reverse.
* @param time How much time to drive
* @param drive The drivetrain subsystem on which this command will run
*/
DriveTime(double speed, units::second_t time, Drivetrain* drive)
: m_speed(speed), m_duration(time), m_drive(drive) {
AddRequirements(m_drive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
class TeleopArcadeDrive
: public frc2::CommandHelper<frc2::Command, TeleopArcadeDrive> {
public:
/**
* Creates a new ArcadeDrive. This command will drive your robot according to
* the speed suppliers. This command does not terminate.
*
* @param drivetrain The drivetrain subsystem on which this command will run
* @param xaxisSpeedSupplier Supplier of forward/backward speed
* @param zaxisRotateSupplier Supplier of rotational speed
*/
TeleopArcadeDrive(Drivetrain* subsystem,
std::function<double()> xaxisSpeedSupplier,
std::function<double()> zaxisRotateSupplier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

class TurnDegrees : public frc2::CommandHelper<frc2::Command, TurnDegrees> {
public:
/**
* Creates a new TurnDegrees. This command will turn your robot for a desired
* rotation (in degrees) and rotational speed.
*
* @param speed The speed which the robot will drive. Negative is in reverse.
* @param angle Degrees to turn. Leverages encoders to compare distance.
* @param drive The drive subsystem on which this command will run
*/
TurnDegrees(double speed, units::degree_t angle, Drivetrain* drive)
: m_speed(speed), m_angle(angle), m_drive(drive) {
AddRequirements(m_drive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@

class TurnTime : public frc2::CommandHelper<frc2::Command, TurnTime> {
public:
/**
* Creates a new TurnTime.
*
* @param speed The speed which the robot will turn. Negative is in reverse.
* @param time How much time to turn
* @param drive The drive subsystem on which this command will run
*/
TurnTime(double speed, units::second_t time, Drivetrain* drive)
: m_speed(speed), m_duration(time), m_drive(drive) {
AddRequirements(m_drive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,44 @@ class Drivetrain : public frc2::SubsystemBase {
units::meter_t GetAverageDistance();

/**
* Returns the acceleration along the X-axis, in m/s².
* The acceleration in the X-axis.
*
* @return The acceleration of the XRP along the X-axis.
*/
units::meters_per_second_squared_t GetAccelX();

/**
* Returns the acceleration along the Y-axis, in m/s².
* The acceleration in the Y-axis.
*
* @return The acceleration of the XRP along the Y-axis.
*/
units::meters_per_second_squared_t GetAccelY();

/**
* Returns the acceleration along the Z-axis, in m/s².
* The acceleration in the Z-axis.
*
* @return The acceleration of the XRP along the Z-axis.
*/
units::meters_per_second_squared_t GetAccelZ();

/**
* Returns the current angle of the Romi around the X-axis, in degrees.
* Current angle of the XRP around the X-axis.
*
* @return The current angle of the XRP.
*/
units::radian_t GetGyroAngleX();

/**
* Returns the current angle of the Romi around the Y-axis, in degrees.
* Current angle of the XRP around the Y-axis.
*
* @return The current angle of the XRP.
*/
units::radian_t GetGyroAngleY();

/**
* Returns the current angle of the Romi around the Z-axis, in degrees.
* Current angle of the XRP around the Z-axis.
*
* @return The current angle of the XRP.
*/
units::radian_t GetGyroAngleZ();

Expand Down

0 comments on commit 4213143

Please sign in to comment.