Skip to content

Commit

Permalink
Final Cleanup on CPP
Browse files Browse the repository at this point in the history
  • Loading branch information
narmstro2020 committed Mar 31, 2024
1 parent 5e6f485 commit 636adc0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
2 changes: 0 additions & 2 deletions wpilibc/src/main/native/cpp/simulation/DCMotorSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include <wpi/MathExtras.h>

#include "frc/system/plant/LinearSystemId.h"

using namespace frc;
using namespace frc::sim;

Expand Down
10 changes: 5 additions & 5 deletions wpilibc/src/test/native/cpp/simulation/DCMotorSimTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include "frc/simulation/DCMotorSim.h"
#include "frc/simulation/EncoderSim.h"
#include "frc/simulation/RoboRioSim.h"
#include "frc/system/plant/LinearSystemId.h"


TEST(DCMotorSimTest, VoltageSteadyState) {
frc::DCMotor gearbox = frc::DCMotor::NEO(1);
frc::LinearSystemId.
frc::sim::DCMotorSim sim{gearbox, 1.0,
units::kilogram_square_meter_t{0.0005}};
frc::LinearSystem<2, 1, 2> plant = frc::LinearSystemId::DCMotorSystem(gearbox, units::kilogram_square_meter_t{0.0005}, 1.0);
frc::sim::DCMotorSim sim{plant, gearbox, 1.0};

frc::Encoder encoder{0, 1};
frc::sim::EncoderSim encoderSim{encoder};
Expand Down Expand Up @@ -62,8 +62,8 @@ TEST(DCMotorSimTest, VoltageSteadyState) {

TEST(DCMotorSimTest, PositionFeedbackControl) {
frc::DCMotor gearbox = frc::DCMotor::NEO(1);
frc::sim::DCMotorSim sim{gearbox, 1.0,
units::kilogram_square_meter_t{0.0005}};
frc::LinearSystem<2, 1, 2> plant = frc::LinearSystemId::DCMotorSystem(gearbox, units::kilogram_square_meter_t{0.0005}, 1.0);
frc::sim::DCMotorSim sim{plant, gearbox, 1.0};

frc::PIDController controller{0.04, 0.0, 0.001};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ public class DCMotorSim extends LinearSystemSim<N2, N1, N2> {
*
* @param plant The linear system representing the DC motor. This system can be created with
* {@link edu.wpi.first.math.system.plant.LinearSystemId#createDCMotorSystem(DCMotor, double,
* double)} or
* {@link edu.wpi.first.math.system.plant.LinearSystemId#createDCMotorSystem(double, double)}.
* double)} or {@link
* edu.wpi.first.math.system.plant.LinearSystemId#createDCMotorSystem(double, double)}.
* @param gearbox The type of and number of motors in the DC motor gearbox.
* @param gearing The gearing of the DC motor (numbers greater than 1 represent reductions).
*/
public DCMotorSim(
LinearSystem<N2, N1, N2> plant,
DCMotor gearbox,
double gearing) {
public DCMotorSim(LinearSystem<N2, N1, N2> plant, DCMotor gearbox, double gearing) {
super(plant);
m_gearbox = gearbox;
m_gearing = gearing;
Expand All @@ -43,9 +40,7 @@ public DCMotorSim(
* Creates a simulated DC motor mechanism.
*
* @param plant The linear system representing the DC motor. This system can be created with
* {@link edu.wpi.first.math.system.plant.LinearSystemId#createDCMotorSystem(DCMotor, double,
* double)} or
* {@link edu.wpi.first.math.system.plant.LinearSystemId#createDCMotorSystem(double, double)}.
* {@link edu.wpi.first.math.system.plant.LinearSystemId#createDCMotorSystem()} methods.
* @param gearbox The type of and number of motors in the DC motor gearbox.
* @param gearing The gearing of the DC motor (numbers greater than 1 represent reductions).
* @param measurementStdDevs The standard deviations of the measurements.
Expand Down Expand Up @@ -145,5 +140,5 @@ public void setInputVoltage(double volts) {
*/
public double getInputVoltage() {
return getInput(0);
}
}
}

0 comments on commit 636adc0

Please sign in to comment.