[wpilib] Move RomiGyro into main wpilibc/j (#3143)

This commit is contained in:
Zhiquan Yeo
2021-02-13 01:14:29 -05:00
committed by GitHub
parent 94e685e1bd
commit 69e8d0b65d
6 changed files with 157 additions and 82 deletions

View File

@@ -1,60 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <hal/SimDevice.h>
class RomiGyro {
public:
RomiGyro();
/**
* Gets the rate of turn in degrees-per-second around the X-axis
*/
double GetRateX();
/**
* Gets the rate of turn in degrees-per-second around the Y-axis
*/
double GetRateY();
/**
* Gets the rate of turn in degrees-per-second around the Z-axis
*/
double GetRateZ();
/**
* Gets the currently reported angle around the X-axis
*/
double GetAngleX();
/**
* Gets the currently reported angle around the X-axis
*/
double GetAngleY();
/**
* Gets the currently reported angle around the X-axis
*/
double GetAngleZ();
/**
* Resets the gyro
*/
void Reset();
private:
hal::SimDevice m_simDevice;
hal::SimDouble m_simRateX;
hal::SimDouble m_simRateY;
hal::SimDouble m_simRateZ;
hal::SimDouble m_simAngleX;
hal::SimDouble m_simAngleY;
hal::SimDouble m_simAngleZ;
double m_angleXOffset = 0;
double m_angleYOffset = 0;
double m_angleZOffset = 0;
};

View File

@@ -8,11 +8,10 @@
#include <frc/Encoder.h>
#include <frc/Spark.h>
#include <frc/drive/DifferentialDrive.h>
#include <frc/romi/RomiGyro.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;
@@ -117,6 +116,6 @@ class Drivetrain : public frc2::SubsystemBase {
frc::DifferentialDrive m_drive{m_leftMotor, m_rightMotor};
RomiGyro m_gyro;
frc::RomiGyro m_gyro;
frc::BuiltInAccelerometer m_accelerometer;
};