mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
class ExpansionHubServo;
|
||||
class ExpansionHubMotor;
|
||||
|
||||
@@ -83,10 +83,10 @@ class ExpansionHub {
|
||||
std::shared_ptr<DataStore> m_dataStore;
|
||||
int m_usbId;
|
||||
|
||||
static wpi::mutex m_handleLock;
|
||||
static wpi::util::mutex m_handleLock;
|
||||
static std::weak_ptr<DataStore> m_storeMap[4];
|
||||
|
||||
static std::shared_ptr<DataStore> GetForUsbId(int usbId);
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/units/voltage.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/** This class controls a specific motor and encoder hooked up to an
|
||||
* ExpansionHub. */
|
||||
@@ -44,7 +44,7 @@ class ExpansionHubMotor {
|
||||
*
|
||||
* @param voltage The voltage to drive the motor at
|
||||
*/
|
||||
void SetVoltage(units::volt_t voltage);
|
||||
void SetVoltage(wpi::units::volt_t voltage);
|
||||
|
||||
/**
|
||||
* Command the motor to drive to a specific position setpoint. This value will
|
||||
@@ -82,7 +82,7 @@ class ExpansionHubMotor {
|
||||
*
|
||||
* @return Motor current
|
||||
*/
|
||||
units::ampere_t GetCurrent() const;
|
||||
wpi::units::ampere_t GetCurrent() const;
|
||||
|
||||
/**
|
||||
* Sets the distance per count of the encoder. Used to scale encoder readings.
|
||||
@@ -152,22 +152,22 @@ class ExpansionHubMotor {
|
||||
ExpansionHub m_hub;
|
||||
int m_channel;
|
||||
|
||||
nt::DoubleSubscriber m_encoderSubscriber;
|
||||
nt::DoubleSubscriber m_encoderVelocitySubscriber;
|
||||
nt::DoubleSubscriber m_currentSubscriber;
|
||||
wpi::nt::DoubleSubscriber m_encoderSubscriber;
|
||||
wpi::nt::DoubleSubscriber m_encoderVelocitySubscriber;
|
||||
wpi::nt::DoubleSubscriber m_currentSubscriber;
|
||||
|
||||
nt::DoublePublisher m_setpointPublisher;
|
||||
nt::BooleanPublisher m_floatOn0Publisher;
|
||||
nt::BooleanPublisher m_enabledPublisher;
|
||||
wpi::nt::DoublePublisher m_setpointPublisher;
|
||||
wpi::nt::BooleanPublisher m_floatOn0Publisher;
|
||||
wpi::nt::BooleanPublisher m_enabledPublisher;
|
||||
|
||||
nt::IntegerPublisher m_modePublisher;
|
||||
wpi::nt::IntegerPublisher m_modePublisher;
|
||||
|
||||
nt::BooleanPublisher m_reversedPublisher;
|
||||
nt::BooleanPublisher m_resetEncoderPublisher;
|
||||
wpi::nt::BooleanPublisher m_reversedPublisher;
|
||||
wpi::nt::BooleanPublisher m_resetEncoderPublisher;
|
||||
|
||||
nt::DoublePublisher m_distancePerCountPublisher;
|
||||
wpi::nt::DoublePublisher m_distancePerCountPublisher;
|
||||
|
||||
ExpansionHubPidConstants m_velocityPidConstants;
|
||||
ExpansionHubPidConstants m_positionPidConstants;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/nt/DoubleTopic.hpp"
|
||||
#include "wpi/nt/IntegerTopic.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
class ExpansionHubMotor;
|
||||
|
||||
/** This class contains PID constants for an ExpansionHub motor. */
|
||||
@@ -67,15 +67,15 @@ class ExpansionHubPidConstants {
|
||||
private:
|
||||
ExpansionHubPidConstants(int usbId, int channel, bool isVelocityPid);
|
||||
|
||||
nt::DoublePublisher m_pPublisher;
|
||||
nt::DoublePublisher m_iPublisher;
|
||||
nt::DoublePublisher m_dPublisher;
|
||||
nt::DoublePublisher m_sPublisher;
|
||||
nt::DoublePublisher m_vPublisher;
|
||||
nt::DoublePublisher m_aPublisher;
|
||||
wpi::nt::DoublePublisher m_pPublisher;
|
||||
wpi::nt::DoublePublisher m_iPublisher;
|
||||
wpi::nt::DoublePublisher m_dPublisher;
|
||||
wpi::nt::DoublePublisher m_sPublisher;
|
||||
wpi::nt::DoublePublisher m_vPublisher;
|
||||
wpi::nt::DoublePublisher m_aPublisher;
|
||||
|
||||
nt::BooleanPublisher m_continuousPublisher;
|
||||
nt::DoublePublisher m_continuousMinimumPublisher;
|
||||
nt::DoublePublisher m_continuousMaximumPublisher;
|
||||
wpi::nt::BooleanPublisher m_continuousPublisher;
|
||||
wpi::nt::DoublePublisher m_continuousMinimumPublisher;
|
||||
wpi::nt::DoublePublisher m_continuousMaximumPublisher;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/units/angle.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/** This class controls a specific servo hooked up to an ExpansionHub. */
|
||||
class ExpansionHubServo {
|
||||
@@ -45,14 +45,14 @@ class ExpansionHubServo {
|
||||
* @param angle Position in angle units. Will be scaled between 0 and 180
|
||||
* degrees
|
||||
*/
|
||||
void SetAngle(units::degree_t angle);
|
||||
void SetAngle(wpi::units::degree_t angle);
|
||||
|
||||
/**
|
||||
* Sets the raw pulse width output on the servo.
|
||||
*
|
||||
* @param pulseWidth Pulse width
|
||||
*/
|
||||
void SetPulseWidth(units::microsecond_t pulseWidth);
|
||||
void SetPulseWidth(wpi::units::microsecond_t pulseWidth);
|
||||
|
||||
/**
|
||||
* Sets if the servo output is enabled or not. Defaults to false.
|
||||
@@ -66,7 +66,7 @@ class ExpansionHubServo {
|
||||
*
|
||||
* @param framePeriod The frame period
|
||||
*/
|
||||
void SetFramePeriod(units::microsecond_t framePeriod);
|
||||
void SetFramePeriod(wpi::units::microsecond_t framePeriod);
|
||||
|
||||
/**
|
||||
* Gets if the underlying ExpansionHub is connected.
|
||||
@@ -84,7 +84,7 @@ class ExpansionHubServo {
|
||||
* @param minAngle Minimum angle
|
||||
* @param maxAngle Maximum angle
|
||||
*/
|
||||
void SetAngleRange(units::degree_t minAngle, units::degree_t maxAngle);
|
||||
void SetAngleRange(wpi::units::degree_t minAngle, wpi::units::degree_t maxAngle);
|
||||
|
||||
/**
|
||||
* Sets the PWM range for the servo.
|
||||
@@ -95,7 +95,7 @@ class ExpansionHubServo {
|
||||
* @param minPwm Minimum PWM
|
||||
* @param maxPwm Maximum PWM
|
||||
*/
|
||||
void SetPWMRange(units::microsecond_t minPwm, units::microsecond_t maxPwm);
|
||||
void SetPWMRange(wpi::units::microsecond_t minPwm, wpi::units::microsecond_t maxPwm);
|
||||
|
||||
/**
|
||||
* Sets whether the servo is reversed.
|
||||
@@ -117,23 +117,23 @@ class ExpansionHubServo {
|
||||
void SetContinousRotationMode(bool enable);
|
||||
|
||||
private:
|
||||
units::microsecond_t GetFullRangeScaleFactor();
|
||||
units::degree_t GetServoAngleRange();
|
||||
wpi::units::microsecond_t GetFullRangeScaleFactor();
|
||||
wpi::units::degree_t GetServoAngleRange();
|
||||
|
||||
ExpansionHub m_hub;
|
||||
int m_channel;
|
||||
|
||||
units::degree_t m_maxServoAngle = 180.0_deg;
|
||||
units::degree_t m_minServoAngle = 0.0_deg;
|
||||
wpi::units::degree_t m_maxServoAngle = 180.0_deg;
|
||||
wpi::units::degree_t m_minServoAngle = 0.0_deg;
|
||||
|
||||
units::microsecond_t m_minPwm = 600_us;
|
||||
units::microsecond_t m_maxPwm = 2400_us;
|
||||
wpi::units::microsecond_t m_minPwm = 600_us;
|
||||
wpi::units::microsecond_t m_maxPwm = 2400_us;
|
||||
|
||||
bool m_reversed = false;
|
||||
bool m_continousMode = false;
|
||||
|
||||
nt::IntegerPublisher m_pulseWidthPublisher;
|
||||
nt::IntegerPublisher m_framePeriodPublisher;
|
||||
nt::BooleanPublisher m_enabledPublisher;
|
||||
wpi::nt::IntegerPublisher m_pulseWidthPublisher;
|
||||
wpi::nt::IntegerPublisher m_framePeriodPublisher;
|
||||
wpi::nt::BooleanPublisher m_enabledPublisher;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/**
|
||||
* Edge configuration.
|
||||
*/
|
||||
@@ -14,4 +14,4 @@ enum class EdgeConfiguration {
|
||||
/// Falling edge configuration.
|
||||
kFallingEdge = 1,
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/**
|
||||
* Tachometer for getting rotational speed from a device.
|
||||
*
|
||||
@@ -25,8 +25,8 @@ namespace frc {
|
||||
* sensor, or optical sensor detecting tape on a shooter wheel. Unlike
|
||||
* encoders, this class only needs a single digital input.
|
||||
*/
|
||||
class Tachometer : public wpi::Sendable,
|
||||
public wpi::SendableHelper<Tachometer> {
|
||||
class Tachometer : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<Tachometer> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a new tachometer.
|
||||
@@ -53,14 +53,14 @@ class Tachometer : public wpi::Sendable,
|
||||
*
|
||||
* @return Current frequency.
|
||||
*/
|
||||
units::hertz_t GetFrequency() const;
|
||||
wpi::units::hertz_t GetFrequency() const;
|
||||
|
||||
/**
|
||||
* Gets the tachometer period.
|
||||
*
|
||||
* @return Current period.
|
||||
*/
|
||||
units::second_t GetPeriod() const;
|
||||
wpi::units::second_t GetPeriod() const;
|
||||
|
||||
/**
|
||||
* Gets the number of edges per revolution.
|
||||
@@ -83,7 +83,7 @@ class Tachometer : public wpi::Sendable,
|
||||
*
|
||||
* @return Current RPS.
|
||||
*/
|
||||
units::turns_per_second_t GetRevolutionsPerSecond() const;
|
||||
wpi::units::turns_per_second_t GetRevolutionsPerSecond() const;
|
||||
|
||||
/**
|
||||
* Gets the current tachometer revolutions per minute.
|
||||
@@ -92,7 +92,7 @@ class Tachometer : public wpi::Sendable,
|
||||
*
|
||||
* @return Current RPM.
|
||||
*/
|
||||
units::revolutions_per_minute_t GetRevolutionsPerMinute() const;
|
||||
wpi::units::revolutions_per_minute_t GetRevolutionsPerMinute() const;
|
||||
|
||||
/**
|
||||
* Gets if the tachometer is stopped.
|
||||
@@ -106,14 +106,14 @@ class Tachometer : public wpi::Sendable,
|
||||
*
|
||||
* @param maxPeriod The max period.
|
||||
*/
|
||||
void SetMaxPeriod(units::second_t maxPeriod);
|
||||
void SetMaxPeriod(wpi::units::second_t maxPeriod);
|
||||
|
||||
protected:
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_CounterHandle, HAL_FreeCounter> m_handle;
|
||||
wpi::hal::Handle<HAL_CounterHandle, HAL_FreeCounter> m_handle;
|
||||
int m_edgesPerRevolution;
|
||||
int32_t m_channel;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/** Up Down Counter.
|
||||
*
|
||||
* This class can count edges on a single digital input or count up based on an
|
||||
* edge from one digital input and down on an edge from another digital input.
|
||||
*
|
||||
*/
|
||||
class UpDownCounter : public wpi::Sendable,
|
||||
public wpi::SendableHelper<UpDownCounter> {
|
||||
class UpDownCounter : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<UpDownCounter> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a new UpDown Counter.
|
||||
@@ -53,10 +53,10 @@ class UpDownCounter : public wpi::Sendable,
|
||||
void SetEdgeConfiguration(EdgeConfiguration configuration);
|
||||
|
||||
protected:
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_CounterHandle, HAL_FreeCounter> m_handle;
|
||||
wpi::hal::Handle<HAL_CounterHandle, HAL_FreeCounter> m_handle;
|
||||
int32_t m_channel;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
class MotorController;
|
||||
|
||||
@@ -55,8 +55,8 @@ class MotorController;
|
||||
* Safety timeouts.
|
||||
*/
|
||||
class DifferentialDrive : public RobotDriveBase,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<DifferentialDrive> {
|
||||
public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<DifferentialDrive> {
|
||||
public:
|
||||
/**
|
||||
* Wheel speeds for a differential drive.
|
||||
@@ -197,7 +197,7 @@ class DifferentialDrive : public RobotDriveBase,
|
||||
void StopMotor() override;
|
||||
std::string GetDescription() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::function<void(double)> m_leftMotor;
|
||||
@@ -208,4 +208,4 @@ class DifferentialDrive : public RobotDriveBase,
|
||||
double m_rightOutput = 0.0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
class MotorController;
|
||||
|
||||
@@ -52,8 +52,8 @@ class MotorController;
|
||||
* methods should be called periodically to avoid Motor Safety timeouts.
|
||||
*/
|
||||
class MecanumDrive : public RobotDriveBase,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<MecanumDrive> {
|
||||
public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<MecanumDrive> {
|
||||
public:
|
||||
/**
|
||||
* Wheel speeds for a mecanum drive.
|
||||
@@ -125,7 +125,7 @@ class MecanumDrive : public RobotDriveBase,
|
||||
* field-oriented controls.
|
||||
*/
|
||||
void DriveCartesian(double xSpeed, double ySpeed, double zRotation,
|
||||
Rotation2d gyroAngle = 0_rad);
|
||||
wpi::math::Rotation2d gyroAngle = 0_rad);
|
||||
|
||||
/**
|
||||
* Drive method for Mecanum platform.
|
||||
@@ -139,7 +139,7 @@ class MecanumDrive : public RobotDriveBase,
|
||||
* @param zRotation The robot's rotation rate around the Z axis [-1.0..1.0].
|
||||
* Counterclockwise is positive.
|
||||
*/
|
||||
void DrivePolar(double magnitude, Rotation2d angle, double zRotation);
|
||||
void DrivePolar(double magnitude, wpi::math::Rotation2d angle, double zRotation);
|
||||
|
||||
/**
|
||||
* Cartesian inverse kinematics for Mecanum platform.
|
||||
@@ -159,12 +159,12 @@ class MecanumDrive : public RobotDriveBase,
|
||||
*/
|
||||
static WheelSpeeds DriveCartesianIK(double xSpeed, double ySpeed,
|
||||
double zRotation,
|
||||
Rotation2d gyroAngle = 0_rad);
|
||||
wpi::math::Rotation2d gyroAngle = 0_rad);
|
||||
|
||||
void StopMotor() override;
|
||||
std::string GetDescription() const override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::function<void(double)> m_frontLeftMotor;
|
||||
@@ -181,4 +181,4 @@ class MecanumDrive : public RobotDriveBase,
|
||||
bool reported = false;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/hardware/motor/MotorSafety.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Common base class for drive platforms.
|
||||
@@ -50,7 +50,7 @@ class RobotDriveBase : public MotorSafety {
|
||||
*
|
||||
* The default value is 0.02. Inputs smaller than the deadband are set to 0.0
|
||||
* while inputs larger than the deadband are scaled from 0.0 to 1.0. See
|
||||
* frc::ApplyDeadband().
|
||||
* wpi::math::ApplyDeadband().
|
||||
*
|
||||
* @param deadband The deadband to set.
|
||||
*/
|
||||
@@ -96,4 +96,4 @@ class RobotDriveBase : public MotorSafety {
|
||||
double m_maxOutput = kDefaultMaxOutput;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/hal/DriverStationTypes.h"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* A wrapper around Driver Station control word.
|
||||
@@ -99,4 +99,4 @@ class DSControlWord {
|
||||
HAL_ControlWord m_controlWord;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace wpi::log {
|
||||
class DataLog;
|
||||
} // namespace wpi::log
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Provide access to the network communication data to / from the Driver
|
||||
@@ -79,26 +79,26 @@ class DriverStation final {
|
||||
* @return The angle clockwise from straight up, or std::nullopt if the
|
||||
* POVDirection is kCenter.
|
||||
*/
|
||||
static constexpr std::optional<Rotation2d> GetAngle(POVDirection angle) {
|
||||
static constexpr std::optional<wpi::math::Rotation2d> GetAngle(POVDirection angle) {
|
||||
switch (angle) {
|
||||
case kCenter:
|
||||
return std::nullopt;
|
||||
case kUp:
|
||||
return Rotation2d{0_deg};
|
||||
return wpi::math::Rotation2d{0_deg};
|
||||
case kUpRight:
|
||||
return Rotation2d{45_deg};
|
||||
return wpi::math::Rotation2d{45_deg};
|
||||
case kRight:
|
||||
return Rotation2d{90_deg};
|
||||
return wpi::math::Rotation2d{90_deg};
|
||||
case kDownRight:
|
||||
return Rotation2d{135_deg};
|
||||
return wpi::math::Rotation2d{135_deg};
|
||||
case kDown:
|
||||
return Rotation2d{180_deg};
|
||||
return wpi::math::Rotation2d{180_deg};
|
||||
case kDownLeft:
|
||||
return Rotation2d{225_deg};
|
||||
return wpi::math::Rotation2d{225_deg};
|
||||
case kLeft:
|
||||
return Rotation2d{270_deg};
|
||||
return wpi::math::Rotation2d{270_deg};
|
||||
case kUpLeft:
|
||||
return Rotation2d{315_deg};
|
||||
return wpi::math::Rotation2d{315_deg};
|
||||
default:
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -433,7 +433,7 @@ class DriverStation final {
|
||||
*
|
||||
* @return Time remaining in current match period (auto or teleop) in seconds
|
||||
*/
|
||||
static units::second_t GetMatchTime();
|
||||
static wpi::units::second_t GetMatchTime();
|
||||
|
||||
/**
|
||||
* Read the battery voltage.
|
||||
@@ -492,4 +492,4 @@ class DriverStation final {
|
||||
DriverStation() = default;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Handle input from Gamepad controllers connected to the Driver Station.
|
||||
@@ -23,8 +23,8 @@ namespace frc {
|
||||
* to have the same mapping, as well as any 3rd party controllers.
|
||||
*/
|
||||
class Gamepad : public GenericHID,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<Gamepad> {
|
||||
public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<Gamepad> {
|
||||
public:
|
||||
/**
|
||||
* Construct an instance of a controller.
|
||||
@@ -1007,11 +1007,11 @@ class Gamepad : public GenericHID,
|
||||
static constexpr int kRightTrigger = 5;
|
||||
};
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
double GetAxisForSendable(int axis) const;
|
||||
bool GetButtonForSendable(int button) const;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/driverstation/DriverStation.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
class BooleanEvent;
|
||||
class EventLoop;
|
||||
@@ -367,4 +367,4 @@ class GenericHID {
|
||||
uint16_t m_rightRumble = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/driverstation/GenericHID.hpp"
|
||||
#include "wpi/units/angle.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Handle input from standard Joysticks connected to the Driver Station.
|
||||
@@ -259,7 +259,7 @@ class Joystick : public GenericHID {
|
||||
*
|
||||
* @return The direction of the vector.
|
||||
*/
|
||||
units::radian_t GetDirection() const;
|
||||
wpi::units::radian_t GetDirection() const;
|
||||
|
||||
private:
|
||||
enum Axis { kX, kY, kZ, kTwist, kThrottle, kNumAxes };
|
||||
@@ -268,4 +268,4 @@ class Joystick : public GenericHID {
|
||||
std::array<int, Axis::kNumAxes> m_axes;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* This class provides an easy way to link actions to active high logic signals.
|
||||
@@ -122,9 +122,9 @@ class BooleanEvent {
|
||||
* @param type The debounce type.
|
||||
* @return The debounced event.
|
||||
*/
|
||||
BooleanEvent Debounce(units::second_t debounceTime,
|
||||
frc::Debouncer::DebounceType type =
|
||||
frc::Debouncer::DebounceType::kRising);
|
||||
BooleanEvent Debounce(wpi::units::second_t debounceTime,
|
||||
wpi::math::Debouncer::DebounceType type =
|
||||
wpi::math::Debouncer::DebounceType::kRising);
|
||||
|
||||
private:
|
||||
/// Poller loop.
|
||||
@@ -135,4 +135,4 @@ class BooleanEvent {
|
||||
/// The state of the condition in the current loop poll.
|
||||
std::shared_ptr<bool> m_state;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/** A declarative way to bind a set of actions to a loop and execute them when
|
||||
* the loop is polled. */
|
||||
class EventLoop {
|
||||
@@ -24,7 +24,7 @@ class EventLoop {
|
||||
*
|
||||
* @param action the action to run.
|
||||
*/
|
||||
void Bind(wpi::unique_function<void()> action);
|
||||
void Bind(wpi::util::unique_function<void()> action);
|
||||
|
||||
/**
|
||||
* Poll all bindings.
|
||||
@@ -37,7 +37,7 @@ class EventLoop {
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
std::vector<wpi::unique_function<void()>> m_bindings;
|
||||
std::vector<wpi::util::unique_function<void()>> m_bindings;
|
||||
bool m_running{false};
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -16,7 +16,7 @@ class NetworkTable;
|
||||
class NetworkTableInstance;
|
||||
} // namespace nt
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/**
|
||||
* A Button that uses a NetworkTable boolean field.
|
||||
*
|
||||
@@ -31,7 +31,7 @@ class NetworkBooleanEvent : public BooleanEvent {
|
||||
* @param loop the loop that polls this event
|
||||
* @param topic The boolean topic that contains the value
|
||||
*/
|
||||
NetworkBooleanEvent(EventLoop* loop, nt::BooleanTopic topic);
|
||||
NetworkBooleanEvent(EventLoop* loop, wpi::nt::BooleanTopic topic);
|
||||
|
||||
/**
|
||||
* Creates a new event with the given boolean subscriber determining whether
|
||||
@@ -40,7 +40,7 @@ class NetworkBooleanEvent : public BooleanEvent {
|
||||
* @param loop the loop that polls this event
|
||||
* @param sub The boolean subscriber that provides the value
|
||||
*/
|
||||
NetworkBooleanEvent(EventLoop* loop, nt::BooleanSubscriber sub);
|
||||
NetworkBooleanEvent(EventLoop* loop, wpi::nt::BooleanSubscriber sub);
|
||||
|
||||
/**
|
||||
* Creates a new event with the given boolean topic determining whether it is
|
||||
@@ -50,7 +50,7 @@ class NetworkBooleanEvent : public BooleanEvent {
|
||||
* @param table The NetworkTable that contains the topic
|
||||
* @param topicName The topic name within the table that contains the value
|
||||
*/
|
||||
NetworkBooleanEvent(EventLoop* loop, std::shared_ptr<nt::NetworkTable> table,
|
||||
NetworkBooleanEvent(EventLoop* loop, std::shared_ptr<wpi::nt::NetworkTable> table,
|
||||
std::string_view topicName);
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class NetworkBooleanEvent : public BooleanEvent {
|
||||
* @param tableName The NetworkTable that contains the topic
|
||||
* @param topicName The topic name within the table that contains the value
|
||||
*/
|
||||
NetworkBooleanEvent(EventLoop* loop, nt::NetworkTableInstance inst,
|
||||
NetworkBooleanEvent(EventLoop* loop, wpi::nt::NetworkTableInstance inst,
|
||||
std::string_view tableName, std::string_view topicName);
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/nt/NTSendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* ADXL345 Accelerometer on I2C.
|
||||
@@ -18,8 +18,8 @@ namespace frc {
|
||||
* an I2C bus. This class assumes the default (not alternate) sensor address of
|
||||
* 0x1D (7-bit address).
|
||||
*/
|
||||
class ADXL345_I2C : public nt::NTSendable,
|
||||
public wpi::SendableHelper<ADXL345_I2C> {
|
||||
class ADXL345_I2C : public wpi::nt::NTSendable,
|
||||
public wpi::util::SendableHelper<ADXL345_I2C> {
|
||||
public:
|
||||
/**
|
||||
* Accelerometer range.
|
||||
@@ -124,16 +124,16 @@ class ADXL345_I2C : public nt::NTSendable,
|
||||
*/
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
void InitSendable(wpi::nt::NTSendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
I2C m_i2c;
|
||||
|
||||
hal::SimDevice m_simDevice;
|
||||
hal::SimEnum m_simRange;
|
||||
hal::SimDouble m_simX;
|
||||
hal::SimDouble m_simY;
|
||||
hal::SimDouble m_simZ;
|
||||
wpi::hal::SimDevice m_simDevice;
|
||||
wpi::hal::SimEnum m_simRange;
|
||||
wpi::hal::SimDouble m_simX;
|
||||
wpi::hal::SimDouble m_simY;
|
||||
wpi::hal::SimDouble m_simZ;
|
||||
|
||||
static constexpr int kPowerCtlRegister = 0x2D;
|
||||
static constexpr int kDataFormatRegister = 0x31;
|
||||
@@ -156,4 +156,4 @@ class ADXL345_I2C : public nt::NTSendable,
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Handle operation of an analog accelerometer.
|
||||
@@ -19,8 +19,8 @@ namespace frc {
|
||||
* sensors have multiple axis and can be treated as multiple devices. Each is
|
||||
* calibrated by finding the center value over a period of time.
|
||||
*/
|
||||
class AnalogAccelerometer : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogAccelerometer> {
|
||||
class AnalogAccelerometer : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<AnalogAccelerometer> {
|
||||
public:
|
||||
/**
|
||||
* Create a new instance of an accelerometer.
|
||||
@@ -89,7 +89,7 @@ class AnalogAccelerometer : public wpi::Sendable,
|
||||
*/
|
||||
void SetZero(double zero);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -102,4 +102,4 @@ class AnalogAccelerometer : public wpi::Sendable,
|
||||
double m_zeroGVoltage = 2.5;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "wpi/hal/CANAPI.h"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* High level class for interfacing with CAN devices conforming to
|
||||
@@ -154,6 +154,6 @@ class CAN {
|
||||
HAL_CAN_Dev_kMiscellaneous;
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_CANHandle, HAL_CleanCAN> m_handle;
|
||||
wpi::hal::Handle<HAL_CANHandle, HAL_CleanCAN> m_handle;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/hal/I2C.h"
|
||||
#include "wpi/hal/I2CTypes.h"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* I2C bus interface class.
|
||||
@@ -153,8 +153,8 @@ class I2C {
|
||||
bool VerifySensor(int registerAddress, int count, const uint8_t* expected);
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_I2CPort, HAL_CloseI2C, HAL_I2C_kInvalid> m_port;
|
||||
wpi::hal::Handle<HAL_I2CPort, HAL_CloseI2C, HAL_I2C_kInvalid> m_port;
|
||||
int m_deviceAddress;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hal/Types.h"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Driver for the RS-232 serial port on the roboRIO.
|
||||
@@ -199,7 +199,7 @@ class SerialPort {
|
||||
*
|
||||
* @param timeout The time to wait for I/O.
|
||||
*/
|
||||
void SetTimeout(units::second_t timeout);
|
||||
void SetTimeout(wpi::units::second_t timeout);
|
||||
|
||||
/**
|
||||
* Specify the size of the input buffer.
|
||||
@@ -254,7 +254,7 @@ class SerialPort {
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_SerialPortHandle, HAL_CloseSerial> m_portHandle;
|
||||
wpi::hal::Handle<HAL_SerialPortHandle, HAL_CloseSerial> m_portHandle;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Analog input class.
|
||||
@@ -25,8 +25,8 @@ namespace frc {
|
||||
* are divided by the number of samples to retain the resolution, but get more
|
||||
* stable values.
|
||||
*/
|
||||
class AnalogInput : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogInput> {
|
||||
class AnalogInput : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<AnalogInput> {
|
||||
public:
|
||||
/**
|
||||
* Construct an analog input.
|
||||
@@ -194,11 +194,11 @@ class AnalogInput : public wpi::Sendable,
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
hal::Handle<HAL_AnalogInputHandle, HAL_FreeAnalogInputPort> m_port;
|
||||
wpi::hal::Handle<HAL_AnalogInputHandle, HAL_FreeAnalogInputPort> m_port;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Interface for counting the number of ticks on a digital input channel.
|
||||
@@ -29,10 +29,10 @@ class CounterBase {
|
||||
|
||||
virtual int Get() const = 0;
|
||||
virtual void Reset() = 0;
|
||||
virtual units::second_t GetPeriod() const = 0;
|
||||
virtual void SetMaxPeriod(units::second_t maxPeriod) = 0;
|
||||
virtual wpi::units::second_t GetPeriod() const = 0;
|
||||
virtual void SetMaxPeriod(wpi::units::second_t maxPeriod) = 0;
|
||||
virtual bool GetStopped() const = 0;
|
||||
virtual bool GetDirection() const = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Class to read a digital input.
|
||||
@@ -19,8 +19,8 @@ namespace frc {
|
||||
* as required. This class is only for devices like switches etc. that aren't
|
||||
* implemented anywhere else.
|
||||
*/
|
||||
class DigitalInput : public wpi::Sendable,
|
||||
public wpi::SendableHelper<DigitalInput> {
|
||||
class DigitalInput : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<DigitalInput> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of a Digital Input class.
|
||||
@@ -55,11 +55,11 @@ class DigitalInput : public wpi::Sendable,
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
hal::Handle<HAL_DigitalHandle, HAL_FreeDIOPort> m_handle;
|
||||
wpi::hal::Handle<HAL_DigitalHandle, HAL_FreeDIOPort> m_handle;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Class to write to digital outputs.
|
||||
@@ -19,8 +19,8 @@ namespace frc {
|
||||
* elsewhere will allocate channels automatically so for those devices it
|
||||
* shouldn't be done here.
|
||||
*/
|
||||
class DigitalOutput : public wpi::Sendable,
|
||||
public wpi::SendableHelper<DigitalOutput> {
|
||||
class DigitalOutput : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<DigitalOutput> {
|
||||
public:
|
||||
/**
|
||||
* Create an instance of a digital output.
|
||||
@@ -66,7 +66,7 @@ class DigitalOutput : public wpi::Sendable,
|
||||
*
|
||||
* @param pulseLength The pulse length in seconds
|
||||
*/
|
||||
void Pulse(units::second_t pulseLength);
|
||||
void Pulse(wpi::units::second_t pulseLength);
|
||||
|
||||
/**
|
||||
* Determine if the pulse is still going.
|
||||
@@ -139,12 +139,12 @@ class DigitalOutput : public wpi::Sendable,
|
||||
*/
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
hal::Handle<HAL_DigitalHandle, HAL_FreeDIOPort> m_handle;
|
||||
hal::Handle<HAL_DigitalPWMHandle> m_pwmGenerator;
|
||||
wpi::hal::Handle<HAL_DigitalHandle, HAL_FreeDIOPort> m_handle;
|
||||
wpi::hal::Handle<HAL_DigitalPWMHandle> m_pwmGenerator;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
class AddressableLED;
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ class AddressableLED;
|
||||
* (off) to 4096. Changes are immediately sent to the FPGA, and the update
|
||||
* occurs at the next FPGA cycle (5.05ms). There is no delay.
|
||||
*/
|
||||
class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
|
||||
class PWM : public wpi::util::Sendable, public wpi::util::SendableHelper<PWM> {
|
||||
public:
|
||||
friend class AddressableLED;
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
|
||||
*
|
||||
* @param time Microsecond PWM value.
|
||||
*/
|
||||
void SetPulseTime(units::microsecond_t time);
|
||||
void SetPulseTime(wpi::units::microsecond_t time);
|
||||
|
||||
/**
|
||||
* Get the PWM pulse time directly from the hardware.
|
||||
@@ -83,7 +83,7 @@ class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
|
||||
*
|
||||
* @return Microsecond PWM control value.
|
||||
*/
|
||||
units::microsecond_t GetPulseTime() const;
|
||||
wpi::units::microsecond_t GetPulseTime() const;
|
||||
|
||||
/**
|
||||
* Temporarily disables the PWM output. The next set call will re-enable
|
||||
@@ -108,11 +108,11 @@ class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
|
||||
void SetSimDevice(HAL_SimDeviceHandle device);
|
||||
|
||||
protected:
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
int m_channel;
|
||||
hal::Handle<HAL_DigitalHandle, HAL_FreePWMPort> m_handle;
|
||||
wpi::hal::Handle<HAL_DigitalHandle, HAL_FreePWMPort> m_handle;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/units/angle.hpp"
|
||||
#include "wpi/units/angular_velocity.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* SystemCore onboard IMU
|
||||
@@ -42,7 +42,7 @@ class OnboardIMU {
|
||||
* Get the yaw value
|
||||
* @return yaw value
|
||||
*/
|
||||
units::radian_t GetYaw();
|
||||
wpi::units::radian_t GetYaw();
|
||||
|
||||
/**
|
||||
* Reset the current yaw value to 0. Future reads of the yaw value will be
|
||||
@@ -51,80 +51,80 @@ class OnboardIMU {
|
||||
void ResetYaw();
|
||||
|
||||
/**
|
||||
* Get the yaw as a Rotation2d.
|
||||
* Get the yaw as a wpi::math::Rotation2d.
|
||||
* @return yaw
|
||||
*/
|
||||
Rotation2d GetRotation2d();
|
||||
wpi::math::Rotation2d GetRotation2d();
|
||||
|
||||
/**
|
||||
* Get the 3D orientation as a Rotation3d.
|
||||
* Get the 3D orientation as a wpi::math::Rotation3d.
|
||||
* @return 3D orientation
|
||||
*/
|
||||
Rotation3d GetRotation3d();
|
||||
wpi::math::Rotation3d GetRotation3d();
|
||||
|
||||
/**
|
||||
* Get the 3D orientation as a Quaternion.
|
||||
* Get the 3D orientation as a wpi::math::Quaternion.
|
||||
* @return 3D orientation
|
||||
*/
|
||||
Quaternion GetQuaternion();
|
||||
wpi::math::Quaternion GetQuaternion();
|
||||
|
||||
/**
|
||||
* Get the angle about the X axis of the IMU.
|
||||
* @return angle about the X axis
|
||||
*/
|
||||
units::radian_t GetAngleX();
|
||||
wpi::units::radian_t GetAngleX();
|
||||
|
||||
/**
|
||||
* Get the angle about the Y axis of the IMU.
|
||||
* @return angle about the Y axis
|
||||
*/
|
||||
units::radian_t GetAngleY();
|
||||
wpi::units::radian_t GetAngleY();
|
||||
|
||||
/**
|
||||
* Get the angle about the Z axis of the IMU.
|
||||
* @return angle about the Z axis
|
||||
*/
|
||||
units::radian_t GetAngleZ();
|
||||
wpi::units::radian_t GetAngleZ();
|
||||
|
||||
/**
|
||||
* Get the angular rate about the X axis of the IMU.
|
||||
* @return angular rate about the X axis
|
||||
*/
|
||||
units::radians_per_second_t GetGyroRateX();
|
||||
wpi::units::radians_per_second_t GetGyroRateX();
|
||||
|
||||
/**
|
||||
* Get the angular rate about the Y axis of the IMU.
|
||||
* @return angular rate about the Y axis
|
||||
*/
|
||||
units::radians_per_second_t GetGyroRateY();
|
||||
wpi::units::radians_per_second_t GetGyroRateY();
|
||||
|
||||
/**
|
||||
* Get the angular rate about the Z axis of the IMU.
|
||||
* @return angular rate about the Z axis
|
||||
*/
|
||||
units::radians_per_second_t GetGyroRateZ();
|
||||
wpi::units::radians_per_second_t GetGyroRateZ();
|
||||
|
||||
/**
|
||||
* Get the acceleration along the X axis of the IMU.
|
||||
* @return acceleration along the X axis
|
||||
*/
|
||||
units::meters_per_second_squared_t GetAccelX();
|
||||
wpi::units::meters_per_second_squared_t GetAccelX();
|
||||
|
||||
/**
|
||||
* Get the acceleration along the Z axis of the IMU.
|
||||
* @return acceleration along the Z axis
|
||||
*/
|
||||
units::meters_per_second_squared_t GetAccelY();
|
||||
wpi::units::meters_per_second_squared_t GetAccelY();
|
||||
|
||||
/**
|
||||
* Get the acceleration along the Z axis of the IMU.
|
||||
* @return acceleration along the Z axis
|
||||
*/
|
||||
units::meters_per_second_squared_t GetAccelZ();
|
||||
wpi::units::meters_per_second_squared_t GetAccelZ();
|
||||
|
||||
private:
|
||||
units::radian_t GetYawNoOffset();
|
||||
wpi::units::radian_t GetYawNoOffset();
|
||||
MountOrientation m_mountOrientation;
|
||||
units::radian_t m_yawOffset{0};
|
||||
wpi::units::radian_t m_yawOffset{0};
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/util/Color.hpp"
|
||||
#include "wpi/util/Color8Bit.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* A class for driving addressable LEDs, such as WS2812B, WS2815, and NeoPixels.
|
||||
@@ -171,7 +171,7 @@ class AddressableLED {
|
||||
std::span<const LEDData> ledData);
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_AddressableLEDHandle, HAL_FreeAddressableLED> m_handle;
|
||||
wpi::hal::Handle<HAL_AddressableLEDHandle, HAL_FreeAddressableLED> m_handle;
|
||||
int m_channel;
|
||||
int m_start{0};
|
||||
int m_length{0};
|
||||
@@ -182,4 +182,4 @@ constexpr auto format_as(AddressableLED::ColorOrder order) {
|
||||
return static_cast<int32_t>(order);
|
||||
}
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/units/velocity.hpp"
|
||||
#include "wpi/util/Color.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
class LEDPattern {
|
||||
public:
|
||||
@@ -26,27 +26,27 @@ class LEDPattern {
|
||||
*/
|
||||
class LEDReader {
|
||||
public:
|
||||
LEDReader(std::function<frc::AddressableLED::LEDData(int)> impl,
|
||||
LEDReader(std::function<wpi::AddressableLED::LEDData(int)> impl,
|
||||
size_t size)
|
||||
: m_impl{std::move(impl)}, m_size{size} {}
|
||||
|
||||
frc::AddressableLED::LEDData operator[](size_t index) const {
|
||||
wpi::AddressableLED::LEDData operator[](size_t index) const {
|
||||
return m_impl(index);
|
||||
}
|
||||
|
||||
size_t size() const { return m_size; }
|
||||
|
||||
private:
|
||||
std::function<frc::AddressableLED::LEDData(int)> m_impl;
|
||||
std::function<wpi::AddressableLED::LEDData(int)> m_impl;
|
||||
size_t m_size;
|
||||
};
|
||||
|
||||
explicit LEDPattern(std::function<void(frc::LEDPattern::LEDReader,
|
||||
std::function<void(int, frc::Color)>)>
|
||||
explicit LEDPattern(std::function<void(wpi::LEDPattern::LEDReader,
|
||||
std::function<void(int, wpi::Color)>)>
|
||||
impl);
|
||||
|
||||
void ApplyTo(LEDReader reader,
|
||||
std::function<void(int, frc::Color)> writer) const;
|
||||
std::function<void(int, wpi::Color)> writer) const;
|
||||
|
||||
/**
|
||||
* Writes the pattern to an LED buffer. Dynamic animations should be called
|
||||
@@ -61,8 +61,8 @@ class LEDPattern {
|
||||
* @param data the current data of the LED strip
|
||||
* @param writer data writer for setting new LED colors on the LED strip
|
||||
*/
|
||||
void ApplyTo(std::span<frc::AddressableLED::LEDData> data,
|
||||
std::function<void(int, frc::Color)> writer) const;
|
||||
void ApplyTo(std::span<wpi::AddressableLED::LEDData> data,
|
||||
std::function<void(int, wpi::Color)> writer) const;
|
||||
|
||||
/**
|
||||
* Writes the pattern to an LED buffer. Dynamic animations should be called
|
||||
@@ -76,7 +76,7 @@ class LEDPattern {
|
||||
*
|
||||
* @param data the current data of the LED strip
|
||||
*/
|
||||
void ApplyTo(std::span<frc::AddressableLED::LEDData> data) const;
|
||||
void ApplyTo(std::span<wpi::AddressableLED::LEDData> data) const;
|
||||
|
||||
/**
|
||||
* Creates a pattern with remapped indices.
|
||||
@@ -120,7 +120,7 @@ class LEDPattern {
|
||||
* long (assuming equal LED density on both segments).
|
||||
*/
|
||||
[[nodiscard]]
|
||||
LEDPattern ScrollAtRelativeSpeed(units::hertz_t velocity);
|
||||
LEDPattern ScrollAtRelativeSpeed(wpi::units::hertz_t velocity);
|
||||
|
||||
/**
|
||||
* Creates a pattern that plays this one scrolling up an LED strip. A negative
|
||||
@@ -131,11 +131,11 @@ class LEDPattern {
|
||||
*
|
||||
* <pre>
|
||||
* // LEDs per meter, a known value taken from the spec sheet of our
|
||||
* particular LED strip units::meter_t LED_SPACING = units::meter_t{1 /60.0};
|
||||
* particular LED strip wpi::units::meter_t LED_SPACING = wpi::units::meter_t{1 /60.0};
|
||||
*
|
||||
* frc::LEDPattern rainbow = frc::LEDPattern::Rainbow();
|
||||
* frc::LEDPattern scrollingRainbow =
|
||||
* rainbow.ScrollAtAbsoluteSpeed(units::feet_per_second_t{1 / 3.0},
|
||||
* wpi::LEDPattern rainbow = wpi::LEDPattern::Rainbow();
|
||||
* wpi::LEDPattern scrollingRainbow =
|
||||
* rainbow.ScrollAtAbsoluteSpeed(wpi::units::feet_per_second_t{1 / 3.0},
|
||||
* LED_SPACING);
|
||||
* </pre>
|
||||
*
|
||||
@@ -149,8 +149,8 @@ class LEDPattern {
|
||||
* @return the scrolling pattern
|
||||
*/
|
||||
[[nodiscard]]
|
||||
LEDPattern ScrollAtAbsoluteSpeed(units::meters_per_second_t velocity,
|
||||
units::meter_t ledSpacing);
|
||||
LEDPattern ScrollAtAbsoluteSpeed(wpi::units::meters_per_second_t velocity,
|
||||
wpi::units::meter_t ledSpacing);
|
||||
|
||||
/**
|
||||
* Creates a pattern that switches between playing this pattern and turning
|
||||
@@ -161,10 +161,10 @@ class LEDPattern {
|
||||
* @return the blinking pattern
|
||||
*/
|
||||
[[nodiscard]]
|
||||
LEDPattern Blink(units::second_t onTime, units::second_t offTime);
|
||||
LEDPattern Blink(wpi::units::second_t onTime, wpi::units::second_t offTime);
|
||||
|
||||
/**
|
||||
* Like {@link LEDPattern::Blink(units::second_t)}, but where the
|
||||
* Like {@link LEDPattern::Blink(wpi::units::second_t)}, but where the
|
||||
* "off" time is exactly equal to the "on" time.
|
||||
*
|
||||
* @param onTime how long the pattern should play for (and be turned off for),
|
||||
@@ -172,7 +172,7 @@ class LEDPattern {
|
||||
* @return the blinking pattern
|
||||
*/
|
||||
[[nodiscard]]
|
||||
LEDPattern Blink(units::second_t onTime);
|
||||
LEDPattern Blink(wpi::units::second_t onTime);
|
||||
|
||||
/**
|
||||
* Creates a pattern that blinks this one on and off in sync with a true/false
|
||||
@@ -194,11 +194,11 @@ class LEDPattern {
|
||||
* @return the breathing pattern
|
||||
*/
|
||||
[[nodiscard]]
|
||||
LEDPattern Breathe(units::second_t period);
|
||||
LEDPattern Breathe(wpi::units::second_t period);
|
||||
|
||||
/**
|
||||
* Creates a pattern that plays this pattern overlaid on another. Anywhere
|
||||
* this pattern sets an LED to off (or {@link frc::Color::kBlack}), the base
|
||||
* this pattern sets an LED to off (or {@link wpi::Color::kBlack}), the base
|
||||
* pattern will be displayed instead.
|
||||
*
|
||||
* @param base the base pattern to overlay on top of
|
||||
@@ -255,10 +255,10 @@ class LEDPattern {
|
||||
*
|
||||
* <pre>
|
||||
* // Solid red, but at 50% brightness
|
||||
* frc::LEDPattern::Solid(frc::Color::kRed).AtBrightness(0.5);
|
||||
* wpi::LEDPattern::Solid(wpi::Color::kRed).AtBrightness(0.5);
|
||||
*
|
||||
* // Solid white, but at only 10% (i.e. ~0.5V)
|
||||
* frc::LEDPattern::Solid(frc:Color::kWhite).AtBrightness(0.1);
|
||||
* wpi::LEDPattern::Solid(frc:Color::kWhite).AtBrightness(0.1);
|
||||
* </pre>
|
||||
*
|
||||
* @param relativeBrightness the multiplier to apply to all channels to modify
|
||||
@@ -294,10 +294,10 @@ class LEDPattern {
|
||||
* travel.
|
||||
*
|
||||
* <pre>
|
||||
* frc::LEDPattern basePattern =
|
||||
* frc::LEDPattern::Gradient(frc::Color::kRed, frc::Color::kBlue);
|
||||
* frc::LEDPattern progressPattern =
|
||||
* basePattern.Mask(frc::LEDPattern::ProgressMaskLayer([&]() {
|
||||
* wpi::LEDPattern basePattern =
|
||||
* wpi::LEDPattern::Gradient(wpi::Color::kRed, wpi::Color::kBlue);
|
||||
* wpi::LEDPattern progressPattern =
|
||||
* basePattern.Mask(wpi::LEDPattern::ProgressMaskLayer([&]() {
|
||||
* return elevator.GetHeight() / elevator.MaxHeight();
|
||||
* });
|
||||
* </pre>
|
||||
@@ -396,8 +396,8 @@ class LEDPattern {
|
||||
static LEDPattern Rainbow(int saturation, int value);
|
||||
|
||||
private:
|
||||
std::function<void(frc::LEDPattern::LEDReader,
|
||||
std::function<void(int, frc::Color)>)>
|
||||
std::function<void(wpi::LEDPattern::LEDReader,
|
||||
std::function<void(int, wpi::Color)>)>
|
||||
m_impl;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "wpi/units/voltage.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Interface for motor controlling devices.
|
||||
@@ -34,7 +34,7 @@ class MotorController {
|
||||
*
|
||||
* @param output The voltage to output.
|
||||
*/
|
||||
virtual void SetVoltage(units::volt_t output);
|
||||
virtual void SetVoltage(wpi::units::volt_t output);
|
||||
|
||||
/**
|
||||
* Common interface for getting the current set speed of a motor controller.
|
||||
@@ -68,4 +68,4 @@ class MotorController {
|
||||
virtual void StopMotor() = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Allows multiple MotorController objects to be linked together.
|
||||
@@ -22,9 +22,9 @@ namespace frc {
|
||||
class [[deprecated(
|
||||
"Use PWMMotorController::AddFollower() or if using CAN motor controllers,"
|
||||
"use their method of following.")]] MotorControllerGroup
|
||||
: public wpi::Sendable,
|
||||
: public wpi::util::Sendable,
|
||||
public MotorController,
|
||||
public wpi::SendableHelper<MotorControllerGroup> {
|
||||
public wpi::util::SendableHelper<MotorControllerGroup> {
|
||||
public:
|
||||
/**
|
||||
* Create a new MotorControllerGroup with the provided MotorControllers.
|
||||
@@ -53,14 +53,14 @@ class [[deprecated(
|
||||
MotorControllerGroup& operator=(MotorControllerGroup&&) = default;
|
||||
|
||||
void Set(double speed) override;
|
||||
void SetVoltage(units::volt_t output) override;
|
||||
void SetVoltage(wpi::units::volt_t output) override;
|
||||
double Get() const override;
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
void Disable() override;
|
||||
void StopMotor() override;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
bool m_isInverted = false;
|
||||
@@ -69,6 +69,6 @@ class [[deprecated(
|
||||
void Initialize();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* The Motor Safety feature acts as a watchdog timer for an individual motor. It
|
||||
@@ -41,14 +41,14 @@ class MotorSafety {
|
||||
*
|
||||
* @param expirationTime The timeout value.
|
||||
*/
|
||||
void SetExpiration(units::second_t expirationTime);
|
||||
void SetExpiration(wpi::units::second_t expirationTime);
|
||||
|
||||
/**
|
||||
* Retrieve the timeout value for the corresponding motor safety object.
|
||||
*
|
||||
* @return the timeout value.
|
||||
*/
|
||||
units::second_t GetExpiration() const;
|
||||
wpi::units::second_t GetExpiration() const;
|
||||
|
||||
/**
|
||||
* Determine if the motor is still operating or has timed out.
|
||||
@@ -108,15 +108,15 @@ class MotorSafety {
|
||||
static constexpr auto kDefaultSafetyExpiration = 100_ms;
|
||||
|
||||
// The expiration time for this object
|
||||
units::second_t m_expiration = kDefaultSafetyExpiration;
|
||||
wpi::units::second_t m_expiration = kDefaultSafetyExpiration;
|
||||
|
||||
// True if motor safety is enabled for this motor
|
||||
bool m_enabled = false;
|
||||
|
||||
// The FPGA clock value when the motor has expired
|
||||
units::second_t m_stopTime = Timer::GetFPGATimestamp();
|
||||
wpi::units::second_t m_stopTime = Timer::GetFPGATimestamp();
|
||||
|
||||
mutable wpi::mutex m_thisMutex;
|
||||
mutable wpi::util::mutex m_thisMutex;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
WPI_IGNORE_DEPRECATED
|
||||
|
||||
@@ -30,8 +30,8 @@ WPI_IGNORE_DEPRECATED
|
||||
*/
|
||||
class PWMMotorController : public MotorController,
|
||||
public MotorSafety,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<PWMMotorController> {
|
||||
public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<PWMMotorController> {
|
||||
public:
|
||||
PWMMotorController(PWMMotorController&&) = default;
|
||||
PWMMotorController& operator=(PWMMotorController&&) = default;
|
||||
@@ -58,7 +58,7 @@ class PWMMotorController : public MotorController,
|
||||
*
|
||||
* @param output The voltage to output.
|
||||
*/
|
||||
void SetVoltage(units::volt_t output) override;
|
||||
void SetVoltage(wpi::units::volt_t output) override;
|
||||
|
||||
/**
|
||||
* Get the recently set value of the PWM. This value is affected by the
|
||||
@@ -76,7 +76,7 @@ class PWMMotorController : public MotorController,
|
||||
* @return The voltage of the motor controller, nominally between -12 V and 12
|
||||
* V.
|
||||
*/
|
||||
virtual units::volt_t GetVoltage() const;
|
||||
virtual wpi::units::volt_t GetVoltage() const;
|
||||
|
||||
void SetInverted(bool isInverted) override;
|
||||
|
||||
@@ -128,7 +128,7 @@ class PWMMotorController : public MotorController,
|
||||
*/
|
||||
PWMMotorController(std::string_view name, int channel);
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
/// PWM instances for motor controller.
|
||||
PWM m_pwm;
|
||||
@@ -136,35 +136,35 @@ class PWMMotorController : public MotorController,
|
||||
void SetSpeed(double speed);
|
||||
double GetSpeed() const;
|
||||
|
||||
void SetBounds(units::microsecond_t maxPwm,
|
||||
units::microsecond_t deadbandMaxPwm,
|
||||
units::microsecond_t centerPwm,
|
||||
units::microsecond_t deadbandMinPwm,
|
||||
units::microsecond_t minPwm);
|
||||
void SetBounds(wpi::units::microsecond_t maxPwm,
|
||||
wpi::units::microsecond_t deadbandMaxPwm,
|
||||
wpi::units::microsecond_t centerPwm,
|
||||
wpi::units::microsecond_t deadbandMinPwm,
|
||||
wpi::units::microsecond_t minPwm);
|
||||
|
||||
private:
|
||||
bool m_isInverted = false;
|
||||
std::vector<PWMMotorController*> m_nonowningFollowers;
|
||||
std::vector<std::unique_ptr<PWMMotorController>> m_owningFollowers;
|
||||
|
||||
hal::SimDevice m_simDevice;
|
||||
hal::SimDouble m_simSpeed;
|
||||
wpi::hal::SimDevice m_simDevice;
|
||||
wpi::hal::SimDouble m_simSpeed;
|
||||
|
||||
bool m_eliminateDeadband{0};
|
||||
units::microsecond_t m_minPwm{0};
|
||||
units::microsecond_t m_deadbandMinPwm{0};
|
||||
units::microsecond_t m_centerPwm{0};
|
||||
units::microsecond_t m_deadbandMaxPwm{0};
|
||||
units::microsecond_t m_maxPwm{0};
|
||||
wpi::units::microsecond_t m_minPwm{0};
|
||||
wpi::units::microsecond_t m_deadbandMinPwm{0};
|
||||
wpi::units::microsecond_t m_centerPwm{0};
|
||||
wpi::units::microsecond_t m_deadbandMaxPwm{0};
|
||||
wpi::units::microsecond_t m_maxPwm{0};
|
||||
|
||||
units::microsecond_t GetMinPositivePwm() const;
|
||||
units::microsecond_t GetMaxNegativePwm() const;
|
||||
units::microsecond_t GetPositiveScaleFactor() const;
|
||||
units::microsecond_t GetNegativeScaleFactor() const;
|
||||
wpi::units::microsecond_t GetMinPositivePwm() const;
|
||||
wpi::units::microsecond_t GetMaxNegativePwm() const;
|
||||
wpi::units::microsecond_t GetPositiveScaleFactor() const;
|
||||
wpi::units::microsecond_t GetNegativeScaleFactor() const;
|
||||
|
||||
PWM* GetPwm() { return &m_pwm; }
|
||||
};
|
||||
|
||||
WPI_UNIGNORE_DEPRECATED
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Class for operating a compressor connected to a pneumatics module.
|
||||
@@ -30,8 +30,8 @@ namespace frc {
|
||||
* loop control. You can only turn off closed loop control, thereby stopping
|
||||
* the compressor from operating.
|
||||
*/
|
||||
class Compressor : public wpi::Sendable,
|
||||
public wpi::SendableHelper<Compressor> {
|
||||
class Compressor : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<Compressor> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a compressor for a specified module and type.
|
||||
@@ -78,7 +78,7 @@ class Compressor : public wpi::Sendable,
|
||||
*
|
||||
* @return Current drawn by the compressor.
|
||||
*/
|
||||
units::ampere_t GetCurrent() const;
|
||||
wpi::units::ampere_t GetCurrent() const;
|
||||
|
||||
/**
|
||||
* If supported by the device, returns the analog input voltage (on channel
|
||||
@@ -89,7 +89,7 @@ class Compressor : public wpi::Sendable,
|
||||
*
|
||||
* @return The analog input voltage, in volts.
|
||||
*/
|
||||
units::volt_t GetAnalogVoltage() const;
|
||||
wpi::units::volt_t GetAnalogVoltage() const;
|
||||
|
||||
/**
|
||||
* If supported by the device, returns the pressure read by the analog
|
||||
@@ -100,7 +100,7 @@ class Compressor : public wpi::Sendable,
|
||||
*
|
||||
* @return The pressure read by the analog pressure sensor.
|
||||
*/
|
||||
units::pounds_per_square_inch_t GetPressure() const;
|
||||
wpi::units::pounds_per_square_inch_t GetPressure() const;
|
||||
|
||||
/**
|
||||
* Disable the compressor.
|
||||
@@ -130,8 +130,8 @@ class Compressor : public wpi::Sendable,
|
||||
* @param maxPressure The maximum pressure. The compressor will turn off when
|
||||
* the pressure reaches this value.
|
||||
*/
|
||||
void EnableAnalog(units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure);
|
||||
void EnableAnalog(wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure);
|
||||
|
||||
/**
|
||||
* If supported by the device, enables the compressor in hybrid mode. This
|
||||
@@ -162,8 +162,8 @@ class Compressor : public wpi::Sendable,
|
||||
* off when the pressure reaches this value or the pressure switch is
|
||||
* disconnected or indicates that the system is full.
|
||||
*/
|
||||
void EnableHybrid(units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure);
|
||||
void EnableHybrid(wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure);
|
||||
|
||||
/**
|
||||
* Returns the active compressor configuration.
|
||||
@@ -172,11 +172,11 @@ class Compressor : public wpi::Sendable,
|
||||
*/
|
||||
CompressorConfigType GetConfigType() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<PneumaticsBase> m_module;
|
||||
PneumaticsModuleType m_moduleType;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/**
|
||||
* Compressor config type.
|
||||
*/
|
||||
@@ -19,4 +19,4 @@ enum class CompressorConfigType {
|
||||
Hybrid = 3
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* DoubleSolenoid class for running 2 channels of high voltage Digital Output
|
||||
@@ -21,8 +21,8 @@ namespace frc {
|
||||
* The DoubleSolenoid class is typically used for pneumatics solenoids that
|
||||
* have two positions controlled by two separate channels.
|
||||
*/
|
||||
class DoubleSolenoid : public wpi::Sendable,
|
||||
public wpi::SendableHelper<DoubleSolenoid> {
|
||||
class DoubleSolenoid : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<DoubleSolenoid> {
|
||||
public:
|
||||
/**
|
||||
* Possible values for a DoubleSolenoid.
|
||||
@@ -125,7 +125,7 @@ class DoubleSolenoid : public wpi::Sendable,
|
||||
*/
|
||||
bool IsRevSolenoidDisabled() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<PneumaticsBase> m_module;
|
||||
@@ -136,4 +136,4 @@ class DoubleSolenoid : public wpi::Sendable,
|
||||
int m_mask;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/DenseMap.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/** Module class for controlling a REV Robotics Pneumatic Hub. */
|
||||
class PneumaticHub : public PneumaticsBase {
|
||||
public:
|
||||
@@ -57,8 +57,8 @@ class PneumaticHub : public PneumaticsBase {
|
||||
* minPressure.
|
||||
*/
|
||||
void EnableCompressorAnalog(
|
||||
units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure) override;
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) override;
|
||||
|
||||
/**
|
||||
* Enables the compressor in hybrid mode. This mode uses both a digital
|
||||
@@ -87,14 +87,14 @@ class PneumaticHub : public PneumaticsBase {
|
||||
* minPressure.
|
||||
*/
|
||||
void EnableCompressorHybrid(
|
||||
units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure) override;
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) override;
|
||||
|
||||
CompressorConfigType GetCompressorConfigType() const override;
|
||||
|
||||
bool GetPressureSwitch() const override;
|
||||
|
||||
units::ampere_t GetCompressorCurrent() const override;
|
||||
wpi::units::ampere_t GetCompressorCurrent() const override;
|
||||
|
||||
void SetSolenoids(int mask, int values) override;
|
||||
|
||||
@@ -106,7 +106,7 @@ class PneumaticHub : public PneumaticsBase {
|
||||
|
||||
void FireOneShot(int index) override;
|
||||
|
||||
void SetOneShotDuration(int index, units::second_t duration) override;
|
||||
void SetOneShotDuration(int index, wpi::units::second_t duration) override;
|
||||
|
||||
bool CheckSolenoidChannel(int channel) const override;
|
||||
|
||||
@@ -255,28 +255,28 @@ class PneumaticHub : public PneumaticsBase {
|
||||
*
|
||||
* @return The input voltage.
|
||||
*/
|
||||
units::volt_t GetInputVoltage() const;
|
||||
wpi::units::volt_t GetInputVoltage() const;
|
||||
|
||||
/**
|
||||
* Returns the current voltage of the regulated 5v supply.
|
||||
*
|
||||
* @return The current voltage of the 5v supply.
|
||||
*/
|
||||
units::volt_t Get5VRegulatedVoltage() const;
|
||||
wpi::units::volt_t Get5VRegulatedVoltage() const;
|
||||
|
||||
/**
|
||||
* Returns the total current drawn by all solenoids.
|
||||
*
|
||||
* @return Total current drawn by all solenoids.
|
||||
*/
|
||||
units::ampere_t GetSolenoidsTotalCurrent() const;
|
||||
wpi::units::ampere_t GetSolenoidsTotalCurrent() const;
|
||||
|
||||
/**
|
||||
* Returns the current voltage of the solenoid power supply.
|
||||
*
|
||||
* @return The current voltage of the solenoid power supply.
|
||||
*/
|
||||
units::volt_t GetSolenoidsVoltage() const;
|
||||
wpi::units::volt_t GetSolenoidsVoltage() const;
|
||||
|
||||
/**
|
||||
* Returns the raw voltage of the specified analog input channel.
|
||||
@@ -284,7 +284,7 @@ class PneumaticHub : public PneumaticsBase {
|
||||
* @param channel The analog input channel to read voltage from.
|
||||
* @return The voltage of the specified analog input channel.
|
||||
*/
|
||||
units::volt_t GetAnalogVoltage(int channel) const override;
|
||||
wpi::units::volt_t GetAnalogVoltage(int channel) const override;
|
||||
|
||||
/**
|
||||
* Returns the pressure read by an analog pressure sensor on the specified
|
||||
@@ -294,7 +294,7 @@ class PneumaticHub : public PneumaticsBase {
|
||||
* @return The pressure read by an analog pressure sensor on the specified
|
||||
* analog input channel.
|
||||
*/
|
||||
units::pounds_per_square_inch_t GetPressure(int channel) const override;
|
||||
wpi::units::pounds_per_square_inch_t GetPressure(int channel) const override;
|
||||
|
||||
private:
|
||||
class DataStore;
|
||||
@@ -308,9 +308,9 @@ class PneumaticHub : public PneumaticsBase {
|
||||
HAL_REVPHHandle m_handle;
|
||||
int m_module;
|
||||
|
||||
static wpi::mutex m_handleLock;
|
||||
static std::unique_ptr<wpi::DenseMap<int, std::weak_ptr<DataStore>>[]>
|
||||
static wpi::util::mutex m_handleLock;
|
||||
static std::unique_ptr<wpi::util::DenseMap<int, std::weak_ptr<DataStore>>[]>
|
||||
m_handleMaps;
|
||||
static std::weak_ptr<DataStore>& GetDataStore(int busId, int module);
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/units/voltage.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
class Solenoid;
|
||||
class DoubleSolenoid;
|
||||
class Compressor;
|
||||
@@ -46,7 +46,7 @@ class PneumaticsBase {
|
||||
*
|
||||
* @return The current drawn by the compressor.
|
||||
*/
|
||||
virtual units::ampere_t GetCompressorCurrent() const = 0;
|
||||
virtual wpi::units::ampere_t GetCompressorCurrent() const = 0;
|
||||
|
||||
/** Disables the compressor. */
|
||||
virtual void DisableCompressor() = 0;
|
||||
@@ -75,8 +75,8 @@ class PneumaticsBase {
|
||||
* off when the pressure reaches this value.
|
||||
*/
|
||||
virtual void EnableCompressorAnalog(
|
||||
units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure) = 0;
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) = 0;
|
||||
|
||||
/**
|
||||
* If supported by the device, enables the compressor in hybrid mode. This
|
||||
@@ -108,8 +108,8 @@ class PneumaticsBase {
|
||||
* disconnected or indicates that the system is full.
|
||||
*/
|
||||
virtual void EnableCompressorHybrid(
|
||||
units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure) = 0;
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) = 0;
|
||||
|
||||
/**
|
||||
* Returns the active compressor configuration.
|
||||
@@ -164,7 +164,7 @@ class PneumaticsBase {
|
||||
* @param index solenoid index
|
||||
* @param duration shot duration
|
||||
*/
|
||||
virtual void SetOneShotDuration(int index, units::second_t duration) = 0;
|
||||
virtual void SetOneShotDuration(int index, wpi::units::second_t duration) = 0;
|
||||
|
||||
/**
|
||||
* Check if a solenoid channel is valid.
|
||||
@@ -215,7 +215,7 @@ class PneumaticsBase {
|
||||
* @param channel The analog input channel to read voltage from.
|
||||
* @return The voltage of the specified analog input channel.
|
||||
*/
|
||||
virtual units::volt_t GetAnalogVoltage(int channel) const = 0;
|
||||
virtual wpi::units::volt_t GetAnalogVoltage(int channel) const = 0;
|
||||
|
||||
/**
|
||||
* If supported by the device, returns the pressure read by an analog
|
||||
@@ -228,7 +228,7 @@ class PneumaticsBase {
|
||||
* @return The pressure read by an analog pressure sensor on the
|
||||
* specified analog input channel.
|
||||
*/
|
||||
virtual units::pounds_per_square_inch_t GetPressure(int channel) const = 0;
|
||||
virtual wpi::units::pounds_per_square_inch_t GetPressure(int channel) const = 0;
|
||||
|
||||
/**
|
||||
* Create a solenoid object for the specified channel.
|
||||
@@ -282,4 +282,4 @@ class PneumaticsBase {
|
||||
*/
|
||||
static int GetDefaultForType(PneumaticsModuleType moduleType);
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/DenseMap.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/** Module class for controlling a Cross The Road Electronics Pneumatics Control
|
||||
* Module. */
|
||||
class PneumaticsControlModule : public PneumaticsBase {
|
||||
@@ -52,8 +52,8 @@ class PneumaticsControlModule : public PneumaticsBase {
|
||||
* @see EnableCompressorDigital()
|
||||
*/
|
||||
void EnableCompressorAnalog(
|
||||
units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure) override;
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) override;
|
||||
|
||||
/**
|
||||
* Enables the compressor in digital mode. Hybrid mode is unsupported by the
|
||||
@@ -64,14 +64,14 @@ class PneumaticsControlModule : public PneumaticsBase {
|
||||
* @see EnableCompressorDigital()
|
||||
*/
|
||||
void EnableCompressorHybrid(
|
||||
units::pounds_per_square_inch_t minPressure,
|
||||
units::pounds_per_square_inch_t maxPressure) override;
|
||||
wpi::units::pounds_per_square_inch_t minPressure,
|
||||
wpi::units::pounds_per_square_inch_t maxPressure) override;
|
||||
|
||||
CompressorConfigType GetCompressorConfigType() const override;
|
||||
|
||||
bool GetPressureSwitch() const override;
|
||||
|
||||
units::ampere_t GetCompressorCurrent() const override;
|
||||
wpi::units::ampere_t GetCompressorCurrent() const override;
|
||||
|
||||
/**
|
||||
* Return whether the compressor current is currently too high.
|
||||
@@ -161,7 +161,7 @@ class PneumaticsControlModule : public PneumaticsBase {
|
||||
|
||||
void FireOneShot(int index) override;
|
||||
|
||||
void SetOneShotDuration(int index, units::second_t duration) override;
|
||||
void SetOneShotDuration(int index, wpi::units::second_t duration) override;
|
||||
|
||||
bool CheckSolenoidChannel(int channel) const override;
|
||||
|
||||
@@ -179,7 +179,7 @@ class PneumaticsControlModule : public PneumaticsBase {
|
||||
* @param channel Unsupported.
|
||||
* @return 0
|
||||
*/
|
||||
units::volt_t GetAnalogVoltage(int channel) const override;
|
||||
wpi::units::volt_t GetAnalogVoltage(int channel) const override;
|
||||
|
||||
/**
|
||||
* Unsupported by the CTRE PCM.
|
||||
@@ -187,7 +187,7 @@ class PneumaticsControlModule : public PneumaticsBase {
|
||||
* @param channel Unsupported.
|
||||
* @return 0
|
||||
*/
|
||||
units::pounds_per_square_inch_t GetPressure(int channel) const override;
|
||||
wpi::units::pounds_per_square_inch_t GetPressure(int channel) const override;
|
||||
|
||||
Solenoid MakeSolenoid(int channel) override;
|
||||
DoubleSolenoid MakeDoubleSolenoid(int forwardChannel,
|
||||
@@ -208,9 +208,9 @@ class PneumaticsControlModule : public PneumaticsBase {
|
||||
HAL_CTREPCMHandle m_handle;
|
||||
int m_module;
|
||||
|
||||
static wpi::mutex m_handleLock;
|
||||
static std::unique_ptr<wpi::DenseMap<int, std::weak_ptr<DataStore>>[]>
|
||||
static wpi::util::mutex m_handleLock;
|
||||
static std::unique_ptr<wpi::util::DenseMap<int, std::weak_ptr<DataStore>>[]>
|
||||
m_handleMaps;
|
||||
static std::weak_ptr<DataStore>& GetDataStore(int busId, int module);
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/**
|
||||
* Pneumatics module type.
|
||||
*/
|
||||
@@ -14,4 +14,4 @@ enum class PneumaticsModuleType {
|
||||
/// REV PH.
|
||||
REVPH
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Solenoid class for running high voltage Digital Output on a pneumatics
|
||||
@@ -22,7 +22,7 @@ namespace frc {
|
||||
* The Solenoid class is typically used for pneumatics solenoids, but could be
|
||||
* used for any device within the current spec of the module.
|
||||
*/
|
||||
class Solenoid : public wpi::Sendable, public wpi::SendableHelper<Solenoid> {
|
||||
class Solenoid : public wpi::util::Sendable, public wpi::util::SendableHelper<Solenoid> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a solenoid for a specified module and type.
|
||||
@@ -100,7 +100,7 @@ class Solenoid : public wpi::Sendable, public wpi::SendableHelper<Solenoid> {
|
||||
*
|
||||
* @see startPulse()
|
||||
*/
|
||||
void SetPulseDuration(units::second_t duration);
|
||||
void SetPulseDuration(wpi::units::second_t duration);
|
||||
|
||||
/**
|
||||
* %Trigger the pneumatics module to generate a pulse of the duration set in
|
||||
@@ -110,7 +110,7 @@ class Solenoid : public wpi::Sendable, public wpi::SendableHelper<Solenoid> {
|
||||
*/
|
||||
void StartPulse();
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<PneumaticsBase> m_module;
|
||||
@@ -118,4 +118,4 @@ class Solenoid : public wpi::Sendable, public wpi::SendableHelper<Solenoid> {
|
||||
int m_channel;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Class for getting voltage, current, temperature, power and energy from the
|
||||
* CTRE Power Distribution Panel (PDP) or REV Power Distribution Hub (PDH).
|
||||
*/
|
||||
class PowerDistribution : public wpi::Sendable,
|
||||
public wpi::SendableHelper<PowerDistribution> {
|
||||
class PowerDistribution : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<PowerDistribution> {
|
||||
public:
|
||||
/// Default module number.
|
||||
static constexpr int kDefaultModule = -1;
|
||||
@@ -343,11 +343,11 @@ class PowerDistribution : public wpi::Sendable,
|
||||
*/
|
||||
StickyFaults GetStickyFaults() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
hal::Handle<HAL_PowerDistributionHandle, HAL_CleanPowerDistribution> m_handle;
|
||||
wpi::hal::Handle<HAL_PowerDistributionHandle, HAL_CleanPowerDistribution> m_handle;
|
||||
int m_module;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
class SharpIR : public wpi::Sendable, public wpi::SendableHelper<SharpIR> {
|
||||
class SharpIR : public wpi::util::Sendable, public wpi::util::SendableHelper<SharpIR> {
|
||||
public:
|
||||
/**
|
||||
* Sharp GP2Y0A02YK0F is an analog IR sensor capable of measuring
|
||||
@@ -65,8 +65,8 @@ class SharpIR : public wpi::Sendable, public wpi::SendableHelper<SharpIR> {
|
||||
* @param min Minimum distance to report
|
||||
* @param max Maximum distance to report
|
||||
*/
|
||||
SharpIR(int channel, double a, double b, units::meter_t min,
|
||||
units::meter_t max);
|
||||
SharpIR(int channel, double a, double b, wpi::units::meter_t min,
|
||||
wpi::units::meter_t max);
|
||||
|
||||
/**
|
||||
* Get the analog input channel number.
|
||||
@@ -80,20 +80,20 @@ class SharpIR : public wpi::Sendable, public wpi::SendableHelper<SharpIR> {
|
||||
*
|
||||
* @return range of the target returned by the sensor
|
||||
*/
|
||||
units::meter_t GetRange() const;
|
||||
wpi::units::meter_t GetRange() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
AnalogInput m_sensor;
|
||||
|
||||
hal::SimDevice m_simDevice;
|
||||
hal::SimDouble m_simRange;
|
||||
wpi::hal::SimDevice m_simDevice;
|
||||
wpi::hal::SimDouble m_simRange;
|
||||
|
||||
double m_A;
|
||||
double m_B;
|
||||
units::meter_t m_min;
|
||||
units::meter_t m_max;
|
||||
wpi::units::meter_t m_min;
|
||||
wpi::units::meter_t m_max;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
class AnalogInput;
|
||||
|
||||
/**
|
||||
* Class for supporting continuous analog encoders, such as the US Digital MA3.
|
||||
*/
|
||||
class AnalogEncoder : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogEncoder> {
|
||||
class AnalogEncoder : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<AnalogEncoder> {
|
||||
public:
|
||||
/**
|
||||
* Construct a new AnalogEncoder attached to a specific AnalogIn channel.
|
||||
@@ -131,7 +131,7 @@ class AnalogEncoder : public wpi::Sendable,
|
||||
*/
|
||||
int GetChannel() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void Init(double fullRange, double expectedZero);
|
||||
@@ -144,7 +144,7 @@ class AnalogEncoder : public wpi::Sendable,
|
||||
double m_sensorMax{1.0};
|
||||
bool m_isInverted{false};
|
||||
|
||||
hal::SimDevice m_simDevice;
|
||||
hal::SimDouble m_simPosition;
|
||||
wpi::hal::SimDevice m_simDevice;
|
||||
wpi::hal::SimDouble m_simPosition;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Class for reading analog potentiometers. Analog potentiometers read in an
|
||||
@@ -18,8 +18,8 @@ namespace frc {
|
||||
* units you choose, by way of the scaling and offset constants passed to the
|
||||
* constructor.
|
||||
*/
|
||||
class AnalogPotentiometer : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogPotentiometer> {
|
||||
class AnalogPotentiometer : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<AnalogPotentiometer> {
|
||||
public:
|
||||
/**
|
||||
* Construct an Analog Potentiometer object from a channel number.
|
||||
@@ -101,11 +101,11 @@ class AnalogPotentiometer : public wpi::Sendable,
|
||||
*/
|
||||
double Get() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AnalogInput> m_analog_input;
|
||||
double m_fullRange, m_offset;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/**
|
||||
* Class to read a duty cycle PWM input.
|
||||
*
|
||||
@@ -21,7 +21,7 @@ namespace frc {
|
||||
* low in that frequency. These can be attached to any SmartIO.
|
||||
*
|
||||
*/
|
||||
class DutyCycle : public wpi::Sendable, public wpi::SendableHelper<DutyCycle> {
|
||||
class DutyCycle : public wpi::util::Sendable, public wpi::util::SendableHelper<DutyCycle> {
|
||||
public:
|
||||
/**
|
||||
* Constructs a DutyCycle input from a smartio channel.
|
||||
@@ -43,7 +43,7 @@ class DutyCycle : public wpi::Sendable, public wpi::SendableHelper<DutyCycle> {
|
||||
*
|
||||
* @return frequency
|
||||
*/
|
||||
units::hertz_t GetFrequency() const;
|
||||
wpi::units::hertz_t GetFrequency() const;
|
||||
|
||||
/**
|
||||
* Get the output ratio of the duty cycle signal.
|
||||
@@ -59,7 +59,7 @@ class DutyCycle : public wpi::Sendable, public wpi::SendableHelper<DutyCycle> {
|
||||
*
|
||||
* @return high time of last pulse
|
||||
*/
|
||||
units::second_t GetHighTime() const;
|
||||
wpi::units::second_t GetHighTime() const;
|
||||
|
||||
/**
|
||||
* Get the channel of the source.
|
||||
@@ -69,11 +69,11 @@ class DutyCycle : public wpi::Sendable, public wpi::SendableHelper<DutyCycle> {
|
||||
int GetSourceChannel() const;
|
||||
|
||||
protected:
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void InitDutyCycle();
|
||||
int m_channel;
|
||||
hal::Handle<HAL_DutyCycleHandle, HAL_FreeDutyCycle> m_handle;
|
||||
wpi::hal::Handle<HAL_DutyCycleHandle, HAL_FreeDutyCycle> m_handle;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
class DutyCycle;
|
||||
|
||||
/**
|
||||
@@ -21,8 +21,8 @@ class DutyCycle;
|
||||
* PWM Output, the CTRE Mag Encoder, the Rev Hex Encoder, and the AM Mag
|
||||
* Encoder.
|
||||
*/
|
||||
class DutyCycleEncoder : public wpi::Sendable,
|
||||
public wpi::SendableHelper<DutyCycleEncoder> {
|
||||
class DutyCycleEncoder : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<DutyCycleEncoder> {
|
||||
public:
|
||||
/**
|
||||
* Construct a new DutyCycleEncoder on a specific channel.
|
||||
@@ -107,7 +107,7 @@ class DutyCycleEncoder : public wpi::Sendable,
|
||||
*
|
||||
* @return duty cycle frequency
|
||||
*/
|
||||
units::hertz_t GetFrequency() const;
|
||||
wpi::units::hertz_t GetFrequency() const;
|
||||
|
||||
/**
|
||||
* Get if the sensor is connected
|
||||
@@ -126,7 +126,7 @@ class DutyCycleEncoder : public wpi::Sendable,
|
||||
*
|
||||
* @param frequency the minimum frequency.
|
||||
*/
|
||||
void SetConnectedFrequencyThreshold(units::hertz_t frequency);
|
||||
void SetConnectedFrequencyThreshold(wpi::units::hertz_t frequency);
|
||||
|
||||
/**
|
||||
* Get the encoder value.
|
||||
@@ -161,7 +161,7 @@ class DutyCycleEncoder : public wpi::Sendable,
|
||||
*
|
||||
* @param frequency the assumed frequency of the sensor
|
||||
*/
|
||||
void SetAssumedFrequency(units::hertz_t frequency);
|
||||
void SetAssumedFrequency(wpi::units::hertz_t frequency);
|
||||
|
||||
/**
|
||||
* Set if this encoder is inverted.
|
||||
@@ -177,23 +177,23 @@ class DutyCycleEncoder : public wpi::Sendable,
|
||||
*/
|
||||
int GetSourceChannel() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
void Init(double fullRange, double expectedZero);
|
||||
double MapSensorRange(double pos) const;
|
||||
|
||||
std::shared_ptr<DutyCycle> m_dutyCycle;
|
||||
units::hertz_t m_frequencyThreshold = {100_Hz};
|
||||
wpi::units::hertz_t m_frequencyThreshold = {100_Hz};
|
||||
double m_fullRange;
|
||||
double m_expectedZero;
|
||||
units::second_t m_period{0_s};
|
||||
wpi::units::second_t m_period{0_s};
|
||||
double m_sensorMin{0.0};
|
||||
double m_sensorMax{1.0};
|
||||
bool m_isInverted{false};
|
||||
|
||||
hal::SimDevice m_simDevice;
|
||||
hal::SimDouble m_simPosition;
|
||||
hal::SimBoolean m_simIsConnected;
|
||||
wpi::hal::SimDevice m_simDevice;
|
||||
wpi::hal::SimDouble m_simPosition;
|
||||
wpi::hal::SimBoolean m_simIsConnected;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
/**
|
||||
* Class to read quad encoders.
|
||||
*
|
||||
@@ -29,8 +29,8 @@ namespace frc {
|
||||
* to be zeroed before use.
|
||||
*/
|
||||
class Encoder : public CounterBase,
|
||||
public wpi::Sendable,
|
||||
public wpi::SendableHelper<Encoder> {
|
||||
public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<Encoder> {
|
||||
public:
|
||||
/**
|
||||
* Encoder constructor.
|
||||
@@ -95,7 +95,7 @@ class Encoder : public CounterBase,
|
||||
* @deprecated Use getRate() in favor of this method.
|
||||
*/
|
||||
[[deprecated("Use GetRate() in favor of this method")]]
|
||||
units::second_t GetPeriod() const override;
|
||||
wpi::units::second_t GetPeriod() const override;
|
||||
|
||||
/**
|
||||
* Sets the maximum period for stopped detection.
|
||||
@@ -115,7 +115,7 @@ class Encoder : public CounterBase,
|
||||
[[deprecated(
|
||||
"Use SetMinRate() in favor of this method. This takes unscaled periods "
|
||||
"and SetMinRate() scales using value from SetDistancePerPulse().")]]
|
||||
void SetMaxPeriod(units::second_t maxPeriod) override;
|
||||
void SetMaxPeriod(wpi::units::second_t maxPeriod) override;
|
||||
|
||||
/**
|
||||
* Determine if the encoder is stopped.
|
||||
@@ -246,7 +246,7 @@ class Encoder : public CounterBase,
|
||||
|
||||
int GetFPGAIndex() const;
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override;
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
@@ -276,7 +276,7 @@ class Encoder : public CounterBase,
|
||||
*/
|
||||
double DecodingScaleFactor() const;
|
||||
|
||||
hal::Handle<HAL_EncoderHandle, HAL_FreeEncoder> m_encoder;
|
||||
wpi::hal::Handle<HAL_EncoderHandle, HAL_FreeEncoder> m_encoder;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
namespace frc::internal {
|
||||
namespace wpi::internal {
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
@@ -70,4 +70,4 @@ class DriverStationModeThread {
|
||||
bool m_userInTeleop{false};
|
||||
bool m_userInTest{false};
|
||||
};
|
||||
} // namespace frc::internal
|
||||
} // namespace wpi::internal
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "wpi/system/Watchdog.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* IterativeRobotBase implements a specific type of robot program framework,
|
||||
@@ -200,7 +200,7 @@ class IterativeRobotBase : public RobotBase {
|
||||
/**
|
||||
* Gets time period between calls to Periodic() functions.
|
||||
*/
|
||||
units::second_t GetPeriod() const;
|
||||
wpi::units::second_t GetPeriod() const;
|
||||
|
||||
/**
|
||||
* Prints list of epochs added so far and their times.
|
||||
@@ -212,7 +212,7 @@ class IterativeRobotBase : public RobotBase {
|
||||
*
|
||||
* @param period Period.
|
||||
*/
|
||||
explicit IterativeRobotBase(units::second_t period);
|
||||
explicit IterativeRobotBase(wpi::units::second_t period);
|
||||
|
||||
~IterativeRobotBase() override = default;
|
||||
|
||||
@@ -229,7 +229,7 @@ class IterativeRobotBase : public RobotBase {
|
||||
enum class Mode { kNone, kDisabled, kAutonomous, kTeleop, kTest };
|
||||
|
||||
Mode m_lastMode = Mode::kNone;
|
||||
units::second_t m_period;
|
||||
wpi::units::second_t m_period;
|
||||
Watchdog m_watchdog;
|
||||
bool m_ntFlushEnabled = true;
|
||||
bool m_calledDsConnected = false;
|
||||
@@ -237,4 +237,4 @@ class IterativeRobotBase : public RobotBase {
|
||||
void PrintLoopOverrunMessage();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/string.h"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
int RunHALInitialization();
|
||||
|
||||
@@ -28,7 +28,7 @@ void ResetMotorSafety();
|
||||
#endif
|
||||
|
||||
template <class Robot>
|
||||
void RunRobot(wpi::mutex& m, Robot** robot) {
|
||||
void RunRobot(wpi::util::mutex& m, Robot** robot) {
|
||||
try {
|
||||
static Robot theRobot;
|
||||
{
|
||||
@@ -36,7 +36,7 @@ void RunRobot(wpi::mutex& m, Robot** robot) {
|
||||
*robot = &theRobot;
|
||||
}
|
||||
theRobot.StartCompetition();
|
||||
} catch (const frc::RuntimeError& e) {
|
||||
} catch (const wpi::RuntimeError& e) {
|
||||
e.Report();
|
||||
FRC_ReportError(
|
||||
err::Error,
|
||||
@@ -75,8 +75,8 @@ int StartRobot() {
|
||||
return halInit;
|
||||
}
|
||||
|
||||
static wpi::mutex m;
|
||||
static wpi::condition_variable cv;
|
||||
static wpi::util::mutex m;
|
||||
static wpi::util::condition_variable cv;
|
||||
static Robot* robot = nullptr;
|
||||
static bool exited = false;
|
||||
|
||||
@@ -124,7 +124,7 @@ int StartRobot() {
|
||||
}
|
||||
|
||||
#ifndef __FRC_SYSTEMCORE__
|
||||
frc::impl::ResetMotorSafety();
|
||||
wpi::impl::ResetMotorSafety();
|
||||
#endif
|
||||
HAL_Shutdown();
|
||||
|
||||
@@ -277,4 +277,4 @@ class RobotBase {
|
||||
NT_Listener connListenerHandle;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Robot state utility functions.
|
||||
@@ -56,4 +56,4 @@ class RobotState {
|
||||
static bool IsTest();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
#include "wpi/util/priority_queue.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* TimedRobot implements the IterativeRobotBase robot program framework.
|
||||
@@ -49,14 +49,14 @@ class TimedRobot : public IterativeRobotBase {
|
||||
*
|
||||
* @param period The period of the robot loop function.
|
||||
*/
|
||||
explicit TimedRobot(units::second_t period = kDefaultPeriod);
|
||||
explicit TimedRobot(wpi::units::second_t period = kDefaultPeriod);
|
||||
|
||||
/**
|
||||
* Constructor for TimedRobot.
|
||||
*
|
||||
* @param frequency The frequency of the robot loop function.
|
||||
*/
|
||||
explicit TimedRobot(units::hertz_t frequency);
|
||||
explicit TimedRobot(wpi::units::hertz_t frequency);
|
||||
|
||||
TimedRobot(TimedRobot&&) = default;
|
||||
TimedRobot& operator=(TimedRobot&&) = default;
|
||||
@@ -86,8 +86,8 @@ class TimedRobot : public IterativeRobotBase {
|
||||
* for scheduling a callback in a different timeslot relative
|
||||
* to TimedRobot.
|
||||
*/
|
||||
void AddPeriodic(std::function<void()> callback, units::second_t period,
|
||||
units::second_t offset = 0_s);
|
||||
void AddPeriodic(std::function<void()> callback, wpi::units::second_t period,
|
||||
wpi::units::second_t offset = 0_s);
|
||||
|
||||
private:
|
||||
class Callback {
|
||||
@@ -110,7 +110,7 @@ class TimedRobot : public IterativeRobotBase {
|
||||
period{period},
|
||||
expirationTime(
|
||||
startTime + offset + period +
|
||||
(std::chrono::microseconds{frc::RobotController::GetFPGATime()} -
|
||||
(std::chrono::microseconds{wpi::RobotController::GetFPGATime()} -
|
||||
startTime) /
|
||||
period * period) {}
|
||||
|
||||
@@ -119,12 +119,12 @@ class TimedRobot : public IterativeRobotBase {
|
||||
}
|
||||
};
|
||||
|
||||
hal::Handle<HAL_NotifierHandle, HAL_CleanNotifier> m_notifier;
|
||||
wpi::hal::Handle<HAL_NotifierHandle, HAL_CleanNotifier> m_notifier;
|
||||
std::chrono::microseconds m_startTime;
|
||||
uint64_t m_loopStartTimeUs = 0;
|
||||
|
||||
wpi::priority_queue<Callback, std::vector<Callback>, std::greater<Callback>>
|
||||
wpi::util::priority_queue<Callback, std::vector<Callback>, std::greater<Callback>>
|
||||
m_callbacks;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/opmode/TimedRobot.hpp"
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* TimesliceRobot extends the TimedRobot robot program framework to provide
|
||||
@@ -75,7 +75,7 @@ namespace frc {
|
||||
* If the robot periodic functions and the controller periodic functions have a
|
||||
* lot of scheduling jitter that cause them to occasionally overlap with later
|
||||
* timeslices, consider giving the main robot thread a real-time priority using
|
||||
* frc::SetCurrentThreadPriority(). An RT priority of 15 is a reasonable choice.
|
||||
* wpi::SetCurrentThreadPriority(). An RT priority of 15 is a reasonable choice.
|
||||
*
|
||||
* If you do enable RT though, <i>make sure your periodic functions do not
|
||||
* block</i>. If they do, the operating system will lock up, and you'll have to
|
||||
@@ -92,8 +92,8 @@ class TimesliceRobot : public TimedRobot {
|
||||
* allocations should be less than or equal to this
|
||||
* value.
|
||||
*/
|
||||
explicit TimesliceRobot(units::second_t robotPeriodicAllocation,
|
||||
units::second_t controllerPeriod);
|
||||
explicit TimesliceRobot(wpi::units::second_t robotPeriodicAllocation,
|
||||
wpi::units::second_t controllerPeriod);
|
||||
|
||||
/**
|
||||
* Schedule a periodic function with the constructor's controller period and
|
||||
@@ -109,11 +109,11 @@ class TimesliceRobot : public TimedRobot {
|
||||
* @param allocation The function's runtime allocation out of the controller
|
||||
* period.
|
||||
*/
|
||||
void Schedule(std::function<void()> func, units::second_t allocation);
|
||||
void Schedule(std::function<void()> func, wpi::units::second_t allocation);
|
||||
|
||||
private:
|
||||
units::second_t m_nextOffset;
|
||||
units::second_t m_controllerPeriod;
|
||||
wpi::units::second_t m_nextOffset;
|
||||
wpi::units::second_t m_controllerPeriod;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* 2D representation of game field for dashboards.
|
||||
@@ -38,7 +38,7 @@ namespace frc {
|
||||
* also be shown by using the GetObject() function. Other objects can
|
||||
* also have multiple poses (which will show the object at multiple locations).
|
||||
*/
|
||||
class Field2d : public nt::NTSendable, public wpi::SendableHelper<Field2d> {
|
||||
class Field2d : public wpi::nt::NTSendable, public wpi::util::SendableHelper<Field2d> {
|
||||
public:
|
||||
using Entry = size_t;
|
||||
|
||||
@@ -52,7 +52,7 @@ class Field2d : public nt::NTSendable, public wpi::SendableHelper<Field2d> {
|
||||
*
|
||||
* @param pose 2D pose
|
||||
*/
|
||||
void SetRobotPose(const Pose2d& pose);
|
||||
void SetRobotPose(const wpi::math::Pose2d& pose);
|
||||
|
||||
/**
|
||||
* Set the robot pose from x, y, and rotation.
|
||||
@@ -61,14 +61,14 @@ class Field2d : public nt::NTSendable, public wpi::SendableHelper<Field2d> {
|
||||
* @param y Y location
|
||||
* @param rotation rotation
|
||||
*/
|
||||
void SetRobotPose(units::meter_t x, units::meter_t y, Rotation2d rotation);
|
||||
void SetRobotPose(wpi::units::meter_t x, wpi::units::meter_t y, wpi::math::Rotation2d rotation);
|
||||
|
||||
/**
|
||||
* Get the robot pose.
|
||||
*
|
||||
* @return 2D pose
|
||||
*/
|
||||
Pose2d GetRobotPose() const;
|
||||
wpi::math::Pose2d GetRobotPose() const;
|
||||
|
||||
/**
|
||||
* Get or create a field object.
|
||||
@@ -84,13 +84,13 @@ class Field2d : public nt::NTSendable, public wpi::SendableHelper<Field2d> {
|
||||
*/
|
||||
FieldObject2d* GetRobotObject();
|
||||
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
void InitSendable(wpi::nt::NTSendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
std::shared_ptr<wpi::nt::NetworkTable> m_table;
|
||||
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
std::vector<std::unique_ptr<FieldObject2d>> m_objects;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
class Field2d;
|
||||
class Trajectory;
|
||||
class wpi::math::Trajectory;
|
||||
|
||||
/**
|
||||
* Game field object on a Field2d.
|
||||
@@ -40,7 +40,7 @@ class FieldObject2d {
|
||||
*
|
||||
* @param pose 2D pose
|
||||
*/
|
||||
void SetPose(const Pose2d& pose);
|
||||
void SetPose(const wpi::math::Pose2d& pose);
|
||||
|
||||
/**
|
||||
* Set the pose from x, y, and rotation.
|
||||
@@ -49,14 +49,14 @@ class FieldObject2d {
|
||||
* @param y Y location
|
||||
* @param rotation rotation
|
||||
*/
|
||||
void SetPose(units::meter_t x, units::meter_t y, Rotation2d rotation);
|
||||
void SetPose(wpi::units::meter_t x, wpi::units::meter_t y, wpi::math::Rotation2d rotation);
|
||||
|
||||
/**
|
||||
* Get the pose.
|
||||
*
|
||||
* @return 2D pose, or 0,0,0 if unknown / does not exist
|
||||
*/
|
||||
Pose2d GetPose() const;
|
||||
wpi::math::Pose2d GetPose() const;
|
||||
|
||||
/**
|
||||
* Set multiple poses from an array of Pose objects.
|
||||
@@ -64,7 +64,7 @@ class FieldObject2d {
|
||||
*
|
||||
* @param poses array of 2D poses
|
||||
*/
|
||||
void SetPoses(std::span<const Pose2d> poses);
|
||||
void SetPoses(std::span<const wpi::math::Pose2d> poses);
|
||||
|
||||
/**
|
||||
* Set multiple poses from an array of Pose objects.
|
||||
@@ -72,38 +72,38 @@ class FieldObject2d {
|
||||
*
|
||||
* @param poses array of 2D poses
|
||||
*/
|
||||
void SetPoses(std::initializer_list<Pose2d> poses);
|
||||
void SetPoses(std::initializer_list<wpi::math::Pose2d> poses);
|
||||
|
||||
/**
|
||||
* Sets poses from a trajectory.
|
||||
*
|
||||
* @param trajectory The trajectory from which poses should be added.
|
||||
*/
|
||||
void SetTrajectory(const Trajectory& trajectory);
|
||||
void SetTrajectory(const wpi::math::Trajectory& trajectory);
|
||||
|
||||
/**
|
||||
* Get multiple poses.
|
||||
*
|
||||
* @return vector of 2D poses
|
||||
*/
|
||||
std::vector<Pose2d> GetPoses() const;
|
||||
std::vector<wpi::math::Pose2d> GetPoses() const;
|
||||
|
||||
/**
|
||||
* Get multiple poses.
|
||||
*
|
||||
* @param out output SmallVector to hold 2D poses
|
||||
* @return span referring to output SmallVector
|
||||
* @param out output wpi::util::SmallVector to hold 2D poses
|
||||
* @return span referring to output wpi::util::SmallVector
|
||||
*/
|
||||
std::span<const Pose2d> GetPoses(wpi::SmallVectorImpl<Pose2d>& out) const;
|
||||
std::span<const wpi::math::Pose2d> GetPoses(wpi::util::SmallVectorImpl<wpi::math::Pose2d>& out) const;
|
||||
|
||||
private:
|
||||
void UpdateEntry(bool setDefault = false);
|
||||
void UpdateFromEntry() const;
|
||||
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
std::string m_name;
|
||||
nt::DoubleArrayEntry m_entry;
|
||||
mutable wpi::SmallVector<Pose2d, 1> m_poses;
|
||||
wpi::nt::DoubleArrayEntry m_entry;
|
||||
mutable wpi::util::SmallVector<wpi::math::Pose2d, 1> m_poses;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace frc::detail {
|
||||
namespace wpi::detail {
|
||||
/**
|
||||
* An executor for running listener tasks posted by Sendable listeners
|
||||
* synchronously from the main application thread.
|
||||
@@ -33,6 +33,6 @@ class ListenerExecutor {
|
||||
private:
|
||||
std::vector<std::function<void()>> m_tasks;
|
||||
std::vector<std::function<void()>> m_runningTasks;
|
||||
wpi::mutex m_lock;
|
||||
wpi::util::mutex m_lock;
|
||||
};
|
||||
} // namespace frc::detail
|
||||
} // namespace wpi::detail
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/util/mutex.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Visual 2D representation of arms, elevators, and general mechanisms through
|
||||
@@ -38,8 +38,8 @@ namespace frc {
|
||||
* @see MechanismLigament2d
|
||||
* @see MechanismRoot2d
|
||||
*/
|
||||
class Mechanism2d : public nt::NTSendable,
|
||||
public wpi::SendableHelper<Mechanism2d> {
|
||||
class Mechanism2d : public wpi::nt::NTSendable,
|
||||
public wpi::util::SendableHelper<Mechanism2d> {
|
||||
public:
|
||||
/**
|
||||
* Create a new Mechanism2d with the given dimensions and background color.
|
||||
@@ -75,16 +75,16 @@ class Mechanism2d : public nt::NTSendable,
|
||||
*/
|
||||
void SetBackgroundColor(const Color8Bit& color);
|
||||
|
||||
void InitSendable(nt::NTSendableBuilder& builder) override;
|
||||
void InitSendable(wpi::nt::NTSendableBuilder& builder) override;
|
||||
|
||||
private:
|
||||
double m_width;
|
||||
double m_height;
|
||||
std::string m_color;
|
||||
mutable wpi::mutex m_mutex;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
wpi::StringMap<MechanismRoot2d> m_roots;
|
||||
nt::DoubleArrayPublisher m_dimsPub;
|
||||
nt::StringPublisher m_colorPub;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
std::shared_ptr<wpi::nt::NetworkTable> m_table;
|
||||
wpi::util::StringMap<MechanismRoot2d> m_roots;
|
||||
wpi::nt::DoubleArrayPublisher m_dimsPub;
|
||||
wpi::nt::StringPublisher m_colorPub;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/units/angle.hpp"
|
||||
#include "wpi/util/Color8Bit.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Ligament node on a Mechanism2d.
|
||||
@@ -26,8 +26,8 @@ namespace frc {
|
||||
class MechanismLigament2d : public MechanismObject2d {
|
||||
public:
|
||||
MechanismLigament2d(std::string_view name, double length,
|
||||
units::degree_t angle, double lineWidth = 6,
|
||||
const frc::Color8Bit& color = {235, 137, 52});
|
||||
wpi::units::degree_t angle, double lineWidth = 6,
|
||||
const wpi::Color8Bit& color = {235, 137, 52});
|
||||
|
||||
/**
|
||||
* Set the ligament color.
|
||||
@@ -62,7 +62,7 @@ class MechanismLigament2d : public MechanismObject2d {
|
||||
*
|
||||
* @param angle the angle
|
||||
*/
|
||||
void SetAngle(units::degree_t angle);
|
||||
void SetAngle(wpi::units::degree_t angle);
|
||||
|
||||
/**
|
||||
* Get the ligament's angle relative to its parent.
|
||||
@@ -86,17 +86,17 @@ class MechanismLigament2d : public MechanismObject2d {
|
||||
double GetLineWeight();
|
||||
|
||||
protected:
|
||||
void UpdateEntries(std::shared_ptr<nt::NetworkTable> table) override;
|
||||
void UpdateEntries(std::shared_ptr<wpi::nt::NetworkTable> table) override;
|
||||
|
||||
private:
|
||||
nt::StringPublisher m_typePub;
|
||||
wpi::nt::StringPublisher m_typePub;
|
||||
double m_length;
|
||||
nt::DoubleEntry m_lengthEntry;
|
||||
wpi::nt::DoubleEntry m_lengthEntry;
|
||||
double m_angle;
|
||||
nt::DoubleEntry m_angleEntry;
|
||||
wpi::nt::DoubleEntry m_angleEntry;
|
||||
double m_weight;
|
||||
nt::DoubleEntry m_weightEntry;
|
||||
wpi::nt::DoubleEntry m_weightEntry;
|
||||
char m_color[10];
|
||||
nt::StringEntry m_colorEntry;
|
||||
wpi::nt::StringEntry m_colorEntry;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/system/Errors.hpp"
|
||||
#include "wpi/util/StringMap.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Common base class for all Mechanism2d node types.
|
||||
@@ -38,9 +38,9 @@ class MechanismObject2d {
|
||||
*
|
||||
* @param table the new table.
|
||||
*/
|
||||
virtual void UpdateEntries(std::shared_ptr<nt::NetworkTable> table) = 0;
|
||||
virtual void UpdateEntries(std::shared_ptr<wpi::nt::NetworkTable> table) = 0;
|
||||
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
|
||||
public:
|
||||
virtual ~MechanismObject2d() = default;
|
||||
@@ -82,8 +82,8 @@ class MechanismObject2d {
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
wpi::StringMap<std::unique_ptr<MechanismObject2d>> m_objects;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
void Update(std::shared_ptr<nt::NetworkTable> table);
|
||||
wpi::util::StringMap<std::unique_ptr<MechanismObject2d>> m_objects;
|
||||
std::shared_ptr<wpi::nt::NetworkTable> m_table;
|
||||
void Update(std::shared_ptr<wpi::nt::NetworkTable> table);
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/nt/DoubleTopic.hpp"
|
||||
#include "wpi/smartdashboard/MechanismObject2d.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Root Mechanism2d node.
|
||||
@@ -43,11 +43,11 @@ class MechanismRoot2d : private MechanismObject2d {
|
||||
using MechanismObject2d::Append;
|
||||
|
||||
private:
|
||||
void UpdateEntries(std::shared_ptr<nt::NetworkTable> table) override;
|
||||
void UpdateEntries(std::shared_ptr<wpi::nt::NetworkTable> table) override;
|
||||
inline void Flush();
|
||||
double m_x;
|
||||
double m_y;
|
||||
nt::DoublePublisher m_xPub;
|
||||
nt::DoublePublisher m_yPub;
|
||||
wpi::nt::DoublePublisher m_xPub;
|
||||
wpi::nt::DoublePublisher m_yPub;
|
||||
};
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#include "wpi/util/FunctionExtras.hpp"
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Implementation detail for SendableBuilder.
|
||||
*/
|
||||
class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
class SendableBuilderImpl : public wpi::nt::NTSendableBuilder {
|
||||
public:
|
||||
SendableBuilderImpl() = default;
|
||||
~SendableBuilderImpl() override = default;
|
||||
@@ -37,13 +37,13 @@ class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
* called.
|
||||
* @param table Network table
|
||||
*/
|
||||
void SetTable(std::shared_ptr<nt::NetworkTable> table);
|
||||
void SetTable(std::shared_ptr<wpi::nt::NetworkTable> table);
|
||||
|
||||
/**
|
||||
* Get the network table.
|
||||
* @return The network table
|
||||
*/
|
||||
std::shared_ptr<nt::NetworkTable> GetTable() override;
|
||||
std::shared_ptr<wpi::nt::NetworkTable> GetTable() override;
|
||||
|
||||
/**
|
||||
* Return whether this sendable has an associated table.
|
||||
@@ -80,8 +80,8 @@ class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
|
||||
void SetSmartDashboardType(std::string_view type) override;
|
||||
void SetActuator(bool value) override;
|
||||
void SetUpdateTable(wpi::unique_function<void()> func) override;
|
||||
nt::Topic GetTopic(std::string_view key) override;
|
||||
void SetUpdateTable(wpi::util::unique_function<void()> func) override;
|
||||
wpi::nt::Topic GetTopic(std::string_view key) override;
|
||||
|
||||
void AddBooleanProperty(std::string_view key, std::function<bool()> getter,
|
||||
std::function<void(bool)> setter) override;
|
||||
@@ -155,44 +155,44 @@ class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
|
||||
void AddSmallStringProperty(
|
||||
std::string_view key,
|
||||
std::function<std::string_view(wpi::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)> getter,
|
||||
std::function<void(std::string_view)> setter) override;
|
||||
|
||||
void AddSmallBooleanArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<std::span<const int>(wpi::SmallVectorImpl<int>& buf)>
|
||||
std::function<std::span<const int>(wpi::util::SmallVectorImpl<int>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const int>)> setter) override;
|
||||
|
||||
void AddSmallIntegerArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
std::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
std::span<const int64_t>(wpi::util::SmallVectorImpl<int64_t>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const int64_t>)> setter) override;
|
||||
|
||||
void AddSmallFloatArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<std::span<const float>(wpi::SmallVectorImpl<float>& buf)>
|
||||
std::function<std::span<const float>(wpi::util::SmallVectorImpl<float>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const float>)> setter) override;
|
||||
|
||||
void AddSmallDoubleArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<std::span<const double>(wpi::SmallVectorImpl<double>& buf)>
|
||||
std::function<std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const double>)> setter) override;
|
||||
|
||||
void AddSmallStringArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
std::span<const std::string>(wpi::SmallVectorImpl<std::string>& buf)>
|
||||
std::span<const std::string>(wpi::util::SmallVectorImpl<std::string>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const std::string>)> setter) override;
|
||||
|
||||
void AddSmallRawProperty(
|
||||
std::string_view key, std::string_view typeString,
|
||||
std::function<std::span<uint8_t>(wpi::SmallVectorImpl<uint8_t>& buf)>
|
||||
std::function<std::span<uint8_t>(wpi::util::SmallVectorImpl<uint8_t>& buf)>
|
||||
getter,
|
||||
std::function<void(std::span<const uint8_t>)> setter) override;
|
||||
|
||||
@@ -225,14 +225,14 @@ class SendableBuilderImpl : public nt::NTSendableBuilder {
|
||||
void AddSmallPropertyImpl(Topic topic, Getter getter, Setter setter);
|
||||
|
||||
std::vector<std::unique_ptr<Property>> m_properties;
|
||||
std::vector<wpi::unique_function<void()>> m_updateTables;
|
||||
std::shared_ptr<nt::NetworkTable> m_table;
|
||||
std::vector<wpi::util::unique_function<void()>> m_updateTables;
|
||||
std::shared_ptr<wpi::nt::NetworkTable> m_table;
|
||||
bool m_controllable = false;
|
||||
bool m_actuator = false;
|
||||
|
||||
nt::BooleanPublisher m_controllablePublisher;
|
||||
nt::StringPublisher m_typePublisher;
|
||||
nt::BooleanPublisher m_actuatorPublisher;
|
||||
wpi::nt::BooleanPublisher m_controllablePublisher;
|
||||
wpi::nt::StringPublisher m_typePublisher;
|
||||
wpi::nt::BooleanPublisher m_actuatorPublisher;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/util/StringMap.hpp"
|
||||
#include "wpi/util/sendable/SendableBuilder.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* The SendableChooser class is a useful tool for presenting a selection of
|
||||
@@ -35,7 +35,7 @@ namespace frc {
|
||||
template <class T>
|
||||
requires std::copy_constructible<T> && std::default_initializable<T>
|
||||
class SendableChooser : public SendableChooserBase {
|
||||
wpi::StringMap<T> m_choices;
|
||||
wpi::util::StringMap<T> m_choices;
|
||||
std::function<void(T)> m_listener;
|
||||
template <class U>
|
||||
static U _unwrap_smart_ptr(const U& value) {
|
||||
@@ -123,7 +123,7 @@ class SendableChooser : public SendableChooserBase {
|
||||
m_listener = listener;
|
||||
}
|
||||
|
||||
void InitSendable(wpi::SendableBuilder& builder) override {
|
||||
void InitSendable(wpi::util::SendableBuilder& builder) override {
|
||||
builder.SetSmartDashboardType("String Chooser");
|
||||
builder.PublishConstInteger(kInstance, m_instance);
|
||||
builder.AddStringArrayProperty(
|
||||
@@ -138,13 +138,13 @@ class SendableChooser : public SendableChooserBase {
|
||||
nullptr);
|
||||
builder.AddSmallStringProperty(
|
||||
kDefault,
|
||||
[=, this](wpi::SmallVectorImpl<char>&) -> std::string_view {
|
||||
[=, this](wpi::util::SmallVectorImpl<char>&) -> std::string_view {
|
||||
return m_defaultChoice;
|
||||
},
|
||||
nullptr);
|
||||
builder.AddSmallStringProperty(
|
||||
kActive,
|
||||
[=, this](wpi::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
[=, this](wpi::util::SmallVectorImpl<char>& buf) -> std::string_view {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
if (m_haveSelected) {
|
||||
buf.assign(m_selected.begin(), m_selected.end());
|
||||
@@ -175,4 +175,4 @@ class SendableChooser : public SendableChooserBase {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/util/sendable/Sendable.hpp"
|
||||
#include "wpi/util/sendable/SendableHelper.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* This class is a non-template base class for SendableChooser.
|
||||
@@ -19,8 +19,8 @@ namespace frc {
|
||||
* It contains static, non-templated variables to avoid their duplication in the
|
||||
* template class.
|
||||
*/
|
||||
class SendableChooserBase : public wpi::Sendable,
|
||||
public wpi::SendableHelper<SendableChooserBase> {
|
||||
class SendableChooserBase : public wpi::util::Sendable,
|
||||
public wpi::util::SendableHelper<SendableChooserBase> {
|
||||
public:
|
||||
SendableChooserBase();
|
||||
~SendableChooserBase() override = default;
|
||||
@@ -38,10 +38,10 @@ class SendableChooserBase : public wpi::Sendable,
|
||||
std::string m_defaultChoice;
|
||||
std::string m_selected;
|
||||
bool m_haveSelected = false;
|
||||
mutable wpi::mutex m_mutex;
|
||||
mutable wpi::util::mutex m_mutex;
|
||||
int m_instance;
|
||||
std::string m_previousVal;
|
||||
static std::atomic_int s_instances;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user