Skip to content

Commit

Permalink
update example code
Browse files Browse the repository at this point in the history
  • Loading branch information
Advay17 committed Nov 13, 2024
1 parent e62b321 commit 31760a7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <frc/motorcontrol/Spark.h>
#include <frc/romi/RomiGyro.h>
#include <frc2/command/SubsystemBase.h>
#include <units/acceleration.h>
#include <units/angle.h>
#include <units/length.h>

class Drivetrain : public frc2::SubsystemBase {
Expand Down Expand Up @@ -73,34 +75,34 @@ class Drivetrain : public frc2::SubsystemBase {
units::meter_t GetAverageDistance();

/**
* Returns the acceleration along the X-axis, in Gs.
* Returns the acceleration along the X-axis.
*/
double GetAccelX();
units::meters_per_second_squared_t GetAccelX();

/**
* Returns the acceleration along the Y-axis, in Gs.
* Returns the acceleration along the Y-axis.
*/
double GetAccelY();
units::meters_per_second_squared_t GetAccelY();

/**
* Returns the acceleration along the Z-axis, in Gs.
* Returns the acceleration 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.
* Returns the current angle of the Romi around the X-axis.
*/
double GetGyroAngleX();
units::radian_t GetGyroAngleX();

/**
* Returns the current angle of the Romi around the Y-axis, in degrees.
* Returns the current angle of the Romi around the Y-axis.
*/
double GetGyroAngleY();
units::radian_t GetGyroAngleY();

/**
* Returns the current angle of the Romi around the Z-axis, in degrees.
* Returns the current angle of the Romi around the Z-axis.
*/
double GetGyroAngleZ();
units::radian_t GetGyroAngleZ();

/**
* Reset the gyro.
Expand Down

0 comments on commit 31760a7

Please sign in to comment.