diff --git a/romiVendordep/src/main/native/cpp/romi/RomiGyro.cpp b/romiVendordep/src/main/native/cpp/romi/RomiGyro.cpp index c44cff9d82..4c67f77abe 100644 --- a/romiVendordep/src/main/native/cpp/romi/RomiGyro.cpp +++ b/romiVendordep/src/main/native/cpp/romi/RomiGyro.cpp @@ -24,60 +24,60 @@ RomiGyro::RomiGyro() : m_simDevice("Gyro:RomiGyro") { } } -double RomiGyro::GetAngle() const { +units::radian_t RomiGyro::GetAngle() const { return GetAngleZ(); } -double RomiGyro::GetRate() const { +units::radians_per_second_t RomiGyro::GetRate() const { return GetRateZ(); } -double RomiGyro::GetRateX() const { +units::radians_per_second_t RomiGyro::GetRateX() const { if (m_simRateX) { - return m_simRateX.Get(); + return units::degrees_per_second_t{m_simRateX.Get()}; } - return 0.0; + return 0.0_rad_per_s; } -double RomiGyro::GetRateY() const { +units::radians_per_second_t RomiGyro::GetRateY() const { if (m_simRateY) { - return m_simRateY.Get(); + return units::degrees_per_second_t{m_simRateY.Get()}; } - return 0.0; + return 0.0_rad_per_s; } -double RomiGyro::GetRateZ() const { +units::radians_per_second_t RomiGyro::GetRateZ() const { if (m_simRateZ) { - return m_simRateZ.Get(); + return units::degrees_per_second_t{m_simRateZ.Get()}; } - return 0.0; + return 0.0_rad_per_s; } -double RomiGyro::GetAngleX() const { +units::radian_t RomiGyro::GetAngleX() const { if (m_simAngleX) { - return m_simAngleX.Get() - m_angleXOffset; + return units::degree_t{m_simAngleX.Get() - m_angleXOffset}; } - return 0.0; + return 0.0_rad; } -double RomiGyro::GetAngleY() const { +units::radian_t RomiGyro::GetAngleY() const { if (m_simAngleY) { - return m_simAngleY.Get() - m_angleYOffset; + return units::degree_t{m_simAngleY.Get() - m_angleYOffset}; } - return 0.0; + return 0.0_rad; } -double RomiGyro::GetAngleZ() const { +units::radian_t RomiGyro::GetAngleZ() const { if (m_simAngleZ) { - return m_simAngleZ.Get() - m_angleZOffset; + return units::degree_t{m_simAngleZ.Get() - m_angleZOffset}; } - return 0.0; + return 0.0_rad; } void RomiGyro::Reset() { diff --git a/romiVendordep/src/main/native/include/frc/romi/RomiGyro.h b/romiVendordep/src/main/native/include/frc/romi/RomiGyro.h index 5ef5045660..b64ee60ec4 100644 --- a/romiVendordep/src/main/native/include/frc/romi/RomiGyro.h +++ b/romiVendordep/src/main/native/include/frc/romi/RomiGyro.h @@ -5,6 +5,8 @@ #pragma once #include +#include +#include namespace frc { @@ -24,55 +26,67 @@ class RomiGyro { RomiGyro(); /** - * Return the actual angle in degrees that the robot is currently facing. + * Return the actual angle in radians that the robot is currently facing. * * The angle is based on integration of the returned rate form the gyro. - * The angle is continuous, that is, it will continue from 360->361 degrees. + * The angle is continuous, that is, it will continue from 2π->3π radians. * This allows algorithms that wouldn't want to see a discontinuity in the - * gyro output as it sweeps from 360 to 0 on the second time around. + * gyro output as it sweeps from 2π to 0 on the second time around. * - * @return the current heading of the robot in degrees. + * @return The current heading of the robot. */ - double GetAngle() const; + units::radian_t GetAngle() const; /** * Return the rate of rotation of the gyro * * The rate is based on the most recent reading of the gyro. * - * @return the current rate in degrees per second + * @return The current rate. */ - double GetRate() const; + units::radians_per_second_t GetRate() const; /** - * Gets the rate of turn in degrees-per-second around the X-axis + * Get the rate of turn in around the X-axis. + * + * @return Rate of turn. */ - double GetRateX() const; + units::radians_per_second_t GetRateX() const; /** - * Gets the rate of turn in degrees-per-second around the Y-axis + * Get the rate of turn in around the Y-axis. + * + * @return Rate of turn. */ - double GetRateY() const; + units::radians_per_second_t GetRateY() const; /** - * Gets the rate of turn in degrees-per-second around the Z-axis + * Get the rate of turn around the Z-axis. + * + * @return Rate of turn. */ - double GetRateZ() const; + units::radians_per_second_t GetRateZ() const; /** - * Gets the currently reported angle around the X-axis + * Get the currently reported angle around the X-axis. + * + * @return Current angle around X-axis. */ - double GetAngleX() const; + units::radian_t GetAngleX() const; /** - * Gets the currently reported angle around the X-axis + * Get the currently reported angle around the Y-axis. + * + * @return Current angle around Y-axis. */ - double GetAngleY() const; + units::radian_t GetAngleY() const; /** - * Gets the currently reported angle around the X-axis + * Get the currently reported angle around the Z-axis. + * + * @return Current angle around Z-axis. */ - double GetAngleZ() const; + units::radian_t GetAngleZ() const; /** * Resets the gyro diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp index 1d212d5c5d..7afc2d77df 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp @@ -63,27 +63,27 @@ units::meter_t Drivetrain::GetAverageDistance() { return (GetLeftDistance() + GetRightDistance()) / 2.0; } -double Drivetrain::GetAccelX() { - return m_accelerometer.GetX(); +units::meters_per_second_squared_t Drivetrain::GetAccelX() { + return units::meters_per_second_squared_t{m_accelerometer.GetX()}; } -double Drivetrain::GetAccelY() { - return m_accelerometer.GetY(); +units::meters_per_second_squared_t Drivetrain::GetAccelY() { + return units::meters_per_second_squared_t{m_accelerometer.GetY()}; } -double Drivetrain::GetAccelZ() { - return m_accelerometer.GetZ(); +units::meters_per_second_squared_t Drivetrain::GetAccelZ() { + return units::meters_per_second_squared_t{m_accelerometer.GetZ()}; } -double Drivetrain::GetGyroAngleX() { +units::radian_t Drivetrain::GetGyroAngleX() { return m_gyro.GetAngleX(); } -double Drivetrain::GetGyroAngleY() { +units::radian_t Drivetrain::GetGyroAngleY() { return m_gyro.GetAngleY(); } -double Drivetrain::GetGyroAngleZ() { +units::radian_t Drivetrain::GetGyroAngleZ() { return m_gyro.GetAngleZ(); } diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousDistance.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousDistance.h index 8991ce60fe..ef01bc4e67 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousDistance.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousDistance.h @@ -15,6 +15,12 @@ class AutonomousDistance : public frc2::CommandHelper { 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), diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousTime.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousTime.h index e25e5ea3af..1666d47322 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousTime.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/AutonomousTime.h @@ -14,6 +14,14 @@ class AutonomousTime : public frc2::CommandHelper { 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)); diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.h index 6011531401..ab279f2dd5 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.h @@ -12,6 +12,14 @@ class DriveDistance : public frc2::CommandHelper { 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 distance The distance 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); diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.h index 9dfd240447..58753924f0 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.h @@ -13,6 +13,14 @@ class DriveTime : public frc2::CommandHelper { 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); diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.h index fe2e241028..c2c35b7d4b 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.h @@ -14,6 +14,14 @@ class TeleopArcadeDrive : public frc2::CommandHelper { 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 xaxisSpeedSupplier, std::function zaxisRotateSupplier); diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.h index c0f25b1900..8c62355173 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.h @@ -13,6 +13,14 @@ class TurnDegrees : public frc2::CommandHelper { 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 degrees 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); diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.h index 3c478a834d..28a7b5fea7 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.h @@ -13,6 +13,13 @@ class TurnTime : public frc2::CommandHelper { 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); diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.h b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.h index d679178fd0..3b55c9e834 100644 --- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.h +++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include class Drivetrain : public frc2::SubsystemBase { @@ -73,34 +75,46 @@ class Drivetrain : public frc2::SubsystemBase { units::meter_t GetAverageDistance(); /** - * Returns the acceleration along the X-axis, in Gs. + * The acceleration in the X-axis. + * + * @return The acceleration of the Romi along the X-axis. */ - double GetAccelX(); + units::meters_per_second_squared_t GetAccelX(); /** - * Returns the acceleration along the Y-axis, in Gs. + * The acceleration in the Y-axis. + * + * @return The acceleration of the Romi along the Y-axis. */ - double GetAccelY(); + units::meters_per_second_squared_t GetAccelY(); /** - * Returns the acceleration along the Z-axis, in Gs. + * The acceleration in the Z-axis. + * + * @return The acceleration of the Romi along the Z-axis. */ - double GetAccelZ(); + units::meters_per_second_squared_t GetAccelZ(); /** - * Returns the current angle of the Romi around the X-axis, in degrees. + * Current angle of the Romi around the X-axis. + * + * @return The current angle of the Romi. */ - double GetGyroAngleX(); + units::radian_t GetGyroAngleX(); /** - * Returns the current angle of the Romi around the Y-axis, in degrees. + * Current angle of the Romi around the Y-axis. + * + * @return The current angle of the Romi. */ - double GetGyroAngleY(); + units::radian_t GetGyroAngleY(); /** - * Returns the current angle of the Romi around the Z-axis, in degrees. + * Current angle of the Romi around the Z-axis. + * + * @return The current angle of the Romi. */ - double GetGyroAngleZ(); + units::radian_t GetGyroAngleZ(); /** * Reset the gyro.