[examples] Add RomiGyro to the Romi Reference example (#3037)

This commit is contained in:
Zhiquan Yeo
2021-01-03 00:59:57 -05:00
committed by GitHub
parent 94f8525721
commit e45a0f6ce2
6 changed files with 399 additions and 0 deletions

View File

@@ -4,12 +4,15 @@
#pragma once
#include <frc/BuiltInAccelerometer.h>
#include <frc/Encoder.h>
#include <frc/Spark.h>
#include <frc/drive/DifferentialDrive.h>
#include <frc2/command/SubsystemBase.h>
#include <units/length.h>
#include "sensors/RomiGyro.h"
class Drivetrain : public frc2::SubsystemBase {
public:
static constexpr double kCountsPerRevolution = 1440.0;
@@ -70,6 +73,41 @@ class Drivetrain : public frc2::SubsystemBase {
*/
units::meter_t GetAverageDistance();
/**
* Returns the acceleration along the X-axis, in Gs.
*/
double GetAccelX();
/**
* Returns the acceleration along the Y-axis, in Gs.
*/
double GetAccelY();
/**
* Returns the acceleration along the Z-axis, in Gs.
*/
double GetAccelZ();
/**
* Returns the current angle of the Romi around the X-axis, in degrees.
*/
double GetGyroAngleX();
/**
* Returns the current angle of the Romi around the Y-axis, in degrees.
*/
double GetGyroAngleY();
/**
* Returns the current angle of the Romi around the Z-axis, in degrees.
*/
double GetGyroAngleZ();
/**
* Reset the gyro.
*/
void ResetGyro();
private:
frc::Spark m_leftMotor{0};
frc::Spark m_rightMotor{1};
@@ -78,4 +116,7 @@ class Drivetrain : public frc2::SubsystemBase {
frc::Encoder m_rightEncoder{6, 7};
frc::DifferentialDrive m_drive{m_leftMotor, m_rightMotor};
RomiGyro m_gyro;
frc::BuiltInAccelerometer m_accelerometer;
};