[examples] Make Romi/XRP Examples use appropriate vendordeps (#5665)

This commit is contained in:
Zhiquan Yeo
2023-09-18 22:42:10 -04:00
committed by GitHub
parent daf7702007
commit 51dcb8b55a
33 changed files with 74 additions and 1693 deletions

View File

@@ -5,6 +5,7 @@
#pragma once
#include <frc/Joystick.h>
#include <frc/romi/OnBoardIO.h>
#include <frc/smartdashboard/SendableChooser.h>
#include <frc2/command/Command.h>
#include <frc2/command/CommandPtr.h>
@@ -14,7 +15,6 @@
#include "commands/AutonomousDistance.h"
#include "commands/AutonomousTime.h"
#include "subsystems/Drivetrain.h"
#include "subsystems/OnBoardIO.h"
/**
* This class is where the bulk of the robot should be declared. Since
@@ -47,8 +47,8 @@ class RobotContainer {
// The robot's subsystems
Drivetrain m_drive;
OnBoardIO m_onboardIO{OnBoardIO::ChannelMode::INPUT,
OnBoardIO::ChannelMode::INPUT};
frc::OnBoardIO m_onboardIO{frc::OnBoardIO::ChannelMode::INPUT,
frc::OnBoardIO::ChannelMode::INPUT};
// Example button
frc2::Trigger m_onboardButtonA{

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/drive/DifferentialDrive.h>
#include <frc/motorcontrol/Spark.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;
};

View File

@@ -1,72 +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 <memory>
#include <frc/DigitalInput.h>
#include <frc/DigitalOutput.h>
#include <frc2/command/SubsystemBase.h>
/**
* This class represents the onboard IO of the Romi
* reference robot. This includes the pushbuttons and
* LEDs.
*
* <p>DIO 0 - Button A (input only)
* DIO 1 - Button B (input) or Green LED (output)
* DIO 2 - Button C (input) or Red LED (output)
* DIO 3 - Yellow LED (output only)
*/
class OnBoardIO : public frc2::SubsystemBase {
public:
enum ChannelMode { INPUT, OUTPUT };
OnBoardIO(OnBoardIO::ChannelMode dio1, OnBoardIO::ChannelMode dio2);
static constexpr auto kMessageInterval = 1_s;
units::second_t m_nextMessageTime = 0_s;
/**
* Gets if the A button is pressed.
*/
bool GetButtonAPressed();
/**
* Gets if the B button is pressed.
*/
bool GetButtonBPressed();
/**
* Gets if the C button is pressed.
*/
bool GetButtonCPressed();
/**
* Sets the green LED.
*/
void SetGreenLed(bool value);
/**
* Sets the red LED.
*/
void SetRedLed(bool value);
/**
* Sets the yellow LED.
*/
void SetYellowLed(bool value);
private:
frc::DigitalInput m_buttonA{0};
frc::DigitalOutput m_yellowLed{3};
// DIO 1
std::unique_ptr<frc::DigitalInput> m_buttonB;
std::unique_ptr<frc::DigitalOutput> m_greenLed;
// DIO 2
std::unique_ptr<frc::DigitalInput> m_buttonC;
std::unique_ptr<frc::DigitalOutput> m_redLed;
};