mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Don't force public variables to use Hungarian notation (#8774)
People generally have expressed a dislike for the Hungarian notation used in member variables, especially in examples/templates, and our styleguide shouldn't be forced on downstream consumers, so this removes all Hungarian notation from the examples/templates. There are _some_ benefits to Hungarian for private member variables (like knowing what's a member vs. local in a PR review) so we'll keep private member variables the same for now, but public variables should no longer use Hungarian notation, since it looks much worse. A new PMD XPath rule has been added to accomplish this goal. Some other non-compliant variables were fixed for the new rule.
This commit is contained in:
@@ -11,11 +11,11 @@ import org.wpilib.util.RawFrame;
|
||||
import org.wpilib.vision.apriltag.jni.AprilTagJNI;
|
||||
|
||||
/** Represents an AprilTag's metadata. */
|
||||
@SuppressWarnings("MemberName")
|
||||
@Json
|
||||
public class AprilTag {
|
||||
/** The tag's ID. */
|
||||
@Json.Property("ID")
|
||||
@SuppressWarnings("PMD.PublicFieldNamingConvention")
|
||||
public int ID;
|
||||
|
||||
/** The tag's pose. */
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.wpilib.vision.apriltag.jni.AprilTagJNI;
|
||||
*/
|
||||
public class AprilTagDetector implements AutoCloseable {
|
||||
/** Detector configuration. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class Config {
|
||||
/**
|
||||
* How many threads should be used for computation. Default is single-threaded operation (1
|
||||
@@ -110,7 +109,6 @@ public class AprilTagDetector implements AutoCloseable {
|
||||
}
|
||||
|
||||
/** Quad threshold parameters. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class QuadThresholdParameters {
|
||||
/** Threshold used to reject quads containing too few pixels. Default is 300 pixels. */
|
||||
public int minClusterPixels = 300;
|
||||
|
||||
@@ -216,19 +216,19 @@ public class AprilTagFieldLayout {
|
||||
* @throws UncheckedIOException If the layout does not exist.
|
||||
*/
|
||||
public static AprilTagFieldLayout loadField(AprilTagFields field) {
|
||||
if (field.m_fieldLayout == null) {
|
||||
if (field.fieldLayout == null) {
|
||||
try {
|
||||
field.m_fieldLayout = loadFromResource(field.m_resourceFile);
|
||||
field.fieldLayout = loadFromResource(field.resourceFile);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(
|
||||
"Could not load AprilTagFieldLayout from " + field.m_resourceFile, e);
|
||||
"Could not load AprilTagFieldLayout from " + field.resourceFile, e);
|
||||
}
|
||||
}
|
||||
// Copy layout because the layout's origin is mutable
|
||||
return new AprilTagFieldLayout(
|
||||
field.m_fieldLayout.getTags(),
|
||||
field.m_fieldLayout.getFieldLength(),
|
||||
field.m_fieldLayout.getFieldWidth());
|
||||
field.fieldLayout.getTags(),
|
||||
field.fieldLayout.getFieldLength(),
|
||||
field.fieldLayout.getFieldWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,11 +264,9 @@ public class AprilTagFieldLayout {
|
||||
}
|
||||
|
||||
static class FieldDimensions {
|
||||
@SuppressWarnings("MemberName")
|
||||
@Json.Property(value = "length")
|
||||
public final double fieldLength;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
@Json.Property(value = "width")
|
||||
public final double fieldWidth;
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ public enum AprilTagFields {
|
||||
public static final AprilTagFields kDefaultField = k2026RebuiltWelded;
|
||||
|
||||
/** Resource filename. */
|
||||
public final String m_resourceFile;
|
||||
public final String resourceFile;
|
||||
|
||||
AprilTagFieldLayout m_fieldLayout;
|
||||
AprilTagFieldLayout fieldLayout;
|
||||
|
||||
AprilTagFields(String resourceFile) {
|
||||
m_resourceFile = kBaseResourceDir + resourceFile;
|
||||
this.resourceFile = kBaseResourceDir + resourceFile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ package org.wpilib.vision.apriltag;
|
||||
import org.wpilib.math.geometry.Transform3d;
|
||||
|
||||
/** A pair of AprilTag pose estimates. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class AprilTagPoseEstimate {
|
||||
/**
|
||||
* Constructs a pose estimate.
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.wpilib.vision.apriltag.jni.AprilTagJNI;
|
||||
/** Pose estimators for AprilTag tags. */
|
||||
public class AprilTagPoseEstimator {
|
||||
/** Configuration for the pose estimator. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class Config {
|
||||
/**
|
||||
* Creates a pose estimator configuration.
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.wpilib.math.util.Units;
|
||||
import org.wpilib.util.runtime.RuntimeLoader;
|
||||
|
||||
class AprilTagDetectorTest {
|
||||
@SuppressWarnings("MemberName")
|
||||
AprilTagDetector detector;
|
||||
|
||||
@BeforeAll
|
||||
|
||||
@@ -49,7 +49,6 @@ import org.wpilib.vision.stream.CameraServer;
|
||||
public final class Main {
|
||||
private static String configFile = "/boot/CameraServerConfig.json";
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class CameraConfig {
|
||||
public String name;
|
||||
public String path;
|
||||
|
||||
@@ -50,25 +50,25 @@ public class SysIdRoutine extends SysIdRoutineLog {
|
||||
* @param mechanism Hardware interface for the SysId routine.
|
||||
*/
|
||||
public SysIdRoutine(Config config, Mechanism mechanism) {
|
||||
super(mechanism.m_name);
|
||||
super(mechanism.name);
|
||||
m_config = config;
|
||||
m_mechanism = mechanism;
|
||||
m_recordState = config.m_recordState != null ? config.m_recordState : this::recordState;
|
||||
m_recordState = config.recordState != null ? config.recordState : this::recordState;
|
||||
}
|
||||
|
||||
/** Hardware-independent configuration for a SysId test routine. */
|
||||
public static class Config {
|
||||
/** The voltage ramp rate used for quasistatic test routines. */
|
||||
public final Velocity<VoltageUnit> m_rampRate;
|
||||
public final Velocity<VoltageUnit> rampRate;
|
||||
|
||||
/** The step voltage output used for dynamic test routines. */
|
||||
public final Voltage m_stepVoltage;
|
||||
public final Voltage stepVoltage;
|
||||
|
||||
/** Safety timeout for the test routine commands. */
|
||||
public final Time m_timeout;
|
||||
public final Time timeout;
|
||||
|
||||
/** Optional handle for recording test state in a third-party logging solution. */
|
||||
public final Consumer<State> m_recordState;
|
||||
public final Consumer<State> recordState;
|
||||
|
||||
/**
|
||||
* Create a new configuration for a SysId test routine.
|
||||
@@ -88,10 +88,10 @@ public class SysIdRoutine extends SysIdRoutineLog {
|
||||
Voltage stepVoltage,
|
||||
Time timeout,
|
||||
Consumer<State> recordState) {
|
||||
m_rampRate = rampRate != null ? rampRate : Volts.of(1).per(Second);
|
||||
m_stepVoltage = stepVoltage != null ? stepVoltage : Volts.of(7);
|
||||
m_timeout = timeout != null ? timeout : Seconds.of(10);
|
||||
m_recordState = recordState;
|
||||
this.rampRate = rampRate != null ? rampRate : Volts.of(1).per(Second);
|
||||
this.stepVoltage = stepVoltage != null ? stepVoltage : Volts.of(7);
|
||||
this.timeout = timeout != null ? timeout : Seconds.of(10);
|
||||
this.recordState = recordState;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,19 +128,19 @@ public class SysIdRoutine extends SysIdRoutineLog {
|
||||
*/
|
||||
public static class Mechanism {
|
||||
/** Sends the SysId-specified drive signal to the mechanism motors during test routines. */
|
||||
public final Consumer<? super Voltage> m_drive;
|
||||
public final Consumer<? super Voltage> drive;
|
||||
|
||||
/**
|
||||
* Returns measured data (voltages, positions, velocities) of the mechanism motors during test
|
||||
* routines.
|
||||
*/
|
||||
public final Consumer<SysIdRoutineLog> m_log;
|
||||
public final Consumer<SysIdRoutineLog> log;
|
||||
|
||||
/** The subsystem containing the motor(s) that is (or are) being characterized. */
|
||||
public final Subsystem m_subsystem;
|
||||
public final Subsystem subsystem;
|
||||
|
||||
/** The name of the mechanism being tested. */
|
||||
public final String m_name;
|
||||
public final String name;
|
||||
|
||||
/**
|
||||
* Create a new mechanism specification for a SysId routine.
|
||||
@@ -160,10 +160,10 @@ public class SysIdRoutine extends SysIdRoutineLog {
|
||||
*/
|
||||
public Mechanism(
|
||||
Consumer<Voltage> drive, Consumer<SysIdRoutineLog> log, Subsystem subsystem, String name) {
|
||||
m_drive = drive;
|
||||
m_log = log != null ? log : l -> {};
|
||||
m_subsystem = subsystem;
|
||||
m_name = name != null ? name : subsystem.getName();
|
||||
this.drive = drive;
|
||||
this.log = log != null ? log : l -> {};
|
||||
this.subsystem = subsystem;
|
||||
this.name = name != null ? name : subsystem.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,24 +217,24 @@ public class SysIdRoutine extends SysIdRoutineLog {
|
||||
|
||||
Timer timer = new Timer();
|
||||
return m_mechanism
|
||||
.m_subsystem
|
||||
.subsystem
|
||||
.runOnce(timer::restart)
|
||||
.andThen(
|
||||
m_mechanism.m_subsystem.run(
|
||||
m_mechanism.subsystem.run(
|
||||
() -> {
|
||||
m_mechanism.m_drive.accept(
|
||||
(Voltage) m_config.m_rampRate.times(Seconds.of(timer.get() * outputSign)));
|
||||
m_mechanism.m_log.accept(this);
|
||||
m_mechanism.drive.accept(
|
||||
(Voltage) m_config.rampRate.times(Seconds.of(timer.get() * outputSign)));
|
||||
m_mechanism.log.accept(this);
|
||||
m_recordState.accept(state);
|
||||
}))
|
||||
.finallyDo(
|
||||
() -> {
|
||||
m_mechanism.m_drive.accept(Volts.of(0));
|
||||
m_mechanism.drive.accept(Volts.of(0));
|
||||
m_recordState.accept(State.NONE);
|
||||
timer.stop();
|
||||
})
|
||||
.withName("sysid-" + state.toString() + "-" + m_mechanism.m_name)
|
||||
.withTimeout(m_config.m_timeout.in(Seconds));
|
||||
.withName("sysid-" + state.toString() + "-" + m_mechanism.name)
|
||||
.withTimeout(m_config.timeout.in(Seconds));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,21 +257,21 @@ public class SysIdRoutine extends SysIdRoutineLog {
|
||||
Voltage[] output = {Volts.zero()};
|
||||
|
||||
return m_mechanism
|
||||
.m_subsystem
|
||||
.runOnce(() -> output[0] = m_config.m_stepVoltage.times(outputSign))
|
||||
.subsystem
|
||||
.runOnce(() -> output[0] = m_config.stepVoltage.times(outputSign))
|
||||
.andThen(
|
||||
m_mechanism.m_subsystem.run(
|
||||
m_mechanism.subsystem.run(
|
||||
() -> {
|
||||
m_mechanism.m_drive.accept(output[0]);
|
||||
m_mechanism.m_log.accept(this);
|
||||
m_mechanism.drive.accept(output[0]);
|
||||
m_mechanism.log.accept(this);
|
||||
m_recordState.accept(state);
|
||||
}))
|
||||
.finallyDo(
|
||||
() -> {
|
||||
m_mechanism.m_drive.accept(Volts.of(0));
|
||||
m_mechanism.drive.accept(Volts.of(0));
|
||||
m_recordState.accept(State.NONE);
|
||||
})
|
||||
.withName("sysid-" + state.toString() + "-" + m_mechanism.m_name)
|
||||
.withTimeout(m_config.m_timeout.in(Seconds));
|
||||
.withName("sysid-" + state.toString() + "-" + m_mechanism.name)
|
||||
.withTimeout(m_config.timeout.in(Seconds));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,24 +18,24 @@ wpi::cmd::CommandPtr SysIdRoutine::Quasistatic(Direction direction) {
|
||||
|
||||
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
|
||||
|
||||
return m_mechanism.m_subsystem->RunOnce([this] { timer.Restart(); })
|
||||
return m_mechanism.subsystem->RunOnce([this] { timer.Restart(); })
|
||||
.AndThen(
|
||||
m_mechanism.m_subsystem
|
||||
m_mechanism.subsystem
|
||||
->Run([this, state, outputSign] {
|
||||
m_outputVolts = outputSign * timer.Get() * m_config.m_rampRate;
|
||||
m_mechanism.m_drive(m_outputVolts);
|
||||
m_mechanism.m_log(this);
|
||||
m_outputVolts = outputSign * timer.Get() * m_config.rampRate;
|
||||
m_mechanism.drive(m_outputVolts);
|
||||
m_mechanism.log(this);
|
||||
m_recordState(state);
|
||||
})
|
||||
.FinallyDo([this] {
|
||||
m_mechanism.m_drive(0_V);
|
||||
m_mechanism.drive(0_V);
|
||||
m_recordState(wpi::sysid::State::NONE);
|
||||
timer.Stop();
|
||||
})
|
||||
.WithName("sysid-" +
|
||||
wpi::sysid::SysIdRoutineLog::StateEnumToString(state) +
|
||||
"-" + m_mechanism.m_name)
|
||||
.WithTimeout(m_config.m_timeout));
|
||||
"-" + m_mechanism.name)
|
||||
.WithTimeout(m_config.timeout));
|
||||
}
|
||||
|
||||
wpi::cmd::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
@@ -48,19 +48,19 @@ wpi::cmd::CommandPtr SysIdRoutine::Dynamic(Direction direction) {
|
||||
|
||||
double outputSign = direction == Direction::kForward ? 1.0 : -1.0;
|
||||
|
||||
return m_mechanism.m_subsystem
|
||||
->RunOnce([this] { m_outputVolts = m_config.m_stepVoltage; })
|
||||
.AndThen(m_mechanism.m_subsystem->Run([this, state, outputSign] {
|
||||
m_mechanism.m_drive(m_outputVolts * outputSign);
|
||||
m_mechanism.m_log(this);
|
||||
return m_mechanism.subsystem
|
||||
->RunOnce([this] { m_outputVolts = m_config.stepVoltage; })
|
||||
.AndThen(m_mechanism.subsystem->Run([this, state, outputSign] {
|
||||
m_mechanism.drive(m_outputVolts * outputSign);
|
||||
m_mechanism.log(this);
|
||||
m_recordState(state);
|
||||
}))
|
||||
.FinallyDo([this] {
|
||||
m_mechanism.m_drive(0_V);
|
||||
m_mechanism.drive(0_V);
|
||||
m_recordState(wpi::sysid::State::NONE);
|
||||
})
|
||||
.WithName("sysid-" +
|
||||
wpi::sysid::SysIdRoutineLog::StateEnumToString(state) + "-" +
|
||||
m_mechanism.m_name)
|
||||
.WithTimeout(m_config.m_timeout);
|
||||
m_mechanism.name)
|
||||
.WithTimeout(m_config.timeout);
|
||||
}
|
||||
|
||||
@@ -23,17 +23,17 @@ using ramp_rate_t = wpi::units::unit_t<wpi::units::compound_unit<
|
||||
class Config {
|
||||
public:
|
||||
/// The voltage ramp rate used for quasistatic test routines.
|
||||
ramp_rate_t m_rampRate{1_V / 1_s};
|
||||
ramp_rate_t rampRate{1_V / 1_s};
|
||||
|
||||
/// The step voltage output used for dynamic test routines.
|
||||
wpi::units::volt_t m_stepVoltage{7_V};
|
||||
wpi::units::volt_t stepVoltage{7_V};
|
||||
|
||||
/// Safety timeout for the test routine commands.
|
||||
wpi::units::second_t m_timeout{10_s};
|
||||
wpi::units::second_t timeout{10_s};
|
||||
|
||||
/// Optional handle for recording test state in a third-party logging
|
||||
/// solution.
|
||||
std::function<void(wpi::sysid::State)> m_recordState;
|
||||
std::function<void(wpi::sysid::State)> recordState;
|
||||
|
||||
/**
|
||||
* Create a new configuration for a SysId test routine.
|
||||
@@ -52,15 +52,15 @@ class Config {
|
||||
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)} {
|
||||
: recordState{std::move(recordState)} {
|
||||
if (rampRate) {
|
||||
m_rampRate = rampRate.value();
|
||||
this->rampRate = rampRate.value();
|
||||
}
|
||||
if (stepVoltage) {
|
||||
m_stepVoltage = stepVoltage.value();
|
||||
this->stepVoltage = stepVoltage.value();
|
||||
}
|
||||
if (timeout) {
|
||||
m_timeout = timeout.value();
|
||||
this->timeout = timeout.value();
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -69,19 +69,19 @@ class Mechanism {
|
||||
public:
|
||||
/// Sends the SysId-specified drive signal to the mechanism motors during test
|
||||
/// routines.
|
||||
std::function<void(wpi::units::volt_t)> m_drive;
|
||||
std::function<void(wpi::units::volt_t)> drive;
|
||||
|
||||
/// Returns measured data (voltages, positions, velocities) of the mechanism
|
||||
/// motors during test routines.
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> m_log;
|
||||
std::function<void(wpi::sysid::SysIdRoutineLog*)> log;
|
||||
|
||||
/// The subsystem containing the motor(s) that is (or are) being
|
||||
/// characterized.
|
||||
wpi::cmd::Subsystem* m_subsystem;
|
||||
wpi::cmd::Subsystem* 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".
|
||||
std::string m_name;
|
||||
std::string name;
|
||||
|
||||
/**
|
||||
* Create a new mechanism specification for a SysId routine.
|
||||
@@ -105,10 +105,10 @@ class Mechanism {
|
||||
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) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
m_subsystem{subsystem},
|
||||
m_name{name} {}
|
||||
: drive{std::move(drive)},
|
||||
log{log ? std::move(log) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
subsystem{subsystem},
|
||||
name{name} {}
|
||||
|
||||
/**
|
||||
* Create a new mechanism specification for a SysId routine. Defaults the
|
||||
@@ -130,10 +130,10 @@ class Mechanism {
|
||||
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) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
m_subsystem{subsystem},
|
||||
m_name{m_subsystem->GetName()} {}
|
||||
: drive{std::move(drive)},
|
||||
log{log ? std::move(log) : [](wpi::sysid::SysIdRoutineLog* log) {}},
|
||||
subsystem{subsystem},
|
||||
name{subsystem->GetName()} {}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -176,10 +176,10 @@ class SysIdRoutine : public wpi::sysid::SysIdRoutineLog {
|
||||
* @param mechanism Hardware interface for the SysId routine.
|
||||
*/
|
||||
SysIdRoutine(Config config, Mechanism mechanism)
|
||||
: SysIdRoutineLog(mechanism.m_name),
|
||||
: SysIdRoutineLog(mechanism.name),
|
||||
m_config(config),
|
||||
m_mechanism(mechanism),
|
||||
m_recordState(config.m_recordState ? config.m_recordState
|
||||
m_recordState(config.recordState ? config.recordState
|
||||
: [this](wpi::sysid::State state) {
|
||||
this->RecordState(state);
|
||||
}) {}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.vision.camera;
|
||||
|
||||
/** USB camera information. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class UsbCameraInfo {
|
||||
/**
|
||||
* Create a new set of UsbCameraInfo.
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.vision.camera;
|
||||
|
||||
/** Video event. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class VideoEvent {
|
||||
/** VideoEvent kind. */
|
||||
public enum Kind {
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.util.Objects;
|
||||
import org.wpilib.util.PixelFormat;
|
||||
|
||||
/** Video mode. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class VideoMode {
|
||||
/**
|
||||
* Create a new video mode.
|
||||
|
||||
@@ -124,7 +124,6 @@ public class DataLogRecord {
|
||||
* Data contained in a start control record as created by DataLog.start() when writing the log.
|
||||
* This can be read by calling getStartData().
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class StartRecordData {
|
||||
StartRecordData(int entry, String name, String type, String metadata) {
|
||||
this.entry = entry;
|
||||
@@ -169,7 +168,6 @@ public class DataLogRecord {
|
||||
* Data contained in a set metadata control record as created by DataLog.setMetadata(). This can
|
||||
* be read by calling getSetMetadataData().
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class MetadataRecordData {
|
||||
MetadataRecordData(int entry, String metadata) {
|
||||
this.entry = entry;
|
||||
|
||||
@@ -119,7 +119,6 @@ class DataLogTest {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
private static int cloneCalls;
|
||||
|
||||
static class CloneableThing implements StructSerializable, Cloneable {
|
||||
@@ -201,10 +200,8 @@ class DataLogTest {
|
||||
public static final ThingStruct struct = new ThingStruct();
|
||||
}
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
private ByteArrayOutputStream data;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
private DataLog log;
|
||||
|
||||
@BeforeEach
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.wpilib.units.measure.Time;
|
||||
* A configuration object to be used by the generated {@code Epilogue} class to customize its
|
||||
* behavior.
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:MemberName")
|
||||
public class EpilogueConfiguration {
|
||||
/**
|
||||
* The backend implementation for Epilogue to use. By default, this will log data directly to
|
||||
|
||||
@@ -17,39 +17,38 @@ import java.nio.file.Path;
|
||||
public class FieldConfig {
|
||||
public static class Corners {
|
||||
@Json.Property("top-left")
|
||||
public double[] m_topLeft;
|
||||
public double[] topLeft;
|
||||
|
||||
@Json.Property("bottom-right")
|
||||
public double[] m_bottomRight;
|
||||
public double[] bottomRight;
|
||||
}
|
||||
|
||||
@Json.Property("game")
|
||||
public String m_game;
|
||||
public String game;
|
||||
|
||||
@Json.Property("field-image")
|
||||
public String m_fieldImage;
|
||||
public String fieldImage;
|
||||
|
||||
@Json.Property("field-corners")
|
||||
public Corners m_fieldCorners;
|
||||
public Corners fieldCorners;
|
||||
|
||||
@Json.Property("field-size")
|
||||
public double[] m_fieldSize;
|
||||
public double[] fieldSize;
|
||||
|
||||
@Json.Property("field-unit")
|
||||
public String m_fieldUnit;
|
||||
public String fieldUnit;
|
||||
|
||||
@Json.Property("program")
|
||||
public String m_program;
|
||||
public String program;
|
||||
|
||||
public FieldConfig() {}
|
||||
|
||||
public URL getImageUrl() {
|
||||
return getClass().getResource(Fields.BASE_RESOURCE_DIR + m_program + "/" + m_fieldImage);
|
||||
return getClass().getResource(Fields.BASE_RESOURCE_DIR + program + "/" + fieldImage);
|
||||
}
|
||||
|
||||
public InputStream getImageAsStream() {
|
||||
return getClass()
|
||||
.getResourceAsStream(Fields.BASE_RESOURCE_DIR + m_program + "/" + m_fieldImage);
|
||||
return getClass().getResourceAsStream(Fields.BASE_RESOURCE_DIR + program + "/" + fieldImage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,6 @@ public enum Fields {
|
||||
|
||||
public static final String BASE_RESOURCE_DIR = "/org/wpilib/fields/";
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String resourceFile;
|
||||
|
||||
Fields(String resourceFile) {
|
||||
|
||||
@@ -55,7 +55,6 @@ public final class CANAPITypes {
|
||||
FIRMWARE_UPDATE(31);
|
||||
|
||||
/** The device type ID. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int id;
|
||||
|
||||
CANDeviceType(int id) {
|
||||
@@ -118,7 +117,6 @@ public final class CANAPITypes {
|
||||
BRUSHLAND_LABS(20);
|
||||
|
||||
/** The manufacturer ID. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int id;
|
||||
|
||||
CANManufacturer(int id) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.hardware.hal;
|
||||
|
||||
/** Structure for holding the match info data request. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class MatchInfoData {
|
||||
/** Stores the event name. */
|
||||
public String eventName = "";
|
||||
|
||||
@@ -7,22 +7,16 @@ package org.wpilib.hardware.hal;
|
||||
/** An individual opmode option. */
|
||||
public class OpModeOption {
|
||||
/** Unique id. Encodes robot mode in bits 57-56, LSB 56 bits is hash of name. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long id;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String name;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String group;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String description;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int textColor;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int backgroundColor;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,88 +8,87 @@ package org.wpilib.hardware.hal;
|
||||
* Faults for a PowerDistribution device. These faults are only active while the condition is
|
||||
* active.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public class PowerDistributionFaults {
|
||||
/** Breaker fault on channel 0. */
|
||||
public final boolean Channel0BreakerFault;
|
||||
public final boolean channel0BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 1. */
|
||||
public final boolean Channel1BreakerFault;
|
||||
public final boolean channel1BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 2. */
|
||||
public final boolean Channel2BreakerFault;
|
||||
public final boolean channel2BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 3. */
|
||||
public final boolean Channel3BreakerFault;
|
||||
public final boolean channel3BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 4. */
|
||||
public final boolean Channel4BreakerFault;
|
||||
public final boolean channel4BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 5. */
|
||||
public final boolean Channel5BreakerFault;
|
||||
public final boolean channel5BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 6. */
|
||||
public final boolean Channel6BreakerFault;
|
||||
public final boolean channel6BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 7. */
|
||||
public final boolean Channel7BreakerFault;
|
||||
public final boolean channel7BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 8. */
|
||||
public final boolean Channel8BreakerFault;
|
||||
public final boolean channel8BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 9. */
|
||||
public final boolean Channel9BreakerFault;
|
||||
public final boolean channel9BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 10. */
|
||||
public final boolean Channel10BreakerFault;
|
||||
public final boolean channel10BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 11. */
|
||||
public final boolean Channel11BreakerFault;
|
||||
public final boolean channel11BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 12. */
|
||||
public final boolean Channel12BreakerFault;
|
||||
public final boolean channel12BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 13. */
|
||||
public final boolean Channel13BreakerFault;
|
||||
public final boolean channel13BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 14. */
|
||||
public final boolean Channel14BreakerFault;
|
||||
public final boolean channel14BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 15. */
|
||||
public final boolean Channel15BreakerFault;
|
||||
public final boolean channel15BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 16. */
|
||||
public final boolean Channel16BreakerFault;
|
||||
public final boolean channel16BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 17. */
|
||||
public final boolean Channel17BreakerFault;
|
||||
public final boolean channel17BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 18. */
|
||||
public final boolean Channel18BreakerFault;
|
||||
public final boolean channel18BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 19. */
|
||||
public final boolean Channel19BreakerFault;
|
||||
public final boolean channel19BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 20. */
|
||||
public final boolean Channel20BreakerFault;
|
||||
public final boolean channel20BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 21. */
|
||||
public final boolean Channel21BreakerFault;
|
||||
public final boolean channel21BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 22. */
|
||||
public final boolean Channel22BreakerFault;
|
||||
public final boolean channel22BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 23. */
|
||||
public final boolean Channel23BreakerFault;
|
||||
public final boolean channel23BreakerFault;
|
||||
|
||||
/** The input voltage is below the minimum voltage. */
|
||||
public final boolean Brownout;
|
||||
public final boolean brownout;
|
||||
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
public final boolean CanWarning;
|
||||
public final boolean canWarning;
|
||||
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
public final boolean HardwareFault;
|
||||
public final boolean hardwareFault;
|
||||
|
||||
/**
|
||||
* Gets whether there is a breaker fault at the specified channel.
|
||||
@@ -101,30 +100,30 @@ public class PowerDistributionFaults {
|
||||
*/
|
||||
public final boolean getBreakerFault(int channel) {
|
||||
return switch (channel) {
|
||||
case 0 -> Channel0BreakerFault;
|
||||
case 1 -> Channel1BreakerFault;
|
||||
case 2 -> Channel2BreakerFault;
|
||||
case 3 -> Channel3BreakerFault;
|
||||
case 4 -> Channel4BreakerFault;
|
||||
case 5 -> Channel5BreakerFault;
|
||||
case 6 -> Channel6BreakerFault;
|
||||
case 7 -> Channel7BreakerFault;
|
||||
case 8 -> Channel8BreakerFault;
|
||||
case 9 -> Channel9BreakerFault;
|
||||
case 10 -> Channel10BreakerFault;
|
||||
case 11 -> Channel11BreakerFault;
|
||||
case 12 -> Channel12BreakerFault;
|
||||
case 13 -> Channel13BreakerFault;
|
||||
case 14 -> Channel14BreakerFault;
|
||||
case 15 -> Channel15BreakerFault;
|
||||
case 16 -> Channel16BreakerFault;
|
||||
case 17 -> Channel17BreakerFault;
|
||||
case 18 -> Channel18BreakerFault;
|
||||
case 19 -> Channel19BreakerFault;
|
||||
case 20 -> Channel20BreakerFault;
|
||||
case 21 -> Channel21BreakerFault;
|
||||
case 22 -> Channel22BreakerFault;
|
||||
case 23 -> Channel23BreakerFault;
|
||||
case 0 -> channel0BreakerFault;
|
||||
case 1 -> channel1BreakerFault;
|
||||
case 2 -> channel2BreakerFault;
|
||||
case 3 -> channel3BreakerFault;
|
||||
case 4 -> channel4BreakerFault;
|
||||
case 5 -> channel5BreakerFault;
|
||||
case 6 -> channel6BreakerFault;
|
||||
case 7 -> channel7BreakerFault;
|
||||
case 8 -> channel8BreakerFault;
|
||||
case 9 -> channel9BreakerFault;
|
||||
case 10 -> channel10BreakerFault;
|
||||
case 11 -> channel11BreakerFault;
|
||||
case 12 -> channel12BreakerFault;
|
||||
case 13 -> channel13BreakerFault;
|
||||
case 14 -> channel14BreakerFault;
|
||||
case 15 -> channel15BreakerFault;
|
||||
case 16 -> channel16BreakerFault;
|
||||
case 17 -> channel17BreakerFault;
|
||||
case 18 -> channel18BreakerFault;
|
||||
case 19 -> channel19BreakerFault;
|
||||
case 20 -> channel20BreakerFault;
|
||||
case 21 -> channel21BreakerFault;
|
||||
case 22 -> channel22BreakerFault;
|
||||
case 23 -> channel23BreakerFault;
|
||||
default ->
|
||||
throw new IndexOutOfBoundsException("Power distribution fault channel out of bounds!");
|
||||
};
|
||||
@@ -136,32 +135,32 @@ public class PowerDistributionFaults {
|
||||
* @param faults faults
|
||||
*/
|
||||
public PowerDistributionFaults(int faults) {
|
||||
Channel0BreakerFault = (faults & 0x1) != 0;
|
||||
Channel1BreakerFault = (faults & 0x2) != 0;
|
||||
Channel2BreakerFault = (faults & 0x4) != 0;
|
||||
Channel3BreakerFault = (faults & 0x8) != 0;
|
||||
Channel4BreakerFault = (faults & 0x10) != 0;
|
||||
Channel5BreakerFault = (faults & 0x20) != 0;
|
||||
Channel6BreakerFault = (faults & 0x40) != 0;
|
||||
Channel7BreakerFault = (faults & 0x80) != 0;
|
||||
Channel8BreakerFault = (faults & 0x100) != 0;
|
||||
Channel9BreakerFault = (faults & 0x200) != 0;
|
||||
Channel10BreakerFault = (faults & 0x400) != 0;
|
||||
Channel11BreakerFault = (faults & 0x800) != 0;
|
||||
Channel12BreakerFault = (faults & 0x1000) != 0;
|
||||
Channel13BreakerFault = (faults & 0x2000) != 0;
|
||||
Channel14BreakerFault = (faults & 0x4000) != 0;
|
||||
Channel15BreakerFault = (faults & 0x8000) != 0;
|
||||
Channel16BreakerFault = (faults & 0x10000) != 0;
|
||||
Channel17BreakerFault = (faults & 0x20000) != 0;
|
||||
Channel18BreakerFault = (faults & 0x40000) != 0;
|
||||
Channel19BreakerFault = (faults & 0x80000) != 0;
|
||||
Channel20BreakerFault = (faults & 0x100000) != 0;
|
||||
Channel21BreakerFault = (faults & 0x200000) != 0;
|
||||
Channel22BreakerFault = (faults & 0x400000) != 0;
|
||||
Channel23BreakerFault = (faults & 0x800000) != 0;
|
||||
Brownout = (faults & 0x1000000) != 0;
|
||||
CanWarning = (faults & 0x2000000) != 0;
|
||||
HardwareFault = (faults & 0x4000000) != 0;
|
||||
channel0BreakerFault = (faults & 0x1) != 0;
|
||||
channel1BreakerFault = (faults & 0x2) != 0;
|
||||
channel2BreakerFault = (faults & 0x4) != 0;
|
||||
channel3BreakerFault = (faults & 0x8) != 0;
|
||||
channel4BreakerFault = (faults & 0x10) != 0;
|
||||
channel5BreakerFault = (faults & 0x20) != 0;
|
||||
channel6BreakerFault = (faults & 0x40) != 0;
|
||||
channel7BreakerFault = (faults & 0x80) != 0;
|
||||
channel8BreakerFault = (faults & 0x100) != 0;
|
||||
channel9BreakerFault = (faults & 0x200) != 0;
|
||||
channel10BreakerFault = (faults & 0x400) != 0;
|
||||
channel11BreakerFault = (faults & 0x800) != 0;
|
||||
channel12BreakerFault = (faults & 0x1000) != 0;
|
||||
channel13BreakerFault = (faults & 0x2000) != 0;
|
||||
channel14BreakerFault = (faults & 0x4000) != 0;
|
||||
channel15BreakerFault = (faults & 0x8000) != 0;
|
||||
channel16BreakerFault = (faults & 0x10000) != 0;
|
||||
channel17BreakerFault = (faults & 0x20000) != 0;
|
||||
channel18BreakerFault = (faults & 0x40000) != 0;
|
||||
channel19BreakerFault = (faults & 0x80000) != 0;
|
||||
channel20BreakerFault = (faults & 0x100000) != 0;
|
||||
channel21BreakerFault = (faults & 0x200000) != 0;
|
||||
channel22BreakerFault = (faults & 0x400000) != 0;
|
||||
channel23BreakerFault = (faults & 0x800000) != 0;
|
||||
brownout = (faults & 0x1000000) != 0;
|
||||
canWarning = (faults & 0x2000000) != 0;
|
||||
hardwareFault = (faults & 0x4000000) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,97 +8,96 @@ package org.wpilib.hardware.hal;
|
||||
* Sticky faults for a PowerDistribution device. These faults will remain active until they are
|
||||
* reset by the user.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public class PowerDistributionStickyFaults {
|
||||
/** Breaker fault on channel 0. */
|
||||
public final boolean Channel0BreakerFault;
|
||||
public final boolean channel0BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 1. */
|
||||
public final boolean Channel1BreakerFault;
|
||||
public final boolean channel1BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 2. */
|
||||
public final boolean Channel2BreakerFault;
|
||||
public final boolean channel2BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 3. */
|
||||
public final boolean Channel3BreakerFault;
|
||||
public final boolean channel3BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 4. */
|
||||
public final boolean Channel4BreakerFault;
|
||||
public final boolean channel4BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 5. */
|
||||
public final boolean Channel5BreakerFault;
|
||||
public final boolean channel5BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 6. */
|
||||
public final boolean Channel6BreakerFault;
|
||||
public final boolean channel6BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 7. */
|
||||
public final boolean Channel7BreakerFault;
|
||||
public final boolean channel7BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 8. */
|
||||
public final boolean Channel8BreakerFault;
|
||||
public final boolean channel8BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 9. */
|
||||
public final boolean Channel9BreakerFault;
|
||||
public final boolean channel9BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 10. */
|
||||
public final boolean Channel10BreakerFault;
|
||||
public final boolean channel10BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 11. */
|
||||
public final boolean Channel11BreakerFault;
|
||||
public final boolean channel11BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 12. */
|
||||
public final boolean Channel12BreakerFault;
|
||||
public final boolean channel12BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 13. */
|
||||
public final boolean Channel13BreakerFault;
|
||||
public final boolean channel13BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 14. */
|
||||
public final boolean Channel14BreakerFault;
|
||||
public final boolean channel14BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 15. */
|
||||
public final boolean Channel15BreakerFault;
|
||||
public final boolean channel15BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 16. */
|
||||
public final boolean Channel16BreakerFault;
|
||||
public final boolean channel16BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 17. */
|
||||
public final boolean Channel17BreakerFault;
|
||||
public final boolean channel17BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 18. */
|
||||
public final boolean Channel18BreakerFault;
|
||||
public final boolean channel18BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 19. */
|
||||
public final boolean Channel19BreakerFault;
|
||||
public final boolean channel19BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 20. */
|
||||
public final boolean Channel20BreakerFault;
|
||||
public final boolean channel20BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 21. */
|
||||
public final boolean Channel21BreakerFault;
|
||||
public final boolean channel21BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 22. */
|
||||
public final boolean Channel22BreakerFault;
|
||||
public final boolean channel22BreakerFault;
|
||||
|
||||
/** Breaker fault on channel 23. */
|
||||
public final boolean Channel23BreakerFault;
|
||||
public final boolean channel23BreakerFault;
|
||||
|
||||
/** The input voltage was below the minimum voltage. */
|
||||
public final boolean Brownout;
|
||||
public final boolean brownout;
|
||||
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
public final boolean CanWarning;
|
||||
public final boolean canWarning;
|
||||
|
||||
/** The device's CAN controller experienced a "Bus Off" event. */
|
||||
public final boolean CanBusOff;
|
||||
public final boolean canBusOff;
|
||||
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
public final boolean HardwareFault;
|
||||
public final boolean hardwareFault;
|
||||
|
||||
/** The firmware on the device has malfunctioned. */
|
||||
public final boolean FirmwareFault;
|
||||
public final boolean firmwareFault;
|
||||
|
||||
/** The device has rebooted. */
|
||||
public final boolean HasReset;
|
||||
public final boolean hasReset;
|
||||
|
||||
/**
|
||||
* Gets whether there is a sticky breaker fault at the specified channel.
|
||||
@@ -110,30 +109,30 @@ public class PowerDistributionStickyFaults {
|
||||
*/
|
||||
public final boolean getBreakerFault(int channel) {
|
||||
return switch (channel) {
|
||||
case 0 -> Channel0BreakerFault;
|
||||
case 1 -> Channel1BreakerFault;
|
||||
case 2 -> Channel2BreakerFault;
|
||||
case 3 -> Channel3BreakerFault;
|
||||
case 4 -> Channel4BreakerFault;
|
||||
case 5 -> Channel5BreakerFault;
|
||||
case 6 -> Channel6BreakerFault;
|
||||
case 7 -> Channel7BreakerFault;
|
||||
case 8 -> Channel8BreakerFault;
|
||||
case 9 -> Channel9BreakerFault;
|
||||
case 10 -> Channel10BreakerFault;
|
||||
case 11 -> Channel11BreakerFault;
|
||||
case 12 -> Channel12BreakerFault;
|
||||
case 13 -> Channel13BreakerFault;
|
||||
case 14 -> Channel14BreakerFault;
|
||||
case 15 -> Channel15BreakerFault;
|
||||
case 16 -> Channel16BreakerFault;
|
||||
case 17 -> Channel17BreakerFault;
|
||||
case 18 -> Channel18BreakerFault;
|
||||
case 19 -> Channel19BreakerFault;
|
||||
case 20 -> Channel20BreakerFault;
|
||||
case 21 -> Channel21BreakerFault;
|
||||
case 22 -> Channel22BreakerFault;
|
||||
case 23 -> Channel23BreakerFault;
|
||||
case 0 -> channel0BreakerFault;
|
||||
case 1 -> channel1BreakerFault;
|
||||
case 2 -> channel2BreakerFault;
|
||||
case 3 -> channel3BreakerFault;
|
||||
case 4 -> channel4BreakerFault;
|
||||
case 5 -> channel5BreakerFault;
|
||||
case 6 -> channel6BreakerFault;
|
||||
case 7 -> channel7BreakerFault;
|
||||
case 8 -> channel8BreakerFault;
|
||||
case 9 -> channel9BreakerFault;
|
||||
case 10 -> channel10BreakerFault;
|
||||
case 11 -> channel11BreakerFault;
|
||||
case 12 -> channel12BreakerFault;
|
||||
case 13 -> channel13BreakerFault;
|
||||
case 14 -> channel14BreakerFault;
|
||||
case 15 -> channel15BreakerFault;
|
||||
case 16 -> channel16BreakerFault;
|
||||
case 17 -> channel17BreakerFault;
|
||||
case 18 -> channel18BreakerFault;
|
||||
case 19 -> channel19BreakerFault;
|
||||
case 20 -> channel20BreakerFault;
|
||||
case 21 -> channel21BreakerFault;
|
||||
case 22 -> channel22BreakerFault;
|
||||
case 23 -> channel23BreakerFault;
|
||||
default ->
|
||||
throw new IndexOutOfBoundsException("Power distribution fault channel out of bounds!");
|
||||
};
|
||||
@@ -145,35 +144,35 @@ public class PowerDistributionStickyFaults {
|
||||
* @param faults faults
|
||||
*/
|
||||
public PowerDistributionStickyFaults(int faults) {
|
||||
Channel0BreakerFault = (faults & 0x1) != 0;
|
||||
Channel1BreakerFault = (faults & 0x2) != 0;
|
||||
Channel2BreakerFault = (faults & 0x4) != 0;
|
||||
Channel3BreakerFault = (faults & 0x8) != 0;
|
||||
Channel4BreakerFault = (faults & 0x10) != 0;
|
||||
Channel5BreakerFault = (faults & 0x20) != 0;
|
||||
Channel6BreakerFault = (faults & 0x40) != 0;
|
||||
Channel7BreakerFault = (faults & 0x80) != 0;
|
||||
Channel8BreakerFault = (faults & 0x100) != 0;
|
||||
Channel9BreakerFault = (faults & 0x200) != 0;
|
||||
Channel10BreakerFault = (faults & 0x400) != 0;
|
||||
Channel11BreakerFault = (faults & 0x800) != 0;
|
||||
Channel12BreakerFault = (faults & 0x1000) != 0;
|
||||
Channel13BreakerFault = (faults & 0x2000) != 0;
|
||||
Channel14BreakerFault = (faults & 0x4000) != 0;
|
||||
Channel15BreakerFault = (faults & 0x8000) != 0;
|
||||
Channel16BreakerFault = (faults & 0x10000) != 0;
|
||||
Channel17BreakerFault = (faults & 0x20000) != 0;
|
||||
Channel18BreakerFault = (faults & 0x40000) != 0;
|
||||
Channel19BreakerFault = (faults & 0x80000) != 0;
|
||||
Channel20BreakerFault = (faults & 0x100000) != 0;
|
||||
Channel21BreakerFault = (faults & 0x200000) != 0;
|
||||
Channel22BreakerFault = (faults & 0x400000) != 0;
|
||||
Channel23BreakerFault = (faults & 0x800000) != 0;
|
||||
Brownout = (faults & 0x1000000) != 0;
|
||||
CanWarning = (faults & 0x2000000) != 0;
|
||||
CanBusOff = (faults & 0x4000000) != 0;
|
||||
HardwareFault = (faults & 0x8000000) != 0;
|
||||
FirmwareFault = (faults & 0x10000000) != 0;
|
||||
HasReset = (faults & 0x20000000) != 0;
|
||||
channel0BreakerFault = (faults & 0x1) != 0;
|
||||
channel1BreakerFault = (faults & 0x2) != 0;
|
||||
channel2BreakerFault = (faults & 0x4) != 0;
|
||||
channel3BreakerFault = (faults & 0x8) != 0;
|
||||
channel4BreakerFault = (faults & 0x10) != 0;
|
||||
channel5BreakerFault = (faults & 0x20) != 0;
|
||||
channel6BreakerFault = (faults & 0x40) != 0;
|
||||
channel7BreakerFault = (faults & 0x80) != 0;
|
||||
channel8BreakerFault = (faults & 0x100) != 0;
|
||||
channel9BreakerFault = (faults & 0x200) != 0;
|
||||
channel10BreakerFault = (faults & 0x400) != 0;
|
||||
channel11BreakerFault = (faults & 0x800) != 0;
|
||||
channel12BreakerFault = (faults & 0x1000) != 0;
|
||||
channel13BreakerFault = (faults & 0x2000) != 0;
|
||||
channel14BreakerFault = (faults & 0x4000) != 0;
|
||||
channel15BreakerFault = (faults & 0x8000) != 0;
|
||||
channel16BreakerFault = (faults & 0x10000) != 0;
|
||||
channel17BreakerFault = (faults & 0x20000) != 0;
|
||||
channel18BreakerFault = (faults & 0x40000) != 0;
|
||||
channel19BreakerFault = (faults & 0x80000) != 0;
|
||||
channel20BreakerFault = (faults & 0x100000) != 0;
|
||||
channel21BreakerFault = (faults & 0x200000) != 0;
|
||||
channel22BreakerFault = (faults & 0x400000) != 0;
|
||||
channel23BreakerFault = (faults & 0x800000) != 0;
|
||||
brownout = (faults & 0x1000000) != 0;
|
||||
canWarning = (faults & 0x2000000) != 0;
|
||||
canBusOff = (faults & 0x4000000) != 0;
|
||||
hardwareFault = (faults & 0x8000000) != 0;
|
||||
firmwareFault = (faults & 0x10000000) != 0;
|
||||
hasReset = (faults & 0x20000000) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.hardware.hal;
|
||||
|
||||
/** Power distribution version. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class PowerDistributionVersion {
|
||||
/** Firmware major version number. */
|
||||
public final int firmwareMajor;
|
||||
|
||||
@@ -5,73 +5,72 @@
|
||||
package org.wpilib.hardware.hal;
|
||||
|
||||
/** Faults for a REV PH. These faults are only active while the condition is active. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class REVPHFaults {
|
||||
/** Fault on channel 0. */
|
||||
public final boolean Channel0Fault;
|
||||
public final boolean channel0Fault;
|
||||
|
||||
/** Fault on channel 1. */
|
||||
public final boolean Channel1Fault;
|
||||
public final boolean channel1Fault;
|
||||
|
||||
/** Fault on channel 2. */
|
||||
public final boolean Channel2Fault;
|
||||
public final boolean channel2Fault;
|
||||
|
||||
/** Fault on channel 3. */
|
||||
public final boolean Channel3Fault;
|
||||
public final boolean channel3Fault;
|
||||
|
||||
/** Fault on channel 4. */
|
||||
public final boolean Channel4Fault;
|
||||
public final boolean channel4Fault;
|
||||
|
||||
/** Fault on channel 5. */
|
||||
public final boolean Channel5Fault;
|
||||
public final boolean channel5Fault;
|
||||
|
||||
/** Fault on channel 6. */
|
||||
public final boolean Channel6Fault;
|
||||
public final boolean channel6Fault;
|
||||
|
||||
/** Fault on channel 7. */
|
||||
public final boolean Channel7Fault;
|
||||
public final boolean channel7Fault;
|
||||
|
||||
/** Fault on channel 8. */
|
||||
public final boolean Channel8Fault;
|
||||
public final boolean channel8Fault;
|
||||
|
||||
/** Fault on channel 9. */
|
||||
public final boolean Channel9Fault;
|
||||
public final boolean channel9Fault;
|
||||
|
||||
/** Fault on channel 10. */
|
||||
public final boolean Channel10Fault;
|
||||
public final boolean channel10Fault;
|
||||
|
||||
/** Fault on channel 11. */
|
||||
public final boolean Channel11Fault;
|
||||
public final boolean channel11Fault;
|
||||
|
||||
/** Fault on channel 12. */
|
||||
public final boolean Channel12Fault;
|
||||
public final boolean channel12Fault;
|
||||
|
||||
/** Fault on channel 13. */
|
||||
public final boolean Channel13Fault;
|
||||
public final boolean channel13Fault;
|
||||
|
||||
/** Fault on channel 14. */
|
||||
public final boolean Channel14Fault;
|
||||
public final boolean channel14Fault;
|
||||
|
||||
/** Fault on channel 15. */
|
||||
public final boolean Channel15Fault;
|
||||
public final boolean channel15Fault;
|
||||
|
||||
/** An overcurrent event occurred on the compressor output. */
|
||||
public final boolean CompressorOverCurrent;
|
||||
public final boolean compressorOverCurrent;
|
||||
|
||||
/** The compressor output has an open circuit. */
|
||||
public final boolean CompressorOpen;
|
||||
public final boolean compressorOpen;
|
||||
|
||||
/** An overcurrent event occurred on a solenoid output. */
|
||||
public final boolean SolenoidOverCurrent;
|
||||
public final boolean solenoidOverCurrent;
|
||||
|
||||
/** The input voltage is below the minimum voltage. */
|
||||
public final boolean Brownout;
|
||||
public final boolean brownout;
|
||||
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
public final boolean CanWarning;
|
||||
public final boolean canWarning;
|
||||
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
public final boolean HardwareFault;
|
||||
public final boolean hardwareFault;
|
||||
|
||||
/**
|
||||
* Gets whether there is a fault at the specified channel.
|
||||
@@ -81,24 +80,24 @@ public class REVPHFaults {
|
||||
* @throws IndexOutOfBoundsException if the provided channel is outside of the range supported by
|
||||
* the hardware.
|
||||
*/
|
||||
public final boolean getChannelFault(int channel) {
|
||||
public final boolean getchannelFault(int channel) {
|
||||
return switch (channel) {
|
||||
case 0 -> Channel0Fault;
|
||||
case 1 -> Channel1Fault;
|
||||
case 2 -> Channel2Fault;
|
||||
case 3 -> Channel3Fault;
|
||||
case 4 -> Channel4Fault;
|
||||
case 5 -> Channel5Fault;
|
||||
case 6 -> Channel6Fault;
|
||||
case 7 -> Channel7Fault;
|
||||
case 8 -> Channel8Fault;
|
||||
case 9 -> Channel9Fault;
|
||||
case 10 -> Channel10Fault;
|
||||
case 11 -> Channel11Fault;
|
||||
case 12 -> Channel12Fault;
|
||||
case 13 -> Channel13Fault;
|
||||
case 14 -> Channel14Fault;
|
||||
case 15 -> Channel15Fault;
|
||||
case 0 -> channel0Fault;
|
||||
case 1 -> channel1Fault;
|
||||
case 2 -> channel2Fault;
|
||||
case 3 -> channel3Fault;
|
||||
case 4 -> channel4Fault;
|
||||
case 5 -> channel5Fault;
|
||||
case 6 -> channel6Fault;
|
||||
case 7 -> channel7Fault;
|
||||
case 8 -> channel8Fault;
|
||||
case 9 -> channel9Fault;
|
||||
case 10 -> channel10Fault;
|
||||
case 11 -> channel11Fault;
|
||||
case 12 -> channel12Fault;
|
||||
case 13 -> channel13Fault;
|
||||
case 14 -> channel14Fault;
|
||||
case 15 -> channel15Fault;
|
||||
default -> throw new IndexOutOfBoundsException("Pneumatics fault channel out of bounds!");
|
||||
};
|
||||
}
|
||||
@@ -109,27 +108,27 @@ public class REVPHFaults {
|
||||
* @param faults the fault bitfields
|
||||
*/
|
||||
public REVPHFaults(int faults) {
|
||||
Channel0Fault = (faults & (1 << 0)) != 0;
|
||||
Channel1Fault = (faults & (1 << 1)) != 0;
|
||||
Channel2Fault = (faults & (1 << 2)) != 0;
|
||||
Channel3Fault = (faults & (1 << 3)) != 0;
|
||||
Channel4Fault = (faults & (1 << 4)) != 0;
|
||||
Channel5Fault = (faults & (1 << 5)) != 0;
|
||||
Channel6Fault = (faults & (1 << 6)) != 0;
|
||||
Channel7Fault = (faults & (1 << 7)) != 0;
|
||||
Channel8Fault = (faults & (1 << 8)) != 0;
|
||||
Channel9Fault = (faults & (1 << 9)) != 0;
|
||||
Channel10Fault = (faults & (1 << 10)) != 0;
|
||||
Channel11Fault = (faults & (1 << 11)) != 0;
|
||||
Channel12Fault = (faults & (1 << 12)) != 0;
|
||||
Channel13Fault = (faults & (1 << 13)) != 0;
|
||||
Channel14Fault = (faults & (1 << 14)) != 0;
|
||||
Channel15Fault = (faults & (1 << 15)) != 0;
|
||||
CompressorOverCurrent = (faults & (1 << 16)) != 0;
|
||||
CompressorOpen = (faults & (1 << 17)) != 0;
|
||||
SolenoidOverCurrent = (faults & (1 << 18)) != 0;
|
||||
Brownout = (faults & (1 << 19)) != 0;
|
||||
CanWarning = (faults & (1 << 20)) != 0;
|
||||
HardwareFault = (faults & (1 << 21)) != 0;
|
||||
channel0Fault = (faults & (1 << 0)) != 0;
|
||||
channel1Fault = (faults & (1 << 1)) != 0;
|
||||
channel2Fault = (faults & (1 << 2)) != 0;
|
||||
channel3Fault = (faults & (1 << 3)) != 0;
|
||||
channel4Fault = (faults & (1 << 4)) != 0;
|
||||
channel5Fault = (faults & (1 << 5)) != 0;
|
||||
channel6Fault = (faults & (1 << 6)) != 0;
|
||||
channel7Fault = (faults & (1 << 7)) != 0;
|
||||
channel8Fault = (faults & (1 << 8)) != 0;
|
||||
channel9Fault = (faults & (1 << 9)) != 0;
|
||||
channel10Fault = (faults & (1 << 10)) != 0;
|
||||
channel11Fault = (faults & (1 << 11)) != 0;
|
||||
channel12Fault = (faults & (1 << 12)) != 0;
|
||||
channel13Fault = (faults & (1 << 13)) != 0;
|
||||
channel14Fault = (faults & (1 << 14)) != 0;
|
||||
channel15Fault = (faults & (1 << 15)) != 0;
|
||||
compressorOverCurrent = (faults & (1 << 16)) != 0;
|
||||
compressorOpen = (faults & (1 << 17)) != 0;
|
||||
solenoidOverCurrent = (faults & (1 << 18)) != 0;
|
||||
brownout = (faults & (1 << 19)) != 0;
|
||||
canWarning = (faults & (1 << 20)) != 0;
|
||||
hardwareFault = (faults & (1 << 21)) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,34 +5,33 @@
|
||||
package org.wpilib.hardware.hal;
|
||||
|
||||
/** Sticky faults for a REV PH. These faults will remain active until they are reset by the user. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class REVPHStickyFaults {
|
||||
/** An overcurrent event occurred on the compressor output. */
|
||||
public final boolean CompressorOverCurrent;
|
||||
public final boolean compressorOverCurrent;
|
||||
|
||||
/** The compressor output has an open circuit. */
|
||||
public final boolean CompressorOpen;
|
||||
public final boolean compressorOpen;
|
||||
|
||||
/** An overcurrent event occurred on a solenoid output. */
|
||||
public final boolean SolenoidOverCurrent;
|
||||
public final boolean solenoidOverCurrent;
|
||||
|
||||
/** The input voltage is below the minimum voltage. */
|
||||
public final boolean Brownout;
|
||||
public final boolean brownout;
|
||||
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
public final boolean CanWarning;
|
||||
public final boolean canWarning;
|
||||
|
||||
/** The device's CAN controller experienced a "Bus Off" event. */
|
||||
public final boolean CanBusOff;
|
||||
public final boolean canBusOff;
|
||||
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
public final boolean HardwareFault;
|
||||
public final boolean hardwareFault;
|
||||
|
||||
/** The firmware on the device has malfunctioned. */
|
||||
public final boolean FirmwareFault;
|
||||
public final boolean firmwareFault;
|
||||
|
||||
/** The device has rebooted. */
|
||||
public final boolean HasReset;
|
||||
public final boolean hasReset;
|
||||
|
||||
/**
|
||||
* Called from HAL.
|
||||
@@ -40,14 +39,14 @@ public class REVPHStickyFaults {
|
||||
* @param faults sticky fault bit mask
|
||||
*/
|
||||
public REVPHStickyFaults(int faults) {
|
||||
CompressorOverCurrent = (faults & 0x1) != 0;
|
||||
CompressorOpen = (faults & 0x2) != 0;
|
||||
SolenoidOverCurrent = (faults & 0x4) != 0;
|
||||
Brownout = (faults & 0x8) != 0;
|
||||
CanWarning = (faults & 0x10) != 0;
|
||||
CanBusOff = (faults & 0x20) != 0;
|
||||
HardwareFault = (faults & 0x40) != 0;
|
||||
FirmwareFault = (faults & 0x80) != 0;
|
||||
HasReset = (faults & 0x100) != 0;
|
||||
compressorOverCurrent = (faults & 0x1) != 0;
|
||||
compressorOpen = (faults & 0x2) != 0;
|
||||
solenoidOverCurrent = (faults & 0x4) != 0;
|
||||
brownout = (faults & 0x8) != 0;
|
||||
canWarning = (faults & 0x10) != 0;
|
||||
canBusOff = (faults & 0x20) != 0;
|
||||
hardwareFault = (faults & 0x40) != 0;
|
||||
firmwareFault = (faults & 0x80) != 0;
|
||||
hasReset = (faults & 0x100) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.hardware.hal;
|
||||
|
||||
/** Version and device data received from a REV PH. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class REVPHVersion {
|
||||
/** The firmware major version. */
|
||||
public final int firmwareMajor;
|
||||
|
||||
@@ -26,10 +26,10 @@ public class SimDevice implements AutoCloseable {
|
||||
BIDIR(SimDeviceJNI.VALUE_BIDIR);
|
||||
|
||||
/** The native value of this Direction. */
|
||||
public final int m_value;
|
||||
public final int value;
|
||||
|
||||
Direction(int value) {
|
||||
m_value = value;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class SimDevice implements AutoCloseable {
|
||||
* @return simulated value object
|
||||
*/
|
||||
public SimValue createValue(String name, Direction direction, HALValue initialValue) {
|
||||
int handle = SimDeviceJNI.createSimValue(m_handle, name, direction.m_value, initialValue);
|
||||
int handle = SimDeviceJNI.createSimValue(m_handle, name, direction.value, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class SimDevice implements AutoCloseable {
|
||||
* @return simulated double value object
|
||||
*/
|
||||
public SimInt createInt(String name, Direction direction, int initialValue) {
|
||||
int handle = SimDeviceJNI.createSimValueInt(m_handle, name, direction.m_value, initialValue);
|
||||
int handle = SimDeviceJNI.createSimValueInt(m_handle, name, direction.value, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class SimDevice implements AutoCloseable {
|
||||
* @return simulated double value object
|
||||
*/
|
||||
public SimLong createLong(String name, Direction direction, long initialValue) {
|
||||
int handle = SimDeviceJNI.createSimValueLong(m_handle, name, direction.m_value, initialValue);
|
||||
int handle = SimDeviceJNI.createSimValueLong(m_handle, name, direction.value, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class SimDevice implements AutoCloseable {
|
||||
* @return simulated double value object
|
||||
*/
|
||||
public SimDouble createDouble(String name, Direction direction, double initialValue) {
|
||||
int handle = SimDeviceJNI.createSimValueDouble(m_handle, name, direction.m_value, initialValue);
|
||||
int handle = SimDeviceJNI.createSimValueDouble(m_handle, name, direction.value, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public class SimDevice implements AutoCloseable {
|
||||
*/
|
||||
public SimEnum createEnum(String name, Direction direction, String[] options, int initialValue) {
|
||||
int handle =
|
||||
SimDeviceJNI.createSimValueEnum(m_handle, name, direction.m_value, options, initialValue);
|
||||
SimDeviceJNI.createSimValueEnum(m_handle, name, direction.value, options, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class SimDevice implements AutoCloseable {
|
||||
String name, Direction direction, String[] options, double[] optionValues, int initialValue) {
|
||||
int handle =
|
||||
SimDeviceJNI.createSimValueEnumDouble(
|
||||
m_handle, name, direction.m_value, options, optionValues, initialValue);
|
||||
m_handle, name, direction.value, options, optionValues, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
@@ -259,8 +259,7 @@ public class SimDevice implements AutoCloseable {
|
||||
* @return simulated boolean value object
|
||||
*/
|
||||
public SimBoolean createBoolean(String name, Direction direction, boolean initialValue) {
|
||||
int handle =
|
||||
SimDeviceJNI.createSimValueBoolean(m_handle, name, direction.m_value, initialValue);
|
||||
int handle = SimDeviceJNI.createSimValueBoolean(m_handle, name, direction.value, initialValue);
|
||||
if (handle <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -7,19 +7,15 @@ package org.wpilib.hardware.hal.can;
|
||||
/** Represents a CAN message read from a stream. */
|
||||
public class CANReceiveMessage {
|
||||
/** The message data. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final byte[] data = new byte[64];
|
||||
|
||||
/** The length of the data received (0-8 bytes). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int length;
|
||||
|
||||
/** The flags of the message. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int flags;
|
||||
|
||||
/** Timestamp message was received, in microseconds (wpi time). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public long timestamp;
|
||||
|
||||
/** Default constructor. */
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.hardware.hal.can;
|
||||
|
||||
/** Structure for holding the result of a CAN Status request. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class CANStatus {
|
||||
/** The utilization of the CAN Bus. */
|
||||
public double percentBusUtilization;
|
||||
|
||||
@@ -7,23 +7,18 @@ package org.wpilib.hardware.hal.can;
|
||||
/** Represents a CAN message read from a stream. */
|
||||
public class CANStreamMessage {
|
||||
/** The message data. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final byte[] data = new byte[64];
|
||||
|
||||
/** The length of the data received (0-64 bytes). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int length;
|
||||
|
||||
/** The flags of the message. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int flags;
|
||||
|
||||
/** Timestamp message was received, in milliseconds (based off of CLOCK_MONOTONIC). */
|
||||
@SuppressWarnings("MemberName")
|
||||
public long timestamp;
|
||||
|
||||
/** The message ID. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public int messageId;
|
||||
|
||||
/** Default constructor. */
|
||||
|
||||
@@ -18,19 +18,14 @@ public class AlertDataJNI extends JNIWrapper {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int handle;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String group;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String text;
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long activeStartTime; // 0 if not active
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public final int level; // ALERT_LEVEL_HIGH, ALERT_LEVEL_MEDIUM, ALERT_LEVEL_LOW
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ public class SimDeviceDataJNI extends JNIWrapper {
|
||||
|
||||
public static native int getSimValueDeviceHandle(int handle);
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class SimDeviceInfo {
|
||||
public String name;
|
||||
public int handle;
|
||||
@@ -74,7 +73,6 @@ public class SimDeviceDataJNI extends JNIWrapper {
|
||||
|
||||
public static native int getSimValueHandle(int device, String name);
|
||||
|
||||
@SuppressWarnings("MemberName")
|
||||
public static class SimValueInfo {
|
||||
public String name;
|
||||
public int handle;
|
||||
|
||||
@@ -24,19 +24,16 @@ public final class Timestamped{{ TypeName }} {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final {{ java.ValueType }} value;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedBoolean {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final boolean value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedBooleanArray {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final boolean[] value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedDouble {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final double value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedDoubleArray {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final double[] value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedFloat {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final float value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedFloatArray {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final float[] value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedInteger {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedIntegerArray {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long[] value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedRaw {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final byte[] value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedString {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String value;
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@ public final class TimestampedStringArray {
|
||||
/**
|
||||
* Timestamp in local time base.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/**
|
||||
* Timestamp in server time base. May be 0 or 1 for locally set values.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/**
|
||||
* Value.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final String[] value;
|
||||
}
|
||||
|
||||
@@ -5,31 +5,30 @@
|
||||
package org.wpilib.networktables;
|
||||
|
||||
/** NetworkTables Connection information. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final class ConnectionInfo {
|
||||
/**
|
||||
* The remote identifier (as set on the remote node by {@link
|
||||
* NetworkTableInstance#startClient(String)}).
|
||||
*/
|
||||
public final String remote_id;
|
||||
public final String remoteId;
|
||||
|
||||
/** The IP address of the remote node. */
|
||||
public final String remote_ip;
|
||||
public final String remoteIp;
|
||||
|
||||
/** The port number of the remote node. */
|
||||
public final int remote_port;
|
||||
public final int remotePort;
|
||||
|
||||
/**
|
||||
* The last time any update was received from the remote node (same scale as returned by {@link
|
||||
* NetworkTablesJNI#now()}).
|
||||
*/
|
||||
public final long last_update;
|
||||
public final long lastUpdate;
|
||||
|
||||
/**
|
||||
* The protocol version being used for this connection. This is in protocol layer format, so
|
||||
* 0x0200 = 2.0, 0x0300 = 3.0).
|
||||
*/
|
||||
public final int protocol_version;
|
||||
public final int protocolVersion;
|
||||
|
||||
/**
|
||||
* Constructor. This should generally only be used internally to NetworkTables.
|
||||
@@ -42,10 +41,10 @@ public final class ConnectionInfo {
|
||||
*/
|
||||
public ConnectionInfo(
|
||||
String remoteId, String remoteIp, int remotePort, long lastUpdate, int protocolVersion) {
|
||||
remote_id = remoteId;
|
||||
remote_ip = remoteIp;
|
||||
remote_port = remotePort;
|
||||
last_update = lastUpdate;
|
||||
protocol_version = protocolVersion;
|
||||
this.remoteId = remoteId;
|
||||
this.remoteIp = remoteIp;
|
||||
this.remotePort = remotePort;
|
||||
this.lastUpdate = lastUpdate;
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.networktables;
|
||||
|
||||
/** NetworkTables log message. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final class LogMessage {
|
||||
/** Critical logging level. */
|
||||
public static final int CRITICAL = 50;
|
||||
|
||||
@@ -10,7 +10,6 @@ package org.wpilib.networktables;
|
||||
* <p>There are different kinds of events. When creating a listener, a combination of event kinds
|
||||
* can be listened to by building an EnumSet of NetworkTableEvent.Kind.
|
||||
*/
|
||||
@SuppressWarnings("MemberName")
|
||||
public final class NetworkTableEvent {
|
||||
/** NetworkTable event kind. */
|
||||
public enum Kind {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.networktables;
|
||||
|
||||
/** NetworkTables publish/subscribe options. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public class PubSubOptions {
|
||||
/**
|
||||
* Construct from a list of options.
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.networktables;
|
||||
|
||||
/** NetworkTables time sync event data. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final class TimeSyncEventData {
|
||||
/**
|
||||
* Offset between local time and server time, in microseconds. Add this value to local time to get
|
||||
|
||||
@@ -24,14 +24,11 @@ public final class TimestampedObject<T> {
|
||||
}
|
||||
|
||||
/** Timestamp in local time base. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long timestamp;
|
||||
|
||||
/** Timestamp in server time base. May be 0 or 1 for locally set values. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final long serverTime;
|
||||
|
||||
/** Value. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final T value;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.networktables;
|
||||
|
||||
/** NetworkTables topic information. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final class TopicInfo {
|
||||
/** Topic handle. */
|
||||
public final int topic;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
package org.wpilib.networktables;
|
||||
|
||||
/** NetworkTables value event data. */
|
||||
@SuppressWarnings("MemberName")
|
||||
public final class ValueEventData {
|
||||
/** Topic handle. Topic.getHandle() can be used to map this to the corresponding Topic object. */
|
||||
public final int topic;
|
||||
|
||||
@@ -17,7 +17,7 @@ class MyRobot(wpilib.TimedRobot):
|
||||
super().__init__()
|
||||
|
||||
self.inst = ntcore.NetworkTableInstance.getDefault()
|
||||
self.doubleArrayTopic = self.inst.getDoubleArrayTopic("m_doubleArrayTopic")
|
||||
self.doubleArrayTopic = self.inst.getDoubleArrayTopic("doubleArrayTopic")
|
||||
|
||||
self.controller = wpilib.NiDsXboxController(0)
|
||||
self.drive = Drivetrain(self.doubleArrayTopic)
|
||||
|
||||
@@ -112,21 +112,17 @@ class SwerveModule:
|
||||
encoderRotation
|
||||
)
|
||||
|
||||
# Calculate the drive output from the drive PID controller.
|
||||
# Calculate the drive output from the drive PID controller and feedforward.
|
||||
driveOutput = self.drivePIDController.calculate(
|
||||
self.driveEncoder.getRate(), velocity.velocity
|
||||
)
|
||||
) + self.driveFeedforward.calculate(velocity.velocity)
|
||||
|
||||
driveFeedforward = self.driveFeedforward.calculate(velocity.velocity)
|
||||
|
||||
# Calculate the turning motor output from the turning PID controller.
|
||||
# Calculate the turning motor output from the turning PID controller and feedforward.
|
||||
turnOutput = self.turningPIDController.calculate(
|
||||
self.turningEncoder.getDistance(), velocity.angle.radians()
|
||||
)
|
||||
|
||||
turnFeedforward = self.turnFeedforward.calculate(
|
||||
) + self.turnFeedforward.calculate(
|
||||
self.turningPIDController.getSetpoint().velocity
|
||||
)
|
||||
|
||||
self.driveMotor.setVoltage(driveOutput + driveFeedforward)
|
||||
self.turningMotor.setVoltage(turnOutput + turnFeedforward)
|
||||
self.driveMotor.setVoltage(driveOutput)
|
||||
self.turningMotor.setVoltage(turnOutput)
|
||||
|
||||
@@ -7,12 +7,12 @@ suppressions PUBLIC "-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||
<suppress files=".*wpilibjIntegrationTests.*"
|
||||
checks="MissingJavadocMethod" />
|
||||
<suppress files="wpimath.*"
|
||||
checks="(LocalVariableName|MemberName|MethodName|MethodTypeParameterName|ParameterName)" />
|
||||
checks="(LocalVariableName|MethodName|MethodTypeParameterName|ParameterName)" />
|
||||
<suppress files=".*JNI.*"
|
||||
checks="(EmptyLineSeparator|LineLength|MissingJavadocMethod|ParameterName)" />
|
||||
<!-- Disable checks for generated protobuf files -->
|
||||
<suppress files=".*generated[/\\].*[/\\]proto[/\\].*"
|
||||
checks="(CustomImportOrder|EmptyLineSeparator|LeftCurly|LineLength|JavadocParagraph|MemberName|MissingJavadocMethod|OverloadMethodsDeclarationOrder|SummaryJavadoc|UnnecessaryParentheses|OperatorWrap|JavadocMethod|JavadocTagContinuationIndentation)" />
|
||||
checks="(CustomImportOrder|EmptyLineSeparator|LeftCurly|LineLength|JavadocParagraph|MissingJavadocMethod|OverloadMethodsDeclarationOrder|SummaryJavadoc|UnnecessaryParentheses|OperatorWrap|JavadocMethod|JavadocTagContinuationIndentation)" />
|
||||
<suppress files="wpilibj[/\\]src[/\\]generated.*"
|
||||
checks="MethodName" />
|
||||
<!-- Disable checkstyle for generated unit files -->
|
||||
|
||||
@@ -168,12 +168,6 @@ module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
<message key="name.invalidPattern"
|
||||
value="Type name ''{0}'' must match pattern ''{1}''." />
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format"
|
||||
value="^(m_([a-zA-Z]|[a-z][a-zA-Z0-9]+)|value)$" />
|
||||
<message key="name.invalidPattern"
|
||||
value="Member name ''{0}'' must match pattern ''{1}''." />
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format"
|
||||
value="^([a-zA-Z]|[a-z][a-zA-Z0-9]+)$" />
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<exclude-pattern>.*/Timestamped.*\.java</exclude-pattern>
|
||||
<exclude-pattern>.*/units/measure/.*\.java</exclude-pattern>
|
||||
|
||||
<exclude-pattern>.*/*IntegrationTests.*</exclude-pattern>
|
||||
<exclude-pattern>.*/*Examples.*</exclude-pattern>
|
||||
<exclude-pattern>.*/*JNI.*</exclude-pattern>
|
||||
<exclude-pattern>.*/math/proto.*</exclude-pattern>
|
||||
<exclude-pattern>.*/command3/proto.*</exclude-pattern>
|
||||
@@ -143,4 +143,22 @@
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
<rule name="PublicFieldNamingConvention"
|
||||
language="java"
|
||||
message="Public fields must follow lowerCamelCase."
|
||||
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
|
||||
<description>
|
||||
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<properties>
|
||||
<property name="xpath">
|
||||
<value>
|
||||
<![CDATA[
|
||||
//ClassDeclaration[not(matches(@PackageName, "org.wpilib.math"))]/ClassBody/FieldDeclaration[@Visibility = 'public' and @Static = false()]/VariableDeclarator[not(matches(@Name, "^[a-z][a-zA-Z0-9]*$"))]
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
|
||||
@@ -150,6 +150,10 @@
|
||||
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD" />
|
||||
<Class name="org.wpilib.epilogue.EpilogueConfiguration" />
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="URF_UNREAD_FIELD" />
|
||||
<Class name="org.wpilib.driverstation.internal.DriverStationBackend$HALJoystickAxesRaw" />
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- PMD will skip variables named `ignore`, but spotbugs isn't as smart -->
|
||||
<Bug pattern="DLS_DEAD_LOCAL_STORE" />
|
||||
|
||||
@@ -329,37 +329,37 @@ PneumaticHub::StickyFaults PneumaticHub::GetStickyFaults() const {
|
||||
bool PneumaticHub::Faults::GetChannelFault(int channel) const {
|
||||
switch (channel) {
|
||||
case 0:
|
||||
return Channel0Fault != 0;
|
||||
return channel0Fault != 0;
|
||||
case 1:
|
||||
return Channel1Fault != 0;
|
||||
return channel1Fault != 0;
|
||||
case 2:
|
||||
return Channel2Fault != 0;
|
||||
return channel2Fault != 0;
|
||||
case 3:
|
||||
return Channel3Fault != 0;
|
||||
return channel3Fault != 0;
|
||||
case 4:
|
||||
return Channel4Fault != 0;
|
||||
return channel4Fault != 0;
|
||||
case 5:
|
||||
return Channel5Fault != 0;
|
||||
return channel5Fault != 0;
|
||||
case 6:
|
||||
return Channel6Fault != 0;
|
||||
return channel6Fault != 0;
|
||||
case 7:
|
||||
return Channel7Fault != 0;
|
||||
return channel7Fault != 0;
|
||||
case 8:
|
||||
return Channel8Fault != 0;
|
||||
return channel8Fault != 0;
|
||||
case 9:
|
||||
return Channel9Fault != 0;
|
||||
return channel9Fault != 0;
|
||||
case 10:
|
||||
return Channel10Fault != 0;
|
||||
return channel10Fault != 0;
|
||||
case 11:
|
||||
return Channel11Fault != 0;
|
||||
return channel11Fault != 0;
|
||||
case 12:
|
||||
return Channel12Fault != 0;
|
||||
return channel12Fault != 0;
|
||||
case 13:
|
||||
return Channel13Fault != 0;
|
||||
return channel13Fault != 0;
|
||||
case 14:
|
||||
return Channel14Fault != 0;
|
||||
return channel14Fault != 0;
|
||||
case 15:
|
||||
return Channel15Fault != 0;
|
||||
return channel15Fault != 0;
|
||||
default:
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange,
|
||||
"Pneumatics fault channel out of bounds!");
|
||||
|
||||
@@ -196,53 +196,53 @@ PowerDistribution::Faults PowerDistribution::GetFaults() const {
|
||||
bool PowerDistribution::Faults::GetBreakerFault(int channel) const {
|
||||
switch (channel) {
|
||||
case 0:
|
||||
return Channel0BreakerFault != 0;
|
||||
return channel0BreakerFault != 0;
|
||||
case 1:
|
||||
return Channel1BreakerFault != 0;
|
||||
return channel1BreakerFault != 0;
|
||||
case 2:
|
||||
return Channel2BreakerFault != 0;
|
||||
return channel2BreakerFault != 0;
|
||||
case 3:
|
||||
return Channel3BreakerFault != 0;
|
||||
return channel3BreakerFault != 0;
|
||||
case 4:
|
||||
return Channel4BreakerFault != 0;
|
||||
return channel4BreakerFault != 0;
|
||||
case 5:
|
||||
return Channel5BreakerFault != 0;
|
||||
return channel5BreakerFault != 0;
|
||||
case 6:
|
||||
return Channel6BreakerFault != 0;
|
||||
return channel6BreakerFault != 0;
|
||||
case 7:
|
||||
return Channel7BreakerFault != 0;
|
||||
return channel7BreakerFault != 0;
|
||||
case 8:
|
||||
return Channel8BreakerFault != 0;
|
||||
return channel8BreakerFault != 0;
|
||||
case 9:
|
||||
return Channel9BreakerFault != 0;
|
||||
return channel9BreakerFault != 0;
|
||||
case 10:
|
||||
return Channel10BreakerFault != 0;
|
||||
return channel10BreakerFault != 0;
|
||||
case 11:
|
||||
return Channel11BreakerFault != 0;
|
||||
return channel11BreakerFault != 0;
|
||||
case 12:
|
||||
return Channel12BreakerFault != 0;
|
||||
return channel12BreakerFault != 0;
|
||||
case 13:
|
||||
return Channel13BreakerFault != 0;
|
||||
return channel13BreakerFault != 0;
|
||||
case 14:
|
||||
return Channel14BreakerFault != 0;
|
||||
return channel14BreakerFault != 0;
|
||||
case 15:
|
||||
return Channel15BreakerFault != 0;
|
||||
return channel15BreakerFault != 0;
|
||||
case 16:
|
||||
return Channel16BreakerFault != 0;
|
||||
return channel16BreakerFault != 0;
|
||||
case 17:
|
||||
return Channel17BreakerFault != 0;
|
||||
return channel17BreakerFault != 0;
|
||||
case 18:
|
||||
return Channel18BreakerFault != 0;
|
||||
return channel18BreakerFault != 0;
|
||||
case 19:
|
||||
return Channel19BreakerFault != 0;
|
||||
return channel19BreakerFault != 0;
|
||||
case 20:
|
||||
return Channel20BreakerFault != 0;
|
||||
return channel20BreakerFault != 0;
|
||||
case 21:
|
||||
return Channel21BreakerFault != 0;
|
||||
return channel21BreakerFault != 0;
|
||||
case 22:
|
||||
return Channel22BreakerFault != 0;
|
||||
return channel22BreakerFault != 0;
|
||||
case 23:
|
||||
return Channel23BreakerFault != 0;
|
||||
return channel23BreakerFault != 0;
|
||||
default:
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange,
|
||||
"Power distribution fault channel out of bounds!");
|
||||
@@ -252,53 +252,53 @@ bool PowerDistribution::Faults::GetBreakerFault(int channel) const {
|
||||
bool PowerDistribution::StickyFaults::GetBreakerFault(int channel) const {
|
||||
switch (channel) {
|
||||
case 0:
|
||||
return Channel0BreakerFault != 0;
|
||||
return channel0BreakerFault != 0;
|
||||
case 1:
|
||||
return Channel1BreakerFault != 0;
|
||||
return channel1BreakerFault != 0;
|
||||
case 2:
|
||||
return Channel2BreakerFault != 0;
|
||||
return channel2BreakerFault != 0;
|
||||
case 3:
|
||||
return Channel3BreakerFault != 0;
|
||||
return channel3BreakerFault != 0;
|
||||
case 4:
|
||||
return Channel4BreakerFault != 0;
|
||||
return channel4BreakerFault != 0;
|
||||
case 5:
|
||||
return Channel5BreakerFault != 0;
|
||||
return channel5BreakerFault != 0;
|
||||
case 6:
|
||||
return Channel6BreakerFault != 0;
|
||||
return channel6BreakerFault != 0;
|
||||
case 7:
|
||||
return Channel7BreakerFault != 0;
|
||||
return channel7BreakerFault != 0;
|
||||
case 8:
|
||||
return Channel8BreakerFault != 0;
|
||||
return channel8BreakerFault != 0;
|
||||
case 9:
|
||||
return Channel9BreakerFault != 0;
|
||||
return channel9BreakerFault != 0;
|
||||
case 10:
|
||||
return Channel10BreakerFault != 0;
|
||||
return channel10BreakerFault != 0;
|
||||
case 11:
|
||||
return Channel11BreakerFault != 0;
|
||||
return channel11BreakerFault != 0;
|
||||
case 12:
|
||||
return Channel12BreakerFault != 0;
|
||||
return channel12BreakerFault != 0;
|
||||
case 13:
|
||||
return Channel13BreakerFault != 0;
|
||||
return channel13BreakerFault != 0;
|
||||
case 14:
|
||||
return Channel14BreakerFault != 0;
|
||||
return channel14BreakerFault != 0;
|
||||
case 15:
|
||||
return Channel15BreakerFault != 0;
|
||||
return channel15BreakerFault != 0;
|
||||
case 16:
|
||||
return Channel16BreakerFault != 0;
|
||||
return channel16BreakerFault != 0;
|
||||
case 17:
|
||||
return Channel17BreakerFault != 0;
|
||||
return channel17BreakerFault != 0;
|
||||
case 18:
|
||||
return Channel18BreakerFault != 0;
|
||||
return channel18BreakerFault != 0;
|
||||
case 19:
|
||||
return Channel19BreakerFault != 0;
|
||||
return channel19BreakerFault != 0;
|
||||
case 20:
|
||||
return Channel20BreakerFault != 0;
|
||||
return channel20BreakerFault != 0;
|
||||
case 21:
|
||||
return Channel21BreakerFault != 0;
|
||||
return channel21BreakerFault != 0;
|
||||
case 22:
|
||||
return Channel22BreakerFault != 0;
|
||||
return channel22BreakerFault != 0;
|
||||
case 23:
|
||||
return Channel23BreakerFault != 0;
|
||||
return channel23BreakerFault != 0;
|
||||
default:
|
||||
throw WPILIB_MakeError(err::ChannelIndexOutOfRange,
|
||||
"Power distribution fault channel out of bounds!");
|
||||
|
||||
@@ -154,49 +154,49 @@ class PneumaticHub : public PneumaticsBase {
|
||||
*/
|
||||
struct Faults {
|
||||
/** Fault on channel 0. */
|
||||
uint32_t Channel0Fault : 1;
|
||||
uint32_t channel0Fault : 1;
|
||||
/** Fault on channel 1. */
|
||||
uint32_t Channel1Fault : 1;
|
||||
uint32_t channel1Fault : 1;
|
||||
/** Fault on channel 2. */
|
||||
uint32_t Channel2Fault : 1;
|
||||
uint32_t channel2Fault : 1;
|
||||
/** Fault on channel 3. */
|
||||
uint32_t Channel3Fault : 1;
|
||||
uint32_t channel3Fault : 1;
|
||||
/** Fault on channel 4. */
|
||||
uint32_t Channel4Fault : 1;
|
||||
uint32_t channel4Fault : 1;
|
||||
/** Fault on channel 5. */
|
||||
uint32_t Channel5Fault : 1;
|
||||
uint32_t channel5Fault : 1;
|
||||
/** Fault on channel 6. */
|
||||
uint32_t Channel6Fault : 1;
|
||||
uint32_t channel6Fault : 1;
|
||||
/** Fault on channel 7. */
|
||||
uint32_t Channel7Fault : 1;
|
||||
uint32_t channel7Fault : 1;
|
||||
/** Fault on channel 8. */
|
||||
uint32_t Channel8Fault : 1;
|
||||
uint32_t channel8Fault : 1;
|
||||
/** Fault on channel 9. */
|
||||
uint32_t Channel9Fault : 1;
|
||||
uint32_t channel9Fault : 1;
|
||||
/** Fault on channel 10. */
|
||||
uint32_t Channel10Fault : 1;
|
||||
uint32_t channel10Fault : 1;
|
||||
/** Fault on channel 11. */
|
||||
uint32_t Channel11Fault : 1;
|
||||
uint32_t channel11Fault : 1;
|
||||
/** Fault on channel 12. */
|
||||
uint32_t Channel12Fault : 1;
|
||||
uint32_t channel12Fault : 1;
|
||||
/** Fault on channel 13. */
|
||||
uint32_t Channel13Fault : 1;
|
||||
uint32_t channel13Fault : 1;
|
||||
/** Fault on channel 14. */
|
||||
uint32_t Channel14Fault : 1;
|
||||
uint32_t channel14Fault : 1;
|
||||
/** Fault on channel 15. */
|
||||
uint32_t Channel15Fault : 1;
|
||||
uint32_t channel15Fault : 1;
|
||||
/** An overcurrent event occurred on the compressor output. */
|
||||
uint32_t CompressorOverCurrent : 1;
|
||||
uint32_t compressorOverCurrent : 1;
|
||||
/** The compressor output has an open circuit. */
|
||||
uint32_t CompressorOpen : 1;
|
||||
uint32_t compressorOpen : 1;
|
||||
/** An overcurrent event occurred on a solenoid output. */
|
||||
uint32_t SolenoidOverCurrent : 1;
|
||||
uint32_t solenoidOverCurrent : 1;
|
||||
/** The input voltage is below the minimum voltage. */
|
||||
uint32_t Brownout : 1;
|
||||
uint32_t brownout : 1;
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
uint32_t CanWarning : 1;
|
||||
uint32_t canWarning : 1;
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
uint32_t HardwareFault : 1;
|
||||
uint32_t hardwareFault : 1;
|
||||
|
||||
/**
|
||||
* Gets whether there is a fault at the specified channel.
|
||||
@@ -221,23 +221,23 @@ class PneumaticHub : public PneumaticsBase {
|
||||
*/
|
||||
struct StickyFaults {
|
||||
/** An overcurrent event occurred on the compressor output. */
|
||||
uint32_t CompressorOverCurrent : 1;
|
||||
uint32_t compressorOverCurrent : 1;
|
||||
/** The compressor output has an open circuit. */
|
||||
uint32_t CompressorOpen : 1;
|
||||
uint32_t compressorOpen : 1;
|
||||
/** An overcurrent event occurred on a solenoid output. */
|
||||
uint32_t SolenoidOverCurrent : 1;
|
||||
uint32_t solenoidOverCurrent : 1;
|
||||
/** The input voltage is below the minimum voltage. */
|
||||
uint32_t Brownout : 1;
|
||||
uint32_t brownout : 1;
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
uint32_t CanWarning : 1;
|
||||
uint32_t canWarning : 1;
|
||||
/** The device's CAN controller experienced a "Bus Off" event. */
|
||||
uint32_t CanBusOff : 1;
|
||||
uint32_t canBusOff : 1;
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
uint32_t HardwareFault : 1;
|
||||
uint32_t hardwareFault : 1;
|
||||
/** The firmware on the device has malfunctioned. */
|
||||
uint32_t FirmwareFault : 1;
|
||||
uint32_t firmwareFault : 1;
|
||||
/** The device has rebooted. */
|
||||
uint32_t HasReset : 1;
|
||||
uint32_t hasReset : 1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -184,59 +184,59 @@ class PowerDistribution : public wpi::util::Sendable,
|
||||
*/
|
||||
struct Faults {
|
||||
/** Breaker fault on channel 0. */
|
||||
uint32_t Channel0BreakerFault : 1;
|
||||
uint32_t channel0BreakerFault : 1;
|
||||
/** Breaker fault on channel 1. */
|
||||
uint32_t Channel1BreakerFault : 1;
|
||||
uint32_t channel1BreakerFault : 1;
|
||||
/** Breaker fault on channel 2. */
|
||||
uint32_t Channel2BreakerFault : 1;
|
||||
uint32_t channel2BreakerFault : 1;
|
||||
/** Breaker fault on channel 3. */
|
||||
uint32_t Channel3BreakerFault : 1;
|
||||
uint32_t channel3BreakerFault : 1;
|
||||
/** Breaker fault on channel 4. */
|
||||
uint32_t Channel4BreakerFault : 1;
|
||||
uint32_t channel4BreakerFault : 1;
|
||||
/** Breaker fault on channel 5. */
|
||||
uint32_t Channel5BreakerFault : 1;
|
||||
uint32_t channel5BreakerFault : 1;
|
||||
/** Breaker fault on channel 6. */
|
||||
uint32_t Channel6BreakerFault : 1;
|
||||
uint32_t channel6BreakerFault : 1;
|
||||
/** Breaker fault on channel 7. */
|
||||
uint32_t Channel7BreakerFault : 1;
|
||||
uint32_t channel7BreakerFault : 1;
|
||||
/** Breaker fault on channel 8. */
|
||||
uint32_t Channel8BreakerFault : 1;
|
||||
uint32_t channel8BreakerFault : 1;
|
||||
/** Breaker fault on channel 9. */
|
||||
uint32_t Channel9BreakerFault : 1;
|
||||
uint32_t channel9BreakerFault : 1;
|
||||
/** Breaker fault on channel 10. */
|
||||
uint32_t Channel10BreakerFault : 1;
|
||||
uint32_t channel10BreakerFault : 1;
|
||||
/** Breaker fault on channel 12. */
|
||||
uint32_t Channel11BreakerFault : 1;
|
||||
uint32_t channel11BreakerFault : 1;
|
||||
/** Breaker fault on channel 13. */
|
||||
uint32_t Channel12BreakerFault : 1;
|
||||
uint32_t channel12BreakerFault : 1;
|
||||
/** Breaker fault on channel 14. */
|
||||
uint32_t Channel13BreakerFault : 1;
|
||||
uint32_t channel13BreakerFault : 1;
|
||||
/** Breaker fault on channel 15. */
|
||||
uint32_t Channel14BreakerFault : 1;
|
||||
uint32_t channel14BreakerFault : 1;
|
||||
/** Breaker fault on channel 16. */
|
||||
uint32_t Channel15BreakerFault : 1;
|
||||
uint32_t channel15BreakerFault : 1;
|
||||
/** Breaker fault on channel 17. */
|
||||
uint32_t Channel16BreakerFault : 1;
|
||||
uint32_t channel16BreakerFault : 1;
|
||||
/** Breaker fault on channel 18. */
|
||||
uint32_t Channel17BreakerFault : 1;
|
||||
uint32_t channel17BreakerFault : 1;
|
||||
/** Breaker fault on channel 19. */
|
||||
uint32_t Channel18BreakerFault : 1;
|
||||
uint32_t channel18BreakerFault : 1;
|
||||
/** Breaker fault on channel 20. */
|
||||
uint32_t Channel19BreakerFault : 1;
|
||||
uint32_t channel19BreakerFault : 1;
|
||||
/** Breaker fault on channel 21. */
|
||||
uint32_t Channel20BreakerFault : 1;
|
||||
uint32_t channel20BreakerFault : 1;
|
||||
/** Breaker fault on channel 22. */
|
||||
uint32_t Channel21BreakerFault : 1;
|
||||
uint32_t channel21BreakerFault : 1;
|
||||
/** Breaker fault on channel 23. */
|
||||
uint32_t Channel22BreakerFault : 1;
|
||||
uint32_t channel22BreakerFault : 1;
|
||||
/** Breaker fault on channel 24. */
|
||||
uint32_t Channel23BreakerFault : 1;
|
||||
uint32_t channel23BreakerFault : 1;
|
||||
/** The input voltage is below the minimum voltage. */
|
||||
uint32_t Brownout : 1;
|
||||
uint32_t brownout : 1;
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
uint32_t CanWarning : 1;
|
||||
uint32_t canWarning : 1;
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
uint32_t HardwareFault : 1;
|
||||
uint32_t hardwareFault : 1;
|
||||
|
||||
/**
|
||||
* Gets whether there is a breaker fault at a specified channel.
|
||||
@@ -263,65 +263,65 @@ class PowerDistribution : public wpi::util::Sendable,
|
||||
*/
|
||||
struct StickyFaults {
|
||||
/** Breaker fault on channel 0. */
|
||||
uint32_t Channel0BreakerFault : 1;
|
||||
uint32_t channel0BreakerFault : 1;
|
||||
/** Breaker fault on channel 1. */
|
||||
uint32_t Channel1BreakerFault : 1;
|
||||
uint32_t channel1BreakerFault : 1;
|
||||
/** Breaker fault on channel 2. */
|
||||
uint32_t Channel2BreakerFault : 1;
|
||||
uint32_t channel2BreakerFault : 1;
|
||||
/** Breaker fault on channel 3. */
|
||||
uint32_t Channel3BreakerFault : 1;
|
||||
uint32_t channel3BreakerFault : 1;
|
||||
/** Breaker fault on channel 4. */
|
||||
uint32_t Channel4BreakerFault : 1;
|
||||
uint32_t channel4BreakerFault : 1;
|
||||
/** Breaker fault on channel 5. */
|
||||
uint32_t Channel5BreakerFault : 1;
|
||||
uint32_t channel5BreakerFault : 1;
|
||||
/** Breaker fault on channel 6. */
|
||||
uint32_t Channel6BreakerFault : 1;
|
||||
uint32_t channel6BreakerFault : 1;
|
||||
/** Breaker fault on channel 7. */
|
||||
uint32_t Channel7BreakerFault : 1;
|
||||
uint32_t channel7BreakerFault : 1;
|
||||
/** Breaker fault on channel 8. */
|
||||
uint32_t Channel8BreakerFault : 1;
|
||||
uint32_t channel8BreakerFault : 1;
|
||||
/** Breaker fault on channel 9. */
|
||||
uint32_t Channel9BreakerFault : 1;
|
||||
uint32_t channel9BreakerFault : 1;
|
||||
/** Breaker fault on channel 10. */
|
||||
uint32_t Channel10BreakerFault : 1;
|
||||
uint32_t channel10BreakerFault : 1;
|
||||
/** Breaker fault on channel 12. */
|
||||
uint32_t Channel11BreakerFault : 1;
|
||||
uint32_t channel11BreakerFault : 1;
|
||||
/** Breaker fault on channel 13. */
|
||||
uint32_t Channel12BreakerFault : 1;
|
||||
uint32_t channel12BreakerFault : 1;
|
||||
/** Breaker fault on channel 14. */
|
||||
uint32_t Channel13BreakerFault : 1;
|
||||
uint32_t channel13BreakerFault : 1;
|
||||
/** Breaker fault on channel 15. */
|
||||
uint32_t Channel14BreakerFault : 1;
|
||||
uint32_t channel14BreakerFault : 1;
|
||||
/** Breaker fault on channel 16. */
|
||||
uint32_t Channel15BreakerFault : 1;
|
||||
uint32_t channel15BreakerFault : 1;
|
||||
/** Breaker fault on channel 17. */
|
||||
uint32_t Channel16BreakerFault : 1;
|
||||
uint32_t channel16BreakerFault : 1;
|
||||
/** Breaker fault on channel 18. */
|
||||
uint32_t Channel17BreakerFault : 1;
|
||||
uint32_t channel17BreakerFault : 1;
|
||||
/** Breaker fault on channel 19. */
|
||||
uint32_t Channel18BreakerFault : 1;
|
||||
uint32_t channel18BreakerFault : 1;
|
||||
/** Breaker fault on channel 20. */
|
||||
uint32_t Channel19BreakerFault : 1;
|
||||
uint32_t channel19BreakerFault : 1;
|
||||
/** Breaker fault on channel 21. */
|
||||
uint32_t Channel20BreakerFault : 1;
|
||||
uint32_t channel20BreakerFault : 1;
|
||||
/** Breaker fault on channel 22. */
|
||||
uint32_t Channel21BreakerFault : 1;
|
||||
uint32_t channel21BreakerFault : 1;
|
||||
/** Breaker fault on channel 23. */
|
||||
uint32_t Channel22BreakerFault : 1;
|
||||
uint32_t channel22BreakerFault : 1;
|
||||
/** Breaker fault on channel 24. */
|
||||
uint32_t Channel23BreakerFault : 1;
|
||||
uint32_t channel23BreakerFault : 1;
|
||||
/** The input voltage is below the minimum voltage. */
|
||||
uint32_t Brownout : 1;
|
||||
uint32_t brownout : 1;
|
||||
/** A warning was raised by the device's CAN controller. */
|
||||
uint32_t CanWarning : 1;
|
||||
uint32_t canWarning : 1;
|
||||
/** The device's CAN controller experienced a "Bus Off" event. */
|
||||
uint32_t CanBusOff : 1;
|
||||
uint32_t canBusOff : 1;
|
||||
/** The hardware on the device has malfunctioned. */
|
||||
uint32_t HardwareFault : 1;
|
||||
uint32_t hardwareFault : 1;
|
||||
/** The firmware on the device has malfunctioned. */
|
||||
uint32_t FirmwareFault : 1;
|
||||
uint32_t firmwareFault : 1;
|
||||
/** The device has rebooted. */
|
||||
uint32_t HasReset : 1;
|
||||
uint32_t hasReset : 1;
|
||||
|
||||
/**
|
||||
* Gets whether there is a sticky breaker fault at the specified channel.
|
||||
|
||||
@@ -54,38 +54,38 @@ classes:
|
||||
UniqueId:
|
||||
wpi::PneumaticHub::Faults:
|
||||
attributes:
|
||||
Channel0Fault:
|
||||
Channel1Fault:
|
||||
Channel2Fault:
|
||||
Channel3Fault:
|
||||
Channel4Fault:
|
||||
Channel5Fault:
|
||||
Channel6Fault:
|
||||
Channel7Fault:
|
||||
Channel8Fault:
|
||||
Channel9Fault:
|
||||
Channel10Fault:
|
||||
Channel11Fault:
|
||||
Channel12Fault:
|
||||
Channel13Fault:
|
||||
Channel14Fault:
|
||||
Channel15Fault:
|
||||
CompressorOverCurrent:
|
||||
CompressorOpen:
|
||||
SolenoidOverCurrent:
|
||||
Brownout:
|
||||
CanWarning:
|
||||
HardwareFault:
|
||||
channel0Fault:
|
||||
channel1Fault:
|
||||
channel2Fault:
|
||||
channel3Fault:
|
||||
channel4Fault:
|
||||
channel5Fault:
|
||||
channel6Fault:
|
||||
channel7Fault:
|
||||
channel8Fault:
|
||||
channel9Fault:
|
||||
channel10Fault:
|
||||
channel11Fault:
|
||||
channel12Fault:
|
||||
channel13Fault:
|
||||
channel14Fault:
|
||||
channel15Fault:
|
||||
compressorOverCurrent:
|
||||
compressorOpen:
|
||||
solenoidOverCurrent:
|
||||
brownout:
|
||||
canWarning:
|
||||
hardwareFault:
|
||||
methods:
|
||||
GetChannelFault:
|
||||
wpi::PneumaticHub::StickyFaults:
|
||||
attributes:
|
||||
CompressorOverCurrent:
|
||||
CompressorOpen:
|
||||
SolenoidOverCurrent:
|
||||
Brownout:
|
||||
CanWarning:
|
||||
CanBusOff:
|
||||
HasReset:
|
||||
HardwareFault:
|
||||
FirmwareFault:
|
||||
compressorOverCurrent:
|
||||
compressorOpen:
|
||||
solenoidOverCurrent:
|
||||
brownout:
|
||||
canWarning:
|
||||
canBusOff:
|
||||
hasReset:
|
||||
hardwareFault:
|
||||
firmwareFault:
|
||||
|
||||
@@ -42,66 +42,66 @@ classes:
|
||||
UniqueId:
|
||||
wpi::PowerDistribution::Faults:
|
||||
attributes:
|
||||
Channel0BreakerFault:
|
||||
Channel1BreakerFault:
|
||||
Channel2BreakerFault:
|
||||
Channel3BreakerFault:
|
||||
Channel4BreakerFault:
|
||||
Channel5BreakerFault:
|
||||
Channel6BreakerFault:
|
||||
Channel7BreakerFault:
|
||||
Channel8BreakerFault:
|
||||
Channel9BreakerFault:
|
||||
Channel10BreakerFault:
|
||||
Channel11BreakerFault:
|
||||
Channel12BreakerFault:
|
||||
Channel13BreakerFault:
|
||||
Channel14BreakerFault:
|
||||
Channel15BreakerFault:
|
||||
Channel16BreakerFault:
|
||||
Channel17BreakerFault:
|
||||
Channel18BreakerFault:
|
||||
Channel19BreakerFault:
|
||||
Channel20BreakerFault:
|
||||
Channel21BreakerFault:
|
||||
Channel22BreakerFault:
|
||||
Channel23BreakerFault:
|
||||
Brownout:
|
||||
CanWarning:
|
||||
HardwareFault:
|
||||
channel0BreakerFault:
|
||||
channel1BreakerFault:
|
||||
channel2BreakerFault:
|
||||
channel3BreakerFault:
|
||||
channel4BreakerFault:
|
||||
channel5BreakerFault:
|
||||
channel6BreakerFault:
|
||||
channel7BreakerFault:
|
||||
channel8BreakerFault:
|
||||
channel9BreakerFault:
|
||||
channel10BreakerFault:
|
||||
channel11BreakerFault:
|
||||
channel12BreakerFault:
|
||||
channel13BreakerFault:
|
||||
channel14BreakerFault:
|
||||
channel15BreakerFault:
|
||||
channel16BreakerFault:
|
||||
channel17BreakerFault:
|
||||
channel18BreakerFault:
|
||||
channel19BreakerFault:
|
||||
channel20BreakerFault:
|
||||
channel21BreakerFault:
|
||||
channel22BreakerFault:
|
||||
channel23BreakerFault:
|
||||
brownout:
|
||||
canWarning:
|
||||
hardwareFault:
|
||||
methods:
|
||||
GetBreakerFault:
|
||||
wpi::PowerDistribution::StickyFaults:
|
||||
attributes:
|
||||
Channel0BreakerFault:
|
||||
Channel1BreakerFault:
|
||||
Channel2BreakerFault:
|
||||
Channel3BreakerFault:
|
||||
Channel4BreakerFault:
|
||||
Channel5BreakerFault:
|
||||
Channel6BreakerFault:
|
||||
Channel7BreakerFault:
|
||||
Channel8BreakerFault:
|
||||
Channel9BreakerFault:
|
||||
Channel10BreakerFault:
|
||||
Channel11BreakerFault:
|
||||
Channel12BreakerFault:
|
||||
Channel13BreakerFault:
|
||||
Channel14BreakerFault:
|
||||
Channel15BreakerFault:
|
||||
Channel16BreakerFault:
|
||||
Channel17BreakerFault:
|
||||
Channel18BreakerFault:
|
||||
Channel19BreakerFault:
|
||||
Channel20BreakerFault:
|
||||
Channel21BreakerFault:
|
||||
Channel22BreakerFault:
|
||||
Channel23BreakerFault:
|
||||
Brownout:
|
||||
CanWarning:
|
||||
CanBusOff:
|
||||
HasReset:
|
||||
HardwareFault:
|
||||
FirmwareFault:
|
||||
channel0BreakerFault:
|
||||
channel1BreakerFault:
|
||||
channel2BreakerFault:
|
||||
channel3BreakerFault:
|
||||
channel4BreakerFault:
|
||||
channel5BreakerFault:
|
||||
channel6BreakerFault:
|
||||
channel7BreakerFault:
|
||||
channel8BreakerFault:
|
||||
channel9BreakerFault:
|
||||
channel10BreakerFault:
|
||||
channel11BreakerFault:
|
||||
channel12BreakerFault:
|
||||
channel13BreakerFault:
|
||||
channel14BreakerFault:
|
||||
channel15BreakerFault:
|
||||
channel16BreakerFault:
|
||||
channel17BreakerFault:
|
||||
channel18BreakerFault:
|
||||
channel19BreakerFault:
|
||||
channel20BreakerFault:
|
||||
channel21BreakerFault:
|
||||
channel22BreakerFault:
|
||||
channel23BreakerFault:
|
||||
brownout:
|
||||
canWarning:
|
||||
canBusOff:
|
||||
hasReset:
|
||||
hardwareFault:
|
||||
firmwareFault:
|
||||
methods:
|
||||
GetBreakerFault:
|
||||
|
||||
@@ -12,30 +12,30 @@
|
||||
* Runs the motors with split arcade steering and a Gamepad.
|
||||
*/
|
||||
class Robot : public wpi::TimedRobot {
|
||||
wpi::PWMSparkMax m_leftMotor{0};
|
||||
wpi::PWMSparkMax m_rightMotor{1};
|
||||
wpi::DifferentialDrive m_robotDrive{
|
||||
[&](double output) { m_leftMotor.SetThrottle(output); },
|
||||
[&](double output) { m_rightMotor.SetThrottle(output); }};
|
||||
wpi::Gamepad m_driverController{0};
|
||||
wpi::PWMSparkMax leftMotor{0};
|
||||
wpi::PWMSparkMax rightMotor{1};
|
||||
wpi::DifferentialDrive robotDrive{
|
||||
[&](double output) { leftMotor.SetThrottle(output); },
|
||||
[&](double output) { rightMotor.SetThrottle(output); }};
|
||||
wpi::Gamepad driverController{0};
|
||||
|
||||
public:
|
||||
Robot() {
|
||||
wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_leftMotor);
|
||||
wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_rightMotor);
|
||||
wpi::util::SendableRegistry::AddChild(&robotDrive, &leftMotor);
|
||||
wpi::util::SendableRegistry::AddChild(&robotDrive, &rightMotor);
|
||||
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_rightMotor.SetInverted(true);
|
||||
rightMotor.SetInverted(true);
|
||||
}
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// Drive with split arcade style
|
||||
// That means that the Y axis of the left stick moves forward
|
||||
// and backward, and the X of the right stick turns left and right.
|
||||
m_robotDrive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
robotDrive.ArcadeDrive(-driverController.GetLeftY(),
|
||||
-driverController.GetRightX());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,26 +5,26 @@
|
||||
#include "Robot.hpp"
|
||||
|
||||
void Robot::SimulationPeriodic() {
|
||||
m_arm.SimulationPeriodic();
|
||||
arm.SimulationPeriodic();
|
||||
}
|
||||
|
||||
void Robot::TeleopInit() {
|
||||
m_arm.LoadPreferences();
|
||||
arm.LoadPreferences();
|
||||
}
|
||||
|
||||
void Robot::TeleopPeriodic() {
|
||||
if (m_joystick.GetTrigger()) {
|
||||
if (joystick.GetTrigger()) {
|
||||
// Here, we run PID control like normal.
|
||||
m_arm.ReachSetpoint();
|
||||
arm.ReachSetpoint();
|
||||
} else {
|
||||
// Otherwise, we disable the motor.
|
||||
m_arm.Stop();
|
||||
arm.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void Robot::DisabledInit() {
|
||||
// This just makes sure that our simulation code knows that the motor's off.
|
||||
m_arm.Stop();
|
||||
arm.Stop();
|
||||
}
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -9,55 +9,55 @@
|
||||
#include "wpi/util/Preferences.hpp"
|
||||
|
||||
Arm::Arm() {
|
||||
m_encoder.SetDistancePerPulse(kArmEncoderDistPerPulse);
|
||||
encoder.SetDistancePerPulse(kArmEncoderDistPerPulse);
|
||||
|
||||
// Put Mechanism 2d to SmartDashboard
|
||||
wpi::SmartDashboard::PutData("Arm Sim", &m_mech2d);
|
||||
wpi::SmartDashboard::PutData("Arm Sim", &mech2d);
|
||||
|
||||
// Set the Arm position setpoint and P constant to Preferences if the keys
|
||||
// don't already exist
|
||||
wpi::Preferences::InitDouble(kArmPositionKey, m_armSetpoint.value());
|
||||
wpi::Preferences::InitDouble(kArmPKey, m_armKp);
|
||||
wpi::Preferences::InitDouble(kArmPositionKey, armSetpoint.value());
|
||||
wpi::Preferences::InitDouble(kArmPKey, armKp);
|
||||
}
|
||||
|
||||
void Arm::SimulationPeriodic() {
|
||||
// In this method, we update our simulation of what our arm is doing
|
||||
// First, we set our "inputs" (voltages)
|
||||
m_armSim.SetInput(wpi::math::Vectord<1>{
|
||||
m_motor.GetThrottle() * wpi::RobotController::GetInputVoltage()});
|
||||
armSim.SetInput(wpi::math::Vectord<1>{
|
||||
motor.GetThrottle() * wpi::RobotController::GetInputVoltage()});
|
||||
|
||||
// Next, we update it. The standard loop time is 20ms.
|
||||
m_armSim.Update(20_ms);
|
||||
armSim.Update(20_ms);
|
||||
|
||||
// Finally, we set our simulated encoder's readings and simulated battery
|
||||
// voltage
|
||||
m_encoderSim.SetDistance(m_armSim.GetAngle().value());
|
||||
encoderSim.SetDistance(armSim.GetAngle().value());
|
||||
// SimBattery estimates loaded battery voltages
|
||||
wpi::sim::RoboRioSim::SetVInVoltage(
|
||||
wpi::sim::BatterySim::Calculate({m_armSim.GetCurrentDraw()}));
|
||||
wpi::sim::BatterySim::Calculate({armSim.GetCurrentDraw()}));
|
||||
|
||||
// Update the Mechanism Arm angle based on the simulated arm angle
|
||||
m_arm->SetAngle(m_armSim.GetAngle());
|
||||
arm->SetAngle(armSim.GetAngle());
|
||||
}
|
||||
|
||||
void Arm::LoadPreferences() {
|
||||
// Read Preferences for Arm setpoint and kP on entering Teleop
|
||||
m_armSetpoint = wpi::units::degree_t{
|
||||
wpi::Preferences::GetDouble(kArmPositionKey, m_armSetpoint.value())};
|
||||
if (m_armKp != wpi::Preferences::GetDouble(kArmPKey, m_armKp)) {
|
||||
m_armKp = wpi::Preferences::GetDouble(kArmPKey, m_armKp);
|
||||
m_controller.SetP(m_armKp);
|
||||
armSetpoint = wpi::units::degree_t{
|
||||
wpi::Preferences::GetDouble(kArmPositionKey, armSetpoint.value())};
|
||||
if (armKp != wpi::Preferences::GetDouble(kArmPKey, armKp)) {
|
||||
armKp = wpi::Preferences::GetDouble(kArmPKey, armKp);
|
||||
controller.SetP(armKp);
|
||||
}
|
||||
}
|
||||
|
||||
void Arm::ReachSetpoint() {
|
||||
// Here, we run PID control like normal, with a setpoint read from
|
||||
// preferences in degrees.
|
||||
double pidOutput = m_controller.Calculate(
|
||||
m_encoder.GetDistance(), (wpi::units::radian_t{m_armSetpoint}.value()));
|
||||
m_motor.SetVoltage(wpi::units::volt_t{pidOutput});
|
||||
double pidOutput = controller.Calculate(
|
||||
encoder.GetDistance(), (wpi::units::radian_t{armSetpoint}.value()));
|
||||
motor.SetVoltage(wpi::units::volt_t{pidOutput});
|
||||
}
|
||||
|
||||
void Arm::Stop() {
|
||||
m_motor.SetThrottle(0.0);
|
||||
motor.SetThrottle(0.0);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ class Robot : public wpi::TimedRobot {
|
||||
void DisabledInit() override;
|
||||
|
||||
private:
|
||||
wpi::Joystick m_joystick{kJoystickPort};
|
||||
Arm m_arm;
|
||||
wpi::Joystick joystick{kJoystickPort};
|
||||
Arm arm;
|
||||
};
|
||||
|
||||
@@ -29,23 +29,23 @@ class Arm {
|
||||
|
||||
private:
|
||||
// The P gain for the PID controller that drives this arm.
|
||||
double m_armKp = kDefaultArmKp;
|
||||
wpi::units::degree_t m_armSetpoint = kDefaultArmSetpoint;
|
||||
double armKp = kDefaultArmKp;
|
||||
wpi::units::degree_t armSetpoint = kDefaultArmSetpoint;
|
||||
|
||||
// The arm gearbox represents a gearbox containing two Vex 775pro motors.
|
||||
wpi::math::DCMotor m_armGearbox = wpi::math::DCMotor::Vex775Pro(2);
|
||||
wpi::math::DCMotor armGearbox = wpi::math::DCMotor::Vex775Pro(2);
|
||||
|
||||
// Standard classes for controlling our arm
|
||||
wpi::math::PIDController m_controller{m_armKp, 0, 0};
|
||||
wpi::Encoder m_encoder{kEncoderAChannel, kEncoderBChannel};
|
||||
wpi::PWMSparkMax m_motor{kMotorPort};
|
||||
wpi::math::PIDController controller{armKp, 0, 0};
|
||||
wpi::Encoder encoder{kEncoderAChannel, kEncoderBChannel};
|
||||
wpi::PWMSparkMax motor{kMotorPort};
|
||||
|
||||
// Simulation classes help us simulate what's going on, including gravity.
|
||||
// This sim represents an arm with 2 775s, a 600:1 reduction, a mass of 5kg,
|
||||
// 30in overall arm length, range of motion in [-75, 255] degrees, and noise
|
||||
// with a standard deviation of 1 encoder tick.
|
||||
wpi::sim::SingleJointedArmSim m_armSim{
|
||||
m_armGearbox,
|
||||
wpi::sim::SingleJointedArmSim armSim{
|
||||
armGearbox,
|
||||
kArmReduction,
|
||||
wpi::sim::SingleJointedArmSim::EstimateMOI(kArmLength, kArmMass),
|
||||
kArmLength,
|
||||
@@ -54,16 +54,16 @@ class Arm {
|
||||
true,
|
||||
0_deg,
|
||||
{kArmEncoderDistPerPulse}};
|
||||
wpi::sim::EncoderSim m_encoderSim{m_encoder};
|
||||
wpi::sim::EncoderSim encoderSim{encoder};
|
||||
|
||||
// Create a Mechanism2d display of an Arm
|
||||
wpi::Mechanism2d m_mech2d{60, 60};
|
||||
wpi::MechanismRoot2d* m_armBase = m_mech2d.GetRoot("ArmBase", 30, 30);
|
||||
wpi::MechanismLigament2d* m_armTower =
|
||||
m_armBase->Append<wpi::MechanismLigament2d>(
|
||||
wpi::Mechanism2d mech2d{60, 60};
|
||||
wpi::MechanismRoot2d* armBase = mech2d.GetRoot("ArmBase", 30, 30);
|
||||
wpi::MechanismLigament2d* armTower =
|
||||
armBase->Append<wpi::MechanismLigament2d>(
|
||||
"Arm Tower", 30, -90_deg, 6,
|
||||
wpi::util::Color8Bit{wpi::util::Color::BLUE});
|
||||
wpi::MechanismLigament2d* m_arm = m_armBase->Append<wpi::MechanismLigament2d>(
|
||||
"Arm", 30, m_armSim.GetAngle(), 6,
|
||||
wpi::MechanismLigament2d* arm = armBase->Append<wpi::MechanismLigament2d>(
|
||||
"Arm", 30, armSim.GetAngle(), 6,
|
||||
wpi::util::Color8Bit{wpi::util::Color::YELLOW});
|
||||
};
|
||||
|
||||
@@ -6,24 +6,24 @@
|
||||
|
||||
void Drivetrain::SetVelocities(
|
||||
const wpi::math::DifferentialDriveWheelVelocities& velocities) {
|
||||
const auto leftFeedforward = m_feedforward.Calculate(velocities.left);
|
||||
const auto rightFeedforward = m_feedforward.Calculate(velocities.right);
|
||||
const double leftOutput = m_leftPIDController.Calculate(
|
||||
m_leftEncoder.GetRate(), velocities.left.value());
|
||||
const double rightOutput = m_rightPIDController.Calculate(
|
||||
m_rightEncoder.GetRate(), velocities.right.value());
|
||||
const auto leftFeedforward = feedforward.Calculate(velocities.left);
|
||||
const auto rightFeedforward = feedforward.Calculate(velocities.right);
|
||||
const double leftOutput = leftPIDController.Calculate(
|
||||
leftEncoder.GetRate(), velocities.left.value());
|
||||
const double rightOutput = rightPIDController.Calculate(
|
||||
rightEncoder.GetRate(), velocities.right.value());
|
||||
|
||||
m_leftLeader.SetVoltage(wpi::units::volt_t{leftOutput} + leftFeedforward);
|
||||
m_rightLeader.SetVoltage(wpi::units::volt_t{rightOutput} + rightFeedforward);
|
||||
leftLeader.SetVoltage(wpi::units::volt_t{leftOutput} + leftFeedforward);
|
||||
rightLeader.SetVoltage(wpi::units::volt_t{rightOutput} + rightFeedforward);
|
||||
}
|
||||
|
||||
void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
|
||||
wpi::units::radians_per_second_t rot) {
|
||||
SetVelocities(m_kinematics.ToWheelVelocities({xVelocity, 0_mps, rot}));
|
||||
SetVelocities(kinematics.ToWheelVelocities({xVelocity, 0_mps, rot}));
|
||||
}
|
||||
|
||||
void Drivetrain::UpdateOdometry() {
|
||||
m_odometry.Update(m_imu.GetRotation2d(),
|
||||
wpi::units::meter_t{m_leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{m_rightEncoder.GetDistance()});
|
||||
odometry.Update(imu.GetRotation2d(),
|
||||
wpi::units::meter_t{leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{rightEncoder.GetDistance()});
|
||||
}
|
||||
|
||||
@@ -11,35 +11,34 @@ class Robot : public wpi::TimedRobot {
|
||||
public:
|
||||
void AutonomousPeriodic() override {
|
||||
TeleopPeriodic();
|
||||
m_drive.UpdateOdometry();
|
||||
drive.UpdateOdometry();
|
||||
}
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// Get the x velocity. We are inverting this because gamepads return
|
||||
// negative values when we push forward.
|
||||
const auto xVelocity =
|
||||
-m_velocityLimiter.Calculate(m_controller.GetLeftY()) *
|
||||
const auto xVelocity = -velocityLimiter.Calculate(controller.GetLeftY()) *
|
||||
Drivetrain::kMaxVelocity;
|
||||
|
||||
// Get the rate of angular rotation. We are inverting this because we want a
|
||||
// positive value when we pull to the left (remember, CCW is positive in
|
||||
// mathematics). Gamepads return positive values when you pull to
|
||||
// the right by default.
|
||||
const auto rot = -m_rotLimiter.Calculate(m_controller.GetRightX()) *
|
||||
const auto rot = -rotLimiter.Calculate(controller.GetRightX()) *
|
||||
Drivetrain::kMaxAngularVelocity;
|
||||
|
||||
m_drive.Drive(xVelocity, rot);
|
||||
drive.Drive(xVelocity, rot);
|
||||
}
|
||||
|
||||
private:
|
||||
wpi::Gamepad m_controller{0};
|
||||
wpi::Gamepad controller{0};
|
||||
|
||||
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0
|
||||
// to 1.
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> m_velocityLimiter{3 / 1_s};
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> m_rotLimiter{3 / 1_s};
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> velocityLimiter{3 / 1_s};
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> rotLimiter{3 / 1_s};
|
||||
|
||||
Drivetrain m_drive;
|
||||
Drivetrain drive;
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -24,25 +24,25 @@
|
||||
class Drivetrain {
|
||||
public:
|
||||
Drivetrain() {
|
||||
m_leftLeader.AddFollower(m_leftFollower);
|
||||
m_rightLeader.AddFollower(m_rightFollower);
|
||||
leftLeader.AddFollower(leftFollower);
|
||||
rightLeader.AddFollower(rightFollower);
|
||||
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_rightLeader.SetInverted(true);
|
||||
rightLeader.SetInverted(true);
|
||||
|
||||
m_imu.ResetYaw();
|
||||
imu.ResetYaw();
|
||||
// Set the distance per pulse for the drive encoders. We can simply use the
|
||||
// distance traveled for one rotation of the wheel divided by the encoder
|
||||
// resolution.
|
||||
m_leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
m_rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
|
||||
m_leftEncoder.Reset();
|
||||
m_rightEncoder.Reset();
|
||||
leftEncoder.Reset();
|
||||
rightEncoder.Reset();
|
||||
}
|
||||
|
||||
static constexpr wpi::units::meters_per_second_t kMaxVelocity =
|
||||
@@ -61,26 +61,26 @@ class Drivetrain {
|
||||
static constexpr double kWheelRadius = 0.0508; // meters
|
||||
static constexpr int kEncoderResolution = 4096;
|
||||
|
||||
wpi::PWMSparkMax m_leftLeader{1};
|
||||
wpi::PWMSparkMax m_leftFollower{2};
|
||||
wpi::PWMSparkMax m_rightLeader{3};
|
||||
wpi::PWMSparkMax m_rightFollower{4};
|
||||
wpi::PWMSparkMax leftLeader{1};
|
||||
wpi::PWMSparkMax leftFollower{2};
|
||||
wpi::PWMSparkMax rightLeader{3};
|
||||
wpi::PWMSparkMax rightFollower{4};
|
||||
|
||||
wpi::Encoder m_leftEncoder{0, 1};
|
||||
wpi::Encoder m_rightEncoder{2, 3};
|
||||
wpi::Encoder leftEncoder{0, 1};
|
||||
wpi::Encoder rightEncoder{2, 3};
|
||||
|
||||
wpi::math::PIDController m_leftPIDController{1.0, 0.0, 0.0};
|
||||
wpi::math::PIDController m_rightPIDController{1.0, 0.0, 0.0};
|
||||
wpi::math::PIDController leftPIDController{1.0, 0.0, 0.0};
|
||||
wpi::math::PIDController rightPIDController{1.0, 0.0, 0.0};
|
||||
|
||||
wpi::OnboardIMU m_imu{wpi::OnboardIMU::FLAT};
|
||||
wpi::OnboardIMU imu{wpi::OnboardIMU::FLAT};
|
||||
|
||||
wpi::math::DifferentialDriveKinematics m_kinematics{kTrackwidth};
|
||||
wpi::math::DifferentialDriveOdometry m_odometry{
|
||||
m_imu.GetRotation2d(), wpi::units::meter_t{m_leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{m_rightEncoder.GetDistance()}};
|
||||
wpi::math::DifferentialDriveKinematics kinematics{kTrackwidth};
|
||||
wpi::math::DifferentialDriveOdometry odometry{
|
||||
imu.GetRotation2d(), wpi::units::meter_t{leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{rightEncoder.GetDistance()}};
|
||||
|
||||
// Gains are for example purposes only - must be determined for your own
|
||||
// robot!
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> m_feedforward{
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> feedforward{
|
||||
1_V, 3_V / 1_mps};
|
||||
};
|
||||
|
||||
@@ -12,47 +12,47 @@
|
||||
#include "wpi/system/RobotController.hpp"
|
||||
|
||||
Drivetrain::Drivetrain() {
|
||||
m_leftLeader.AddFollower(m_leftFollower);
|
||||
m_rightLeader.AddFollower(m_rightFollower);
|
||||
leftLeader.AddFollower(leftFollower);
|
||||
rightLeader.AddFollower(rightFollower);
|
||||
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_rightLeader.SetInverted(true);
|
||||
rightLeader.SetInverted(true);
|
||||
|
||||
m_imu.ResetYaw();
|
||||
imu.ResetYaw();
|
||||
|
||||
// Set the distance per pulse for the drive encoders. We can simply use the
|
||||
// distance traveled for one rotation of the wheel divided by the encoder
|
||||
// resolution.
|
||||
m_leftEncoder.SetDistancePerPulse(
|
||||
leftEncoder.SetDistancePerPulse(
|
||||
(2 * std::numbers::pi * kWheelRadius / kEncoderResolution).value());
|
||||
m_rightEncoder.SetDistancePerPulse(
|
||||
rightEncoder.SetDistancePerPulse(
|
||||
(2 * std::numbers::pi * kWheelRadius / kEncoderResolution).value());
|
||||
|
||||
m_leftEncoder.Reset();
|
||||
m_rightEncoder.Reset();
|
||||
leftEncoder.Reset();
|
||||
rightEncoder.Reset();
|
||||
|
||||
wpi::SmartDashboard::PutData("FieldSim", &m_fieldSim);
|
||||
wpi::SmartDashboard::PutData("Approximation", &m_fieldApproximation);
|
||||
wpi::SmartDashboard::PutData("FieldSim", &fieldSim);
|
||||
wpi::SmartDashboard::PutData("Approximation", &fieldApproximation);
|
||||
}
|
||||
|
||||
void Drivetrain::SetVelocities(
|
||||
const wpi::math::DifferentialDriveWheelVelocities& velocities) {
|
||||
const auto leftFeedforward = m_feedforward.Calculate(velocities.left);
|
||||
const auto rightFeedforward = m_feedforward.Calculate(velocities.right);
|
||||
const double leftOutput = m_leftPIDController.Calculate(
|
||||
m_leftEncoder.GetRate(), velocities.left.value());
|
||||
const double rightOutput = m_rightPIDController.Calculate(
|
||||
m_rightEncoder.GetRate(), velocities.right.value());
|
||||
const auto leftFeedforward = feedforward.Calculate(velocities.left);
|
||||
const auto rightFeedforward = feedforward.Calculate(velocities.right);
|
||||
const double leftOutput = leftPIDController.Calculate(
|
||||
leftEncoder.GetRate(), velocities.left.value());
|
||||
const double rightOutput = rightPIDController.Calculate(
|
||||
rightEncoder.GetRate(), velocities.right.value());
|
||||
|
||||
m_leftLeader.SetVoltage(wpi::units::volt_t{leftOutput} + leftFeedforward);
|
||||
m_rightLeader.SetVoltage(wpi::units::volt_t{rightOutput} + rightFeedforward);
|
||||
leftLeader.SetVoltage(wpi::units::volt_t{leftOutput} + leftFeedforward);
|
||||
rightLeader.SetVoltage(wpi::units::volt_t{rightOutput} + rightFeedforward);
|
||||
}
|
||||
|
||||
void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
|
||||
wpi::units::radians_per_second_t rot) {
|
||||
SetVelocities(m_kinematics.ToWheelVelocities({xVelocity, 0_mps, rot}));
|
||||
SetVelocities(kinematics.ToWheelVelocities({xVelocity, 0_mps, rot}));
|
||||
}
|
||||
|
||||
void Drivetrain::PublishCameraToObject(
|
||||
@@ -93,19 +93,19 @@ wpi::math::Pose3d Drivetrain::ObjectToRobotPose(
|
||||
}
|
||||
|
||||
void Drivetrain::UpdateOdometry() {
|
||||
m_poseEstimator.Update(m_imu.GetRotation2d(),
|
||||
wpi::units::meter_t{m_leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{m_rightEncoder.GetDistance()});
|
||||
poseEstimator.Update(imu.GetRotation2d(),
|
||||
wpi::units::meter_t{leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{rightEncoder.GetDistance()});
|
||||
|
||||
// Publish cameraToObject transformation to networktables --this would
|
||||
// normally be handled by the computer vision solution.
|
||||
PublishCameraToObject(m_objectInField, m_robotToCamera,
|
||||
m_cameraToObjectEntryRef, m_drivetrainSimulator);
|
||||
PublishCameraToObject(objectInField, robotToCamera, cameraToObjectEntryRef,
|
||||
drivetrainSimulator);
|
||||
|
||||
// Compute the robot's field-relative position exclusively from vision
|
||||
// measurements.
|
||||
wpi::math::Pose3d visionMeasurement3d = ObjectToRobotPose(
|
||||
m_objectInField, m_robotToCamera, m_cameraToObjectEntryRef);
|
||||
wpi::math::Pose3d visionMeasurement3d =
|
||||
ObjectToRobotPose(objectInField, robotToCamera, cameraToObjectEntryRef);
|
||||
|
||||
// Convert robot's pose from wpi::math::Pose3d to wpi::math::Pose2d needed to
|
||||
// apply vision measurements.
|
||||
@@ -114,7 +114,7 @@ void Drivetrain::UpdateOdometry() {
|
||||
// Apply vision measurements. For simulation purposes only, we don't input a
|
||||
// latency delay -- on a real robot, this must be calculated based either on
|
||||
// known latency or timestamps.
|
||||
m_poseEstimator.AddVisionMeasurement(visionMeasurement2d,
|
||||
poseEstimator.AddVisionMeasurement(visionMeasurement2d,
|
||||
wpi::Timer::GetTimestamp());
|
||||
}
|
||||
|
||||
@@ -122,24 +122,22 @@ void Drivetrain::SimulationPeriodic() {
|
||||
// To update our simulation, we set motor voltage inputs, update the
|
||||
// simulation, and write the simulated positions and velocities to our
|
||||
// simulated encoder and gyro.
|
||||
m_drivetrainSimulator.SetInputs(
|
||||
wpi::units::volt_t{m_leftLeader.GetThrottle()} *
|
||||
drivetrainSimulator.SetInputs(wpi::units::volt_t{leftLeader.GetThrottle()} *
|
||||
wpi::RobotController::GetInputVoltage(),
|
||||
wpi::units::volt_t{m_rightLeader.GetThrottle()} *
|
||||
wpi::units::volt_t{rightLeader.GetThrottle()} *
|
||||
wpi::RobotController::GetInputVoltage());
|
||||
m_drivetrainSimulator.Update(20_ms);
|
||||
drivetrainSimulator.Update(20_ms);
|
||||
|
||||
m_leftEncoderSim.SetDistance(m_drivetrainSimulator.GetLeftPosition().value());
|
||||
m_leftEncoderSim.SetRate(m_drivetrainSimulator.GetLeftVelocity().value());
|
||||
m_rightEncoderSim.SetDistance(
|
||||
m_drivetrainSimulator.GetRightPosition().value());
|
||||
m_rightEncoderSim.SetRate(m_drivetrainSimulator.GetRightVelocity().value());
|
||||
// m_gyroSim.SetAngle(-m_drivetrainSimulator.GetHeading().Degrees().value());
|
||||
leftEncoderSim.SetDistance(drivetrainSimulator.GetLeftPosition().value());
|
||||
leftEncoderSim.SetRate(drivetrainSimulator.GetLeftVelocity().value());
|
||||
rightEncoderSim.SetDistance(drivetrainSimulator.GetRightPosition().value());
|
||||
rightEncoderSim.SetRate(drivetrainSimulator.GetRightVelocity().value());
|
||||
// gyroSim.SetAngle(-drivetrainSimulator.GetHeading().Degrees().value());
|
||||
// // TODO(Ryan): fixup when sim implemented
|
||||
}
|
||||
|
||||
void Drivetrain::Periodic() {
|
||||
UpdateOdometry();
|
||||
m_fieldSim.SetRobotPose(m_drivetrainSimulator.GetPose());
|
||||
m_fieldApproximation.SetRobotPose(m_poseEstimator.GetEstimatedPosition());
|
||||
fieldSim.SetRobotPose(drivetrainSimulator.GetPose());
|
||||
fieldApproximation.SetRobotPose(poseEstimator.GetEstimatedPosition());
|
||||
}
|
||||
|
||||
@@ -11,39 +11,38 @@ class Robot : public wpi::TimedRobot {
|
||||
public:
|
||||
void AutonomousPeriodic() override {
|
||||
TeleopPeriodic();
|
||||
m_drive.UpdateOdometry();
|
||||
drive.UpdateOdometry();
|
||||
}
|
||||
|
||||
void RobotPeriodic() override { m_drive.Periodic(); }
|
||||
void RobotPeriodic() override { drive.Periodic(); }
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// Get the x velocity. We are inverting this because gamepads return
|
||||
// negative values when we push forward.
|
||||
const auto xVelocity =
|
||||
-m_velocityLimiter.Calculate(m_controller.GetLeftY()) *
|
||||
const auto xVelocity = -velocityLimiter.Calculate(controller.GetLeftY()) *
|
||||
Drivetrain::kMaxVelocity;
|
||||
|
||||
// Get the rate of angular rotation. We are inverting this because we want a
|
||||
// positive value when we pull to the left (remember, CCW is positive in
|
||||
// mathematics). Gamepads return positive values when you pull to
|
||||
// the right by default.
|
||||
const auto rot = -m_rotLimiter.Calculate(m_controller.GetRightX()) *
|
||||
const auto rot = -rotLimiter.Calculate(controller.GetRightX()) *
|
||||
Drivetrain::kMaxAngularVelocity;
|
||||
|
||||
m_drive.Drive(xVelocity, rot);
|
||||
drive.Drive(xVelocity, rot);
|
||||
}
|
||||
|
||||
void SimulationPeriodic() override { m_drive.SimulationPeriodic(); }
|
||||
void SimulationPeriodic() override { drive.SimulationPeriodic(); }
|
||||
|
||||
private:
|
||||
wpi::Gamepad m_controller{0};
|
||||
wpi::Gamepad controller{0};
|
||||
|
||||
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0
|
||||
// to 1.
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> m_velocityLimiter{3 / 1_s};
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> m_rotLimiter{3 / 1_s};
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> velocityLimiter{3 / 1_s};
|
||||
wpi::math::SlewRateLimiter<wpi::units::scalar> rotLimiter{3 / 1_s};
|
||||
|
||||
Drivetrain m_drive;
|
||||
Drivetrain drive;
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -114,64 +114,63 @@ class Drivetrain {
|
||||
static constexpr std::array<double, 7> kDefaultVal{0.0, 0.0, 0.0, 0.0,
|
||||
0.0, 0.0, 0.0};
|
||||
|
||||
wpi::math::Transform3d m_robotToCamera{
|
||||
wpi::math::Transform3d robotToCamera{
|
||||
wpi::math::Translation3d{1_m, 1_m, 1_m},
|
||||
wpi::math::Rotation3d{0_rad, 0_rad,
|
||||
wpi::units::radian_t{std::numbers::pi / 2}}};
|
||||
|
||||
wpi::nt::NetworkTableInstance m_inst{
|
||||
wpi::nt::NetworkTableInstance inst{
|
||||
wpi::nt::NetworkTableInstance::GetDefault()};
|
||||
wpi::nt::DoubleArrayTopic m_cameraToObjectTopic{
|
||||
m_inst.GetDoubleArrayTopic("m_cameraToObjectTopic")};
|
||||
wpi::nt::DoubleArrayEntry m_cameraToObjectEntry =
|
||||
m_cameraToObjectTopic.GetEntry(kDefaultVal);
|
||||
wpi::nt::DoubleArrayEntry& m_cameraToObjectEntryRef = m_cameraToObjectEntry;
|
||||
wpi::nt::DoubleArrayTopic cameraToObjectTopic{
|
||||
inst.GetDoubleArrayTopic("cameraToObjectTopic")};
|
||||
wpi::nt::DoubleArrayEntry cameraToObjectEntry =
|
||||
cameraToObjectTopic.GetEntry(kDefaultVal);
|
||||
wpi::nt::DoubleArrayEntry& cameraToObjectEntryRef = cameraToObjectEntry;
|
||||
|
||||
wpi::apriltag::AprilTagFieldLayout m_aprilTagFieldLayout{
|
||||
wpi::apriltag::AprilTagFieldLayout aprilTagFieldLayout{
|
||||
wpi::apriltag::AprilTagFieldLayout::LoadField(
|
||||
wpi::apriltag::AprilTagField::k2024Crescendo)};
|
||||
wpi::math::Pose3d m_objectInField{
|
||||
m_aprilTagFieldLayout.GetTagPose(0).value()};
|
||||
wpi::math::Pose3d objectInField{aprilTagFieldLayout.GetTagPose(0).value()};
|
||||
|
||||
wpi::PWMSparkMax m_leftLeader{1};
|
||||
wpi::PWMSparkMax m_leftFollower{2};
|
||||
wpi::PWMSparkMax m_rightLeader{3};
|
||||
wpi::PWMSparkMax m_rightFollower{4};
|
||||
wpi::PWMSparkMax leftLeader{1};
|
||||
wpi::PWMSparkMax leftFollower{2};
|
||||
wpi::PWMSparkMax rightLeader{3};
|
||||
wpi::PWMSparkMax rightFollower{4};
|
||||
|
||||
wpi::Encoder m_leftEncoder{0, 1};
|
||||
wpi::Encoder m_rightEncoder{2, 3};
|
||||
wpi::Encoder leftEncoder{0, 1};
|
||||
wpi::Encoder rightEncoder{2, 3};
|
||||
|
||||
wpi::math::PIDController m_leftPIDController{1.0, 0.0, 0.0};
|
||||
wpi::math::PIDController m_rightPIDController{1.0, 0.0, 0.0};
|
||||
wpi::math::PIDController leftPIDController{1.0, 0.0, 0.0};
|
||||
wpi::math::PIDController rightPIDController{1.0, 0.0, 0.0};
|
||||
|
||||
wpi::OnboardIMU m_imu{wpi::OnboardIMU::FLAT};
|
||||
wpi::OnboardIMU imu{wpi::OnboardIMU::FLAT};
|
||||
|
||||
wpi::math::DifferentialDriveKinematics m_kinematics{kTrackwidth};
|
||||
wpi::math::DifferentialDriveKinematics kinematics{kTrackwidth};
|
||||
|
||||
// Gains are for example purposes only - must be determined for your own
|
||||
// robot!
|
||||
wpi::math::DifferentialDrivePoseEstimator m_poseEstimator{
|
||||
m_kinematics,
|
||||
m_imu.GetRotation2d(),
|
||||
wpi::units::meter_t{m_leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{m_rightEncoder.GetDistance()},
|
||||
wpi::math::DifferentialDrivePoseEstimator poseEstimator{
|
||||
kinematics,
|
||||
imu.GetRotation2d(),
|
||||
wpi::units::meter_t{leftEncoder.GetDistance()},
|
||||
wpi::units::meter_t{rightEncoder.GetDistance()},
|
||||
wpi::math::Pose2d{},
|
||||
{0.01, 0.01, 0.01},
|
||||
{0.1, 0.1, 0.1}};
|
||||
|
||||
// Gains are for example purposes only - must be determined for your own
|
||||
// robot!
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> m_feedforward{
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> feedforward{
|
||||
1_V, 3_V / 1_mps};
|
||||
|
||||
// Simulation classes
|
||||
wpi::sim::EncoderSim m_leftEncoderSim{m_leftEncoder};
|
||||
wpi::sim::EncoderSim m_rightEncoderSim{m_rightEncoder};
|
||||
wpi::Field2d m_fieldSim;
|
||||
wpi::Field2d m_fieldApproximation;
|
||||
wpi::math::LinearSystem<2, 2, 2> m_drivetrainSystem =
|
||||
wpi::sim::EncoderSim leftEncoderSim{leftEncoder};
|
||||
wpi::sim::EncoderSim rightEncoderSim{rightEncoder};
|
||||
wpi::Field2d fieldSim;
|
||||
wpi::Field2d fieldApproximation;
|
||||
wpi::math::LinearSystem<2, 2, 2> drivetrainSystem =
|
||||
wpi::math::Models::DifferentialDriveFromSysId(
|
||||
1.98_V / 1_mps, 0.2_V / 1_mps_sq, 1.5_V / 1_mps, 0.3_V / 1_mps_sq);
|
||||
wpi::sim::DifferentialDrivetrainSim m_drivetrainSimulator{
|
||||
m_drivetrainSystem, kTrackwidth, wpi::math::DCMotor::CIM(2), 8, 2_in};
|
||||
wpi::sim::DifferentialDrivetrainSim drivetrainSimulator{
|
||||
drivetrainSystem, kTrackwidth, wpi::math::DCMotor::CIM(2), 8, 2_in};
|
||||
};
|
||||
|
||||
@@ -35,11 +35,11 @@ void Robot::DisabledPeriodic() {}
|
||||
* RobotContainer} class.
|
||||
*/
|
||||
void Robot::AutonomousInit() {
|
||||
m_autonomousCommand = m_container.GetAutonomousCommand();
|
||||
autonomousCommand = container.GetAutonomousCommand();
|
||||
|
||||
if (m_autonomousCommand) {
|
||||
if (autonomousCommand) {
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(
|
||||
m_autonomousCommand.value());
|
||||
autonomousCommand.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ void Robot::TeleopInit() {
|
||||
// teleop starts running. If you want the autonomous to
|
||||
// continue until interrupted by another command, remove
|
||||
// this line or comment it out.
|
||||
if (m_autonomousCommand) {
|
||||
m_autonomousCommand->Cancel();
|
||||
m_autonomousCommand.reset();
|
||||
if (autonomousCommand) {
|
||||
autonomousCommand->Cancel();
|
||||
autonomousCommand.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,31 +13,31 @@ RobotContainer::RobotContainer() {
|
||||
ConfigureButtonBindings();
|
||||
|
||||
// Set up default drive command
|
||||
m_drive.SetDefaultCommand(wpi::cmd::Run(
|
||||
drive.SetDefaultCommand(wpi::cmd::Run(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
drive.ArcadeDrive(-driverController.GetLeftY(),
|
||||
-driverController.GetRightX());
|
||||
},
|
||||
{&m_drive}));
|
||||
{&drive}));
|
||||
}
|
||||
|
||||
void RobotContainer::ConfigureButtonBindings() {
|
||||
// Configure your button bindings here
|
||||
|
||||
// While holding the bumper button, drive at half velocity
|
||||
m_driverController.RightBumper()
|
||||
.OnTrue(m_driveHalfVelocity.get())
|
||||
.OnFalse(m_driveFullVelocity.get());
|
||||
driverController.RightBumper()
|
||||
.OnTrue(driveHalfVelocity.get())
|
||||
.OnFalse(driveFullVelocity.get());
|
||||
|
||||
// Drive forward by 3 meters when the 'South Face' button is pressed, with a
|
||||
// timeout of 10 seconds
|
||||
m_driverController.SouthFace().OnTrue(
|
||||
m_drive.ProfiledDriveDistance(3_m).WithTimeout(10_s));
|
||||
driverController.SouthFace().OnTrue(
|
||||
drive.ProfiledDriveDistance(3_m).WithTimeout(10_s));
|
||||
|
||||
// Do the same thing as above when the 'East Face' button is pressed, but
|
||||
// without resetting the encoders
|
||||
m_driverController.EastFace().OnTrue(
|
||||
m_drive.DynamicProfiledDriveDistance(3_m).WithTimeout(10_s));
|
||||
driverController.EastFace().OnTrue(
|
||||
drive.DynamicProfiledDriveDistance(3_m).WithTimeout(10_s));
|
||||
}
|
||||
|
||||
wpi::cmd::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
|
||||
@@ -9,24 +9,24 @@
|
||||
using namespace DriveConstants;
|
||||
|
||||
DriveSubsystem::DriveSubsystem()
|
||||
: m_leftLeader{kLeftMotor1Port},
|
||||
m_leftFollower{kLeftMotor2Port},
|
||||
m_rightLeader{kRightMotor1Port},
|
||||
m_rightFollower{kRightMotor2Port},
|
||||
m_feedforward{ks, kv, ka} {
|
||||
wpi::util::SendableRegistry::AddChild(&m_drive, &m_leftLeader);
|
||||
wpi::util::SendableRegistry::AddChild(&m_drive, &m_rightLeader);
|
||||
: leftLeader{kLeftMotor1Port},
|
||||
leftFollower{kLeftMotor2Port},
|
||||
rightLeader{kRightMotor1Port},
|
||||
rightFollower{kRightMotor2Port},
|
||||
feedforward{ks, kv, ka} {
|
||||
wpi::util::SendableRegistry::AddChild(&drive, &leftLeader);
|
||||
wpi::util::SendableRegistry::AddChild(&drive, &rightLeader);
|
||||
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_rightLeader.SetInverted(true);
|
||||
rightLeader.SetInverted(true);
|
||||
|
||||
m_leftFollower.Follow(m_leftLeader);
|
||||
m_rightFollower.Follow(m_rightLeader);
|
||||
leftFollower.Follow(leftLeader);
|
||||
rightFollower.Follow(rightLeader);
|
||||
|
||||
m_leftLeader.SetPID(kp, 0, 0);
|
||||
m_rightLeader.SetPID(kp, 0, 0);
|
||||
leftLeader.SetPID(kp, 0, 0);
|
||||
rightLeader.SetPID(kp, 0, 0);
|
||||
}
|
||||
|
||||
void DriveSubsystem::Periodic() {
|
||||
@@ -39,37 +39,37 @@ void DriveSubsystem::SetDriveStates(
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::State nextLeft,
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::State nextRight) {
|
||||
// Feedforward is divided by battery voltage to normalize it to [-1, 1]
|
||||
m_leftLeader.SetSetpoint(
|
||||
leftLeader.SetSetpoint(
|
||||
ExampleSmartMotorController::PIDMode::kPosition,
|
||||
currentLeft.position.value(),
|
||||
m_feedforward.Calculate(currentLeft.velocity, nextLeft.velocity) /
|
||||
feedforward.Calculate(currentLeft.velocity, nextLeft.velocity) /
|
||||
wpi::RobotController::GetBatteryVoltage());
|
||||
m_rightLeader.SetSetpoint(
|
||||
rightLeader.SetSetpoint(
|
||||
ExampleSmartMotorController::PIDMode::kPosition,
|
||||
currentRight.position.value(),
|
||||
m_feedforward.Calculate(currentRight.velocity, nextRight.velocity) /
|
||||
feedforward.Calculate(currentRight.velocity, nextRight.velocity) /
|
||||
wpi::RobotController::GetBatteryVoltage());
|
||||
}
|
||||
|
||||
void DriveSubsystem::ArcadeDrive(double fwd, double rot) {
|
||||
m_drive.ArcadeDrive(fwd, rot);
|
||||
drive.ArcadeDrive(fwd, rot);
|
||||
}
|
||||
|
||||
void DriveSubsystem::ResetEncoders() {
|
||||
m_leftLeader.ResetEncoder();
|
||||
m_rightLeader.ResetEncoder();
|
||||
leftLeader.ResetEncoder();
|
||||
rightLeader.ResetEncoder();
|
||||
}
|
||||
|
||||
wpi::units::meter_t DriveSubsystem::GetLeftEncoderDistance() {
|
||||
return wpi::units::meter_t{m_leftLeader.GetEncoderDistance()};
|
||||
return wpi::units::meter_t{leftLeader.GetEncoderDistance()};
|
||||
}
|
||||
|
||||
wpi::units::meter_t DriveSubsystem::GetRightEncoderDistance() {
|
||||
return wpi::units::meter_t{m_rightLeader.GetEncoderDistance()};
|
||||
return wpi::units::meter_t{rightLeader.GetEncoderDistance()};
|
||||
}
|
||||
|
||||
void DriveSubsystem::SetMaxOutput(double maxOutput) {
|
||||
m_drive.SetMaxOutput(maxOutput);
|
||||
drive.SetMaxOutput(maxOutput);
|
||||
}
|
||||
|
||||
wpi::cmd::CommandPtr DriveSubsystem::ProfiledDriveDistance(
|
||||
@@ -77,21 +77,21 @@ wpi::cmd::CommandPtr DriveSubsystem::ProfiledDriveDistance(
|
||||
return StartRun(
|
||||
[&] {
|
||||
// Restart timer so profile setpoints start at the beginning
|
||||
m_timer.Restart();
|
||||
timer.Restart();
|
||||
ResetEncoders();
|
||||
},
|
||||
[&] {
|
||||
// Current state never changes, so we need to use a timer to get
|
||||
// the setpoints we need to be at
|
||||
auto currentTime = m_timer.Get();
|
||||
auto currentTime = timer.Get();
|
||||
auto currentSetpoint =
|
||||
m_profile.Calculate(currentTime, {}, {distance, 0_mps});
|
||||
auto nextSetpoint = m_profile.Calculate(currentTime + kDt, {},
|
||||
{distance, 0_mps});
|
||||
profile.Calculate(currentTime, {}, {distance, 0_mps});
|
||||
auto nextSetpoint =
|
||||
profile.Calculate(currentTime + kDt, {}, {distance, 0_mps});
|
||||
SetDriveStates(currentSetpoint, currentSetpoint, nextSetpoint,
|
||||
nextSetpoint);
|
||||
})
|
||||
.Until([&] { return m_profile.IsFinished(0_s); });
|
||||
.Until([&] { return profile.IsFinished(0_s); });
|
||||
}
|
||||
|
||||
wpi::cmd::CommandPtr DriveSubsystem::DynamicProfiledDriveDistance(
|
||||
@@ -99,32 +99,32 @@ wpi::cmd::CommandPtr DriveSubsystem::DynamicProfiledDriveDistance(
|
||||
return StartRun(
|
||||
[&] {
|
||||
// Restart timer so profile setpoints start at the beginning
|
||||
m_timer.Restart();
|
||||
timer.Restart();
|
||||
// Store distance so we know the target distance for each encoder
|
||||
m_initialLeftDistance = GetLeftEncoderDistance();
|
||||
m_initialRightDistance = GetRightEncoderDistance();
|
||||
initialLeftDistance = GetLeftEncoderDistance();
|
||||
initialRightDistance = GetRightEncoderDistance();
|
||||
},
|
||||
[&] {
|
||||
// Current state never changes for the duration of the command,
|
||||
// so we need to use a timer to get the setpoints we need to be
|
||||
// at
|
||||
auto currentTime = m_timer.Get();
|
||||
auto currentTime = timer.Get();
|
||||
|
||||
auto currentLeftSetpoint = m_profile.Calculate(
|
||||
currentTime, {m_initialLeftDistance, 0_mps},
|
||||
{m_initialLeftDistance + distance, 0_mps});
|
||||
auto currentRightSetpoint = m_profile.Calculate(
|
||||
currentTime, {m_initialRightDistance, 0_mps},
|
||||
{m_initialRightDistance + distance, 0_mps});
|
||||
auto currentLeftSetpoint =
|
||||
profile.Calculate(currentTime, {initialLeftDistance, 0_mps},
|
||||
{initialLeftDistance + distance, 0_mps});
|
||||
auto currentRightSetpoint =
|
||||
profile.Calculate(currentTime, {initialRightDistance, 0_mps},
|
||||
{initialRightDistance + distance, 0_mps});
|
||||
|
||||
auto nextLeftSetpoint = m_profile.Calculate(
|
||||
currentTime + kDt, {m_initialLeftDistance, 0_mps},
|
||||
{m_initialLeftDistance + distance, 0_mps});
|
||||
auto nextRightSetpoint = m_profile.Calculate(
|
||||
currentTime + kDt, {m_initialRightDistance, 0_mps},
|
||||
{m_initialRightDistance + distance, 0_mps});
|
||||
auto nextLeftSetpoint = profile.Calculate(
|
||||
currentTime + kDt, {initialLeftDistance, 0_mps},
|
||||
{initialLeftDistance + distance, 0_mps});
|
||||
auto nextRightSetpoint = profile.Calculate(
|
||||
currentTime + kDt, {initialRightDistance, 0_mps},
|
||||
{initialRightDistance + distance, 0_mps});
|
||||
SetDriveStates(currentLeftSetpoint, currentRightSetpoint,
|
||||
nextLeftSetpoint, nextRightSetpoint);
|
||||
})
|
||||
.Until([&] { return m_profile.IsFinished(0_s); });
|
||||
.Until([&] { return profile.IsFinished(0_s); });
|
||||
}
|
||||
|
||||
@@ -66,9 +66,9 @@ class ExampleSmartMotorController {
|
||||
*/
|
||||
void ResetEncoder() {}
|
||||
|
||||
void Set(double velocity) { m_value = velocity; }
|
||||
void Set(double velocity) { value = velocity; }
|
||||
|
||||
double Get() const { return m_value; }
|
||||
double Get() const { return value; }
|
||||
|
||||
void SetInverted(bool isInverted) {}
|
||||
|
||||
@@ -79,5 +79,5 @@ class ExampleSmartMotorController {
|
||||
void StopMotor() {}
|
||||
|
||||
private:
|
||||
double m_value = 0.0;
|
||||
double value = 0.0;
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ class Robot : public wpi::TimedRobot {
|
||||
private:
|
||||
// Have it null by default so that if testing teleop it
|
||||
// doesn't have undefined behavior and potentially crash.
|
||||
std::optional<wpi::cmd::CommandPtr> m_autonomousCommand;
|
||||
std::optional<wpi::cmd::CommandPtr> autonomousCommand;
|
||||
|
||||
RobotContainer m_container;
|
||||
RobotContainer container;
|
||||
};
|
||||
|
||||
@@ -26,19 +26,18 @@ class RobotContainer {
|
||||
|
||||
private:
|
||||
// The driver's controller
|
||||
wpi::cmd::CommandGamepad m_driverController{
|
||||
OIConstants::kDriverControllerPort};
|
||||
wpi::cmd::CommandGamepad driverController{OIConstants::kDriverControllerPort};
|
||||
|
||||
// The robot's subsystems and commands are defined here...
|
||||
|
||||
// The robot's subsystems
|
||||
DriveSubsystem m_drive;
|
||||
DriveSubsystem drive;
|
||||
|
||||
// RobotContainer-owned commands
|
||||
wpi::cmd::CommandPtr m_driveHalfVelocity =
|
||||
wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {});
|
||||
wpi::cmd::CommandPtr m_driveFullVelocity =
|
||||
wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(1); }, {});
|
||||
wpi::cmd::CommandPtr driveHalfVelocity =
|
||||
wpi::cmd::RunOnce([this] { drive.SetMaxOutput(0.5); }, {});
|
||||
wpi::cmd::CommandPtr driveFullVelocity =
|
||||
wpi::cmd::RunOnce([this] { drive.SetMaxOutput(1); }, {});
|
||||
|
||||
void ConfigureButtonBindings();
|
||||
};
|
||||
|
||||
@@ -95,25 +95,24 @@ class DriveSubsystem : public wpi::cmd::SubsystemBase {
|
||||
wpi::units::meter_t distance);
|
||||
|
||||
private:
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters> m_profile{
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters> profile{
|
||||
{DriveConstants::kMaxVelocity, DriveConstants::kMaxAcceleration}};
|
||||
wpi::Timer m_timer;
|
||||
wpi::units::meter_t m_initialLeftDistance;
|
||||
wpi::units::meter_t m_initialRightDistance;
|
||||
wpi::Timer timer;
|
||||
wpi::units::meter_t initialLeftDistance;
|
||||
wpi::units::meter_t initialRightDistance;
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
// declared private and exposed only through public methods.
|
||||
|
||||
// The motor controllers
|
||||
ExampleSmartMotorController m_leftLeader;
|
||||
ExampleSmartMotorController m_leftFollower;
|
||||
ExampleSmartMotorController m_rightLeader;
|
||||
ExampleSmartMotorController m_rightFollower;
|
||||
ExampleSmartMotorController leftLeader;
|
||||
ExampleSmartMotorController leftFollower;
|
||||
ExampleSmartMotorController rightLeader;
|
||||
ExampleSmartMotorController rightFollower;
|
||||
|
||||
// A feedforward component for the drive
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> m_feedforward;
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> feedforward;
|
||||
|
||||
// The robot's drive
|
||||
wpi::DifferentialDrive m_drive{
|
||||
[&](double output) { m_leftLeader.Set(output); },
|
||||
[&](double output) { m_rightLeader.Set(output); }};
|
||||
wpi::DifferentialDrive drive{[&](double output) { leftLeader.Set(output); },
|
||||
[&](double output) { rightLeader.Set(output); }};
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ class Robot : public wpi::TimedRobot {
|
||||
// to measure this is fairly easy. Set the value to 0, place the mechanism
|
||||
// where you want "0" to be, and observe the value on the dashboard, That
|
||||
// is the value to enter for the 3rd parameter.
|
||||
wpi::DutyCycleEncoder m_dutyCycleEncoder{0, fullRange, expectedZero};
|
||||
wpi::DutyCycleEncoder dutyCycleEncoder{0, fullRange, expectedZero};
|
||||
|
||||
public:
|
||||
Robot() {
|
||||
@@ -32,18 +32,18 @@ class Robot : public wpi::TimedRobot {
|
||||
// those values. This number doesn't have to be perfect,
|
||||
// just having a fairly close value will make the output readings
|
||||
// much more stable.
|
||||
m_dutyCycleEncoder.SetAssumedFrequency(967.8_Hz);
|
||||
dutyCycleEncoder.SetAssumedFrequency(967.8_Hz);
|
||||
}
|
||||
|
||||
void RobotPeriodic() override {
|
||||
// Connected can be checked, and uses the frequency of the encoder
|
||||
auto connected = m_dutyCycleEncoder.IsConnected();
|
||||
auto connected = dutyCycleEncoder.IsConnected();
|
||||
|
||||
// Duty Cycle Frequency in Hz
|
||||
auto frequency = m_dutyCycleEncoder.GetFrequency();
|
||||
auto frequency = dutyCycleEncoder.GetFrequency();
|
||||
|
||||
// Output of encoder
|
||||
auto output = m_dutyCycleEncoder.Get();
|
||||
auto output = dutyCycleEncoder.Get();
|
||||
|
||||
// By default, the output will wrap around to the full range value
|
||||
// when the sensor goes below 0. However, for moving mechanisms this
|
||||
|
||||
@@ -19,44 +19,44 @@ class Robot : public wpi::TimedRobot {
|
||||
|
||||
Robot() {
|
||||
// Note: These gains are fake, and will have to be tuned for your robot.
|
||||
m_motor.SetPID(1.3, 0.0, 0.7);
|
||||
motor.SetPID(1.3, 0.0, 0.7);
|
||||
}
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
if (m_joystick.GetRawButtonPressed(2)) {
|
||||
m_goal = {5_m, 0_mps};
|
||||
} else if (m_joystick.GetRawButtonPressed(3)) {
|
||||
m_goal = {0_m, 0_mps};
|
||||
if (joystick.GetRawButtonPressed(2)) {
|
||||
goal = {5_m, 0_mps};
|
||||
} else if (joystick.GetRawButtonPressed(3)) {
|
||||
goal = {0_m, 0_mps};
|
||||
}
|
||||
|
||||
// Retrieve the profiled setpoint for the next timestep. This setpoint moves
|
||||
// toward the goal while obeying the constraints.
|
||||
auto next = m_profile.Calculate(kDt, m_goal, m_setpoint);
|
||||
auto next = profile.Calculate(kDt, goal, setpoint);
|
||||
|
||||
// Send setpoint to offboard controller PID
|
||||
m_motor.SetSetpoint(
|
||||
motor.SetSetpoint(
|
||||
ExampleSmartMotorController::PIDMode::kPosition,
|
||||
m_setpoint.position.value(),
|
||||
m_feedforward.Calculate(m_setpoint.velocity, next.velocity) / 12_V);
|
||||
setpoint.position.value(),
|
||||
feedforward.Calculate(setpoint.velocity, next.velocity) / 12_V);
|
||||
|
||||
m_setpoint = next;
|
||||
setpoint = next;
|
||||
}
|
||||
|
||||
private:
|
||||
wpi::Joystick m_joystick{1};
|
||||
ExampleSmartMotorController m_motor{1};
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> m_feedforward{
|
||||
wpi::Joystick joystick{1};
|
||||
ExampleSmartMotorController motor{1};
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> feedforward{
|
||||
// Note: These gains are fake, and will have to be tuned for your robot.
|
||||
1_V, 1_V / 1_mps, 1_V / 1_mps_sq};
|
||||
|
||||
// Create a motion profile with the given maximum velocity and maximum
|
||||
// acceleration constraints for the next setpoint.
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts>
|
||||
m_profile{{10_V, 1_V / 1_mps, 1_V / 1_mps_sq}};
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts> profile{
|
||||
{10_V, 1_V / 1_mps, 1_V / 1_mps_sq}};
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts>::State
|
||||
m_goal;
|
||||
goal;
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts>::State
|
||||
m_setpoint;
|
||||
setpoint;
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -9,32 +9,32 @@
|
||||
void Robot::RobotPeriodic() {
|
||||
// Update the telemetry, including mechanism visualization, regardless of
|
||||
// mode.
|
||||
m_elevator.UpdateTelemetry();
|
||||
elevator.UpdateTelemetry();
|
||||
}
|
||||
|
||||
void Robot::SimulationPeriodic() {
|
||||
// Update the simulation model.
|
||||
m_elevator.SimulationPeriodic();
|
||||
elevator.SimulationPeriodic();
|
||||
}
|
||||
|
||||
void Robot::TeleopInit() {
|
||||
// This just makes sure that our simulation code knows that the motor's off.
|
||||
m_elevator.Reset();
|
||||
elevator.Reset();
|
||||
}
|
||||
|
||||
void Robot::TeleopPeriodic() {
|
||||
if (m_joystick.GetTrigger()) {
|
||||
if (joystick.GetTrigger()) {
|
||||
// Here, we set the constant setpoint of 0.75 meters.
|
||||
m_elevator.ReachGoal(Constants::kSetpoint);
|
||||
elevator.ReachGoal(Constants::kSetpoint);
|
||||
} else {
|
||||
// Otherwise, we update the setpoint to 0.
|
||||
m_elevator.ReachGoal(Constants::kLowerSetpoint);
|
||||
elevator.ReachGoal(Constants::kLowerSetpoint);
|
||||
}
|
||||
}
|
||||
|
||||
void Robot::DisabledInit() {
|
||||
// This just makes sure that our simulation code knows that the motor's off.
|
||||
m_elevator.Stop();
|
||||
elevator.Stop();
|
||||
}
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -8,56 +8,56 @@
|
||||
#include "wpi/system/RobotController.hpp"
|
||||
|
||||
Elevator::Elevator() {
|
||||
m_encoder.SetDistancePerPulse(Constants::kArmEncoderDistPerPulse);
|
||||
encoder.SetDistancePerPulse(Constants::kArmEncoderDistPerPulse);
|
||||
|
||||
// Put Mechanism 2d to SmartDashboard
|
||||
// To view the Elevator visualization, select Network Tables -> SmartDashboard
|
||||
// -> Elevator Sim
|
||||
wpi::SmartDashboard::PutData("Elevator Sim", &m_mech2d);
|
||||
wpi::SmartDashboard::PutData("Elevator Sim", &mech2d);
|
||||
}
|
||||
|
||||
void Elevator::SimulationPeriodic() {
|
||||
// In this method, we update our simulation of what our elevator is doing
|
||||
// First, we set our "inputs" (voltages)
|
||||
m_elevatorSim.SetInput(wpi::math::Vectord<1>{
|
||||
m_motorSim.GetThrottle() * wpi::RobotController::GetInputVoltage()});
|
||||
elevatorSim.SetInput(wpi::math::Vectord<1>{
|
||||
motorSim.GetThrottle() * wpi::RobotController::GetInputVoltage()});
|
||||
|
||||
// Next, we update it. The standard loop time is 20ms.
|
||||
m_elevatorSim.Update(20_ms);
|
||||
elevatorSim.Update(20_ms);
|
||||
|
||||
// Finally, we set our simulated encoder's readings and simulated battery
|
||||
// voltage
|
||||
m_encoderSim.SetDistance(m_elevatorSim.GetPosition().value());
|
||||
encoderSim.SetDistance(elevatorSim.GetPosition().value());
|
||||
// SimBattery estimates loaded battery voltages
|
||||
wpi::sim::RoboRioSim::SetVInVoltage(
|
||||
wpi::sim::BatterySim::Calculate({m_elevatorSim.GetCurrentDraw()}));
|
||||
wpi::sim::BatterySim::Calculate({elevatorSim.GetCurrentDraw()}));
|
||||
}
|
||||
|
||||
void Elevator::UpdateTelemetry() {
|
||||
// Update the Elevator length based on the simulated elevator height
|
||||
m_elevatorMech2d->SetLength(m_encoder.GetDistance());
|
||||
elevatorMech2d->SetLength(encoder.GetDistance());
|
||||
}
|
||||
|
||||
void Elevator::ReachGoal(wpi::units::meter_t goal) {
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts>::State
|
||||
goalState{goal, 0_mps};
|
||||
|
||||
auto next = m_profile.Calculate(20_ms, m_setpoint, goalState);
|
||||
auto next = profile.Calculate(20_ms, setpoint, goalState);
|
||||
|
||||
auto pidOutput = m_controller.Calculate(m_encoder.GetDistance(),
|
||||
m_setpoint.position / 1_m);
|
||||
auto pidOutput =
|
||||
controller.Calculate(encoder.GetDistance(), setpoint.position / 1_m);
|
||||
auto feedforwardOutput =
|
||||
m_feedforward.Calculate(m_setpoint.velocity, next.velocity);
|
||||
feedforward.Calculate(setpoint.velocity, next.velocity);
|
||||
|
||||
m_motor.SetVoltage(wpi::units::volt_t{pidOutput} + feedforwardOutput);
|
||||
motor.SetVoltage(wpi::units::volt_t{pidOutput} + feedforwardOutput);
|
||||
|
||||
m_setpoint = next;
|
||||
setpoint = next;
|
||||
}
|
||||
|
||||
void Elevator::Reset() {
|
||||
m_setpoint = {m_encoder.GetDistance() * 1_m, 0_mps};
|
||||
setpoint = {encoder.GetDistance() * 1_m, 0_mps};
|
||||
}
|
||||
|
||||
void Elevator::Stop() {
|
||||
m_motor.SetThrottle(0.0);
|
||||
motor.SetThrottle(0.0);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ class Robot : public wpi::TimedRobot {
|
||||
void DisabledInit() override;
|
||||
|
||||
private:
|
||||
wpi::Joystick m_joystick{Constants::kJoystickPort};
|
||||
Elevator m_elevator;
|
||||
wpi::Joystick joystick{Constants::kJoystickPort};
|
||||
Elevator elevator;
|
||||
};
|
||||
|
||||
@@ -31,30 +31,30 @@ class Elevator {
|
||||
|
||||
private:
|
||||
// This gearbox represents a gearbox containing 4 Vex 775pro motors.
|
||||
wpi::math::DCMotor m_elevatorGearbox = wpi::math::DCMotor::NEO(2);
|
||||
wpi::math::DCMotor elevatorGearbox = wpi::math::DCMotor::NEO(2);
|
||||
|
||||
// Standard classes for controlling our elevator
|
||||
wpi::math::ExponentialProfile<wpi::units::meters,
|
||||
wpi::units::volts>::Constraints m_constraints{
|
||||
wpi::units::volts>::Constraints constraints{
|
||||
Constants::kElevatorMaxV, Constants::kElevatorkV, Constants::kElevatorkA};
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts>
|
||||
m_profile{m_constraints};
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts> profile{
|
||||
constraints};
|
||||
wpi::math::ExponentialProfile<wpi::units::meters, wpi::units::volts>::State
|
||||
m_setpoint;
|
||||
setpoint;
|
||||
|
||||
wpi::math::PIDController m_controller{
|
||||
wpi::math::PIDController controller{
|
||||
Constants::kElevatorKp, Constants::kElevatorKi, Constants::kElevatorKd};
|
||||
|
||||
wpi::math::ElevatorFeedforward m_feedforward{
|
||||
wpi::math::ElevatorFeedforward feedforward{
|
||||
Constants::kElevatorkS, Constants::kElevatorkG, Constants::kElevatorkV,
|
||||
Constants::kElevatorkA};
|
||||
wpi::Encoder m_encoder{Constants::kEncoderAChannel,
|
||||
wpi::Encoder encoder{Constants::kEncoderAChannel,
|
||||
Constants::kEncoderBChannel};
|
||||
wpi::PWMSparkMax m_motor{Constants::kMotorPort};
|
||||
wpi::sim::PWMMotorControllerSim m_motorSim{m_motor};
|
||||
wpi::PWMSparkMax motor{Constants::kMotorPort};
|
||||
wpi::sim::PWMMotorControllerSim motorSim{motor};
|
||||
|
||||
// Simulation classes help us simulate what's going on, including gravity.
|
||||
wpi::sim::ElevatorSim m_elevatorSim{m_elevatorGearbox,
|
||||
wpi::sim::ElevatorSim elevatorSim{elevatorGearbox,
|
||||
Constants::kElevatorGearing,
|
||||
Constants::kCarriageMass,
|
||||
Constants::kElevatorDrumRadius,
|
||||
@@ -63,13 +63,13 @@ class Elevator {
|
||||
true,
|
||||
0_m,
|
||||
{0.005}};
|
||||
wpi::sim::EncoderSim m_encoderSim{m_encoder};
|
||||
wpi::sim::EncoderSim encoderSim{encoder};
|
||||
|
||||
// Create a Mechanism2d display of an elevator
|
||||
wpi::Mechanism2d m_mech2d{10_in / 1_m, 51_in / 1_m};
|
||||
wpi::MechanismRoot2d* m_elevatorRoot =
|
||||
m_mech2d.GetRoot("Elevator Root", 5_in / 1_m, 0.5_in / 1_m);
|
||||
wpi::MechanismLigament2d* m_elevatorMech2d =
|
||||
m_elevatorRoot->Append<wpi::MechanismLigament2d>(
|
||||
"Elevator", m_elevatorSim.GetPosition().value(), 90_deg);
|
||||
wpi::Mechanism2d mech2d{10_in / 1_m, 51_in / 1_m};
|
||||
wpi::MechanismRoot2d* elevatorRoot =
|
||||
mech2d.GetRoot("Elevator Root", 5_in / 1_m, 0.5_in / 1_m);
|
||||
wpi::MechanismLigament2d* elevatorMech2d =
|
||||
elevatorRoot->Append<wpi::MechanismLigament2d>(
|
||||
"Elevator", elevatorSim.GetPosition().value(), 90_deg);
|
||||
};
|
||||
|
||||
@@ -22,21 +22,20 @@ class Robot : public wpi::TimedRobot {
|
||||
static constexpr wpi::units::second_t kDt = 20_ms;
|
||||
|
||||
Robot() {
|
||||
m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * std::numbers::pi * 1.5);
|
||||
encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * std::numbers::pi * 1.5);
|
||||
}
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
if (m_joystick.GetRawButtonPressed(2)) {
|
||||
m_controller.SetGoal(5_m);
|
||||
} else if (m_joystick.GetRawButtonPressed(3)) {
|
||||
m_controller.SetGoal(0_m);
|
||||
if (joystick.GetRawButtonPressed(2)) {
|
||||
controller.SetGoal(5_m);
|
||||
} else if (joystick.GetRawButtonPressed(3)) {
|
||||
controller.SetGoal(0_m);
|
||||
}
|
||||
|
||||
// Run controller and update motor output
|
||||
m_motor.SetVoltage(
|
||||
wpi::units::volt_t{m_controller.Calculate(
|
||||
wpi::units::meter_t{m_encoder.GetDistance()})} +
|
||||
m_feedforward.Calculate(m_controller.GetSetpoint().velocity));
|
||||
motor.SetVoltage(wpi::units::volt_t{controller.Calculate(
|
||||
wpi::units::meter_t{encoder.GetDistance()})} +
|
||||
feedforward.Calculate(controller.GetSetpoint().velocity));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -50,17 +49,17 @@ class Robot : public wpi::TimedRobot {
|
||||
static constexpr wpi::units::volt_t kG = 1.2_V;
|
||||
static constexpr auto kV = 1.3_V / 1_mps;
|
||||
|
||||
wpi::Joystick m_joystick{1};
|
||||
wpi::Encoder m_encoder{1, 2};
|
||||
wpi::PWMSparkMax m_motor{1};
|
||||
wpi::Joystick joystick{1};
|
||||
wpi::Encoder encoder{1, 2};
|
||||
wpi::PWMSparkMax motor{1};
|
||||
|
||||
// Create a PID controller whose setpoint's change is subject to maximum
|
||||
// velocity and acceleration constraints.
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::Constraints m_constraints{
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::Constraints constraints{
|
||||
kMaxVelocity, kMaxAcceleration};
|
||||
wpi::math::ProfiledPIDController<wpi::units::meters> m_controller{
|
||||
kP, kI, kD, m_constraints, kDt};
|
||||
wpi::math::ElevatorFeedforward m_feedforward{kS, kG, kV};
|
||||
wpi::math::ProfiledPIDController<wpi::units::meters> controller{
|
||||
kP, kI, kD, constraints, kDt};
|
||||
wpi::math::ElevatorFeedforward feedforward{kS, kG, kV};
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -9,27 +9,27 @@
|
||||
void Robot::RobotPeriodic() {
|
||||
// Update the telemetry, including mechanism visualization, regardless of
|
||||
// mode.
|
||||
m_elevator.UpdateTelemetry();
|
||||
elevator.UpdateTelemetry();
|
||||
}
|
||||
|
||||
void Robot::SimulationPeriodic() {
|
||||
// Update the simulation model.
|
||||
m_elevator.SimulationPeriodic();
|
||||
elevator.SimulationPeriodic();
|
||||
}
|
||||
|
||||
void Robot::TeleopPeriodic() {
|
||||
if (m_joystick.GetTrigger()) {
|
||||
if (joystick.GetTrigger()) {
|
||||
// Here, we set the constant setpoint of 0.75 meters.
|
||||
m_elevator.ReachGoal(Constants::kSetpoint);
|
||||
elevator.ReachGoal(Constants::kSetpoint);
|
||||
} else {
|
||||
// Otherwise, we update the setpoint to 0.
|
||||
m_elevator.ReachGoal(0.0_m);
|
||||
elevator.ReachGoal(0.0_m);
|
||||
}
|
||||
}
|
||||
|
||||
void Robot::DisabledInit() {
|
||||
// This just makes sure that our simulation code knows that the motor's off.
|
||||
m_elevator.Stop();
|
||||
elevator.Stop();
|
||||
}
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -8,47 +8,47 @@
|
||||
#include "wpi/system/RobotController.hpp"
|
||||
|
||||
Elevator::Elevator() {
|
||||
m_encoder.SetDistancePerPulse(Constants::kArmEncoderDistPerPulse);
|
||||
encoder.SetDistancePerPulse(Constants::kArmEncoderDistPerPulse);
|
||||
|
||||
// Put Mechanism 2d to SmartDashboard
|
||||
// To view the Elevator visualization, select Network Tables -> SmartDashboard
|
||||
// -> Elevator Sim
|
||||
wpi::SmartDashboard::PutData("Elevator Sim", &m_mech2d);
|
||||
wpi::SmartDashboard::PutData("Elevator Sim", &mech2d);
|
||||
}
|
||||
|
||||
void Elevator::SimulationPeriodic() {
|
||||
// In this method, we update our simulation of what our elevator is doing
|
||||
// First, we set our "inputs" (voltages)
|
||||
m_elevatorSim.SetInput(wpi::math::Vectord<1>{
|
||||
m_motorSim.GetThrottle() * wpi::RobotController::GetInputVoltage()});
|
||||
elevatorSim.SetInput(wpi::math::Vectord<1>{
|
||||
motorSim.GetThrottle() * wpi::RobotController::GetInputVoltage()});
|
||||
|
||||
// Next, we update it. The standard loop time is 20ms.
|
||||
m_elevatorSim.Update(20_ms);
|
||||
elevatorSim.Update(20_ms);
|
||||
|
||||
// Finally, we set our simulated encoder's readings and simulated battery
|
||||
// voltage
|
||||
m_encoderSim.SetDistance(m_elevatorSim.GetPosition().value());
|
||||
encoderSim.SetDistance(elevatorSim.GetPosition().value());
|
||||
// SimBattery estimates loaded battery voltages
|
||||
wpi::sim::RoboRioSim::SetVInVoltage(
|
||||
wpi::sim::BatterySim::Calculate({m_elevatorSim.GetCurrentDraw()}));
|
||||
wpi::sim::BatterySim::Calculate({elevatorSim.GetCurrentDraw()}));
|
||||
}
|
||||
|
||||
void Elevator::UpdateTelemetry() {
|
||||
// Update the Elevator length based on the simulated elevator height
|
||||
m_elevatorMech2d->SetLength(m_encoder.GetDistance());
|
||||
elevatorMech2d->SetLength(encoder.GetDistance());
|
||||
}
|
||||
|
||||
void Elevator::ReachGoal(wpi::units::meter_t goal) {
|
||||
m_controller.SetGoal(goal);
|
||||
controller.SetGoal(goal);
|
||||
// With the setpoint value we run PID control like normal
|
||||
double pidOutput =
|
||||
m_controller.Calculate(wpi::units::meter_t{m_encoder.GetDistance()});
|
||||
controller.Calculate(wpi::units::meter_t{encoder.GetDistance()});
|
||||
wpi::units::volt_t feedforwardOutput =
|
||||
m_feedforward.Calculate(m_controller.GetSetpoint().velocity);
|
||||
m_motor.SetVoltage(wpi::units::volt_t{pidOutput} + feedforwardOutput);
|
||||
feedforward.Calculate(controller.GetSetpoint().velocity);
|
||||
motor.SetVoltage(wpi::units::volt_t{pidOutput} + feedforwardOutput);
|
||||
}
|
||||
|
||||
void Elevator::Stop() {
|
||||
m_controller.SetGoal(0.0_m);
|
||||
m_motor.SetThrottle(0.0);
|
||||
controller.SetGoal(0.0_m);
|
||||
motor.SetThrottle(0.0);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,6 @@ class Robot : public wpi::TimedRobot {
|
||||
void DisabledInit() override;
|
||||
|
||||
private:
|
||||
wpi::Joystick m_joystick{Constants::kJoystickPort};
|
||||
Elevator m_elevator;
|
||||
wpi::Joystick joystick{Constants::kJoystickPort};
|
||||
Elevator elevator;
|
||||
};
|
||||
|
||||
@@ -30,25 +30,25 @@ class Elevator {
|
||||
|
||||
private:
|
||||
// This gearbox represents a gearbox containing 4 Vex 775pro motors.
|
||||
wpi::math::DCMotor m_elevatorGearbox = wpi::math::DCMotor::Vex775Pro(4);
|
||||
wpi::math::DCMotor elevatorGearbox = wpi::math::DCMotor::Vex775Pro(4);
|
||||
|
||||
// Standard classes for controlling our elevator
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::Constraints m_constraints{
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::Constraints constraints{
|
||||
2.45_mps, 2.45_mps_sq};
|
||||
wpi::math::ProfiledPIDController<wpi::units::meters> m_controller{
|
||||
wpi::math::ProfiledPIDController<wpi::units::meters> controller{
|
||||
Constants::kElevatorKp, Constants::kElevatorKi, Constants::kElevatorKd,
|
||||
m_constraints};
|
||||
constraints};
|
||||
|
||||
wpi::math::ElevatorFeedforward m_feedforward{
|
||||
wpi::math::ElevatorFeedforward feedforward{
|
||||
Constants::kElevatorkS, Constants::kElevatorkG, Constants::kElevatorkV,
|
||||
Constants::kElevatorkA};
|
||||
wpi::Encoder m_encoder{Constants::kEncoderAChannel,
|
||||
wpi::Encoder encoder{Constants::kEncoderAChannel,
|
||||
Constants::kEncoderBChannel};
|
||||
wpi::PWMSparkMax m_motor{Constants::kMotorPort};
|
||||
wpi::sim::PWMMotorControllerSim m_motorSim{m_motor};
|
||||
wpi::PWMSparkMax motor{Constants::kMotorPort};
|
||||
wpi::sim::PWMMotorControllerSim motorSim{motor};
|
||||
|
||||
// Simulation classes help us simulate what's going on, including gravity.
|
||||
wpi::sim::ElevatorSim m_elevatorSim{m_elevatorGearbox,
|
||||
wpi::sim::ElevatorSim elevatorSim{elevatorGearbox,
|
||||
Constants::kElevatorGearing,
|
||||
Constants::kCarriageMass,
|
||||
Constants::kElevatorDrumRadius,
|
||||
@@ -57,13 +57,12 @@ class Elevator {
|
||||
true,
|
||||
0_m,
|
||||
{0.01}};
|
||||
wpi::sim::EncoderSim m_encoderSim{m_encoder};
|
||||
wpi::sim::EncoderSim encoderSim{encoder};
|
||||
|
||||
// Create a Mechanism2d display of an elevator
|
||||
wpi::Mechanism2d m_mech2d{20, 50};
|
||||
wpi::MechanismRoot2d* m_elevatorRoot =
|
||||
m_mech2d.GetRoot("Elevator Root", 10, 0);
|
||||
wpi::MechanismLigament2d* m_elevatorMech2d =
|
||||
m_elevatorRoot->Append<wpi::MechanismLigament2d>(
|
||||
"Elevator", m_elevatorSim.GetPosition().value(), 90_deg);
|
||||
wpi::Mechanism2d mech2d{20, 50};
|
||||
wpi::MechanismRoot2d* elevatorRoot = mech2d.GetRoot("Elevator Root", 10, 0);
|
||||
wpi::MechanismLigament2d* elevatorMech2d =
|
||||
elevatorRoot->Append<wpi::MechanismLigament2d>(
|
||||
"Elevator", elevatorSim.GetPosition().value(), 90_deg);
|
||||
};
|
||||
|
||||
@@ -19,39 +19,39 @@ class Robot : public wpi::TimedRobot {
|
||||
|
||||
Robot() {
|
||||
// Note: These gains are fake, and will have to be tuned for your robot.
|
||||
m_motor.SetPID(1.3, 0.0, 0.7);
|
||||
motor.SetPID(1.3, 0.0, 0.7);
|
||||
}
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
if (m_joystick.GetRawButtonPressed(2)) {
|
||||
m_goal = {5_m, 0_mps};
|
||||
} else if (m_joystick.GetRawButtonPressed(3)) {
|
||||
m_goal = {0_m, 0_mps};
|
||||
if (joystick.GetRawButtonPressed(2)) {
|
||||
goal = {5_m, 0_mps};
|
||||
} else if (joystick.GetRawButtonPressed(3)) {
|
||||
goal = {0_m, 0_mps};
|
||||
}
|
||||
|
||||
// Retrieve the profiled setpoint for the next timestep. This setpoint moves
|
||||
// toward the goal while obeying the constraints.
|
||||
m_setpoint = m_profile.Calculate(kDt, m_setpoint, m_goal);
|
||||
setpoint = profile.Calculate(kDt, setpoint, goal);
|
||||
|
||||
// Send setpoint to offboard controller PID
|
||||
m_motor.SetSetpoint(ExampleSmartMotorController::PIDMode::kPosition,
|
||||
m_setpoint.position.value(),
|
||||
m_feedforward.Calculate(m_setpoint.velocity) / 12_V);
|
||||
motor.SetSetpoint(ExampleSmartMotorController::PIDMode::kPosition,
|
||||
setpoint.position.value(),
|
||||
feedforward.Calculate(setpoint.velocity) / 12_V);
|
||||
}
|
||||
|
||||
private:
|
||||
wpi::Joystick m_joystick{1};
|
||||
ExampleSmartMotorController m_motor{1};
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> m_feedforward{
|
||||
wpi::Joystick joystick{1};
|
||||
ExampleSmartMotorController motor{1};
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::meters> feedforward{
|
||||
// Note: These gains are fake, and will have to be tuned for your robot.
|
||||
1_V, 1.5_V * 1_s / 1_m};
|
||||
|
||||
// Create a motion profile with the given maximum velocity and maximum
|
||||
// acceleration constraints for the next setpoint.
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters> m_profile{
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters> profile{
|
||||
{1.75_mps, 0.75_mps_sq}};
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::State m_goal;
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::State m_setpoint;
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::State goal;
|
||||
wpi::math::TrapezoidProfile<wpi::units::meters>::State setpoint;
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -34,29 +34,29 @@ class Robot : public wpi::TimedRobot {
|
||||
* On a quadrature encoder, values range from 1-255; larger values result in
|
||||
* smoother but potentially less accurate rates than lower values.
|
||||
*/
|
||||
m_encoder.SetSamplesToAverage(5);
|
||||
encoder.SetSamplesToAverage(5);
|
||||
|
||||
/* Defines how far the mechanism attached to the encoder moves per pulse. In
|
||||
* this case, we assume that a 360 count encoder is directly attached to a 3
|
||||
* inch diameter (1.5inch radius) wheel, and that we want to measure
|
||||
* distance in inches.
|
||||
*/
|
||||
m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * std::numbers::pi * 1.5);
|
||||
encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * std::numbers::pi * 1.5);
|
||||
|
||||
/* Defines the lowest rate at which the encoder will not be considered
|
||||
* stopped, for the purposes of the GetStopped() method. Units are in
|
||||
* distance / second, where distance refers to the units of distance that
|
||||
* you are using, in this case inches.
|
||||
*/
|
||||
m_encoder.SetMinRate(1.0);
|
||||
encoder.SetMinRate(1.0);
|
||||
}
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// Retrieve the net displacement of the Encoder since the last Reset.
|
||||
wpi::SmartDashboard::PutNumber("Encoder Distance", m_encoder.GetDistance());
|
||||
wpi::SmartDashboard::PutNumber("Encoder Distance", encoder.GetDistance());
|
||||
|
||||
// Retrieve the current rate of the encoder.
|
||||
wpi::SmartDashboard::PutNumber("Encoder Rate", m_encoder.GetRate());
|
||||
wpi::SmartDashboard::PutNumber("Encoder Rate", encoder.GetRate());
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -76,7 +76,7 @@ class Robot : public wpi::TimedRobot {
|
||||
* and defaults to X4. Faster (X4) encoding gives greater positional
|
||||
* precision but more noise in the rate.
|
||||
*/
|
||||
wpi::Encoder m_encoder{1, 2, false, wpi::Encoder::EncodingType::X4};
|
||||
wpi::Encoder encoder{1, 2, false, wpi::Encoder::EncodingType::X4};
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -11,27 +11,27 @@
|
||||
class Robot : public wpi::TimedRobot {
|
||||
public:
|
||||
Robot() {
|
||||
wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_left);
|
||||
wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_right);
|
||||
wpi::util::SendableRegistry::AddChild(&robotDrive, &left);
|
||||
wpi::util::SendableRegistry::AddChild(&robotDrive, &right);
|
||||
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_right.SetInverted(true);
|
||||
m_robotDrive.SetExpiration(100_ms);
|
||||
m_timer.Start();
|
||||
right.SetInverted(true);
|
||||
robotDrive.SetExpiration(100_ms);
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
void AutonomousInit() override { m_timer.Restart(); }
|
||||
void AutonomousInit() override { timer.Restart(); }
|
||||
|
||||
void AutonomousPeriodic() override {
|
||||
// Drive for 2 seconds
|
||||
if (m_timer.Get() < 2_s) {
|
||||
if (timer.Get() < 2_s) {
|
||||
// Drive forwards half velocity, make sure to turn input squaring off
|
||||
m_robotDrive.ArcadeDrive(0.5, 0.0, false);
|
||||
robotDrive.ArcadeDrive(0.5, 0.0, false);
|
||||
} else {
|
||||
// Stop robot
|
||||
m_robotDrive.ArcadeDrive(0.0, 0.0, false);
|
||||
robotDrive.ArcadeDrive(0.0, 0.0, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ class Robot : public wpi::TimedRobot {
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
// Drive with arcade style (use right stick to steer)
|
||||
m_robotDrive.ArcadeDrive(-m_controller.GetLeftY(),
|
||||
m_controller.GetRightX());
|
||||
robotDrive.ArcadeDrive(-controller.GetLeftY(), controller.GetRightX());
|
||||
}
|
||||
|
||||
void UtilityInit() override {}
|
||||
@@ -49,14 +48,14 @@ class Robot : public wpi::TimedRobot {
|
||||
|
||||
private:
|
||||
// Robot drive system
|
||||
wpi::PWMSparkMax m_left{0};
|
||||
wpi::PWMSparkMax m_right{1};
|
||||
wpi::DifferentialDrive m_robotDrive{
|
||||
[&](double output) { m_left.SetThrottle(output); },
|
||||
[&](double output) { m_right.SetThrottle(output); }};
|
||||
wpi::PWMSparkMax left{0};
|
||||
wpi::PWMSparkMax right{1};
|
||||
wpi::DifferentialDrive robotDrive{
|
||||
[&](double output) { left.SetThrottle(output); },
|
||||
[&](double output) { right.SetThrottle(output); }};
|
||||
|
||||
wpi::Gamepad m_controller{0};
|
||||
wpi::Timer m_timer;
|
||||
wpi::Gamepad controller{0};
|
||||
wpi::Timer timer;
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -21,10 +21,10 @@ class Robot : public wpi::TimedRobot {
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
// result in both sides moving forward. Depending on how your robot's
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_right.SetInverted(true);
|
||||
right.SetInverted(true);
|
||||
|
||||
wpi::util::SendableRegistry::AddChild(&m_drive, &m_left);
|
||||
wpi::util::SendableRegistry::AddChild(&m_drive, &m_right);
|
||||
wpi::util::SendableRegistry::AddChild(&drive, &left);
|
||||
wpi::util::SendableRegistry::AddChild(&drive, &right);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ class Robot : public wpi::TimedRobot {
|
||||
*/
|
||||
void TeleopPeriodic() override {
|
||||
double turningValue =
|
||||
(kAngleSetpoint - m_imu.GetRotation2d().Degrees().value()) * kP;
|
||||
m_drive.ArcadeDrive(-m_joystick.GetY(), -turningValue);
|
||||
(kAngleSetpoint - imu.GetRotation2d().Degrees().value()) * kP;
|
||||
drive.ArcadeDrive(-joystick.GetY(), -turningValue);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -48,14 +48,14 @@ class Robot : public wpi::TimedRobot {
|
||||
wpi::OnboardIMU::FLAT;
|
||||
static constexpr int kJoystickPort = 0;
|
||||
|
||||
wpi::PWMSparkMax m_left{kLeftMotorPort};
|
||||
wpi::PWMSparkMax m_right{kRightMotorPort};
|
||||
wpi::DifferentialDrive m_drive{
|
||||
[&](double output) { m_left.SetThrottle(output); },
|
||||
[&](double output) { m_right.SetThrottle(output); }};
|
||||
wpi::PWMSparkMax left{kLeftMotorPort};
|
||||
wpi::PWMSparkMax right{kRightMotorPort};
|
||||
wpi::DifferentialDrive drive{
|
||||
[&](double output) { left.SetThrottle(output); },
|
||||
[&](double output) { right.SetThrottle(output); }};
|
||||
|
||||
wpi::OnboardIMU m_imu{kIMUMountOrientation};
|
||||
wpi::Joystick m_joystick{kJoystickPort};
|
||||
wpi::OnboardIMU imu{kIMUMountOrientation};
|
||||
wpi::Joystick joystick{kJoystickPort};
|
||||
};
|
||||
|
||||
#ifndef RUNNING_WPILIB_TESTS
|
||||
|
||||
@@ -44,10 +44,10 @@ void Robot::DisabledPeriodic() {}
|
||||
* RobotContainer} class.
|
||||
*/
|
||||
void Robot::AutonomousInit() {
|
||||
m_autonomousCommand = m_container.GetAutonomousCommand();
|
||||
autonomousCommand = container.GetAutonomousCommand();
|
||||
|
||||
if (m_autonomousCommand != nullptr) {
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_autonomousCommand);
|
||||
if (autonomousCommand != nullptr) {
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(autonomousCommand);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ void Robot::TeleopInit() {
|
||||
// teleop starts running. If you want the autonomous to
|
||||
// continue until interrupted by another command, remove
|
||||
// this line or comment it out.
|
||||
if (m_autonomousCommand != nullptr) {
|
||||
m_autonomousCommand->Cancel();
|
||||
m_autonomousCommand = nullptr;
|
||||
if (autonomousCommand != nullptr) {
|
||||
autonomousCommand->Cancel();
|
||||
autonomousCommand = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user