mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -11,18 +11,18 @@
|
||||
#include "wpi/system/Errors.hpp"
|
||||
#include "wpi/system/Timer.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::romi;
|
||||
|
||||
OnBoardIO::OnBoardIO(OnBoardIO::ChannelMode dio1, OnBoardIO::ChannelMode dio2) {
|
||||
if (dio1 == ChannelMode::INPUT) {
|
||||
m_buttonB = std::make_unique<frc::DigitalInput>(1);
|
||||
m_buttonB = std::make_unique<wpi::DigitalInput>(1);
|
||||
} else {
|
||||
m_greenLed = std::make_unique<frc::DigitalOutput>(1);
|
||||
m_greenLed = std::make_unique<wpi::DigitalOutput>(1);
|
||||
}
|
||||
if (dio2 == ChannelMode::INPUT) {
|
||||
m_buttonC = std::make_unique<frc::DigitalInput>(2);
|
||||
m_buttonC = std::make_unique<wpi::DigitalInput>(2);
|
||||
} else {
|
||||
m_redLed = std::make_unique<frc::DigitalOutput>(2);
|
||||
m_redLed = std::make_unique<wpi::DigitalOutput>(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ bool OnBoardIO::GetButtonBPressed() {
|
||||
return m_buttonB->Get();
|
||||
}
|
||||
|
||||
auto currentTime = frc::Timer::GetTimestamp();
|
||||
auto currentTime = wpi::Timer::GetTimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "{}", "Button B was not configured");
|
||||
FRC_ReportError(wpi::err::Error, "{}", "Button B was not configured");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
}
|
||||
return false;
|
||||
@@ -48,9 +48,9 @@ bool OnBoardIO::GetButtonCPressed() {
|
||||
return m_buttonC->Get();
|
||||
}
|
||||
|
||||
auto currentTime = frc::Timer::GetTimestamp();
|
||||
auto currentTime = wpi::Timer::GetTimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "{}", "Button C was not configured");
|
||||
FRC_ReportError(wpi::err::Error, "{}", "Button C was not configured");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
}
|
||||
return false;
|
||||
@@ -60,9 +60,9 @@ void OnBoardIO::SetGreenLed(bool value) {
|
||||
if (m_greenLed) {
|
||||
m_greenLed->Set(value);
|
||||
} else {
|
||||
auto currentTime = frc::Timer::GetTimestamp();
|
||||
auto currentTime = wpi::Timer::GetTimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "{}", "Green LED was not configured");
|
||||
FRC_ReportError(wpi::err::Error, "{}", "Green LED was not configured");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
}
|
||||
}
|
||||
@@ -72,9 +72,9 @@ void OnBoardIO::SetRedLed(bool value) {
|
||||
if (m_redLed) {
|
||||
m_redLed->Set(value);
|
||||
} else {
|
||||
auto currentTime = frc::Timer::GetTimestamp();
|
||||
auto currentTime = wpi::Timer::GetTimestamp();
|
||||
if (currentTime > m_nextMessageTime) {
|
||||
FRC_ReportError(frc::err::Error, "{}", "Red LED was not configured");
|
||||
FRC_ReportError(wpi::err::Error, "{}", "Red LED was not configured");
|
||||
m_nextMessageTime = currentTime + kMessageInterval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "wpi/romi/RomiGyro.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::romi;
|
||||
|
||||
RomiGyro::RomiGyro() : m_simDevice("Gyro:RomiGyro") {
|
||||
if (m_simDevice) {
|
||||
@@ -24,57 +24,57 @@ RomiGyro::RomiGyro() : m_simDevice("Gyro:RomiGyro") {
|
||||
}
|
||||
}
|
||||
|
||||
units::radian_t RomiGyro::GetAngle() const {
|
||||
wpi::units::radian_t RomiGyro::GetAngle() const {
|
||||
return GetAngleZ();
|
||||
}
|
||||
|
||||
units::radians_per_second_t RomiGyro::GetRate() const {
|
||||
wpi::units::radians_per_second_t RomiGyro::GetRate() const {
|
||||
return GetRateZ();
|
||||
}
|
||||
|
||||
units::radians_per_second_t RomiGyro::GetRateX() const {
|
||||
wpi::units::radians_per_second_t RomiGyro::GetRateX() const {
|
||||
if (m_simRateX) {
|
||||
return units::degrees_per_second_t{m_simRateX.Get()};
|
||||
return wpi::units::degrees_per_second_t{m_simRateX.Get()};
|
||||
}
|
||||
|
||||
return 0.0_rad_per_s;
|
||||
}
|
||||
|
||||
units::radians_per_second_t RomiGyro::GetRateY() const {
|
||||
wpi::units::radians_per_second_t RomiGyro::GetRateY() const {
|
||||
if (m_simRateY) {
|
||||
return units::degrees_per_second_t{m_simRateY.Get()};
|
||||
return wpi::units::degrees_per_second_t{m_simRateY.Get()};
|
||||
}
|
||||
|
||||
return 0.0_rad_per_s;
|
||||
}
|
||||
|
||||
units::radians_per_second_t RomiGyro::GetRateZ() const {
|
||||
wpi::units::radians_per_second_t RomiGyro::GetRateZ() const {
|
||||
if (m_simRateZ) {
|
||||
return units::degrees_per_second_t{m_simRateZ.Get()};
|
||||
return wpi::units::degrees_per_second_t{m_simRateZ.Get()};
|
||||
}
|
||||
|
||||
return 0.0_rad_per_s;
|
||||
}
|
||||
|
||||
units::radian_t RomiGyro::GetAngleX() const {
|
||||
wpi::units::radian_t RomiGyro::GetAngleX() const {
|
||||
if (m_simAngleX) {
|
||||
return units::degree_t{m_simAngleX.Get() - m_angleXOffset};
|
||||
return wpi::units::degree_t{m_simAngleX.Get() - m_angleXOffset};
|
||||
}
|
||||
|
||||
return 0.0_rad;
|
||||
}
|
||||
|
||||
units::radian_t RomiGyro::GetAngleY() const {
|
||||
wpi::units::radian_t RomiGyro::GetAngleY() const {
|
||||
if (m_simAngleY) {
|
||||
return units::degree_t{m_simAngleY.Get() - m_angleYOffset};
|
||||
return wpi::units::degree_t{m_simAngleY.Get() - m_angleYOffset};
|
||||
}
|
||||
|
||||
return 0.0_rad;
|
||||
}
|
||||
|
||||
units::radian_t RomiGyro::GetAngleZ() const {
|
||||
wpi::units::radian_t RomiGyro::GetAngleZ() const {
|
||||
if (m_simAngleZ) {
|
||||
return units::degree_t{m_simAngleZ.Get() - m_angleZOffset};
|
||||
return wpi::units::degree_t{m_simAngleZ.Get() - m_angleZOffset};
|
||||
}
|
||||
|
||||
return 0.0_rad;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "wpi/romi/RomiMotor.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi::romi;
|
||||
|
||||
RomiMotor::RomiMotor(int channel) : PWMMotorController("Romi Motor", channel) {
|
||||
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hardware/discrete/DigitalOutput.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::romi {
|
||||
|
||||
/**
|
||||
* @ingroup romi_api
|
||||
@@ -34,7 +34,7 @@ class OnBoardIO {
|
||||
OnBoardIO(OnBoardIO::ChannelMode dio1, OnBoardIO::ChannelMode dio2);
|
||||
|
||||
static constexpr auto kMessageInterval = 1_s;
|
||||
units::second_t m_nextMessageTime = 0_s;
|
||||
wpi::units::second_t m_nextMessageTime = 0_s;
|
||||
|
||||
/**
|
||||
* Gets if the A button is pressed.
|
||||
@@ -67,18 +67,18 @@ class OnBoardIO {
|
||||
void SetYellowLed(bool value);
|
||||
|
||||
private:
|
||||
frc::DigitalInput m_buttonA{0};
|
||||
frc::DigitalOutput m_yellowLed{3};
|
||||
wpi::DigitalInput m_buttonA{0};
|
||||
wpi::DigitalOutput m_yellowLed{3};
|
||||
|
||||
// DIO 1
|
||||
std::unique_ptr<frc::DigitalInput> m_buttonB;
|
||||
std::unique_ptr<frc::DigitalOutput> m_greenLed;
|
||||
std::unique_ptr<wpi::DigitalInput> m_buttonB;
|
||||
std::unique_ptr<wpi::DigitalOutput> m_greenLed;
|
||||
|
||||
// DIO 2
|
||||
std::unique_ptr<frc::DigitalInput> m_buttonC;
|
||||
std::unique_ptr<frc::DigitalOutput> m_redLed;
|
||||
std::unique_ptr<wpi::DigitalInput> m_buttonC;
|
||||
std::unique_ptr<wpi::DigitalOutput> m_redLed;
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::romi
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/units/angle.hpp"
|
||||
#include "wpi/units/angular_velocity.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::romi {
|
||||
|
||||
/**
|
||||
* @ingroup romi_api
|
||||
@@ -35,7 +35,7 @@ class RomiGyro {
|
||||
*
|
||||
* @return The current heading of the robot.
|
||||
*/
|
||||
units::radian_t GetAngle() const;
|
||||
wpi::units::radian_t GetAngle() const;
|
||||
|
||||
/**
|
||||
* Return the rate of rotation of the gyro
|
||||
@@ -44,49 +44,49 @@ class RomiGyro {
|
||||
*
|
||||
* @return The current rate.
|
||||
*/
|
||||
units::radians_per_second_t GetRate() const;
|
||||
wpi::units::radians_per_second_t GetRate() const;
|
||||
|
||||
/**
|
||||
* Get the rate of turn in around the X-axis.
|
||||
*
|
||||
* @return Rate of turn.
|
||||
*/
|
||||
units::radians_per_second_t GetRateX() const;
|
||||
wpi::units::radians_per_second_t GetRateX() const;
|
||||
|
||||
/**
|
||||
* Get the rate of turn in around the Y-axis.
|
||||
*
|
||||
* @return Rate of turn.
|
||||
*/
|
||||
units::radians_per_second_t GetRateY() const;
|
||||
wpi::units::radians_per_second_t GetRateY() const;
|
||||
|
||||
/**
|
||||
* Get the rate of turn around the Z-axis.
|
||||
*
|
||||
* @return Rate of turn.
|
||||
*/
|
||||
units::radians_per_second_t GetRateZ() const;
|
||||
wpi::units::radians_per_second_t GetRateZ() const;
|
||||
|
||||
/**
|
||||
* Get the currently reported angle around the X-axis.
|
||||
*
|
||||
* @return Current angle around X-axis.
|
||||
*/
|
||||
units::radian_t GetAngleX() const;
|
||||
wpi::units::radian_t GetAngleX() const;
|
||||
|
||||
/**
|
||||
* Get the currently reported angle around the Y-axis.
|
||||
*
|
||||
* @return Current angle around Y-axis.
|
||||
*/
|
||||
units::radian_t GetAngleY() const;
|
||||
wpi::units::radian_t GetAngleY() const;
|
||||
|
||||
/**
|
||||
* Get the currently reported angle around the Z-axis.
|
||||
*
|
||||
* @return Current angle around Z-axis.
|
||||
*/
|
||||
units::radian_t GetAngleZ() const;
|
||||
wpi::units::radian_t GetAngleZ() const;
|
||||
|
||||
/**
|
||||
* Resets the gyro
|
||||
@@ -109,4 +109,4 @@ class RomiGyro {
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::romi
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/hardware/motor/PWMMotorController.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi::romi {
|
||||
|
||||
/**
|
||||
* @defgroup romi_api Romi Hardware API
|
||||
@@ -34,4 +34,4 @@ class RomiMotor : public PWMMotorController {
|
||||
|
||||
/** @} */
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi::romi
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
classes:
|
||||
frc::OnBoardIO:
|
||||
wpi::OnBoardIO:
|
||||
attributes:
|
||||
kMessageInterval:
|
||||
m_nextMessageTime:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
classes:
|
||||
frc::RomiGyro:
|
||||
wpi::RomiGyro:
|
||||
methods:
|
||||
RomiGyro:
|
||||
GetAngle:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
classes:
|
||||
frc::RomiMotor:
|
||||
wpi::RomiMotor:
|
||||
methods:
|
||||
RomiMotor:
|
||||
|
||||
Reference in New Issue
Block a user