mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[glass, wpilib] Replace remaining references to Speed Controller with Motor Controller (#4769)
This commit is contained in:
@@ -163,7 +163,7 @@ doxygen {
|
||||
warn_if_undocumented false
|
||||
warn_no_paramdoc true
|
||||
|
||||
//enable doxygen preprocessor expansion of WPI_DEPRECATED to fix SpeedController docs
|
||||
//enable doxygen preprocessor expansion of WPI_DEPRECATED to fix MotorController docs
|
||||
enable_preprocessing true
|
||||
macro_expansion true
|
||||
expand_only_predef true
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "glass/hardware/SpeedController.h"
|
||||
#include "glass/hardware/MotorController.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
@@ -12,13 +12,13 @@
|
||||
|
||||
using namespace glass;
|
||||
|
||||
void glass::DisplaySpeedController(SpeedControllerModel* m) {
|
||||
void glass::DisplayMotorController(MotorControllerModel* m) {
|
||||
// Get duty cycle data from the model and do not display anything if the data
|
||||
// is null.
|
||||
auto dc = m->GetPercentData();
|
||||
if (!dc || !m->Exists()) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
|
||||
ImGui::Text("Unknown SpeedController");
|
||||
ImGui::Text("Unknown MotorController");
|
||||
ImGui::PopStyleColor();
|
||||
return;
|
||||
}
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
namespace glass {
|
||||
class DataSource;
|
||||
class SpeedControllerModel : public Model {
|
||||
class MotorControllerModel : public Model {
|
||||
public:
|
||||
virtual const char* GetName() const = 0;
|
||||
virtual const char* GetSimDevice() const = 0;
|
||||
virtual DataSource* GetPercentData() = 0;
|
||||
virtual void SetPercent(double value) = 0;
|
||||
};
|
||||
void DisplaySpeedController(SpeedControllerModel* m);
|
||||
void DisplayMotorController(MotorControllerModel* m);
|
||||
} // namespace glass
|
||||
@@ -2,17 +2,17 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include "glass/networktables/NTSpeedController.h"
|
||||
#include "glass/networktables/NTMotorController.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
|
||||
using namespace glass;
|
||||
|
||||
NTSpeedControllerModel::NTSpeedControllerModel(std::string_view path)
|
||||
: NTSpeedControllerModel(nt::NetworkTableInstance::GetDefault(), path) {}
|
||||
NTMotorControllerModel::NTMotorControllerModel(std::string_view path)
|
||||
: NTMotorControllerModel(nt::NetworkTableInstance::GetDefault(), path) {}
|
||||
|
||||
NTSpeedControllerModel::NTSpeedControllerModel(nt::NetworkTableInstance inst,
|
||||
NTMotorControllerModel::NTMotorControllerModel(nt::NetworkTableInstance inst,
|
||||
std::string_view path)
|
||||
: m_inst{inst},
|
||||
m_value{inst.GetDoubleTopic(fmt::format("{}/Value", path))
|
||||
@@ -23,11 +23,11 @@ NTSpeedControllerModel::NTSpeedControllerModel(nt::NetworkTableInstance inst,
|
||||
m_valueData{fmt::format("NT_SpdCtrl:{}", path)},
|
||||
m_nameValue{wpi::rsplit(path, '/').second} {}
|
||||
|
||||
void NTSpeedControllerModel::SetPercent(double value) {
|
||||
void NTMotorControllerModel::SetPercent(double value) {
|
||||
m_value.Set(value);
|
||||
}
|
||||
|
||||
void NTSpeedControllerModel::Update() {
|
||||
void NTMotorControllerModel::Update() {
|
||||
for (auto&& v : m_value.ReadQueue()) {
|
||||
m_valueData.SetValue(v.value, v.time);
|
||||
}
|
||||
@@ -39,6 +39,6 @@ void NTSpeedControllerModel::Update() {
|
||||
}
|
||||
}
|
||||
|
||||
bool NTSpeedControllerModel::Exists() {
|
||||
bool NTMotorControllerModel::Exists() {
|
||||
return m_value.Exists();
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "glass/networktables/NTGyro.h"
|
||||
#include "glass/networktables/NTMecanumDrive.h"
|
||||
#include "glass/networktables/NTMechanism2D.h"
|
||||
#include "glass/networktables/NTMotorController.h"
|
||||
#include "glass/networktables/NTPIDController.h"
|
||||
#include "glass/networktables/NTSpeedController.h"
|
||||
#include "glass/networktables/NTStringChooser.h"
|
||||
#include "glass/networktables/NTSubsystem.h"
|
||||
#include "glass/networktables/NetworkTablesProvider.h"
|
||||
@@ -142,14 +142,14 @@ void glass::AddStandardNetworkTablesViews(NetworkTablesProvider& provider) {
|
||||
});
|
||||
});
|
||||
provider.Register(
|
||||
NTSpeedControllerModel::kType,
|
||||
NTMotorControllerModel::kType,
|
||||
[](nt::NetworkTableInstance inst, const char* path) {
|
||||
return std::make_unique<NTSpeedControllerModel>(inst, path);
|
||||
return std::make_unique<NTMotorControllerModel>(inst, path);
|
||||
},
|
||||
[](Window* win, Model* model, const char* path) {
|
||||
win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
|
||||
return MakeFunctionView([=] {
|
||||
DisplaySpeedController(static_cast<NTSpeedControllerModel*>(model));
|
||||
DisplayMotorController(static_cast<NTMotorControllerModel*>(model));
|
||||
});
|
||||
});
|
||||
provider.Register(
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
#include <networktables/StringTopic.h>
|
||||
|
||||
#include "glass/DataSource.h"
|
||||
#include "glass/hardware/SpeedController.h"
|
||||
#include "glass/hardware/MotorController.h"
|
||||
|
||||
namespace glass {
|
||||
class NTSpeedControllerModel : public SpeedControllerModel {
|
||||
class NTMotorControllerModel : public MotorControllerModel {
|
||||
public:
|
||||
static constexpr const char* kType = "Motor Controller";
|
||||
|
||||
explicit NTSpeedControllerModel(std::string_view path);
|
||||
NTSpeedControllerModel(nt::NetworkTableInstance inst, std::string_view path);
|
||||
explicit NTMotorControllerModel(std::string_view path);
|
||||
NTMotorControllerModel(nt::NetworkTableInstance inst, std::string_view path);
|
||||
|
||||
const char* GetName() const override { return m_nameValue.c_str(); }
|
||||
const char* GetSimDevice() const override { return nullptr; }
|
||||
@@ -38,7 +38,7 @@ constexpr int32_t kExpectedLoopTiming = 40;
|
||||
* reliably down to 10.0 ms; starting at about 8.5ms, the servo sometimes hums
|
||||
* and get hot; by 5.0ms the hum is nearly continuous
|
||||
* - 10ms periods work well for Victor 884
|
||||
* - 5ms periods allows higher update rates for Luminary Micro Jaguar speed
|
||||
* - 5ms periods allows higher update rates for Luminary Micro Jaguar motor
|
||||
* controllers. Due to the shipping firmware on the Jaguar, we can't run the
|
||||
* update period less than 5.05 ms.
|
||||
*
|
||||
|
||||
@@ -30,7 +30,7 @@ constexpr int32_t kExpectedLoopTiming = 40;
|
||||
* reliably down to 10.0 ms; starting at about 8.5ms, the servo sometimes hums
|
||||
* and get hot; by 5.0ms the hum is nearly continuous
|
||||
* - 10ms periods work well for Victor 884
|
||||
* - 5ms periods allows higher update rates for Luminary Micro Jaguar speed
|
||||
* - 5ms periods allows higher update rates for Luminary Micro Jaguar motor
|
||||
* controllers. Due to the shipping firmware on the Jaguar, we can't run the
|
||||
* update period less than 5.05 ms.
|
||||
*
|
||||
|
||||
@@ -219,7 +219,7 @@ Joystick data is an input to the robot program and should be updated for each in
|
||||
|
||||
[``"PWM"``]:#pwm-output-pwm
|
||||
|
||||
PWMs may be used to control either speed controllers or servos. Typically only one of either ``"<speed"`` (for a speed controller) or ``"<position"`` (for a servo) is used for a given PWM.
|
||||
PWMs may be used to control either motor controllers or servos. Typically only one of either ``"<speed"`` (for a motor controller) or ``"<position"`` (for a servo) is used for a given PWM.
|
||||
|
||||
| Data Key | Type | Description |
|
||||
| --------------- | ------- | ------------------------------------------ |
|
||||
|
||||
@@ -20,7 +20,7 @@ static constexpr const char* widgetStrings[] = {
|
||||
"ComboBox Chooser",
|
||||
"Split Button Chooser",
|
||||
"Encoder",
|
||||
"Speed Controller",
|
||||
"Motor Controller",
|
||||
"Command",
|
||||
"PID Command",
|
||||
"PID Controller",
|
||||
|
||||
@@ -166,7 +166,7 @@ class PWM : public wpi::Sendable, public wpi::SendableHelper<PWM> {
|
||||
/**
|
||||
* Optionally eliminate the deadband from a motor controller.
|
||||
*
|
||||
* @param eliminateDeadband If true, set the motor curve on the speed
|
||||
* @param eliminateDeadband If true, set the motor curve on the motor
|
||||
* controller to eliminate the deadband in the middle
|
||||
* of the range. Otherwise, keep the full range
|
||||
* without modifying any values.
|
||||
|
||||
@@ -23,7 +23,7 @@ class MotorController {
|
||||
virtual void Set(double speed) = 0;
|
||||
|
||||
/**
|
||||
* Sets the voltage output of the SpeedController. Compensates for
|
||||
* Sets the voltage output of the MotorController. Compensates for
|
||||
* the current bus voltage to ensure that the desired voltage is output even
|
||||
* if the battery voltage is below 12V - highly useful when the voltage
|
||||
* outputs are "meaningful" (e.g. they come from a feedforward calculation).
|
||||
|
||||
@@ -64,7 +64,7 @@ class PWMMotorController : public MotorController,
|
||||
/**
|
||||
* Optionally eliminate the deadband from a motor controller.
|
||||
*
|
||||
* @param eliminateDeadband If true, set the motor curve on the speed
|
||||
* @param eliminateDeadband If true, set the motor curve on the motor
|
||||
* controller to eliminate the deadband in the middle
|
||||
* of the range. Otherwise, keep the full range
|
||||
* without modifying any values.
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace frc {
|
||||
class ShuffleboardContainer;
|
||||
|
||||
/**
|
||||
* A Shuffleboard widget that handles a Sendable object such as a speed
|
||||
* A Shuffleboard widget that handles a Sendable object such as a motor
|
||||
* controller or sensor.
|
||||
*/
|
||||
class ComplexWidget final : public ShuffleboardWidget<ComplexWidget> {
|
||||
|
||||
@@ -18,13 +18,13 @@ std::ostream& operator<<(std::ostream& os,
|
||||
const MotorControllerGroupTestType& type) {
|
||||
switch (type) {
|
||||
case TEST_ONE:
|
||||
os << "MotorControllerGroup with one speed controller";
|
||||
os << "MotorControllerGroup with one motor controller";
|
||||
break;
|
||||
case TEST_TWO:
|
||||
os << "MotorControllerGroup with two speed controllers";
|
||||
os << "MotorControllerGroup with two motor controllers";
|
||||
break;
|
||||
case TEST_THREE:
|
||||
os << "MotorControllerGroup with three speed controllers";
|
||||
os << "MotorControllerGroup with three motor controllers";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -37,32 +37,32 @@ std::ostream& operator<<(std::ostream& os,
|
||||
class MotorControllerGroupTest
|
||||
: public testing::TestWithParam<MotorControllerGroupTestType> {
|
||||
protected:
|
||||
std::vector<MockMotorController> m_speedControllers;
|
||||
std::vector<MockMotorController> m_motorControllers;
|
||||
std::unique_ptr<MotorControllerGroup> m_group;
|
||||
|
||||
void SetUp() override {
|
||||
switch (GetParam()) {
|
||||
case TEST_ONE: {
|
||||
m_speedControllers.emplace_back();
|
||||
m_group = std::make_unique<MotorControllerGroup>(m_speedControllers[0]);
|
||||
m_motorControllers.emplace_back();
|
||||
m_group = std::make_unique<MotorControllerGroup>(m_motorControllers[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
case TEST_TWO: {
|
||||
m_speedControllers.emplace_back();
|
||||
m_speedControllers.emplace_back();
|
||||
m_group = std::make_unique<MotorControllerGroup>(m_speedControllers[0],
|
||||
m_speedControllers[1]);
|
||||
m_motorControllers.emplace_back();
|
||||
m_motorControllers.emplace_back();
|
||||
m_group = std::make_unique<MotorControllerGroup>(m_motorControllers[0],
|
||||
m_motorControllers[1]);
|
||||
break;
|
||||
}
|
||||
|
||||
case TEST_THREE: {
|
||||
m_speedControllers.emplace_back();
|
||||
m_speedControllers.emplace_back();
|
||||
m_speedControllers.emplace_back();
|
||||
m_group = std::make_unique<MotorControllerGroup>(m_speedControllers[0],
|
||||
m_speedControllers[1],
|
||||
m_speedControllers[2]);
|
||||
m_motorControllers.emplace_back();
|
||||
m_motorControllers.emplace_back();
|
||||
m_motorControllers.emplace_back();
|
||||
m_group = std::make_unique<MotorControllerGroup>(m_motorControllers[0],
|
||||
m_motorControllers[1],
|
||||
m_motorControllers[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -72,8 +72,8 @@ class MotorControllerGroupTest
|
||||
TEST_P(MotorControllerGroupTest, Set) {
|
||||
m_group->Set(1.0);
|
||||
|
||||
for (auto& speedController : m_speedControllers) {
|
||||
EXPECT_FLOAT_EQ(speedController.Get(), 1.0);
|
||||
for (auto& motorController : m_motorControllers) {
|
||||
EXPECT_FLOAT_EQ(motorController.Get(), 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,13 +84,13 @@ TEST_P(MotorControllerGroupTest, GetInverted) {
|
||||
}
|
||||
|
||||
TEST_P(MotorControllerGroupTest, SetInvertedDoesNotModifyMotorControllers) {
|
||||
for (auto& speedController : m_speedControllers) {
|
||||
speedController.SetInverted(false);
|
||||
for (auto& motorController : m_motorControllers) {
|
||||
motorController.SetInverted(false);
|
||||
}
|
||||
m_group->SetInverted(true);
|
||||
|
||||
for (auto& speedController : m_speedControllers) {
|
||||
EXPECT_EQ(speedController.GetInverted(), false);
|
||||
for (auto& motorController : m_motorControllers) {
|
||||
EXPECT_EQ(motorController.GetInverted(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ TEST_P(MotorControllerGroupTest, SetInvertedDoesInvert) {
|
||||
m_group->SetInverted(true);
|
||||
m_group->Set(1.0);
|
||||
|
||||
for (auto& speedController : m_speedControllers) {
|
||||
EXPECT_FLOAT_EQ(speedController.Get(), -1.0);
|
||||
for (auto& motorController : m_motorControllers) {
|
||||
EXPECT_FLOAT_EQ(motorController.Get(), -1.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ TEST_P(MotorControllerGroupTest, Disable) {
|
||||
m_group->Set(1.0);
|
||||
m_group->Disable();
|
||||
|
||||
for (auto& speedController : m_speedControllers) {
|
||||
EXPECT_FLOAT_EQ(speedController.Get(), 0.0);
|
||||
for (auto& motorController : m_motorControllers) {
|
||||
EXPECT_FLOAT_EQ(motorController.Get(), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ TEST_P(MotorControllerGroupTest, StopMotor) {
|
||||
m_group->Set(1.0);
|
||||
m_group->StopMotor();
|
||||
|
||||
for (auto& speedController : m_speedControllers) {
|
||||
EXPECT_FLOAT_EQ(speedController.Get(), 0.0);
|
||||
for (auto& motorController : m_motorControllers) {
|
||||
EXPECT_FLOAT_EQ(motorController.Get(), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* operator control part of the program, the joystick is read and the value is
|
||||
* written to the motor.
|
||||
*
|
||||
* Joystick analog values range from -1 to 1 and speed controller inputs as
|
||||
* Joystick analog values range from -1 to 1 and motor controller inputs as
|
||||
* range from -1 to 1 making it easy to work together.
|
||||
*/
|
||||
class Robot : public frc::TimedRobot {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* operator control part of the program, the joystick is read and the value is
|
||||
* written to the motor.
|
||||
*
|
||||
* Joystick analog values range from -1 to 1 and speed controller inputs as
|
||||
* Joystick analog values range from -1 to 1 and motor controller inputs as
|
||||
* range from -1 to 1 making it easy to work together.
|
||||
*
|
||||
* In addition, the encoder value of an encoder connected to ports 0 and 1 is
|
||||
|
||||
@@ -13,7 +13,7 @@ import edu.wpi.first.wpilibj.motorcontrol.PWMSparkMax;
|
||||
* This sample program shows how to control a motor using a joystick. In the operator control part
|
||||
* of the program, the joystick is read and the value is written to the motor.
|
||||
*
|
||||
* <p>Joystick analog values range from -1 to 1 and speed controller inputs also range from -1 to 1
|
||||
* <p>Joystick analog values range from -1 to 1 and motor controller inputs also range from -1 to 1
|
||||
* making it easy to work together.
|
||||
*/
|
||||
public class Robot extends TimedRobot {
|
||||
|
||||
@@ -15,7 +15,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
* This sample program shows how to control a motor using a joystick. In the operator control part
|
||||
* of the program, the joystick is read and the value is written to the motor.
|
||||
*
|
||||
* <p>Joystick analog values range from -1 to 1 and speed controller inputs also range from -1 to 1
|
||||
* <p>Joystick analog values range from -1 to 1 and motor controller inputs also range from -1 to 1
|
||||
* making it easy to work together.
|
||||
*
|
||||
* <p>In addition, the encoder value of an encoder connected to ports 0 and 1 is consistently sent
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class MotorEncoderFixture<T extends MotorController> implements
|
||||
public abstract int getPDPChannel();
|
||||
|
||||
/**
|
||||
* Where the implementer of this class should pass the speed controller Constructor should only be
|
||||
* Where the implementer of this class should pass the motor controller Constructor should only be
|
||||
* called from outside this class if the Motor controller is not also an implementation of PWM
|
||||
* interface.
|
||||
*
|
||||
@@ -75,7 +75,7 @@ public abstract class MotorEncoderFixture<T extends MotorController> implements
|
||||
m_encoder = new Encoder(m_alphaSource, m_betaSource);
|
||||
m_counters[0] = new Counter(m_alphaSource);
|
||||
m_counters[1] = new Counter(m_betaSource);
|
||||
logger.fine("Creating the speed controller!");
|
||||
logger.fine("Creating the motor controller!");
|
||||
m_motor = giveMotorController();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user