mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -14,10 +14,10 @@
|
||||
#include "wpi/sysid/SysIdRoutineLog.hpp"
|
||||
#include "wpi/system/Timer.hpp"
|
||||
|
||||
namespace frc2::sysid {
|
||||
namespace wpi::cmd::sysid {
|
||||
|
||||
using ramp_rate_t = units::unit_t<
|
||||
units::compound_unit<units::volt, units::inverse<units::second>>>;
|
||||
using ramp_rate_t = wpi::units::unit_t<
|
||||
wpi::units::compound_unit<wpi::units::volt, wpi::units::inverse<wpi::units::second>>>;
|
||||
|
||||
/** Hardware-independent configuration for a SysId test routine. */
|
||||
class Config {
|
||||
@@ -26,14 +26,14 @@ class Config {
|
||||
ramp_rate_t m_rampRate{1_V / 1_s};
|
||||
|
||||
/// The step voltage output used for dynamic test routines.
|
||||
units::volt_t m_stepVoltage{7_V};
|
||||
wpi::units::volt_t m_stepVoltage{7_V};
|
||||
|
||||
/// Safety timeout for the test routine commands.
|
||||
units::second_t m_timeout{10_s};
|
||||
wpi::units::second_t m_timeout{10_s};
|
||||
|
||||
/// Optional handle for recording test state in a third-party logging
|
||||
/// solution.
|
||||
std::function<void(frc::sysid::State)> m_recordState;
|
||||
std::function<void(wpi::sysid::State)> m_recordState;
|
||||
|
||||
/**
|
||||
* Create a new configuration for a SysId test routine.
|
||||
@@ -49,9 +49,9 @@ class Config {
|
||||
* passed to this callback instead of logged in WPILog.
|
||||
*/
|
||||
Config(std::optional<ramp_rate_t> rampRate,
|
||||
std::optional<units::volt_t> stepVoltage,
|
||||
std::optional<units::second_t> timeout,
|
||||
std::function<void(frc::sysid::State)> recordState)
|
||||
std::optional<wpi::units::volt_t> stepVoltage,
|
||||
std::optional<wpi::units::second_t> timeout,
|
||||
std::function<void(wpi::sysid::State)> recordState)
|
||||
: m_recordState{std::move(recordState)} {
|
||||
if (rampRate) {
|
||||
m_rampRate = rampRate.value();
|
||||
@@ -69,15 +69,15 @@ class Mechanism {
|
||||
public:
|
||||
/// Sends the SysId-specified drive signal to the mechanism motors during test
|
||||
/// routines.
|
||||
std::function<void(units::volt_t)> m_drive;
|
||||
std::function<void(wpi::units::volt_t)> m_drive;
|
||||
|
||||
/// Returns measured data (voltages, positions, velocities) of the mechanism
|
||||
/// motors during test routines.
|
||||
std::function<void(frc::sysid::SysIdRoutineLog*)> m_log;
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> m_log;
|
||||
|
||||
/// The subsystem containing the motor(s) that is (or are) being
|
||||
/// characterized.
|
||||
frc2::Subsystem* m_subsystem;
|
||||
wpi::cmd::Subsystem* m_subsystem;
|
||||
|
||||
/// The name of the mechanism being tested. Will be appended to the log entry
|
||||
/// title for the routine's test state, e.g. "sysid-test-state-mechanism".
|
||||
@@ -102,11 +102,11 @@ class Mechanism {
|
||||
* "sysid-test-state-mechanism". Defaults to the name of the subsystem if
|
||||
* left null.
|
||||
*/
|
||||
Mechanism(std::function<void(units::volt_t)> drive,
|
||||
std::function<void(frc::sysid::SysIdRoutineLog*)> log,
|
||||
frc2::Subsystem* subsystem, std::string_view name)
|
||||
Mechanism(std::function<void(wpi::units::volt_t)> drive,
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> log,
|
||||
wpi::cmd::Subsystem* subsystem, std::string_view name)
|
||||
: m_drive{std::move(drive)},
|
||||
m_log{log ? std::move(log) : [](frc::sysid::SysIdRoutineLog* log) {}},
|
||||
m_log{log ? std::move(log) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
m_subsystem{subsystem},
|
||||
m_name{name} {}
|
||||
|
||||
@@ -127,11 +127,11 @@ class Mechanism {
|
||||
* test commands. The subsystem's `name` will be appended to the log entry
|
||||
* title for the routine's test state, e.g. "sysid-test-state-subsystem".
|
||||
*/
|
||||
Mechanism(std::function<void(units::volt_t)> drive,
|
||||
std::function<void(frc::sysid::SysIdRoutineLog*)> log,
|
||||
frc2::Subsystem* subsystem)
|
||||
Mechanism(std::function<void(wpi::units::volt_t)> drive,
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> log,
|
||||
wpi::cmd::Subsystem* subsystem)
|
||||
: m_drive{std::move(drive)},
|
||||
m_log{log ? std::move(log) : [](frc::sysid::SysIdRoutineLog* log) {}},
|
||||
m_log{log ? std::move(log) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
m_subsystem{subsystem},
|
||||
m_name{m_subsystem->GetName()} {}
|
||||
};
|
||||
@@ -167,7 +167,7 @@ enum Direction {
|
||||
* times in a single logfile, the user will need to select which of the tests to
|
||||
* use for the fit in the analysis tool.
|
||||
*/
|
||||
class SysIdRoutine : public frc::sysid::SysIdRoutineLog {
|
||||
class SysIdRoutine : public wpi::sysid::SysIdRoutineLog {
|
||||
public:
|
||||
/**
|
||||
* Create a new SysId characterization routine.
|
||||
@@ -180,18 +180,18 @@ class SysIdRoutine : public frc::sysid::SysIdRoutineLog {
|
||||
m_config(config),
|
||||
m_mechanism(mechanism),
|
||||
m_recordState(config.m_recordState ? config.m_recordState
|
||||
: [this](frc::sysid::State state) {
|
||||
: [this](wpi::sysid::State state) {
|
||||
this->RecordState(state);
|
||||
}) {}
|
||||
|
||||
frc2::CommandPtr Quasistatic(Direction direction);
|
||||
frc2::CommandPtr Dynamic(Direction direction);
|
||||
wpi::cmd::CommandPtr Quasistatic(Direction direction);
|
||||
wpi::cmd::CommandPtr Dynamic(Direction direction);
|
||||
|
||||
private:
|
||||
Config m_config;
|
||||
Mechanism m_mechanism;
|
||||
units::volt_t m_outputVolts{0};
|
||||
std::function<void(frc::sysid::State)> m_recordState;
|
||||
frc::Timer timer;
|
||||
wpi::units::volt_t m_outputVolts{0};
|
||||
std::function<void(wpi::sysid::State)> m_recordState;
|
||||
wpi::Timer timer;
|
||||
};
|
||||
} // namespace frc2::sysid
|
||||
} // namespace wpi::cmd::sysid
|
||||
|
||||
Reference in New Issue
Block a user