SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -6,7 +6,7 @@
#include "wpi/hal/SimDevice.h"
namespace frc {
namespace wpi {
class ADXL345_I2C;
@@ -46,10 +46,10 @@ class ADXL345Sim {
void SetZ(double accel);
private:
hal::SimDouble m_simX;
hal::SimDouble m_simY;
hal::SimDouble m_simZ;
wpi::hal::SimDouble m_simX;
wpi::hal::SimDouble m_simY;
wpi::hal::SimDouble m_simZ;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -10,7 +10,7 @@
struct HAL_AddressableLEDData;
namespace frc {
namespace wpi {
class AddressableLED;
@@ -165,4 +165,4 @@ class AddressableLEDSim {
int m_channel;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -8,7 +8,7 @@
#include "wpi/math/geometry/Rotation2d.hpp"
#include "wpi/units/angle.hpp"
namespace frc {
namespace wpi {
class AnalogEncoder;
@@ -39,7 +39,7 @@ class AnalogEncoderSim {
double Get();
private:
hal::SimDouble m_positionSim;
wpi::hal::SimDouble m_positionSim;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -8,7 +8,7 @@
#include "wpi/simulation/CallbackStore.hpp"
namespace frc {
namespace wpi {
class AnalogInput;
@@ -146,4 +146,4 @@ class AnalogInputSim {
int m_index;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -12,7 +12,7 @@
#include "wpi/units/impedance.hpp"
#include "wpi/units/voltage.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* A utility class to simulate the robot battery.
@@ -31,9 +31,9 @@ class BatterySim {
* @param currents The currents drawn from the battery.
* @return The battery's voltage under load.
*/
static units::volt_t Calculate(units::volt_t nominalVoltage,
units::ohm_t resistance,
std::span<const units::ampere_t> currents) {
static wpi::units::volt_t Calculate(wpi::units::volt_t nominalVoltage,
wpi::units::ohm_t resistance,
std::span<const wpi::units::ampere_t> currents) {
return std::max(0_V, nominalVoltage - std::accumulate(currents.begin(),
currents.end(), 0_A) *
resistance);
@@ -51,9 +51,9 @@ class BatterySim {
* @param currents The currents drawn from the battery.
* @return The battery's voltage under load.
*/
static units::volt_t Calculate(
units::volt_t nominalVoltage, units::ohm_t resistance,
std::initializer_list<units::ampere_t> currents) {
static wpi::units::volt_t Calculate(
wpi::units::volt_t nominalVoltage, wpi::units::ohm_t resistance,
std::initializer_list<wpi::units::ampere_t> currents) {
return std::max(0_V, nominalVoltage - std::accumulate(currents.begin(),
currents.end(), 0_A) *
resistance);
@@ -69,7 +69,7 @@ class BatterySim {
* @param currents The currents drawn from the battery.
* @return The battery's voltage under load.
*/
static units::volt_t Calculate(std::span<const units::ampere_t> currents) {
static wpi::units::volt_t Calculate(std::span<const wpi::units::ampere_t> currents) {
return Calculate(12_V, 0.02_Ohm, currents);
}
@@ -83,10 +83,10 @@ class BatterySim {
* @param currents The currents drawn from the battery.
* @return The battery's voltage under load.
*/
static units::volt_t Calculate(
std::initializer_list<units::ampere_t> currents) {
static wpi::units::volt_t Calculate(
std::initializer_list<wpi::units::ampere_t> currents) {
return Calculate(12_V, 0.02_Ohm, currents);
}
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -10,7 +10,7 @@
#include "wpi/simulation/CallbackStore.hpp"
#include "wpi/simulation/PneumaticsBaseSim.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Class to control a simulated Pneumatic Control Module (PCM).
@@ -140,4 +140,4 @@ class CTREPCMSim : public PneumaticsBaseSim {
void ResetData() override;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -9,7 +9,7 @@
#include "wpi/hal/Value.h"
namespace frc::sim {
namespace wpi::sim {
using NotifyCallback = std::function<void(std::string_view, const HAL_Value*)>;
using ConstBufferCallback = std::function<void(
@@ -75,4 +75,4 @@ class CallbackStore {
enum CancelType { Normal, Channel, NoIndex };
CancelType cancelType;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -13,7 +13,7 @@
#include "wpi/units/moment_of_inertia.hpp"
#include "wpi/units/torque.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Represents a simulated DC motor mechanism.
*/
@@ -23,14 +23,14 @@ class DCMotorSim : public LinearSystemSim<2, 1, 2> {
* Creates a simulated DC motor mechanism.
*
* @param plant The linear system representing the DC motor. This
* system can be created with LinearSystemId::DCMotorSystem(). If
* LinearSystemId::DCMotorSystem(kV, kA) is used, the distance unit must be
* system can be created with wpi::math::LinearSystemId::DCMotorSystem(). If
* wpi::math::LinearSystemId::DCMotorSystem(kV, kA) is used, the distance unit must be
* radians.
* @param gearbox The type of and number of motors in the DC motor
* gearbox.
* @param measurementStdDevs The standard deviation of the measurement noise.
*/
DCMotorSim(const LinearSystem<2, 1, 2>& plant, const DCMotor& gearbox,
DCMotorSim(const wpi::math::LinearSystem<2, 1, 2>& plant, const wpi::math::DCMotor& gearbox,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
using LinearSystemSim::SetState;
@@ -41,76 +41,76 @@ class DCMotorSim : public LinearSystemSim<2, 1, 2> {
* @param angularPosition The new position
* @param angularVelocity The new velocity
*/
void SetState(units::radian_t angularPosition,
units::radians_per_second_t angularVelocity);
void SetState(wpi::units::radian_t angularPosition,
wpi::units::radians_per_second_t angularVelocity);
/**
* Sets the DC motor's angular position.
*
* @param angularPosition The new position in radians.
*/
void SetAngle(units::radian_t angularPosition);
void SetAngle(wpi::units::radian_t angularPosition);
/**
* Sets the DC motor's angular velocity.
*
* @param angularVelocity The new velocity in radians per second.
*/
void SetAngularVelocity(units::radians_per_second_t angularVelocity);
void SetAngularVelocity(wpi::units::radians_per_second_t angularVelocity);
/**
* Returns the DC motor position.
*
* @return The DC motor position.
*/
units::radian_t GetAngularPosition() const;
wpi::units::radian_t GetAngularPosition() const;
/**
* Returns the DC motor velocity.
*
* @return The DC motor velocity.
*/
units::radians_per_second_t GetAngularVelocity() const;
wpi::units::radians_per_second_t GetAngularVelocity() const;
/**
* Returns the DC motor acceleration.
*
* @return The DC motor acceleration
*/
units::radians_per_second_squared_t GetAngularAcceleration() const;
wpi::units::radians_per_second_squared_t GetAngularAcceleration() const;
/**
* Returns the DC motor torque.
*
* @return The DC motor torque
*/
units::newton_meter_t GetTorque() const;
wpi::units::newton_meter_t GetTorque() const;
/**
* Returns the DC motor current draw.
*
* @return The DC motor current draw.
*/
units::ampere_t GetCurrentDraw() const;
wpi::units::ampere_t GetCurrentDraw() const;
/**
* Gets the input voltage for the DC motor.
*
* @return The DC motor input voltage.
*/
units::volt_t GetInputVoltage() const;
wpi::units::volt_t GetInputVoltage() const;
/**
* Sets the input voltage for the DC motor.
*
* @param voltage The input voltage.
*/
void SetInputVoltage(units::volt_t voltage);
void SetInputVoltage(wpi::units::volt_t voltage);
/**
* Returns the gearbox.
*/
const DCMotor& GetGearbox() const;
const wpi::math::DCMotor& GetGearbox() const;
/**
* Returns the gearing;
@@ -120,11 +120,11 @@ class DCMotorSim : public LinearSystemSim<2, 1, 2> {
/**
* Returns the moment of inertia
*/
units::kilogram_square_meter_t GetJ() const;
wpi::units::kilogram_square_meter_t GetJ() const;
private:
DCMotor m_gearbox;
wpi::math::DCMotor m_gearbox;
double m_gearing;
units::kilogram_square_meter_t m_j;
wpi::units::kilogram_square_meter_t m_j;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -8,7 +8,7 @@
#include "wpi/simulation/CallbackStore.hpp"
namespace frc {
namespace wpi {
class DigitalInput;
class DigitalOutput;
@@ -178,4 +178,4 @@ class DIOSim {
int m_index;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -13,19 +13,19 @@
#include "wpi/units/time.hpp"
#include "wpi/units/voltage.hpp"
namespace frc::sim {
namespace wpi::sim {
class DifferentialDrivetrainSim {
public:
/**
* Creates a simulated differential drivetrain.
*
* @param plant The LinearSystem representing the robot's drivetrain. This
* @param plant The wpi::math::LinearSystem representing the robot's drivetrain. This
* system can be created with
* LinearSystemId::DrivetrainVelocitySystem() or
* LinearSystemId::IdentifyDrivetrainSystem().
* wpi::math::LinearSystemId::DrivetrainVelocitySystem() or
* wpi::math::LinearSystemId::IdentifyDrivetrainSystem().
* @param trackwidth The robot's trackwidth.
* @param driveMotor A DCMotor representing the left side of the drivetrain.
* @param driveMotor A wpi::math::DCMotor representing the left side of the drivetrain.
* @param gearingRatio The gearingRatio ratio of the left side, as output over
* input. This must be the same ratio as the ratio used to
* identify or create the plant.
@@ -40,14 +40,14 @@ class DifferentialDrivetrainSim {
* starting point.
*/
DifferentialDrivetrainSim(
LinearSystem<2, 2, 2> plant, units::meter_t trackwidth,
DCMotor driveMotor, double gearingRatio, units::meter_t wheelRadius,
wpi::math::LinearSystem<2, 2, 2> plant, wpi::units::meter_t trackwidth,
wpi::math::DCMotor driveMotor, double gearingRatio, wpi::units::meter_t wheelRadius,
const std::array<double, 7>& measurementStdDevs = {});
/**
* Creates a simulated differential drivetrain.
*
* @param driveMotor A DCMotor representing the left side of the drivetrain.
* @param driveMotor A wpi::math::DCMotor representing the left side of the drivetrain.
* @param gearing The gearing on the drive between motor and wheel, as
* output over input. This must be the same ratio as the
* ratio used to identify or create the plant.
@@ -67,9 +67,9 @@ class DifferentialDrivetrainSim {
* starting point.
*/
DifferentialDrivetrainSim(
frc::DCMotor driveMotor, double gearing, units::kilogram_square_meter_t J,
units::kilogram_t mass, units::meter_t wheelRadius,
units::meter_t trackwidth,
wpi::math::DCMotor driveMotor, double gearing, wpi::units::kilogram_square_meter_t J,
wpi::units::kilogram_t mass, wpi::units::meter_t wheelRadius,
wpi::units::meter_t trackwidth,
const std::array<double, 7>& measurementStdDevs = {});
/**
@@ -88,7 +88,7 @@ class DifferentialDrivetrainSim {
* @param leftVoltage The left voltage.
* @param rightVoltage The right voltage.
*/
void SetInputs(units::volt_t leftVoltage, units::volt_t rightVoltage);
void SetInputs(wpi::units::volt_t leftVoltage, wpi::units::volt_t rightVoltage);
/**
* Sets the gearing reduction on the drivetrain. This is commonly used for
@@ -101,10 +101,10 @@ class DifferentialDrivetrainSim {
/**
* Updates the simulation.
*
* @param dt The time that's passed since the last Update(units::second_t)
* @param dt The time that's passed since the last Update(wpi::units::second_t)
* call.
*/
void Update(units::second_t dt);
void Update(wpi::units::second_t dt);
/**
* Returns the current gearing reduction of the drivetrain, as output over
@@ -118,73 +118,73 @@ class DifferentialDrivetrainSim {
* Note that this angle is counterclockwise-positive, while most gyros are
* clockwise positive.
*/
Rotation2d GetHeading() const;
wpi::math::Rotation2d GetHeading() const;
/**
* Returns the current pose.
*/
Pose2d GetPose() const;
wpi::math::Pose2d GetPose() const;
/**
* Get the right encoder position in meters.
* @return The encoder position.
*/
units::meter_t GetRightPosition() const {
return units::meter_t{GetOutput(State::kRightPosition)};
wpi::units::meter_t GetRightPosition() const {
return wpi::units::meter_t{GetOutput(State::kRightPosition)};
}
/**
* Get the right encoder velocity in meters per second.
* @return The encoder velocity.
*/
units::meters_per_second_t GetRightVelocity() const {
return units::meters_per_second_t{GetOutput(State::kRightVelocity)};
wpi::units::meters_per_second_t GetRightVelocity() const {
return wpi::units::meters_per_second_t{GetOutput(State::kRightVelocity)};
}
/**
* Get the left encoder position in meters.
* @return The encoder position.
*/
units::meter_t GetLeftPosition() const {
return units::meter_t{GetOutput(State::kLeftPosition)};
wpi::units::meter_t GetLeftPosition() const {
return wpi::units::meter_t{GetOutput(State::kLeftPosition)};
}
/**
* Get the left encoder velocity in meters per second.
* @return The encoder velocity.
*/
units::meters_per_second_t GetLeftVelocity() const {
return units::meters_per_second_t{GetOutput(State::kLeftVelocity)};
wpi::units::meters_per_second_t GetLeftVelocity() const {
return wpi::units::meters_per_second_t{GetOutput(State::kLeftVelocity)};
}
/**
* Returns the currently drawn current for the right side.
*/
units::ampere_t GetRightCurrentDraw() const;
wpi::units::ampere_t GetRightCurrentDraw() const;
/**
* Returns the currently drawn current for the left side.
*/
units::ampere_t GetLeftCurrentDraw() const;
wpi::units::ampere_t GetLeftCurrentDraw() const;
/**
* Returns the currently drawn current.
*/
units::ampere_t GetCurrentDraw() const;
wpi::units::ampere_t GetCurrentDraw() const;
/**
* Sets the system state.
*
* @param state The state.
*/
void SetState(const Vectord<7>& state);
void SetState(const wpi::math::Vectord<7>& state);
/**
* Sets the system pose.
*
* @param pose The pose.
*/
void SetPose(const frc::Pose2d& pose);
void SetPose(const wpi::math::Pose2d& pose);
/**
* The differential drive dynamics function.
@@ -193,7 +193,7 @@ class DifferentialDrivetrainSim {
* @param u The input.
* @return The state derivative with respect to time.
*/
Vectord<7> Dynamics(const Vectord<7>& x, const Eigen::Vector2d& u);
wpi::math::Vectord<7> Dynamics(const wpi::math::Vectord<7>& x, const Eigen::Vector2d& u);
class State {
public:
@@ -234,24 +234,24 @@ class DifferentialDrivetrainSim {
class KitbotMotor {
public:
/// One CIM motor per drive side.
static constexpr frc::DCMotor SingleCIMPerSide = frc::DCMotor::CIM(1);
static constexpr wpi::math::DCMotor SingleCIMPerSide = wpi::math::DCMotor::CIM(1);
/// Two CIM motors per drive side.
static constexpr frc::DCMotor DualCIMPerSide = frc::DCMotor::CIM(2);
static constexpr wpi::math::DCMotor DualCIMPerSide = wpi::math::DCMotor::CIM(2);
/// One Mini CIM motor per drive side.
static constexpr frc::DCMotor SingleMiniCIMPerSide =
frc::DCMotor::MiniCIM(1);
static constexpr wpi::math::DCMotor SingleMiniCIMPerSide =
wpi::math::DCMotor::MiniCIM(1);
/// Two Mini CIM motors per drive side.
static constexpr frc::DCMotor DualMiniCIMPerSide = frc::DCMotor::MiniCIM(2);
static constexpr wpi::math::DCMotor DualMiniCIMPerSide = wpi::math::DCMotor::MiniCIM(2);
/// One Falcon 500 motor per drive side.
static constexpr frc::DCMotor SingleFalcon500PerSide =
frc::DCMotor::Falcon500(1);
static constexpr wpi::math::DCMotor SingleFalcon500PerSide =
wpi::math::DCMotor::Falcon500(1);
/// Two Falcon 500 motors per drive side.
static constexpr frc::DCMotor DualFalcon500PerSide =
frc::DCMotor::Falcon500(2);
static constexpr wpi::math::DCMotor DualFalcon500PerSide =
wpi::math::DCMotor::Falcon500(2);
/// One NEO motor per drive side.
static constexpr frc::DCMotor SingleNEOPerSide = frc::DCMotor::NEO(1);
static constexpr wpi::math::DCMotor SingleNEOPerSide = wpi::math::DCMotor::NEO(1);
/// Two NEO motors per drive side.
static constexpr frc::DCMotor DualNEOPerSide = frc::DCMotor::NEO(2);
static constexpr wpi::math::DCMotor DualNEOPerSide = wpi::math::DCMotor::NEO(2);
};
/**
@@ -260,11 +260,11 @@ class DifferentialDrivetrainSim {
class KitbotWheelSize {
public:
/// Six inch diameter wheels.
static constexpr units::meter_t kSixInch = 6_in;
static constexpr wpi::units::meter_t kSixInch = 6_in;
/// Eight inch diameter wheels.
static constexpr units::meter_t kEightInch = 8_in;
static constexpr wpi::units::meter_t kEightInch = 8_in;
/// Ten inch diameter wheels.
static constexpr units::meter_t kTenInch = 10_in;
static constexpr wpi::units::meter_t kTenInch = 10_in;
};
/**
@@ -281,11 +281,11 @@ class DifferentialDrivetrainSim {
* starting point.
*/
static DifferentialDrivetrainSim CreateKitbotSim(
frc::DCMotor motor, double gearing, units::meter_t wheelSize,
wpi::math::DCMotor motor, double gearing, wpi::units::meter_t wheelSize,
const std::array<double, 7>& measurementStdDevs = {}) {
// MOI estimation -- note that I = mr² for point masses
units::kilogram_square_meter_t batteryMoi = 12.5_lb * 10_in * 10_in;
units::kilogram_square_meter_t gearboxMoi = (2.8_lb + 2.0_lb) *
wpi::units::kilogram_square_meter_t batteryMoi = 12.5_lb * 10_in * 10_in;
wpi::units::kilogram_square_meter_t gearboxMoi = (2.8_lb + 2.0_lb) *
2 // CIM plus toughbox per side
* (26_in / 2) * (26_in / 2);
@@ -310,8 +310,8 @@ class DifferentialDrivetrainSim {
* starting point.
*/
static DifferentialDrivetrainSim CreateKitbotSim(
frc::DCMotor motor, double gearing, units::meter_t wheelSize,
units::kilogram_square_meter_t J,
wpi::math::DCMotor motor, double gearing, wpi::units::meter_t wheelSize,
wpi::units::kilogram_square_meter_t J,
const std::array<double, 7>& measurementStdDevs = {}) {
return DifferentialDrivetrainSim{
motor, gearing, J, 60_lb, wheelSize / 2.0, 26_in, measurementStdDevs};
@@ -328,7 +328,7 @@ class DifferentialDrivetrainSim {
/**
* Returns the current output vector y.
*/
Vectord<7> GetOutput() const;
wpi::math::Vectord<7> GetOutput() const;
/**
* Returns an element of the state vector. Note that this will not include
@@ -341,20 +341,20 @@ class DifferentialDrivetrainSim {
/**
* Returns the current state vector x. Note that this will not include noise!
*/
Vectord<7> GetState() const;
wpi::math::Vectord<7> GetState() const;
LinearSystem<2, 2, 2> m_plant;
units::meter_t m_rb;
units::meter_t m_wheelRadius;
wpi::math::LinearSystem<2, 2, 2> m_plant;
wpi::units::meter_t m_rb;
wpi::units::meter_t m_wheelRadius;
DCMotor m_motor;
wpi::math::DCMotor m_motor;
double m_originalGearing;
double m_currentGearing;
Vectord<7> m_x;
wpi::math::Vectord<7> m_x;
Eigen::Vector2d m_u;
Vectord<7> m_y;
wpi::math::Vectord<7> m_y;
std::array<double, 7> m_measurementStdDevs;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -8,7 +8,7 @@
#include "wpi/simulation/CallbackStore.hpp"
namespace frc {
namespace wpi {
class DigitalOutput;
@@ -133,4 +133,4 @@ class DigitalPWMSim {
int m_index;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -10,7 +10,7 @@
#include "wpi/hardware/pneumatic/PneumaticsModuleType.hpp"
#include "wpi/simulation/PneumaticsBaseSim.hpp"
namespace frc::sim {
namespace wpi::sim {
class DoubleSolenoidSim {
public:
@@ -30,4 +30,4 @@ class DoubleSolenoidSim {
int m_rev;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -10,7 +10,7 @@
#include "wpi/hal/DriverStationTypes.h"
#include "wpi/simulation/CallbackStore.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Class to control a simulated driver station.
@@ -396,4 +396,4 @@ class DriverStationSim {
*/
static void ResetData();
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -7,7 +7,7 @@
#include "wpi/hal/SimDevice.h"
#include "wpi/units/angle.hpp"
namespace frc {
namespace wpi {
class DutyCycleEncoder;
@@ -61,9 +61,9 @@ class DutyCycleEncoderSim {
void SetConnected(bool isConnected);
private:
hal::SimDouble m_simPosition;
hal::SimBoolean m_simIsConnected;
wpi::hal::SimDouble m_simPosition;
wpi::hal::SimBoolean m_simIsConnected;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -9,7 +9,7 @@
#include "wpi/simulation/CallbackStore.hpp"
#include "wpi/units/frequency.hpp"
namespace frc {
namespace wpi {
class DutyCycle;
@@ -76,14 +76,14 @@ class DutyCycleSim {
*
* @return the duty cycle frequency
*/
units::hertz_t GetFrequency() const;
wpi::units::hertz_t GetFrequency() const;
/**
* Change the duty cycle frequency.
*
* @param frequency the new frequency
*/
void SetFrequency(units::hertz_t frequency);
void SetFrequency(wpi::units::hertz_t frequency);
/**
* Register a callback to be run whenever the output changes.
@@ -121,4 +121,4 @@ class DutyCycleSim {
int m_index;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -12,27 +12,27 @@
#include "wpi/units/mass.hpp"
#include "wpi/units/velocity.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Represents a simulated elevator mechanism.
*/
class ElevatorSim : public LinearSystemSim<2, 1, 2> {
public:
template <typename Distance>
using Velocity_t = units::unit_t<
units::compound_unit<Distance, units::inverse<units::seconds>>>;
using Velocity_t = wpi::units::unit_t<
wpi::units::compound_unit<Distance, wpi::units::inverse<wpi::units::seconds>>>;
template <typename Distance>
using Acceleration_t = units::unit_t<units::compound_unit<
units::compound_unit<Distance, units::inverse<units::seconds>>,
units::inverse<units::seconds>>>;
using Acceleration_t = wpi::units::unit_t<wpi::units::compound_unit<
wpi::units::compound_unit<Distance, wpi::units::inverse<wpi::units::seconds>>,
wpi::units::inverse<wpi::units::seconds>>>;
/**
* Constructs a simulated elevator mechanism.
*
* @param plant The linear system that represents the elevator.
* This system can be created with
* LinearSystemId::ElevatorSystem().
* wpi::math::LinearSystemId::ElevatorSystem().
* @param gearbox The type of and number of motors in your
* elevator gearbox.
* @param minHeight The minimum allowed height of the elevator.
@@ -41,9 +41,9 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param startingHeight The starting height of the elevator.
* @param measurementStdDevs The standard deviation of the measurements.
*/
ElevatorSim(const LinearSystem<2, 1, 2>& plant, const DCMotor& gearbox,
units::meter_t minHeight, units::meter_t maxHeight,
bool simulateGravity, units::meter_t startingHeight,
ElevatorSim(const wpi::math::LinearSystem<2, 1, 2>& plant, const wpi::math::DCMotor& gearbox,
wpi::units::meter_t minHeight, wpi::units::meter_t maxHeight,
bool simulateGravity, wpi::units::meter_t startingHeight,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
/**
@@ -62,10 +62,10 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param startingHeight The starting height of the elevator.
* @param measurementStdDevs The standard deviation of the measurements.
*/
ElevatorSim(const DCMotor& gearbox, double gearing,
units::kilogram_t carriageMass, units::meter_t drumRadius,
units::meter_t minHeight, units::meter_t maxHeight,
bool simulateGravity, units::meter_t startingHeight,
ElevatorSim(const wpi::math::DCMotor& gearbox, double gearing,
wpi::units::kilogram_t carriageMass, wpi::units::meter_t drumRadius,
wpi::units::meter_t minHeight, wpi::units::meter_t maxHeight,
bool simulateGravity, wpi::units::meter_t startingHeight,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
/**
@@ -82,13 +82,13 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param measurementStdDevs The standard deviation of the measurements.
*/
template <typename Distance>
requires std::same_as<units::meter, Distance> ||
std::same_as<units::radian, Distance>
requires std::same_as<wpi::units::meter, Distance> ||
std::same_as<wpi::units::radian, Distance>
ElevatorSim(decltype(1_V / Velocity_t<Distance>(1)) kV,
decltype(1_V / Acceleration_t<Distance>(1)) kA,
const DCMotor& gearbox, units::meter_t minHeight,
units::meter_t maxHeight, bool simulateGravity,
units::meter_t startingHeight,
const wpi::math::DCMotor& gearbox, wpi::units::meter_t minHeight,
wpi::units::meter_t maxHeight, bool simulateGravity,
wpi::units::meter_t startingHeight,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
using LinearSystemSim::SetState;
@@ -98,7 +98,7 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param position The new position
* @param velocity The new velocity
*/
void SetState(units::meter_t position, units::meters_per_second_t velocity);
void SetState(wpi::units::meter_t position, wpi::units::meters_per_second_t velocity);
/**
* Returns whether the elevator would hit the lower limit.
@@ -106,7 +106,7 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param elevatorHeight The elevator height.
* @return Whether the elevator would hit the lower limit.
*/
bool WouldHitLowerLimit(units::meter_t elevatorHeight) const;
bool WouldHitLowerLimit(wpi::units::meter_t elevatorHeight) const;
/**
* Returns whether the elevator would hit the upper limit.
@@ -114,7 +114,7 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param elevatorHeight The elevator height.
* @return Whether the elevator would hit the upper limit.
*/
bool WouldHitUpperLimit(units::meter_t elevatorHeight) const;
bool WouldHitUpperLimit(wpi::units::meter_t elevatorHeight) const;
/**
* Returns whether the elevator has hit the lower limit.
@@ -135,28 +135,28 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
*
* @return The position of the elevator.
*/
units::meter_t GetPosition() const;
wpi::units::meter_t GetPosition() const;
/**
* Returns the velocity of the elevator.
*
* @return The velocity of the elevator.
*/
units::meters_per_second_t GetVelocity() const;
wpi::units::meters_per_second_t GetVelocity() const;
/**
* Returns the elevator current draw.
*
* @return The elevator current draw.
*/
units::ampere_t GetCurrentDraw() const;
wpi::units::ampere_t GetCurrentDraw() const;
/**
* Sets the input voltage for the elevator.
*
* @param voltage The input voltage.
*/
void SetInputVoltage(units::volt_t voltage);
void SetInputVoltage(wpi::units::volt_t voltage);
protected:
/**
@@ -166,13 +166,13 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param u The system inputs (voltage).
* @param dt The time difference between controller updates.
*/
Vectord<2> UpdateX(const Vectord<2>& currentXhat, const Vectord<1>& u,
units::second_t dt) override;
wpi::math::Vectord<2> UpdateX(const wpi::math::Vectord<2>& currentXhat, const wpi::math::Vectord<1>& u,
wpi::units::second_t dt) override;
private:
DCMotor m_gearbox;
units::meter_t m_minHeight;
units::meter_t m_maxHeight;
wpi::math::DCMotor m_gearbox;
wpi::units::meter_t m_minHeight;
wpi::units::meter_t m_maxHeight;
bool m_simulateGravity;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -8,7 +8,7 @@
#include "wpi/simulation/CallbackStore.hpp"
namespace frc {
namespace wpi {
class Encoder;
@@ -317,4 +317,4 @@ class EncoderSim {
int m_index;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -12,7 +12,7 @@
#include "wpi/units/moment_of_inertia.hpp"
#include "wpi/units/torque.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Represents a simulated flywheel mechanism.
*/
@@ -23,13 +23,13 @@ class FlywheelSim : public LinearSystemSim<1, 1, 1> {
*
* @param plant The linear system representing the flywheel. This
* system can be created with
* LinearSystemId::FlywheelSystem() or
* LinearSystemId::IdentifyVelocitySystem().
* wpi::math::LinearSystemId::FlywheelSystem() or
* wpi::math::LinearSystemId::IdentifyVelocitySystem().
* @param gearbox The type of and number of motors in the flywheel
* gearbox.
* @param measurementStdDevs The standard deviation of the measurement noise.
*/
FlywheelSim(const LinearSystem<1, 1, 1>& plant, const DCMotor& gearbox,
FlywheelSim(const wpi::math::LinearSystem<1, 1, 1>& plant, const wpi::math::DCMotor& gearbox,
const std::array<double, 1>& measurementStdDevs = {0.0});
using LinearSystemSim::SetState;
@@ -39,54 +39,54 @@ class FlywheelSim : public LinearSystemSim<1, 1, 1> {
*
* @param velocity The new velocity
*/
void SetVelocity(units::radians_per_second_t velocity);
void SetVelocity(wpi::units::radians_per_second_t velocity);
/**
* Returns the flywheel's velocity.
*
* @return The flywheel's velocity.
*/
units::radians_per_second_t GetAngularVelocity() const;
wpi::units::radians_per_second_t GetAngularVelocity() const;
/**
* Returns the flywheel's acceleration.
*
* @return The flywheel's acceleration
*/
units::radians_per_second_squared_t GetAngularAcceleration() const;
wpi::units::radians_per_second_squared_t GetAngularAcceleration() const;
/**
* Returns the flywheel's torque.
*
* @return The flywheel's torque
*/
units::newton_meter_t GetTorque() const;
wpi::units::newton_meter_t GetTorque() const;
/**
* Returns the flywheel's current draw.
*
* @return The flywheel's current draw.
*/
units::ampere_t GetCurrentDraw() const;
wpi::units::ampere_t GetCurrentDraw() const;
/**
* Gets the input voltage for the flywheel.
*
* @return The flywheel input voltage.
*/
units::volt_t GetInputVoltage() const;
wpi::units::volt_t GetInputVoltage() const;
/**
* Sets the input voltage for the flywheel.
*
* @param voltage The input voltage.
*/
void SetInputVoltage(units::volt_t voltage);
void SetInputVoltage(wpi::units::volt_t voltage);
/**
* Returns the gearbox.
*/
DCMotor Gearbox() const { return m_gearbox; }
wpi::math::DCMotor Gearbox() const { return m_gearbox; }
/**
* Returns the gearing;
@@ -96,11 +96,11 @@ class FlywheelSim : public LinearSystemSim<1, 1, 1> {
/**
* Returns the moment of inertia
*/
units::kilogram_square_meter_t J() const { return m_j; }
wpi::units::kilogram_square_meter_t J() const { return m_j; }
private:
DCMotor m_gearbox;
wpi::math::DCMotor m_gearbox;
double m_gearing;
units::kilogram_square_meter_t m_j;
wpi::units::kilogram_square_meter_t m_j;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -6,7 +6,7 @@
#include "wpi/simulation/GenericHIDSim.hpp"
namespace frc {
namespace wpi {
class Gamepad;
@@ -257,4 +257,4 @@ class GamepadSim : public GenericHIDSim {
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -9,7 +9,7 @@
#include "wpi/driverstation/DriverStation.hpp"
#include "wpi/driverstation/GenericHID.hpp"
namespace frc {
namespace wpi {
class GenericHID;
@@ -140,4 +140,4 @@ class GenericHIDSim {
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -6,7 +6,7 @@
#include "wpi/simulation/GenericHIDSim.hpp"
namespace frc {
namespace wpi {
class Joystick;
@@ -85,4 +85,4 @@ class JoystickSim : public GenericHIDSim {
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -12,7 +12,7 @@
#include "wpi/units/current.hpp"
#include "wpi/units/time.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* This class helps simulate linear systems. To use this class, do the following
* in the simulationPeriodic() method.
@@ -35,12 +35,12 @@ class LinearSystemSim {
* @param measurementStdDevs The standard deviations of the measurements.
*/
explicit LinearSystemSim(
const LinearSystem<States, Inputs, Outputs>& system,
const wpi::math::LinearSystem<States, Inputs, Outputs>& system,
const std::array<double, Outputs>& measurementStdDevs = {})
: m_plant(system), m_measurementStdDevs(measurementStdDevs) {
m_x = Vectord<States>::Zero();
m_y = Vectord<Outputs>::Zero();
m_u = Vectord<Inputs>::Zero();
m_x = wpi::math::Vectord<States>::Zero();
m_y = wpi::math::Vectord<Outputs>::Zero();
m_u = wpi::math::Vectord<Inputs>::Zero();
}
virtual ~LinearSystemSim() = default;
@@ -50,7 +50,7 @@ class LinearSystemSim {
*
* @param dt The time between updates.
*/
void Update(units::second_t dt) {
void Update(wpi::units::second_t dt) {
// Update x. By default, this is the linear system dynamics xₖ₊₁ = Axₖ +
// Buₖ.
m_x = UpdateX(m_x, m_u, dt);
@@ -61,7 +61,7 @@ class LinearSystemSim {
// Add noise. If the user did not pass a noise vector to the
// constructor, then this method will not do anything because
// the standard deviations default to zero.
m_y += frc::MakeWhiteNoiseVector<Outputs>(m_measurementStdDevs);
m_y += wpi::math::MakeWhiteNoiseVector<Outputs>(m_measurementStdDevs);
}
/**
@@ -69,7 +69,7 @@ class LinearSystemSim {
*
* @return The current output of the plant.
*/
const Vectord<Outputs>& GetOutput() const { return m_y; }
const wpi::math::Vectord<Outputs>& GetOutput() const { return m_y; }
/**
* Returns an element of the current output of the plant.
@@ -84,7 +84,7 @@ class LinearSystemSim {
*
* @param u The system inputs.
*/
void SetInput(const Vectord<Inputs>& u) { m_u = u; }
void SetInput(const wpi::math::Vectord<Inputs>& u) { m_u = u; }
/**
* Sets the system inputs.
@@ -99,7 +99,7 @@ class LinearSystemSim {
*
* @return The current input of the plant.
*/
const Vectord<Inputs>& GetInput() const { return m_u; }
const wpi::math::Vectord<Inputs>& GetInput() const { return m_u; }
/**
* Returns an element of the current input of the plant.
@@ -114,7 +114,7 @@ class LinearSystemSim {
*
* @param state The new state.
*/
void SetState(const Vectord<States>& state) {
void SetState(const wpi::math::Vectord<States>& state) {
m_x = state;
// Update the output to reflect the new state.
@@ -131,9 +131,9 @@ class LinearSystemSim {
* @param u The system inputs (usually voltage).
* @param dt The time difference between controller updates.
*/
virtual Vectord<States> UpdateX(const Vectord<States>& currentXhat,
const Vectord<Inputs>& u,
units::second_t dt) {
virtual wpi::math::Vectord<States> UpdateX(const wpi::math::Vectord<States>& currentXhat,
const wpi::math::Vectord<Inputs>& u,
wpi::units::second_t dt) {
return m_plant.CalculateX(currentXhat, u, dt);
}
@@ -144,23 +144,23 @@ class LinearSystemSim {
* @param maxInput The maximum magnitude of the input vector after clamping.
*/
void ClampInput(double maxInput) {
m_u = frc::DesaturateInputVector<Inputs>(m_u, maxInput);
m_u = wpi::math::DesaturateInputVector<Inputs>(m_u, maxInput);
}
/// The plant that represents the linear system.
LinearSystem<States, Inputs, Outputs> m_plant;
wpi::math::LinearSystem<States, Inputs, Outputs> m_plant;
/// State vector.
Vectord<States> m_x;
wpi::math::Vectord<States> m_x;
/// Input vector.
Vectord<Inputs> m_u;
wpi::math::Vectord<Inputs> m_u;
/// Output vector.
Vectord<Outputs> m_y;
wpi::math::Vectord<Outputs> m_y;
/// The standard deviations of measurements, used for adding noise to the
/// measurements.
std::array<double, Outputs> m_measurementStdDevs;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -8,7 +8,7 @@
#include "wpi/hardware/motor/PWMMotorController.hpp"
#include "wpi/units/length.hpp"
namespace frc {
namespace wpi {
class PWMMotorController;
@@ -23,7 +23,7 @@ class PWMMotorControllerSim {
double GetSpeed() const;
private:
hal::SimDouble m_simSpeed;
wpi::hal::SimDouble m_simSpeed;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -8,7 +8,7 @@
#include "wpi/simulation/CallbackStore.hpp"
namespace frc {
namespace wpi {
class PWM;
class PWMMotorController;
@@ -118,4 +118,4 @@ class PWMSim {
int m_index;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -10,7 +10,7 @@
#include "wpi/hardware/pneumatic/PneumaticsModuleType.hpp"
#include "wpi/simulation/CallbackStore.hpp"
namespace frc::sim {
namespace wpi::sim {
class PneumaticsBaseSim {
public:
@@ -195,4 +195,4 @@ class PneumaticsBaseSim {
explicit PneumaticsBaseSim(const PneumaticsBase& module);
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -8,7 +8,7 @@
#include "wpi/simulation/CallbackStore.hpp"
namespace frc {
namespace wpi {
class PowerDistribution;
@@ -168,4 +168,4 @@ class PowerDistributionSim {
int m_index;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -10,7 +10,7 @@
#include "wpi/simulation/CallbackStore.hpp"
#include "wpi/simulation/PneumaticsBaseSim.hpp"
namespace frc {
namespace wpi {
class Compressor;
@@ -120,4 +120,4 @@ class REVPHSim : public PneumaticsBaseSim {
void ResetData() override;
};
} // namespace sim
} // namespace frc
} // namespace wpi

View File

@@ -13,7 +13,7 @@
#include "wpi/units/temperature.hpp"
#include "wpi/units/voltage.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* A utility class to control a simulated RoboRIO.
@@ -36,14 +36,14 @@ class RoboRioSim {
*
* @return the Vin voltage
*/
static units::volt_t GetVInVoltage();
static wpi::units::volt_t GetVInVoltage();
/**
* Define the Vin voltage.
*
* @param vInVoltage the new voltage
*/
static void SetVInVoltage(units::volt_t vInVoltage);
static void SetVInVoltage(wpi::units::volt_t vInVoltage);
/**
* Register a callback to be run whenever the 3.3V rail voltage changes.
@@ -62,14 +62,14 @@ class RoboRioSim {
*
* @return the 3.3V rail voltage
*/
static units::volt_t GetUserVoltage3V3();
static wpi::units::volt_t GetUserVoltage3V3();
/**
* Define the 3.3V rail voltage.
*
* @param userVoltage3V3 the new voltage
*/
static void SetUserVoltage3V3(units::volt_t userVoltage3V3);
static void SetUserVoltage3V3(wpi::units::volt_t userVoltage3V3);
/**
* Register a callback to be run whenever the 3.3V rail current changes.
@@ -88,14 +88,14 @@ class RoboRioSim {
*
* @return the 3.3V rail current
*/
static units::ampere_t GetUserCurrent3V3();
static wpi::units::ampere_t GetUserCurrent3V3();
/**
* Define the 3.3V rail current.
*
* @param userCurrent3V3 the new current
*/
static void SetUserCurrent3V3(units::ampere_t userCurrent3V3);
static void SetUserCurrent3V3(wpi::units::ampere_t userCurrent3V3);
/**
* Register a callback to be run whenever the 3.3V rail active state changes.
@@ -166,14 +166,14 @@ class RoboRioSim {
*
* @return the brownout voltage
*/
static units::volt_t GetBrownoutVoltage();
static wpi::units::volt_t GetBrownoutVoltage();
/**
* Define the brownout voltage.
*
* @param brownoutVoltage the new voltage
*/
static void SetBrownoutVoltage(units::volt_t brownoutVoltage);
static void SetBrownoutVoltage(wpi::units::volt_t brownoutVoltage);
/**
* Register a callback to be run whenever the cpu temp changes.
@@ -191,14 +191,14 @@ class RoboRioSim {
*
* @return the cpu temp.
*/
static units::celsius_t GetCPUTemp();
static wpi::units::celsius_t GetCPUTemp();
/**
* Define the cpu temp.
*
* @param cpuTemp the new cpu temp.
*/
static void SetCPUTemp(units::celsius_t cpuTemp);
static void SetCPUTemp(wpi::units::celsius_t cpuTemp);
/**
* Register a callback to be run whenever the team number changes.
@@ -258,4 +258,4 @@ class RoboRioSim {
*/
static void ResetData();
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -10,7 +10,7 @@
#include "wpi/nt/StringTopic.hpp"
#include "wpi/opmode/RobotBase.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Class that facilitates control of a SendableChooser's selected option in
@@ -31,7 +31,7 @@ class SendableChooserSim {
* @param inst The NetworkTables instance.
* @param path The path where the SendableChooser is published.
*/
SendableChooserSim(nt::NetworkTableInstance inst, std::string_view path);
SendableChooserSim(wpi::nt::NetworkTableInstance inst, std::string_view path);
/**
* Set the selected option.
@@ -40,6 +40,6 @@ class SendableChooserSim {
void SetSelected(std::string_view option);
private:
nt::StringPublisher m_publisher;
wpi::nt::StringPublisher m_publisher;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -8,7 +8,7 @@
#include "wpi/hardware/range/SharpIR.hpp"
#include "wpi/units/length.hpp"
namespace frc {
namespace wpi {
/** Simulation class for Sharp IR sensors. */
class SharpIRSim {
@@ -32,10 +32,10 @@ class SharpIRSim {
*
* @param range range of the target returned by the sensor
*/
void SetRange(units::meter_t range);
void SetRange(wpi::units::meter_t range);
private:
hal::SimDouble m_simRange;
wpi::hal::SimDouble m_simRange;
};
} // namespace frc
} // namespace wpi

View File

@@ -11,7 +11,7 @@
#include "wpi/hal/SimDevice.h"
#include "wpi/hal/simulation/SimDeviceData.h"
namespace frc::sim {
namespace wpi::sim {
/**
* Class to control the simulation side of a SimDevice.
@@ -62,7 +62,7 @@ class SimDeviceSim {
* @param name the property name
* @return the property object
*/
hal::SimValue GetValue(const char* name) const;
wpi::hal::SimValue GetValue(const char* name) const;
/**
* Get the property object with the given name.
@@ -70,7 +70,7 @@ class SimDeviceSim {
* @param name the property name
* @return the property object
*/
hal::SimInt GetInt(const char* name) const;
wpi::hal::SimInt GetInt(const char* name) const;
/**
* Get the property object with the given name.
@@ -78,7 +78,7 @@ class SimDeviceSim {
* @param name the property name
* @return the property object
*/
hal::SimLong GetLong(const char* name) const;
wpi::hal::SimLong GetLong(const char* name) const;
/**
* Get the property object with the given name.
@@ -86,7 +86,7 @@ class SimDeviceSim {
* @param name the property name
* @return the property object
*/
hal::SimDouble GetDouble(const char* name) const;
wpi::hal::SimDouble GetDouble(const char* name) const;
/**
* Get the property object with the given name.
@@ -94,7 +94,7 @@ class SimDeviceSim {
* @param name the property name
* @return the property object
*/
hal::SimEnum GetEnum(const char* name) const;
wpi::hal::SimEnum GetEnum(const char* name) const;
/**
* Get the property object with the given name.
@@ -102,7 +102,7 @@ class SimDeviceSim {
* @param name the property name
* @return the property object
*/
hal::SimBoolean GetBoolean(const char* name) const;
wpi::hal::SimBoolean GetBoolean(const char* name) const;
/**
* Get all options for the given enum.
@@ -159,4 +159,4 @@ class SimDeviceSim {
private:
HAL_SimDeviceHandle m_handle;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -9,7 +9,7 @@
#include "wpi/hal/HALBase.h"
#include "wpi/units/time.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Override the HAL runtime type (simulated/real).
@@ -51,13 +51,13 @@ bool IsTimingPaused();
*
* @param delta the amount to advance (in seconds)
*/
void StepTiming(units::second_t delta);
void StepTiming(wpi::units::second_t delta);
/**
* Advance the simulator time and return immediately.
*
* @param delta the amount to advance (in seconds)
*/
void StepTimingAsync(units::second_t delta);
void StepTimingAsync(wpi::units::second_t delta);
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -13,7 +13,7 @@
#include "wpi/units/mass.hpp"
#include "wpi/units/moment_of_inertia.hpp"
namespace frc::sim {
namespace wpi::sim {
/**
* Represents a simulated arm mechanism.
*/
@@ -24,7 +24,7 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
*
* @param system The system representing this arm. This system can
* be created with
* LinearSystemId::SingleJointedArmSystem().
* wpi::math::LinearSystemId::SingleJointedArmSystem().
* @param gearbox The type and number of motors on the arm gearbox.
* @param gearing The gear ratio of the arm (numbers greater than 1
* represent reductions).
@@ -35,11 +35,11 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param startingAngle The initial position of the arm.
* @param measurementStdDevs The standard deviations of the measurements.
*/
SingleJointedArmSim(const LinearSystem<2, 1, 2>& system,
const DCMotor& gearbox, double gearing,
units::meter_t armLength, units::radian_t minAngle,
units::radian_t maxAngle, bool simulateGravity,
units::radian_t startingAngle,
SingleJointedArmSim(const wpi::math::LinearSystem<2, 1, 2>& system,
const wpi::math::DCMotor& gearbox, double gearing,
wpi::units::meter_t armLength, wpi::units::radian_t minAngle,
wpi::units::radian_t maxAngle, bool simulateGravity,
wpi::units::radian_t startingAngle,
const std::array<double, 2>& measurementStdDevs = {0.0,
0.0});
/**
@@ -57,11 +57,11 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param startingAngle The initial position of the arm.
* @param measurementStdDevs The standard deviation of the measurement noise.
*/
SingleJointedArmSim(const DCMotor& gearbox, double gearing,
units::kilogram_square_meter_t moi,
units::meter_t armLength, units::radian_t minAngle,
units::radian_t maxAngle, bool simulateGravity,
units::radian_t startingAngle,
SingleJointedArmSim(const wpi::math::DCMotor& gearbox, double gearing,
wpi::units::kilogram_square_meter_t moi,
wpi::units::meter_t armLength, wpi::units::radian_t minAngle,
wpi::units::radian_t maxAngle, bool simulateGravity,
wpi::units::radian_t startingAngle,
const std::array<double, 2>& measurementStdDevs = {0.0,
0.0});
@@ -74,7 +74,7 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param angle The new angle.
* @param velocity The new angular velocity.
*/
void SetState(units::radian_t angle, units::radians_per_second_t velocity);
void SetState(wpi::units::radian_t angle, wpi::units::radians_per_second_t velocity);
/**
* Returns whether the arm would hit the lower limit.
@@ -82,7 +82,7 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param armAngle The arm height.
* @return Whether the arm would hit the lower limit.
*/
bool WouldHitLowerLimit(units::radian_t armAngle) const;
bool WouldHitLowerLimit(wpi::units::radian_t armAngle) const;
/**
* Returns whether the arm would hit the upper limit.
@@ -90,7 +90,7 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param armAngle The arm height.
* @return Whether the arm would hit the upper limit.
*/
bool WouldHitUpperLimit(units::radian_t armAngle) const;
bool WouldHitUpperLimit(wpi::units::radian_t armAngle) const;
/**
* Returns whether the arm has hit the lower limit.
@@ -111,28 +111,28 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
*
* @return The current arm angle.
*/
units::radian_t GetAngle() const;
wpi::units::radian_t GetAngle() const;
/**
* Returns the current arm velocity.
*
* @return The current arm velocity.
*/
units::radians_per_second_t GetVelocity() const;
wpi::units::radians_per_second_t GetVelocity() const;
/**
* Returns the arm current draw.
*
* @return The arm current draw.
*/
units::ampere_t GetCurrentDraw() const;
wpi::units::ampere_t GetCurrentDraw() const;
/**
* Sets the input voltage for the arm.
*
* @param voltage The input voltage.
*/
void SetInputVoltage(units::volt_t voltage);
void SetInputVoltage(wpi::units::volt_t voltage);
/**
* Calculates a rough estimate of the moment of inertia of an arm given its
@@ -143,8 +143,8 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
*
* @return The calculated moment of inertia.
*/
static constexpr units::kilogram_square_meter_t EstimateMOI(
units::meter_t length, units::kilogram_t mass) {
static constexpr wpi::units::kilogram_square_meter_t EstimateMOI(
wpi::units::meter_t length, wpi::units::kilogram_t mass) {
return 1.0 / 3.0 * mass * length * length;
}
@@ -156,15 +156,15 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param u The system inputs (voltage).
* @param dt The time difference between controller updates.
*/
Vectord<2> UpdateX(const Vectord<2>& currentXhat, const Vectord<1>& u,
units::second_t dt) override;
wpi::math::Vectord<2> UpdateX(const wpi::math::Vectord<2>& currentXhat, const wpi::math::Vectord<1>& u,
wpi::units::second_t dt) override;
private:
units::meter_t m_armLen;
units::radian_t m_minAngle;
units::radian_t m_maxAngle;
const DCMotor m_gearbox;
wpi::units::meter_t m_armLen;
wpi::units::radian_t m_minAngle;
wpi::units::radian_t m_maxAngle;
const wpi::math::DCMotor m_gearbox;
double m_gearing;
bool m_simulateGravity;
};
} // namespace frc::sim
} // namespace wpi::sim

View File

@@ -9,7 +9,7 @@
#include "wpi/hardware/pneumatic/PneumaticsModuleType.hpp"
#include "wpi/simulation/PneumaticsBaseSim.hpp"
namespace frc::sim {
namespace wpi::sim {
class SolenoidSim {
public:
@@ -41,4 +41,4 @@ class SolenoidSim {
int m_channel;
};
} // namespace frc::sim
} // namespace wpi::sim