mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[romi/xrp] Add Romi and XRP Vendordeps (#5644)
This commit is contained in:
76
romiVendordep/src/main/native/include/frc/romi/OnBoardIO.h
Normal file
76
romiVendordep/src/main/native/include/frc/romi/OnBoardIO.h
Normal file
@@ -0,0 +1,76 @@
|
||||
// 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 <units/time.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* 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:
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
91
romiVendordep/src/main/native/include/frc/romi/RomiGyro.h
Normal file
91
romiVendordep/src/main/native/include/frc/romi/RomiGyro.h
Normal file
@@ -0,0 +1,91 @@
|
||||
// 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>
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Use a rate gyro to return the robots heading relative to a starting position.
|
||||
*
|
||||
* This class is for the Romi onboard gyro, and will only work in
|
||||
* simulation/Romi mode. Only one instance of a RomiGyro is supported.
|
||||
*/
|
||||
class RomiGyro {
|
||||
public:
|
||||
RomiGyro();
|
||||
|
||||
/**
|
||||
* Return the actual angle in degrees 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.
|
||||
* 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.
|
||||
*
|
||||
* @return the current heading of the robot in degrees.
|
||||
*/
|
||||
double 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
|
||||
*/
|
||||
double GetRate() const;
|
||||
|
||||
/**
|
||||
* Gets the rate of turn in degrees-per-second around the X-axis
|
||||
*/
|
||||
double GetRateX() const;
|
||||
|
||||
/**
|
||||
* Gets the rate of turn in degrees-per-second around the Y-axis
|
||||
*/
|
||||
double GetRateY() const;
|
||||
|
||||
/**
|
||||
* Gets the rate of turn in degrees-per-second around the Z-axis
|
||||
*/
|
||||
double GetRateZ() const;
|
||||
|
||||
/**
|
||||
* Gets the currently reported angle around the X-axis
|
||||
*/
|
||||
double GetAngleX() const;
|
||||
|
||||
/**
|
||||
* Gets the currently reported angle around the X-axis
|
||||
*/
|
||||
double GetAngleY() const;
|
||||
|
||||
/**
|
||||
* Gets the currently reported angle around the X-axis
|
||||
*/
|
||||
double GetAngleZ() const;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
30
romiVendordep/src/main/native/include/frc/romi/RomiMotor.h
Normal file
30
romiVendordep/src/main/native/include/frc/romi/RomiMotor.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// 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 <frc/motorcontrol/PWMMotorController.h>
|
||||
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* RomiMotor
|
||||
*
|
||||
* A general use PWM motor controller representing the motors on a Romi robot
|
||||
*/
|
||||
class RomiMotor : public PWMMotorController {
|
||||
public:
|
||||
/**
|
||||
* Constructor for a RomiMotor.
|
||||
*
|
||||
* @param channel The PWM channel that the RomiMotor is attached to.
|
||||
* 0 is left, 1 is right
|
||||
*/
|
||||
explicit RomiMotor(int channel);
|
||||
|
||||
RomiMotor(RomiMotor&&) = default;
|
||||
RomiMotor& operator=(RomiMotor&&) = default;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
Reference in New Issue
Block a user