Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion glass/src/lib/native/cpp/hardware/PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using namespace wpi::glass;

void wpi::glass::DisplayPWM(PWMModel* model, int index, bool outputsEnabled) {
auto data = model->GetSpeedData();
auto data = model->GetDutyCycleData();
if (!data) {
return;
}
Expand Down
10 changes: 5 additions & 5 deletions glass/src/lib/native/cpp/other/Drive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ void wpi::glass::DisplayDrive(DriveModel* m) {
// Draw the primary rectangle.
draw->AddRect(ImVec2(x1, y1), ImVec2(x2, y2), color);

// Display the speed vector.
// Display the velocity vector.
ImVec2 center{(x1 + x2) / 2.0f, (y1 + y2) / 2.0f};
ImVec2 speed = m->GetSpeedVector();
ImVec2 arrow = center + speed * 50.0f;
ImVec2 velocity = m->GetVelocityVector();
ImVec2 arrow = center + velocity * 50.0f;

draw->AddLine(center, arrow, color, 2.0f);

Expand All @@ -61,8 +61,8 @@ void wpi::glass::DisplayDrive(DriveModel* m) {
};

// Draw the arrow if there is any translation; draw an X otherwise.
if (std::abs(speed.y) > 0 || std::abs(speed.x) > 0) {
drawArrow(arrow, std::atan2(speed.x, -speed.y));
if (std::abs(velocity.y) > 0 || std::abs(velocity.x) > 0) {
drawArrow(arrow, std::atan2(velocity.x, -velocity.y));
} else {
ImVec2 a{7.5f, +7.5f};
ImVec2 b{7.5f, -7.5f};
Expand Down
4 changes: 2 additions & 2 deletions glass/src/lib/native/include/wpi/glass/hardware/PWM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class DoubleSource;

class PWMModel : public Model {
public:
virtual DoubleSource* GetSpeedData() = 0;
virtual DoubleSource* GetDutyCycleData() = 0;

virtual void SetSpeed(double val) = 0;
virtual void SetDutyCycle(double dutyCycle) = 0;
};

class PWMsModel : public Model {
Expand Down
2 changes: 1 addition & 1 deletion glass/src/lib/native/include/wpi/glass/other/Drive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DriveModel : public Model {
virtual const char* GetName() const = 0;
virtual const std::vector<WheelInfo>& GetWheels() const = 0;

virtual ImVec2 GetSpeedVector() const = 0;
virtual ImVec2 GetVelocityVector() const = 0;

// Clamped between -1 and 1 with -1 being full CCW.
virtual double GetRotation() const = 0;
Expand Down
12 changes: 7 additions & 5 deletions glass/src/libnt/native/cpp/NTDifferentialDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ NTDifferentialDriveModel::NTDifferentialDriveModel(
m_name{inst.GetStringTopic(fmt::format("{}/.name", path)).Subscribe("")},
m_controllable{inst.GetBooleanTopic(fmt::format("{}/.controllable", path))
.Subscribe(false)},
m_lPercent{inst.GetDoubleTopic(fmt::format("{}/Left Motor Speed", path))
.GetEntry(0)},
m_rPercent{inst.GetDoubleTopic(fmt::format("{}/Right Motor Speed", path))
.GetEntry(0)},
m_lPercent{
inst.GetDoubleTopic(fmt::format("{}/Left Motor Velocity", path))
.GetEntry(0)},
m_rPercent{
inst.GetDoubleTopic(fmt::format("{}/Right Motor Velocity", path))
.GetEntry(0)},
m_nameValue{wpi::util::rsplit(path, '/').second},
m_lPercentData{fmt::format("NTDiffDriveL:{}", path)},
m_rPercentData{fmt::format("NTDiffDriveR:{}", path)} {
Expand Down Expand Up @@ -55,7 +57,7 @@ void NTDifferentialDriveModel::Update() {
double l = m_lPercentData.GetValue();
double r = m_rPercentData.GetValue();

m_speedVector = ImVec2(0.0, -(l + r) / 2.0);
m_velocityVector = ImVec2(0.0, -(l + r) / 2.0);
m_rotation = (l - r) / 2.0;
}

Expand Down
14 changes: 7 additions & 7 deletions glass/src/libnt/native/cpp/NTMecanumDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ NTMecanumDriveModel::NTMecanumDriveModel(wpi::nt::NetworkTableInstance inst,
m_controllable{inst.GetBooleanTopic(fmt::format("{}/.controllable", path))
.Subscribe(0)},
m_flPercent{
inst.GetDoubleTopic(fmt::format("{}/Front Left Motor Speed", path))
.GetEntry(0)},
m_frPercent{
inst.GetDoubleTopic(fmt::format("{}/Front Right Motor Speed", path))
inst.GetDoubleTopic(fmt::format("{}/Front Left Motor Velocity", path))
.GetEntry(0)},
m_frPercent{inst.GetDoubleTopic(
fmt::format("{}/Front Right Motor Velocity", path))
.GetEntry(0)},
m_rlPercent{
inst.GetDoubleTopic(fmt::format("{}/Rear Left Motor Speed", path))
inst.GetDoubleTopic(fmt::format("{}/Rear Left Motor Velocity", path))
.GetEntry(0)},
m_rrPercent{
inst.GetDoubleTopic(fmt::format("{}/Rear Right Motor Speed", path))
inst.GetDoubleTopic(fmt::format("{}/Rear Right Motor Velocity", path))
.GetEntry(0)},
m_nameValue{wpi::util::rsplit(path, '/').second},
m_flPercentData{fmt::format("NTMcnmDriveFL:{}", path)},
Expand Down Expand Up @@ -78,7 +78,7 @@ void NTMecanumDriveModel::Update() {
double rl = m_rlPercentData.GetValue();
double rr = m_rrPercentData.GetValue();

m_speedVector =
m_velocityVector =
ImVec2((fl - fr - rl + rr) / 4.0f, -(fl + fr + rl + rr) / 4.0f);
m_rotation = -(-fl + fr - rl + rr) / 4;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NTDifferentialDriveModel : public DriveModel {
return m_wheels;
}

ImVec2 GetSpeedVector() const override { return m_speedVector; }
ImVec2 GetVelocityVector() const override { return m_velocityVector; }
double GetRotation() const override { return m_rotation; }

void Update() override;
Expand All @@ -49,7 +49,7 @@ class NTDifferentialDriveModel : public DriveModel {
DoubleSource m_rPercentData;

std::vector<DriveModel::WheelInfo> m_wheels;
ImVec2 m_speedVector;
ImVec2 m_velocityVector;
double m_rotation;
};
} // namespace wpi::glass
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NTMecanumDriveModel : public DriveModel {
return m_wheels;
}

ImVec2 GetSpeedVector() const override { return m_speedVector; }
ImVec2 GetVelocityVector() const override { return m_velocityVector; }
double GetRotation() const override { return m_rotation; }

void Update() override;
Expand All @@ -53,7 +53,7 @@ class NTMecanumDriveModel : public DriveModel {
DoubleSource m_rrPercentData;

std::vector<DriveModel::WheelInfo> m_wheels;
ImVec2 m_speedVector;
ImVec2 m_velocityVector;
double m_rotation;
};
} // namespace wpi::glass
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class CounterJNI extends JNIWrapper {
* Gets the Period of the most recent count.
*
* <p>Returns the time interval of the most recent count. This can be used for velocity
* calculations to determine shaft speed.
* calculations to determine shaft velocity.
*
* @param counterHandle the counter handle
* @return the period of the last two pulses in units of seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static native int initializeEncoder(
* Gets the Period of the most recent count.
*
* <p>Returns the time interval of the most recent count. This can be used for velocity
* calculations to determine shaft speed.
* calculations to determine shaft velocity.
*
* @param encoderHandle the encoder handle
* @return the period of the last two pulses in units of seconds
Expand Down
2 changes: 1 addition & 1 deletion hal/src/main/native/include/wpi/hal/Counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int32_t HAL_GetCounter(HAL_CounterHandle counterHandle, int32_t* status);
* Gets the Period of the most recent count.
*
* Returns the time interval of the most recent count. This can be used for
* velocity calculations to determine shaft speed.
* velocity calculations to determine shaft velocity.
*
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
Expand Down
2 changes: 1 addition & 1 deletion hal/src/main/native/include/wpi/hal/Encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void HAL_ResetEncoder(HAL_EncoderHandle encoderHandle, int32_t* status);
* Gets the Period of the most recent count.
*
* Returns the time interval of the most recent count. This can be used for
* velocity calculations to determine shaft speed.
* velocity calculations to determine shaft velocity.
*
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class RomiMotor extends PWMMotorController {
/** Common initialization code called by all constructors. */
protected final void initRomiMotor() {
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
setSpeed(0.0);
setDutyCycle(0.0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion romiVendordep/src/main/native/cpp/romi/RomiMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ using namespace wpi::romi;

RomiMotor::RomiMotor(int channel) : PWMMotorController("Romi Motor", channel) {
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_5Ms);
SetSpeed(0.0);
SetDutyCycle(0.0);
}
10 changes: 5 additions & 5 deletions simulation/halsim_gui/src/main/native/cpp/PWMSimGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ HALSIMGUI_DATASOURCE_DOUBLE_INDEXED(PWMPulseMicrosecond, "PWM");

class PWMSimModel : public wpi::glass::PWMModel {
public:
explicit PWMSimModel(int32_t index) : m_index{index}, m_speed{m_index} {}
explicit PWMSimModel(int32_t index) : m_index{index}, m_dutyCycle{m_index} {}

void Update() override {}

bool Exists() override { return HALSIM_GetPWMInitialized(m_index); }

wpi::glass::DoubleSource* GetSpeedData() override { return &m_speed; }
wpi::glass::DoubleSource* GetDutyCycleData() override { return &m_dutyCycle; }

void SetSpeed(double val) override {
HALSIM_SetPWMPulseMicrosecond(m_index, val);
void SetDutyCycle(double dutyCycle) override {
HALSIM_SetPWMPulseMicrosecond(m_index, dutyCycle);
}

private:
int32_t m_index;
PWMPulseMicrosecondSource m_speed;
PWMPulseMicrosecondSource m_dutyCycle;
};

class PWMsSimModel : public wpi::glass::PWMsModel {
Expand Down
2 changes: 1 addition & 1 deletion simulation/halsim_ws_core/doc/hardware_ws_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ A pneumatic control module is used to regulate the pressure in a pneumatic syste

[``"PWM"``]:#pwm-output-pwm

PWMs may be used to control either motor controllers or servos. Typically only one of either ``"<speed"`` (for a motor controller) ``"<position"`` (for a servo), or ``"raw"`` is used for a given PWM.
PWMs may be used to control either motor controllers or servos. Typically only one of either ``"<duty_cycle"`` (for a motor controller) ``"<position"`` (for a servo), or ``"raw"`` is used for a given PWM.

| Data Key | Type | Description |
| ------------------- | ------- | ------------------------------------------ |
Expand Down
2 changes: 1 addition & 1 deletion simulation/halsim_ws_core/doc/wpilib-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ components:
type: PWM
device: "1"
data:
"<speed": 0.5
"<duty_cycle": 0.5
- payload:
type: DIO
device: "3"
Expand Down
4 changes: 2 additions & 2 deletions simulation/halsim_xrp/src/main/native/cpp/XRP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ void XRP::HandleMotorSimValueChanged(const wpi::util::json& data) {
deviceId = 3;
}

if (deviceId != -1 && motorData.find("<speed") != motorData.end()) {
m_motor_outputs[deviceId] = motorData["<speed"];
if (deviceId != -1 && motorData.find("<duty_cycle") != motorData.end()) {
m_motor_outputs[deviceId] = motorData["<duty_cycle"];
}
}

Expand Down
2 changes: 1 addition & 1 deletion styleguide/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Class name="org.wpilib.math.controller.LinearSystemLoopTest" />
<Class name="~org\.wpilib\.math\.estimator\.[^.]*PoseEstimator(3d)?Test" />
<Class name="org.wpilib.math.filter.LinearFilterTest" />
<Class name="org.wpilib.math.kinematics.ChassisSpeedsTest" />
<Class name="org.wpilib.math.kinematics.ChassisVelocitiesTest" />
<Class name="org.wpilib.hardware.led.LEDPatternTest" />
<Class name="org.wpilib.simulation.AnalogInputSimTest" />
</Or>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ sysid::TrimStepVoltageData(std::vector<PreparedData>* data,
// Find maximum speed reached
const auto maxSpeed =
GetMaxSpeed(*data, [](auto&& pt) { return pt.velocity; });
// Find place where 90% of maximum speed exceeded
// Find place where 90% of maximum velocity exceeded
auto endIt = std::find_if(
data->begin(), data->end(), [&](const PreparedData& entry) {
return std::abs(entry.velocity) > maxSpeed * 0.9;
Expand Down
4 changes: 2 additions & 2 deletions wpilibc/robotpy_pybind_build_info.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using namespace wpi;
{{ name }}::{{ name }}(int channel) : PWMMotorController("{{ name }}", channel) {
SetBounds({{ pulse_width_ms.max }}_ms, {{ pulse_width_ms.deadbandMax }}_ms, {{ pulse_width_ms.center }}_ms, {{ pulse_width_ms.deadbandMin }}_ms, {{ pulse_width_ms.min }}_ms);
m_pwm.SetOutputPeriod(PWM::kOutputPeriod_{{ OutputPeriod | default("5", true)}}Ms);
SetSpeed(0.0);
SetDutyCycle(0.0);

HAL_ReportUsage("IO", GetChannel(), "{{ ResourceName }}");
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading