From 50880b113fc739164eb1f009e6043a254013249c Mon Sep 17 00:00:00 2001
From: Gold856 <117957790+Gold856@users.noreply.github.com>
Date: Mon, 2 Sep 2024 17:59:18 -0400
Subject: [PATCH 1/4] Don't force public variables to have an m_ prefix
---
.../src/main/java/org/wpilib/vision/apriltag/AprilTag.java | 2 +-
.../java/org/wpilib/vision/apriltag/AprilTagDetector.java | 2 --
.../java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java | 2 --
.../org/wpilib/vision/apriltag/AprilTagPoseEstimate.java | 1 -
.../org/wpilib/vision/apriltag/AprilTagPoseEstimator.java | 1 -
.../multiCameraServer/src/main/java/org/wpilib/Main.java | 1 -
.../main/java/org/wpilib/vision/camera/UsbCameraInfo.java | 1 -
.../src/main/java/org/wpilib/vision/camera/VideoEvent.java | 1 -
cscore/src/main/java/org/wpilib/vision/camera/VideoMode.java | 1 -
datalog/src/main/java/org/wpilib/datalog/DataLogRecord.java | 2 --
.../main/java/org/wpilib/epilogue/EpilogueConfiguration.java | 1 -
hal/src/main/java/org/wpilib/hardware/hal/CANAPITypes.java | 2 --
hal/src/main/java/org/wpilib/hardware/hal/MatchInfoData.java | 1 -
.../org/wpilib/hardware/hal/PowerDistributionVersion.java | 1 -
hal/src/main/java/org/wpilib/hardware/hal/REVPHVersion.java | 1 -
hal/src/main/java/org/wpilib/hardware/hal/can/CANStatus.java | 1 -
.../java/org/wpilib/hardware/hal/can/CANStreamMessage.java | 5 -----
.../org/wpilib/hardware/hal/simulation/SimDeviceDataJNI.java | 2 --
ntcore/src/generate/main/java/Timestamped.java.jinja | 3 ---
.../java/org/wpilib/networktables/TimestampedBoolean.java | 3 ---
.../org/wpilib/networktables/TimestampedBooleanArray.java | 3 ---
.../java/org/wpilib/networktables/TimestampedDouble.java | 3 ---
.../org/wpilib/networktables/TimestampedDoubleArray.java | 3 ---
.../main/java/org/wpilib/networktables/TimestampedFloat.java | 3 ---
.../java/org/wpilib/networktables/TimestampedFloatArray.java | 3 ---
.../java/org/wpilib/networktables/TimestampedInteger.java | 3 ---
.../org/wpilib/networktables/TimestampedIntegerArray.java | 3 ---
.../main/java/org/wpilib/networktables/TimestampedRaw.java | 3 ---
.../java/org/wpilib/networktables/TimestampedString.java | 3 ---
.../org/wpilib/networktables/TimestampedStringArray.java | 3 ---
.../main/java/org/wpilib/networktables/ConnectionInfo.java | 1 -
.../src/main/java/org/wpilib/networktables/LogMessage.java | 1 -
.../java/org/wpilib/networktables/NetworkTableEvent.java | 1 -
.../main/java/org/wpilib/networktables/PubSubOptions.java | 1 -
.../java/org/wpilib/networktables/TimeSyncEventData.java | 1 -
.../java/org/wpilib/networktables/TimestampedObject.java | 3 ---
ntcore/src/main/java/org/wpilib/networktables/TopicInfo.java | 1 -
.../main/java/org/wpilib/networktables/ValueEventData.java | 1 -
styleguide/checkstyle.xml | 1 +
.../src/main/java/org/wpilib/counter/EdgeConfiguration.java | 1 -
.../src/main/java/org/wpilib/drive/DifferentialDrive.java | 1 -
wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java | 1 -
.../examples/rapidreactcommandbot/subsystems/Storage.java | 1 -
wpiutil/src/main/java/org/wpilib/util/Color.java | 1 -
wpiutil/src/main/java/org/wpilib/util/Color8Bit.java | 1 -
.../main/java/org/wpilib/util/struct/StructFieldType.java | 4 ----
.../org/wpilib/util/struct/parser/ParsedDeclaration.java | 5 -----
.../java/org/wpilib/util/struct/parser/ParsedSchema.java | 1 -
48 files changed, 2 insertions(+), 89 deletions(-)
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java
index b2f36c1d0c0..3e6c0d48779 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java
@@ -11,11 +11,11 @@
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("MemberName")
public int ID;
/** The tag's pose. */
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagDetector.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagDetector.java
index 6bba9cc671e..22aa4f09b60 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagDetector.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagDetector.java
@@ -14,7 +14,6 @@
*/
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 boolean equals(Object obj) {
}
/** 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;
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
index 62b878ed9be..6ad63ea8862 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
@@ -264,11 +264,9 @@ public int hashCode() {
}
static class FieldDimensions {
- @SuppressWarnings("MemberName")
@Json.Property(value = "length")
public final double fieldLength;
- @SuppressWarnings("MemberName")
@Json.Property(value = "width")
public final double fieldWidth;
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimate.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimate.java
index 54727e1a4f8..2025e069c8e 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimate.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimate.java
@@ -7,7 +7,6 @@
import org.wpilib.math.geometry.Transform3d;
/** A pair of AprilTag pose estimates. */
-@SuppressWarnings("MemberName")
public class AprilTagPoseEstimate {
/**
* Constructs a pose estimate.
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimator.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimator.java
index 224b78f3ef8..2c9c3f1d31c 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimator.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagPoseEstimator.java
@@ -10,7 +10,6 @@
/** Pose estimators for AprilTag tags. */
public class AprilTagPoseEstimator {
/** Configuration for the pose estimator. */
- @SuppressWarnings("MemberName")
public static class Config {
/**
* Creates a pose estimator configuration.
diff --git a/cameraserver/multiCameraServer/src/main/java/org/wpilib/Main.java b/cameraserver/multiCameraServer/src/main/java/org/wpilib/Main.java
index 8da41bb3409..0ab2e7c226c 100644
--- a/cameraserver/multiCameraServer/src/main/java/org/wpilib/Main.java
+++ b/cameraserver/multiCameraServer/src/main/java/org/wpilib/Main.java
@@ -49,7 +49,6 @@
public final class Main {
private static String configFile = "/boot/CameraServerConfig.json";
- @SuppressWarnings("MemberName")
public static class CameraConfig {
public String name;
public String path;
diff --git a/cscore/src/main/java/org/wpilib/vision/camera/UsbCameraInfo.java b/cscore/src/main/java/org/wpilib/vision/camera/UsbCameraInfo.java
index dc164b4854d..503a27e7520 100644
--- a/cscore/src/main/java/org/wpilib/vision/camera/UsbCameraInfo.java
+++ b/cscore/src/main/java/org/wpilib/vision/camera/UsbCameraInfo.java
@@ -5,7 +5,6 @@
package org.wpilib.vision.camera;
/** USB camera information. */
-@SuppressWarnings("MemberName")
public class UsbCameraInfo {
/**
* Create a new set of UsbCameraInfo.
diff --git a/cscore/src/main/java/org/wpilib/vision/camera/VideoEvent.java b/cscore/src/main/java/org/wpilib/vision/camera/VideoEvent.java
index 61657eb413f..9977af91fd6 100644
--- a/cscore/src/main/java/org/wpilib/vision/camera/VideoEvent.java
+++ b/cscore/src/main/java/org/wpilib/vision/camera/VideoEvent.java
@@ -5,7 +5,6 @@
package org.wpilib.vision.camera;
/** Video event. */
-@SuppressWarnings("MemberName")
public class VideoEvent {
/** VideoEvent kind. */
public enum Kind {
diff --git a/cscore/src/main/java/org/wpilib/vision/camera/VideoMode.java b/cscore/src/main/java/org/wpilib/vision/camera/VideoMode.java
index 24f9e98fe62..34e86503806 100644
--- a/cscore/src/main/java/org/wpilib/vision/camera/VideoMode.java
+++ b/cscore/src/main/java/org/wpilib/vision/camera/VideoMode.java
@@ -8,7 +8,6 @@
import org.wpilib.util.PixelFormat;
/** Video mode. */
-@SuppressWarnings("MemberName")
public class VideoMode {
/**
* Create a new video mode.
diff --git a/datalog/src/main/java/org/wpilib/datalog/DataLogRecord.java b/datalog/src/main/java/org/wpilib/datalog/DataLogRecord.java
index b2f06388517..c7af37d3410 100644
--- a/datalog/src/main/java/org/wpilib/datalog/DataLogRecord.java
+++ b/datalog/src/main/java/org/wpilib/datalog/DataLogRecord.java
@@ -124,7 +124,6 @@ public boolean isSetMetadata() {
* 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 StartRecordData getStartData() {
* 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;
diff --git a/epilogue-runtime/src/main/java/org/wpilib/epilogue/EpilogueConfiguration.java b/epilogue-runtime/src/main/java/org/wpilib/epilogue/EpilogueConfiguration.java
index 5e046eb87a8..91d9753bc39 100644
--- a/epilogue-runtime/src/main/java/org/wpilib/epilogue/EpilogueConfiguration.java
+++ b/epilogue-runtime/src/main/java/org/wpilib/epilogue/EpilogueConfiguration.java
@@ -15,7 +15,6 @@
* 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
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/CANAPITypes.java b/hal/src/main/java/org/wpilib/hardware/hal/CANAPITypes.java
index df13e5c67fa..403bc8ce53e 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/CANAPITypes.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/CANAPITypes.java
@@ -55,7 +55,6 @@ public enum CANDeviceType {
FIRMWARE_UPDATE(31);
/** The device type ID. */
- @SuppressWarnings("MemberName")
public final int id;
CANDeviceType(int id) {
@@ -118,7 +117,6 @@ public enum CANManufacturer {
BRUSHLAND_LABS(20);
/** The manufacturer ID. */
- @SuppressWarnings("MemberName")
public final int id;
CANManufacturer(int id) {
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/MatchInfoData.java b/hal/src/main/java/org/wpilib/hardware/hal/MatchInfoData.java
index 3b8eb6aee7d..2c738813766 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/MatchInfoData.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/MatchInfoData.java
@@ -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 = "";
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionVersion.java b/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionVersion.java
index 086ed42f780..62f221e4d93 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionVersion.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionVersion.java
@@ -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;
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/REVPHVersion.java b/hal/src/main/java/org/wpilib/hardware/hal/REVPHVersion.java
index 1dbd075f549..d63860839a0 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/REVPHVersion.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/REVPHVersion.java
@@ -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;
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/can/CANStatus.java b/hal/src/main/java/org/wpilib/hardware/hal/can/CANStatus.java
index e5aeb1e0645..badd06e39f2 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/can/CANStatus.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/can/CANStatus.java
@@ -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;
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/can/CANStreamMessage.java b/hal/src/main/java/org/wpilib/hardware/hal/can/CANStreamMessage.java
index d268103820f..e7c491ed7a4 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/can/CANStreamMessage.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/can/CANStreamMessage.java
@@ -7,23 +7,18 @@
/** 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. */
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/simulation/SimDeviceDataJNI.java b/hal/src/main/java/org/wpilib/hardware/hal/simulation/SimDeviceDataJNI.java
index 89fd771cb93..cd6c343048f 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/simulation/SimDeviceDataJNI.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/simulation/SimDeviceDataJNI.java
@@ -29,7 +29,6 @@ public static native int registerSimDeviceFreedCallback(
public static native int getSimValueDeviceHandle(int handle);
- @SuppressWarnings("MemberName")
public static class SimDeviceInfo {
public String name;
public int handle;
@@ -74,7 +73,6 @@ public static native int registerSimValueResetCallback(
public static native int getSimValueHandle(int device, String name);
- @SuppressWarnings("MemberName")
public static class SimValueInfo {
public String name;
public int handle;
diff --git a/ntcore/src/generate/main/java/Timestamped.java.jinja b/ntcore/src/generate/main/java/Timestamped.java.jinja
index 144cc5023da..580037dc220 100644
--- a/ntcore/src/generate/main/java/Timestamped.java.jinja
+++ b/ntcore/src/generate/main/java/Timestamped.java.jinja
@@ -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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBoolean.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBoolean.java
index aa8590d2135..7104e088807 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBoolean.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBoolean.java
@@ -24,18 +24,15 @@ public TimestampedBoolean(long timestamp, long serverTime, boolean value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBooleanArray.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBooleanArray.java
index 24218f65355..c027f725b14 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBooleanArray.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedBooleanArray.java
@@ -24,18 +24,15 @@ public TimestampedBooleanArray(long timestamp, long serverTime, boolean[] value)
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDouble.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDouble.java
index 7a5ceaf50e4..7a9e46d67b9 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDouble.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDouble.java
@@ -24,18 +24,15 @@ public TimestampedDouble(long timestamp, long serverTime, double value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDoubleArray.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDoubleArray.java
index ff8d3c02061..9da8fdb87fe 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDoubleArray.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedDoubleArray.java
@@ -24,18 +24,15 @@ public TimestampedDoubleArray(long timestamp, long serverTime, double[] value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloat.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloat.java
index 3ecf2c32d2b..f12f87149bc 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloat.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloat.java
@@ -24,18 +24,15 @@ public TimestampedFloat(long timestamp, long serverTime, float value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloatArray.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloatArray.java
index 70dbc9d6a8d..1c9a5f826ba 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloatArray.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedFloatArray.java
@@ -24,18 +24,15 @@ public TimestampedFloatArray(long timestamp, long serverTime, float[] value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedInteger.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedInteger.java
index 56cee7539bd..2eec4426222 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedInteger.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedInteger.java
@@ -24,18 +24,15 @@ public TimestampedInteger(long timestamp, long serverTime, long value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedIntegerArray.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedIntegerArray.java
index 9221386eed0..91f2966f2c8 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedIntegerArray.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedIntegerArray.java
@@ -24,18 +24,15 @@ public TimestampedIntegerArray(long timestamp, long serverTime, long[] value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedRaw.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedRaw.java
index a54e54b4c16..74984d93244 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedRaw.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedRaw.java
@@ -24,18 +24,15 @@ public TimestampedRaw(long timestamp, long serverTime, byte[] value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedString.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedString.java
index 860d3527634..1e275580c33 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedString.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedString.java
@@ -24,18 +24,15 @@ public TimestampedString(long timestamp, long serverTime, String value) {
/**
* 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;
}
diff --git a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedStringArray.java b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedStringArray.java
index 29d094683f6..87fb72c1857 100644
--- a/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedStringArray.java
+++ b/ntcore/src/generated/main/java/org/wpilib/networktables/TimestampedStringArray.java
@@ -24,18 +24,15 @@ public TimestampedStringArray(long timestamp, long serverTime, String[] value) {
/**
* 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;
}
diff --git a/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java b/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java
index 33ef2525db5..f0a0746893b 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java
@@ -5,7 +5,6 @@
package org.wpilib.networktables;
/** NetworkTables Connection information. */
-@SuppressWarnings("MemberName")
public final class ConnectionInfo {
/**
* The remote identifier (as set on the remote node by {@link
diff --git a/ntcore/src/main/java/org/wpilib/networktables/LogMessage.java b/ntcore/src/main/java/org/wpilib/networktables/LogMessage.java
index f35599b6990..a7faa20f4cd 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/LogMessage.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/LogMessage.java
@@ -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;
diff --git a/ntcore/src/main/java/org/wpilib/networktables/NetworkTableEvent.java b/ntcore/src/main/java/org/wpilib/networktables/NetworkTableEvent.java
index 401ac50535b..49c1c9a1e36 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/NetworkTableEvent.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/NetworkTableEvent.java
@@ -10,7 +10,6 @@
*
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 {
diff --git a/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java b/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java
index 2bf16c7d757..b50cae5cb8e 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/PubSubOptions.java
@@ -5,7 +5,6 @@
package org.wpilib.networktables;
/** NetworkTables publish/subscribe options. */
-@SuppressWarnings("MemberName")
public class PubSubOptions {
/**
* Construct from a list of options.
diff --git a/ntcore/src/main/java/org/wpilib/networktables/TimeSyncEventData.java b/ntcore/src/main/java/org/wpilib/networktables/TimeSyncEventData.java
index bc3d96f8edd..b1dbc2dfdc7 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/TimeSyncEventData.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/TimeSyncEventData.java
@@ -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
diff --git a/ntcore/src/main/java/org/wpilib/networktables/TimestampedObject.java b/ntcore/src/main/java/org/wpilib/networktables/TimestampedObject.java
index 7ecc94d09e4..a2726c41526 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/TimestampedObject.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/TimestampedObject.java
@@ -24,14 +24,11 @@ public TimestampedObject(long timestamp, long serverTime, T value) {
}
/** 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;
}
diff --git a/ntcore/src/main/java/org/wpilib/networktables/TopicInfo.java b/ntcore/src/main/java/org/wpilib/networktables/TopicInfo.java
index 754ec4d67f7..71eedbb0465 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/TopicInfo.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/TopicInfo.java
@@ -5,7 +5,6 @@
package org.wpilib.networktables;
/** NetworkTables topic information. */
-@SuppressWarnings("MemberName")
public final class TopicInfo {
/** Topic handle. */
public final int topic;
diff --git a/ntcore/src/main/java/org/wpilib/networktables/ValueEventData.java b/ntcore/src/main/java/org/wpilib/networktables/ValueEventData.java
index ba381f58e1d..c59f83a0d95 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/ValueEventData.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/ValueEventData.java
@@ -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;
diff --git a/styleguide/checkstyle.xml b/styleguide/checkstyle.xml
index 9ebe62c3c27..e641c16291e 100644
--- a/styleguide/checkstyle.xml
+++ b/styleguide/checkstyle.xml
@@ -173,6 +173,7 @@ module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
value="^(m_([a-zA-Z]|[a-z][a-zA-Z0-9]+)|value)$" />
+
Uses normalized voltage [-1.0..1.0].
*/
- @SuppressWarnings("MemberName")
public static class WheelVelocities {
/** Left wheel velocity. */
public double left;
diff --git a/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java b/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java
index 8badcfb6769..05e9469109c 100644
--- a/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java
+++ b/wpilibj/src/main/java/org/wpilib/drive/MecanumDrive.java
@@ -70,7 +70,6 @@ public class MecanumDrive extends RobotDriveBase implements Sendable, AutoClosea
*
* Uses normalized voltage [-1.0..1.0].
*/
- @SuppressWarnings("MemberName")
public static class WheelVelocities {
/** Front-left wheel velocity. */
public double frontLeft;
diff --git a/wpilibjExamples/src/main/java/org/wpilib/examples/rapidreactcommandbot/subsystems/Storage.java b/wpilibjExamples/src/main/java/org/wpilib/examples/rapidreactcommandbot/subsystems/Storage.java
index 17e197f28ee..94fec8a24ff 100644
--- a/wpilibjExamples/src/main/java/org/wpilib/examples/rapidreactcommandbot/subsystems/Storage.java
+++ b/wpilibjExamples/src/main/java/org/wpilib/examples/rapidreactcommandbot/subsystems/Storage.java
@@ -23,7 +23,6 @@ public class Storage extends SubsystemBase {
// inter-subsystem communications
/** Whether the ball storage is full. */
@Logged(name = "Has Cargo")
- @SuppressWarnings("checkstyle:MemberName")
public final Trigger hasCargo = new Trigger(m_ballSensor::get);
/** Create a new Storage subsystem. */
diff --git a/wpiutil/src/main/java/org/wpilib/util/Color.java b/wpiutil/src/main/java/org/wpilib/util/Color.java
index 90a79afb6f5..eb17e25e9b9 100644
--- a/wpiutil/src/main/java/org/wpilib/util/Color.java
+++ b/wpiutil/src/main/java/org/wpilib/util/Color.java
@@ -11,7 +11,6 @@
*
*
Limited to 12 bits of precision.
*/
-@SuppressWarnings("MemberName")
public class Color {
/** Red component (0-1). */
public final double red;
diff --git a/wpiutil/src/main/java/org/wpilib/util/Color8Bit.java b/wpiutil/src/main/java/org/wpilib/util/Color8Bit.java
index d33ca81f34b..8aed51822c7 100644
--- a/wpiutil/src/main/java/org/wpilib/util/Color8Bit.java
+++ b/wpiutil/src/main/java/org/wpilib/util/Color8Bit.java
@@ -7,7 +7,6 @@
import java.util.Objects;
/** Represents colors with 8 bits of precision. */
-@SuppressWarnings("MemberName")
public class Color8Bit {
/** Red component (0-255). */
public final int red;
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldType.java b/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldType.java
index d550dd8dca9..4140055a974 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldType.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldType.java
@@ -34,19 +34,15 @@ public enum StructFieldType {
STRUCT("struct", false, false, 0);
/** The name of the data type. */
- @SuppressWarnings("MemberName")
public final String name;
/** Indicates if the data type is a signed integer. */
- @SuppressWarnings("MemberName")
public final boolean isInt;
/** Indicates if the data type is an unsigned integer. */
- @SuppressWarnings("MemberName")
public final boolean isUint;
/** The size (in bytes) of the data type. */
- @SuppressWarnings("MemberName")
public final int size;
StructFieldType(String name, boolean isInt, boolean isUint, int size) {
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedDeclaration.java b/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedDeclaration.java
index 5b7a5e09bc1..e2aeaccbcbf 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedDeclaration.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedDeclaration.java
@@ -9,23 +9,18 @@
/** Raw struct schema declaration. */
public class ParsedDeclaration {
/** Type string. */
- @SuppressWarnings("MemberName")
public String typeString;
/** Name. */
- @SuppressWarnings("MemberName")
public String name;
/** Enum values. */
- @SuppressWarnings("MemberName")
public Map enumValues;
/** Array size. */
- @SuppressWarnings("MemberName")
public int arraySize = 1;
/** Bit width. */
- @SuppressWarnings("MemberName")
public int bitWidth;
/** Default constructor. */
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedSchema.java b/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedSchema.java
index 767765a88d0..72c816108e8 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedSchema.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/parser/ParsedSchema.java
@@ -10,7 +10,6 @@
/** Raw struct schema. */
public class ParsedSchema {
/** Declarations. */
- @SuppressWarnings("MemberName")
public List declarations = new ArrayList<>();
/** Default constructor. */
From a0c7a70806a1627e141958e28923f06062be39bc Mon Sep 17 00:00:00 2001
From: Gold856 <117957790+Gold856@users.noreply.github.com>
Date: Wed, 4 Sep 2024 10:29:22 -0400
Subject: [PATCH 2/4] Remove m_ prefix from public variables
---
.../vision/apriltag/AprilTagFieldLayout.java | 4 +-
.../vision/apriltag/AprilTagFields.java | 4 +-
.../wpilib/command2/sysid/SysIdRoutine.java | 68 +++++++++----------
.../java/org/wpilib/fields/FieldConfig.java | 21 +++---
.../main/java/org/wpilib/fields/Fields.java | 1 -
.../org/wpilib/hardware/hal/SimDevice.java | 19 +++---
.../DifferentialDriveFeedforward.java | 16 ++---
.../DifferentialDriveFeedforwardProto.java | 8 +--
.../DifferentialDriveFeedforwardStruct.java | 8 +--
.../DifferentialDriveFeedforwardProto.cpp | 8 +--
.../DifferentialDriveFeedforwardStruct.cpp | 8 +--
.../DifferentialDriveFeedforward.hpp | 16 ++---
.../semiwrap/DifferentialDriveFeedforward.yml | 8 +--
...DifferentialDriveFeedforwardProtoTest.java | 8 +--
...ifferentialDriveFeedforwardStructTest.java | 8 +--
.../DifferentialDriveFeedforwardProtoTest.cpp | 8 +--
...DifferentialDriveFeedforwardStructTest.cpp | 8 +--
17 files changed, 109 insertions(+), 112 deletions(-)
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
index 6ad63ea8862..2c125f36475 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
@@ -218,10 +218,10 @@ public void serialize(Path path) throws IOException {
public static AprilTagFieldLayout loadField(AprilTagFields field) {
if (field.m_fieldLayout == null) {
try {
- field.m_fieldLayout = loadFromResource(field.m_resourceFile);
+ field.m_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
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java
index f0c75bc2b21..d2169d309bc 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java
@@ -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;
AprilTagFields(String resourceFile) {
- m_resourceFile = kBaseResourceDir + resourceFile;
+ this.resourceFile = kBaseResourceDir + resourceFile;
}
}
diff --git a/commandsv2/src/main/java/org/wpilib/command2/sysid/SysIdRoutine.java b/commandsv2/src/main/java/org/wpilib/command2/sysid/SysIdRoutine.java
index 56fdd5c90d5..30d67e0021c 100644
--- a/commandsv2/src/main/java/org/wpilib/command2/sysid/SysIdRoutine.java
+++ b/commandsv2/src/main/java/org/wpilib/command2/sysid/SysIdRoutine.java
@@ -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 m_rampRate;
+ public final Velocity 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 m_recordState;
+ public final Consumer recordState;
/**
* Create a new configuration for a SysId test routine.
@@ -88,10 +88,10 @@ public Config(
Voltage stepVoltage,
Time timeout,
Consumer 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 Config() {
*/
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 m_log;
+ public final Consumer 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 static class Mechanism {
*/
public Mechanism(
Consumer drive, Consumer 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 Command quasistatic(Direction direction) {
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 Command dynamic(Direction direction) {
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));
}
}
diff --git a/fields/src/main/java/org/wpilib/fields/FieldConfig.java b/fields/src/main/java/org/wpilib/fields/FieldConfig.java
index bdbfd6668c6..9891602fac6 100644
--- a/fields/src/main/java/org/wpilib/fields/FieldConfig.java
+++ b/fields/src/main/java/org/wpilib/fields/FieldConfig.java
@@ -17,39 +17,38 @@
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);
}
/**
diff --git a/fields/src/main/java/org/wpilib/fields/Fields.java b/fields/src/main/java/org/wpilib/fields/Fields.java
index b0f7c506421..9a469922838 100644
--- a/fields/src/main/java/org/wpilib/fields/Fields.java
+++ b/fields/src/main/java/org/wpilib/fields/Fields.java
@@ -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) {
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/SimDevice.java b/hal/src/main/java/org/wpilib/hardware/hal/SimDevice.java
index 373613fd318..91a9c49cf78 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/SimDevice.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/SimDevice.java
@@ -26,10 +26,10 @@ public enum Direction {
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 String getName() {
* @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 SimValue createValue(String name, Direction direction, HALValue initialVa
* @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 SimInt createInt(String name, Direction direction, int initialValue) {
* @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 SimLong createLong(String name, Direction direction, long initialValue) {
* @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 SimDouble createDouble(String name, Direction direction, double initialVa
*/
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 SimEnum createEnumDouble(
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 SimEnum createEnumDouble(
* @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;
}
diff --git a/wpimath/src/main/java/org/wpilib/math/controller/DifferentialDriveFeedforward.java b/wpimath/src/main/java/org/wpilib/math/controller/DifferentialDriveFeedforward.java
index d15c54388a0..71273e97cd2 100644
--- a/wpimath/src/main/java/org/wpilib/math/controller/DifferentialDriveFeedforward.java
+++ b/wpimath/src/main/java/org/wpilib/math/controller/DifferentialDriveFeedforward.java
@@ -18,16 +18,16 @@ public class DifferentialDriveFeedforward implements ProtobufSerializable, Struc
private final LinearSystem m_plant;
/** The linear velocity gain in volts per (meters per second). */
- public final double m_kVLinear;
+ public final double kVLinear;
/** The linear acceleration gain in volts per (meters per second squared). */
- public final double m_kALinear;
+ public final double kALinear;
/** The angular velocity gain in volts per (radians per second). */
- public final double m_kVAngular;
+ public final double kVAngular;
/** The angular acceleration gain in volts per (radians per second squared). */
- public final double m_kAAngular;
+ public final double kAAngular;
/**
* Creates a new DifferentialDriveFeedforward with the specified parameters.
@@ -56,10 +56,10 @@ public DifferentialDriveFeedforward(
public DifferentialDriveFeedforward(
double kVLinear, double kALinear, double kVAngular, double kAAngular) {
m_plant = Models.differentialDriveFromSysId(kVLinear, kALinear, kVAngular, kAAngular);
- m_kVLinear = kVLinear;
- m_kALinear = kALinear;
- m_kVAngular = kVAngular;
- m_kAAngular = kAAngular;
+ this.kVLinear = kVLinear;
+ this.kALinear = kALinear;
+ this.kVAngular = kVAngular;
+ this.kAAngular = kAAngular;
}
/**
diff --git a/wpimath/src/main/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProto.java b/wpimath/src/main/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProto.java
index f1a2cfa8e09..8cd51ebd6be 100644
--- a/wpimath/src/main/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProto.java
+++ b/wpimath/src/main/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProto.java
@@ -34,9 +34,9 @@ public DifferentialDriveFeedforward unpack(ProtobufDifferentialDriveFeedforward
@Override
public void pack(ProtobufDifferentialDriveFeedforward msg, DifferentialDriveFeedforward value) {
- msg.setKvLinear(value.m_kVLinear);
- msg.setKaLinear(value.m_kALinear);
- msg.setKvAngular(value.m_kVAngular);
- msg.setKaAngular(value.m_kAAngular);
+ msg.setKvLinear(value.kVLinear);
+ msg.setKaLinear(value.kALinear);
+ msg.setKvAngular(value.kVAngular);
+ msg.setKaAngular(value.kAAngular);
}
}
diff --git a/wpimath/src/main/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStruct.java b/wpimath/src/main/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStruct.java
index 66fc9a5e2a4..48dc9132f4d 100644
--- a/wpimath/src/main/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStruct.java
+++ b/wpimath/src/main/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStruct.java
@@ -41,9 +41,9 @@ public DifferentialDriveFeedforward unpack(ByteBuffer bb) {
@Override
public void pack(ByteBuffer bb, DifferentialDriveFeedforward value) {
- bb.putDouble(value.m_kVLinear);
- bb.putDouble(value.m_kALinear);
- bb.putDouble(value.m_kVAngular);
- bb.putDouble(value.m_kAAngular);
+ bb.putDouble(value.kVLinear);
+ bb.putDouble(value.kALinear);
+ bb.putDouble(value.kVAngular);
+ bb.putDouble(value.kAAngular);
}
}
diff --git a/wpimath/src/main/native/cpp/controller/proto/DifferentialDriveFeedforwardProto.cpp b/wpimath/src/main/native/cpp/controller/proto/DifferentialDriveFeedforwardProto.cpp
index 742a27d1d17..703a8960a74 100644
--- a/wpimath/src/main/native/cpp/controller/proto/DifferentialDriveFeedforwardProto.cpp
+++ b/wpimath/src/main/native/cpp/controller/proto/DifferentialDriveFeedforwardProto.cpp
@@ -25,10 +25,10 @@ bool wpi::util::Protobuf::Pack(
OutputStream& stream,
const wpi::math::DifferentialDriveFeedforward& value) {
wpi_proto_ProtobufDifferentialDriveFeedforward msg{
- .kv_linear = value.m_kVLinear.value(),
- .ka_linear = value.m_kALinear.value(),
- .kv_angular = value.m_kVAngular.value(),
- .ka_angular = value.m_kAAngular.value(),
+ .kv_linear = value.kVLinear.value(),
+ .ka_linear = value.kALinear.value(),
+ .kv_angular = value.kVAngular.value(),
+ .ka_angular = value.kAAngular.value(),
};
return stream.Encode(msg);
}
diff --git a/wpimath/src/main/native/cpp/controller/struct/DifferentialDriveFeedforwardStruct.cpp b/wpimath/src/main/native/cpp/controller/struct/DifferentialDriveFeedforwardStruct.cpp
index de924ac96ad..3275befefd4 100644
--- a/wpimath/src/main/native/cpp/controller/struct/DifferentialDriveFeedforwardStruct.cpp
+++ b/wpimath/src/main/native/cpp/controller/struct/DifferentialDriveFeedforwardStruct.cpp
@@ -27,8 +27,8 @@ wpi::util::Struct::Unpack(
void wpi::util::Struct::Pack(
std::span data,
const wpi::math::DifferentialDriveFeedforward& value) {
- wpi::util::PackStruct(data, value.m_kVLinear.value());
- wpi::util::PackStruct(data, value.m_kALinear.value());
- wpi::util::PackStruct(data, value.m_kVAngular.value());
- wpi::util::PackStruct(data, value.m_kAAngular.value());
+ wpi::util::PackStruct(data, value.kVLinear.value());
+ wpi::util::PackStruct(data, value.kALinear.value());
+ wpi::util::PackStruct(data, value.kVAngular.value());
+ wpi::util::PackStruct(data, value.kAAngular.value());
}
diff --git a/wpimath/src/main/native/include/wpi/math/controller/DifferentialDriveFeedforward.hpp b/wpimath/src/main/native/include/wpi/math/controller/DifferentialDriveFeedforward.hpp
index 0b320ad9fcf..90b1bfb4a5f 100644
--- a/wpimath/src/main/native/include/wpi/math/controller/DifferentialDriveFeedforward.hpp
+++ b/wpimath/src/main/native/include/wpi/math/controller/DifferentialDriveFeedforward.hpp
@@ -66,10 +66,10 @@ class WPILIB_DLLEXPORT DifferentialDriveFeedforward {
decltype(1_V / 1_mps_sq) kAAngular)
: m_plant{wpi::math::Models::DifferentialDriveFromSysId(
kVLinear, kALinear, kVAngular, kAAngular)},
- m_kVLinear{kVLinear},
- m_kALinear{kALinear},
- m_kVAngular{kVAngular},
- m_kAAngular{kAAngular} {}
+ kVLinear{kVLinear},
+ kALinear{kALinear},
+ kVAngular{kVAngular},
+ kAAngular{kAAngular} {}
/**
* Calculates the differential drive feedforward inputs given velocity
@@ -92,10 +92,10 @@ class WPILIB_DLLEXPORT DifferentialDriveFeedforward {
wpi::units::meters_per_second_t nextRightVelocity,
wpi::units::second_t dt);
- decltype(1_V / 1_mps) m_kVLinear;
- decltype(1_V / 1_mps_sq) m_kALinear;
- decltype(1_V / 1_mps) m_kVAngular;
- decltype(1_V / 1_mps_sq) m_kAAngular;
+ decltype(1_V / 1_mps) kVLinear;
+ decltype(1_V / 1_mps_sq) kALinear;
+ decltype(1_V / 1_mps) kVAngular;
+ decltype(1_V / 1_mps_sq) kAAngular;
};
} // namespace wpi::math
diff --git a/wpimath/src/main/python/semiwrap/DifferentialDriveFeedforward.yml b/wpimath/src/main/python/semiwrap/DifferentialDriveFeedforward.yml
index 6abe7270d80..c4b2169ccd3 100644
--- a/wpimath/src/main/python/semiwrap/DifferentialDriveFeedforward.yml
+++ b/wpimath/src/main/python/semiwrap/DifferentialDriveFeedforward.yml
@@ -7,10 +7,10 @@ classes:
- wpi::units::radians_per_second_squared
- wpi::units::compound_unit
attributes:
- m_kVLinear:
- m_kALinear:
- m_kVAngular:
- m_kAAngular:
+ kVLinear:
+ kALinear:
+ kVAngular:
+ kAAngular:
methods:
DifferentialDriveFeedforward:
overloads:
diff --git a/wpimath/src/test/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProtoTest.java b/wpimath/src/test/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProtoTest.java
index a1da6199cb9..982905c5260 100644
--- a/wpimath/src/test/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProtoTest.java
+++ b/wpimath/src/test/java/org/wpilib/math/controller/proto/DifferentialDriveFeedforwardProtoTest.java
@@ -22,9 +22,9 @@ class DifferentialDriveFeedforwardProtoTest
@Override
public void checkEquals(
DifferentialDriveFeedforward testData, DifferentialDriveFeedforward data) {
- assertEquals(testData.m_kVLinear, data.m_kVLinear);
- assertEquals(testData.m_kALinear, data.m_kALinear);
- assertEquals(testData.m_kVAngular, data.m_kVAngular);
- assertEquals(testData.m_kAAngular, data.m_kAAngular);
+ assertEquals(testData.kVLinear, data.kVLinear);
+ assertEquals(testData.kALinear, data.kALinear);
+ assertEquals(testData.kVAngular, data.kVAngular);
+ assertEquals(testData.kAAngular, data.kAAngular);
}
}
diff --git a/wpimath/src/test/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStructTest.java b/wpimath/src/test/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStructTest.java
index 1d95b5405bb..04bc82e19e6 100644
--- a/wpimath/src/test/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStructTest.java
+++ b/wpimath/src/test/java/org/wpilib/math/controller/struct/DifferentialDriveFeedforwardStructTest.java
@@ -20,9 +20,9 @@ class DifferentialDriveFeedforwardStructTest extends StructTestBase
Date: Wed, 4 Jun 2025 08:31:11 -0400
Subject: [PATCH 3/4] Add new rules
---
.../org/wpilib/vision/apriltag/AprilTag.java | 2 +-
.../vision/apriltag/AprilTagFieldLayout.java | 12 +-
.../vision/apriltag/AprilTagFields.java | 2 +-
.../vision/apriltag/AprilTagDetectorTest.java | 3 +-
.../wpilib/vision/stream/CameraServer.java | 182 +++---
.../org/wpilib/command2/button/Trigger.java | 2 +-
.../cpp/frc2/command/sysid/SysIdRoutine.cpp | 32 +-
.../wpi/commands2/sysid/SysIdRoutine.hpp | 50 +-
.../command2/button/NetworkButtonTest.java | 12 +-
.../command2/sysid/SysIdRoutineTest.java | 118 ++--
.../java/org/wpilib/command3/Binding.java | 2 +-
.../org/wpilib/command3/CommandState.java | 16 +-
.../wpilib/command3/CommandTraceHelper.java | 2 +-
.../org/wpilib/command3/Continuation.java | 14 +-
.../wpilib/command3/ContinuationScope.java | 8 +-
.../org/wpilib/command3/SchedulerTest.java | 2 +-
.../org/wpilib/vision/camera/ImageSource.java | 2 +-
.../wpilib/vision/camera/VideoProperty.java | 26 +-
.../org/wpilib/datalog/DoubleLogEntry.java | 4 +-
.../org/wpilib/datalog/FloatLogEntry.java | 4 +-
.../org/wpilib/datalog/IntegerLogEntry.java | 4 +-
.../java/org/wpilib/datalog/DataLogTest.java | 47 +-
.../epilogue/processor/EpilogueGenerator.java | 4 +-
.../org/wpilib/hardware/hal/OpModeOption.java | 6 -
.../hardware/hal/PowerDistributionFaults.java | 2 +-
.../hal/PowerDistributionStickyFaults.java | 2 +-
.../org/wpilib/hardware/hal/REVPHFaults.java | 2 +-
.../hardware/hal/REVPHStickyFaults.java | 2 +-
.../hardware/hal/can/CANReceiveMessage.java | 4 -
.../hardware/hal/simulation/AlertDataJNI.java | 5 -
.../CoroutineYieldInLoopDetector.java | 44 +-
.../wpilib/networktables/ConnectionInfo.java | 20 +-
shared/java/javastyle.gradle | 3 +
styleguide/checkstyle.xml | 7 -
styleguide/pmd-ruleset.xml | 37 +-
.../src/test/native/cpp/TimedRobotTest.cpp | 582 +++++++++---------
.../internal/DriverStationBackend.java | 272 ++++----
.../java/org/wpilib/framework/RobotBase.java | 2 +-
.../java/org/wpilib/framework/TimedRobot.java | 1 -
.../hardware/accelerometer/ADXL345_I2C.java | 1 -
.../wpilib/hardware/discrete/AnalogInput.java | 2 +-
.../hardware/expansionhub/ExpansionHub.java | 52 +-
.../wpilib/hardware/led/AddressableLED.java | 8 +-
.../hardware/led/AddressableLEDBuffer.java | 18 +-
.../hardware/pneumatic/PneumaticHub.java | 76 +--
.../pneumatic/PneumaticsControlModule.java | 68 +-
.../org/wpilib/hardware/range/SharpIR.java | 4 +
.../wpilib/hardware/rotation/DutyCycle.java | 3 +-
.../org/wpilib/hardware/rotation/Encoder.java | 2 +-
.../internal/PeriodicPriorityQueue.java | 50 +-
.../java/org/wpilib/simulation/AlertSim.java | 5 -
.../simulation/DifferentialDrivetrainSim.java | 2 +-
.../org/wpilib/smartdashboard/Field2d.java | 6 +-
.../wpilib/smartdashboard/FieldObject2d.java | 20 +-
.../smartdashboard/ListenerExecutor.java | 2 +-
.../smartdashboard/SendableBuilderImpl.java | 1 +
.../main/java/org/wpilib/system/Watchdog.java | 4 +-
.../wpilib/event/NetworkBooleanEventTest.java | 12 +-
.../org/wpilib/framework/OpModeRobotTest.java | 41 +-
.../org/wpilib/framework/TimedRobotTest.java | 582 +++++++++---------
.../wpilib/framework/TimesliceRobotTest.java | 12 +-
.../led/AddressableLEDBufferTest.java | 6 +-
.../wpilib/hardware/led/LEDPatternTest.java | 52 +-
.../wpilib/math/estimator/PoseEstimator.java | 2 +-
.../math/estimator/PoseEstimator3d.java | 2 +-
.../wpilib/math/geometry/CoordinateAxis.java | 4 +-
.../math/geometry/CoordinateSystem.java | 6 +-
.../LTVDifferentialDriveControllerTest.java | 10 +-
.../math/controller/LinearSystemLoopTest.java | 10 +-
.../java/org/wpilib/math/linalg/DARETest.java | 3 +-
.../trajectory/ExponentialProfileTest.java | 6 +-
.../java/org/wpilib/units/ExampleUnit.java | 2 +-
.../util/sendable/SendableRegistry.java | 1 +
.../org/wpilib/util/struct/DynamicStruct.java | 88 +--
.../wpilib/util/struct/StructDescriptor.java | 52 +-
.../util/struct/StructDescriptorDatabase.java | 12 +-
.../util/struct/StructFieldDescriptor.java | 22 +-
.../org/wpilib/util/struct/parser/Lexer.java | 26 +-
.../org/wpilib/util/struct/parser/Parser.java | 12 +-
.../org/wpilib/util/ConstructorMatchTest.java | 6 +-
.../wpilib/util/cleanup/CleanupPoolTest.java | 16 +-
.../util/cleanup/ReflectionCleanupTest.java | 28 +-
.../wpilib/util/struct/DynamicStructTest.java | 5 +-
.../util/struct/StructGeneratorTest.java | 18 +-
84 files changed, 1455 insertions(+), 1446 deletions(-)
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java
index 3e6c0d48779..394014381b8 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTag.java
@@ -15,7 +15,7 @@
public class AprilTag {
/** The tag's ID. */
@Json.Property("ID")
- @SuppressWarnings("MemberName")
+ @SuppressWarnings("PMD.PublicFieldNamingConvention")
public int ID;
/** The tag's pose. */
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
index 2c125f36475..cc4734674a6 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFieldLayout.java
@@ -51,6 +51,7 @@ public enum OriginPosition {
@Json.Ignore private final Map m_apriltags = new HashMap<>();
@Json.Property("field")
+ @SuppressWarnings("PMD.PublicFieldNamingConvention")
FieldDimensions m_fieldDimensions;
@Json.Ignore private Pose3d m_origin;
@@ -216,9 +217,9 @@ public void serialize(Path path) throws IOException {
* @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.resourceFile);
+ field.fieldLayout = loadFromResource(field.resourceFile);
} catch (IOException e) {
throw new UncheckedIOException(
"Could not load AprilTagFieldLayout from " + field.resourceFile, e);
@@ -226,9 +227,9 @@ public static AprilTagFieldLayout loadField(AprilTagFields field) {
}
// 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());
}
/**
@@ -263,6 +264,7 @@ public int hashCode() {
return Objects.hash(m_apriltags, m_origin);
}
+ @SuppressWarnings("PMD.PublicMemberInNonPublicType")
static class FieldDimensions {
@Json.Property(value = "length")
public final double fieldLength;
diff --git a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java
index d2169d309bc..fe3ce21a47f 100644
--- a/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java
+++ b/apriltag/src/main/java/org/wpilib/vision/apriltag/AprilTagFields.java
@@ -30,7 +30,7 @@ public enum AprilTagFields {
/** Resource filename. */
public final String resourceFile;
- AprilTagFieldLayout m_fieldLayout;
+ AprilTagFieldLayout fieldLayout;
AprilTagFields(String resourceFile) {
this.resourceFile = kBaseResourceDir + resourceFile;
diff --git a/apriltag/src/test/java/org/wpilib/vision/apriltag/AprilTagDetectorTest.java b/apriltag/src/test/java/org/wpilib/vision/apriltag/AprilTagDetectorTest.java
index 1678997f1e7..a026edbc01e 100644
--- a/apriltag/src/test/java/org/wpilib/vision/apriltag/AprilTagDetectorTest.java
+++ b/apriltag/src/test/java/org/wpilib/vision/apriltag/AprilTagDetectorTest.java
@@ -25,7 +25,6 @@
import org.wpilib.util.runtime.RuntimeLoader;
class AprilTagDetectorTest {
- @SuppressWarnings("MemberName")
AprilTagDetector detector;
@BeforeAll
@@ -110,7 +109,7 @@ void testRemoveFamily() {
detector.removeFamily("tag16h5");
}
- public Mat loadImage(String resource) throws IOException {
+ Mat loadImage(String resource) throws IOException {
Mat encoded;
try (InputStream is = getClass().getResource(resource).openStream()) {
try (ByteArrayOutputStream os = new ByteArrayOutputStream(is.available())) {
diff --git a/cameraserver/src/main/java/org/wpilib/vision/stream/CameraServer.java b/cameraserver/src/main/java/org/wpilib/vision/stream/CameraServer.java
index 73a3dc21012..8a1e93cc855 100644
--- a/cameraserver/src/main/java/org/wpilib/vision/stream/CameraServer.java
+++ b/cameraserver/src/main/java/org/wpilib/vision/stream/CameraServer.java
@@ -60,28 +60,28 @@ private static final class PropertyPublisher implements AutoCloseable {
try {
switch (event.propertyKind) {
case kBoolean:
- m_booleanValueEntry = table.getBooleanTopic(name).getEntry(false);
- m_booleanValueEntry.setDefault(event.value != 0);
+ booleanValueEntry = table.getBooleanTopic(name).getEntry(false);
+ booleanValueEntry.setDefault(event.value != 0);
break;
case kEnum:
- m_choicesTopic = table.getStringArrayTopic(infoName + "/choices");
+ choicesTopic = table.getStringArrayTopic(infoName + "/choices");
// fallthrough
case kInteger:
- m_integerValueEntry = table.getIntegerTopic(name).getEntry(0);
- m_minPublisher = table.getIntegerTopic(infoName + "/min").publish();
- m_maxPublisher = table.getIntegerTopic(infoName + "/max").publish();
- m_stepPublisher = table.getIntegerTopic(infoName + "/step").publish();
- m_defaultPublisher = table.getIntegerTopic(infoName + "/default").publish();
-
- m_integerValueEntry.setDefault(event.value);
- m_minPublisher.set(CameraServerJNI.getPropertyMin(event.propertyHandle));
- m_maxPublisher.set(CameraServerJNI.getPropertyMax(event.propertyHandle));
- m_stepPublisher.set(CameraServerJNI.getPropertyStep(event.propertyHandle));
- m_defaultPublisher.set(CameraServerJNI.getPropertyDefault(event.propertyHandle));
+ integerValueEntry = table.getIntegerTopic(name).getEntry(0);
+ minPublisher = table.getIntegerTopic(infoName + "/min").publish();
+ maxPublisher = table.getIntegerTopic(infoName + "/max").publish();
+ stepPublisher = table.getIntegerTopic(infoName + "/step").publish();
+ defaultPublisher = table.getIntegerTopic(infoName + "/default").publish();
+
+ integerValueEntry.setDefault(event.value);
+ minPublisher.set(CameraServerJNI.getPropertyMin(event.propertyHandle));
+ maxPublisher.set(CameraServerJNI.getPropertyMax(event.propertyHandle));
+ stepPublisher.set(CameraServerJNI.getPropertyStep(event.propertyHandle));
+ defaultPublisher.set(CameraServerJNI.getPropertyDefault(event.propertyHandle));
break;
case kString:
- m_stringValueEntry = table.getStringTopic(name).getEntry("");
- m_stringValueEntry.setDefault(event.valueStr);
+ stringValueEntry = table.getStringTopic(name).getEntry("");
+ stringValueEntry.setDefault(event.valueStr);
break;
default:
break;
@@ -94,18 +94,18 @@ private static final class PropertyPublisher implements AutoCloseable {
void update(VideoEvent event) {
switch (event.propertyKind) {
case kBoolean -> {
- if (m_booleanValueEntry != null) {
- m_booleanValueEntry.set(event.value != 0);
+ if (booleanValueEntry != null) {
+ booleanValueEntry.set(event.value != 0);
}
}
case kInteger, kEnum -> {
- if (m_integerValueEntry != null) {
- m_integerValueEntry.set(event.value);
+ if (integerValueEntry != null) {
+ integerValueEntry.set(event.value);
}
}
case kString -> {
- if (m_stringValueEntry != null) {
- m_stringValueEntry.set(event.valueStr);
+ if (stringValueEntry != null) {
+ stringValueEntry.set(event.valueStr);
}
}
default -> {
@@ -117,65 +117,65 @@ void update(VideoEvent event) {
@Override
public void close() {
try {
- if (m_booleanValueEntry != null) {
- m_booleanValueEntry.close();
+ if (booleanValueEntry != null) {
+ booleanValueEntry.close();
}
- if (m_integerValueEntry != null) {
- m_integerValueEntry.close();
+ if (integerValueEntry != null) {
+ integerValueEntry.close();
}
- if (m_stringValueEntry != null) {
- m_stringValueEntry.close();
+ if (stringValueEntry != null) {
+ stringValueEntry.close();
}
- if (m_minPublisher != null) {
- m_minPublisher.close();
+ if (minPublisher != null) {
+ minPublisher.close();
}
- if (m_maxPublisher != null) {
- m_maxPublisher.close();
+ if (maxPublisher != null) {
+ maxPublisher.close();
}
- if (m_stepPublisher != null) {
- m_stepPublisher.close();
+ if (stepPublisher != null) {
+ stepPublisher.close();
}
- if (m_defaultPublisher != null) {
- m_defaultPublisher.close();
+ if (defaultPublisher != null) {
+ defaultPublisher.close();
}
- if (m_choicesPublisher != null) {
- m_choicesPublisher.close();
+ if (choicesPublisher != null) {
+ choicesPublisher.close();
}
} finally {
Reference.reachabilityFence(m_videoListener);
}
}
- BooleanEntry m_booleanValueEntry;
- IntegerEntry m_integerValueEntry;
- StringEntry m_stringValueEntry;
- IntegerPublisher m_minPublisher;
- IntegerPublisher m_maxPublisher;
- IntegerPublisher m_stepPublisher;
- IntegerPublisher m_defaultPublisher;
- StringArrayTopic m_choicesTopic;
- StringArrayPublisher m_choicesPublisher;
+ BooleanEntry booleanValueEntry;
+ IntegerEntry integerValueEntry;
+ StringEntry stringValueEntry;
+ IntegerPublisher minPublisher;
+ IntegerPublisher maxPublisher;
+ IntegerPublisher stepPublisher;
+ IntegerPublisher defaultPublisher;
+ StringArrayTopic choicesTopic;
+ StringArrayPublisher choicesPublisher;
}
private static final class SourcePublisher implements AutoCloseable {
SourcePublisher(NetworkTable table, int sourceHandle) {
- this.m_table = table;
- m_sourcePublisher = table.getStringTopic("source").publish();
- m_descriptionPublisher = table.getStringTopic("description").publish();
- m_connectedPublisher = table.getBooleanTopic("connected").publish();
- m_streamsPublisher = table.getStringArrayTopic("streams").publish();
- m_modeEntry = table.getStringTopic("mode").getEntry("");
- m_modesPublisher = table.getStringArrayTopic("modes").publish();
-
- m_sourcePublisher.set(makeSourceValue(sourceHandle));
- m_descriptionPublisher.set(CameraServerJNI.getSourceDescription(sourceHandle));
- m_connectedPublisher.set(CameraServerJNI.isSourceConnected(sourceHandle));
- m_streamsPublisher.set(getSourceStreamValues(sourceHandle));
+ this.table = table;
+ sourceUriPublisher = table.getStringTopic("source").publish();
+ descriptionPublisher = table.getStringTopic("description").publish();
+ connectedPublisher = table.getBooleanTopic("connected").publish();
+ streamsPublisher = table.getStringArrayTopic("streams").publish();
+ modeEntry = table.getStringTopic("mode").getEntry("");
+ modesPublisher = table.getStringArrayTopic("modes").publish();
+
+ sourceUriPublisher.set(makeSourceValue(sourceHandle));
+ descriptionPublisher.set(CameraServerJNI.getSourceDescription(sourceHandle));
+ connectedPublisher.set(CameraServerJNI.isSourceConnected(sourceHandle));
+ streamsPublisher.set(getSourceStreamValues(sourceHandle));
try {
VideoMode mode = CameraServerJNI.getSourceVideoMode(sourceHandle);
- m_modeEntry.setDefault(videoModeToString(mode));
- m_modesPublisher.set(getSourceModeValues(sourceHandle));
+ modeEntry.setDefault(videoModeToString(mode));
+ modesPublisher.set(getSourceModeValues(sourceHandle));
} catch (VideoException ignored) {
// Do nothing. Let the other event handlers update this if there is an error.
}
@@ -183,25 +183,25 @@ private static final class SourcePublisher implements AutoCloseable {
@Override
public void close() throws Exception {
- m_sourcePublisher.close();
- m_descriptionPublisher.close();
- m_connectedPublisher.close();
- m_streamsPublisher.close();
- m_modeEntry.close();
- m_modesPublisher.close();
- for (PropertyPublisher pp : m_properties.values()) {
+ sourceUriPublisher.close();
+ descriptionPublisher.close();
+ connectedPublisher.close();
+ streamsPublisher.close();
+ modeEntry.close();
+ modesPublisher.close();
+ for (PropertyPublisher pp : properties.values()) {
pp.close();
}
}
- final NetworkTable m_table;
- final StringPublisher m_sourcePublisher;
- final StringPublisher m_descriptionPublisher;
- final BooleanPublisher m_connectedPublisher;
- final StringArrayPublisher m_streamsPublisher;
- final StringEntry m_modeEntry;
- final StringArrayPublisher m_modesPublisher;
- final Map m_properties = new HashMap<>();
+ final NetworkTable table;
+ final StringPublisher sourceUriPublisher;
+ final StringPublisher descriptionPublisher;
+ final BooleanPublisher connectedPublisher;
+ final StringArrayPublisher streamsPublisher;
+ final StringEntry modeEntry;
+ final StringArrayPublisher modesPublisher;
+ final Map properties = new HashMap<>();
}
private static final AtomicInteger m_defaultUsbDevice = new AtomicInteger();
@@ -253,40 +253,40 @@ public void close() throws Exception {
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
if (publisher != null) {
// update the description too (as it may have changed)
- publisher.m_descriptionPublisher.set(
+ publisher.descriptionPublisher.set(
CameraServerJNI.getSourceDescription(event.sourceHandle));
- publisher.m_connectedPublisher.set(true);
+ publisher.connectedPublisher.set(true);
}
}
case kSourceDisconnected -> {
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
if (publisher != null) {
- publisher.m_connectedPublisher.set(false);
+ publisher.connectedPublisher.set(false);
}
}
case kSourceVideoModesUpdated -> {
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
if (publisher != null) {
- publisher.m_modesPublisher.set(getSourceModeValues(event.sourceHandle));
+ publisher.modesPublisher.set(getSourceModeValues(event.sourceHandle));
}
}
case kSourceVideoModeChanged -> {
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
if (publisher != null) {
- publisher.m_modeEntry.set(videoModeToString(event.mode));
+ publisher.modeEntry.set(videoModeToString(event.mode));
}
}
case kSourcePropertyCreated -> {
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
if (publisher != null) {
- publisher.m_properties.put(
- event.propertyHandle, new PropertyPublisher(publisher.m_table, event));
+ publisher.properties.put(
+ event.propertyHandle, new PropertyPublisher(publisher.table, event));
}
}
case kSourcePropertyValueUpdated -> {
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
if (publisher != null) {
- PropertyPublisher pp = publisher.m_properties.get(event.propertyHandle);
+ PropertyPublisher pp = publisher.properties.get(event.propertyHandle);
if (pp != null) {
pp.update(event);
}
@@ -295,15 +295,15 @@ public void close() throws Exception {
case kSourcePropertyChoicesUpdated -> {
SourcePublisher publisher = m_publishers.get(event.sourceHandle);
if (publisher != null) {
- PropertyPublisher pp = publisher.m_properties.get(event.propertyHandle);
- if (pp != null && pp.m_choicesTopic != null) {
+ PropertyPublisher pp = publisher.properties.get(event.propertyHandle);
+ if (pp != null && pp.choicesTopic != null) {
try {
String[] choices =
CameraServerJNI.getEnumPropertyChoices(event.propertyHandle);
- if (pp.m_choicesPublisher == null) {
- pp.m_choicesPublisher = pp.m_choicesTopic.publish();
+ if (pp.choicesPublisher == null) {
+ pp.choicesPublisher = pp.choicesTopic.publish();
}
- pp.m_choicesPublisher.set(choices);
+ pp.choicesPublisher.set(choices);
} catch (VideoException ignored) {
// ignore (just don't publish choices if we can't get them)
}
@@ -459,7 +459,7 @@ private static synchronized void updateStreamValues() {
// Set table value
String[] values = getSinkStreamValues(sink);
if (values.length > 0) {
- publisher.m_streamsPublisher.set(values);
+ publisher.streamsPublisher.set(values);
}
}
}
@@ -474,7 +474,7 @@ private static synchronized void updateStreamValues() {
// Set table value
String[] values = getSourceStreamValues(source);
if (values.length > 0) {
- publisher.m_streamsPublisher.set(values);
+ publisher.streamsPublisher.set(values);
}
}
}
diff --git a/commandsv2/src/main/java/org/wpilib/command2/button/Trigger.java b/commandsv2/src/main/java/org/wpilib/command2/button/Trigger.java
index cf0980b8b05..0e5ccd1d885 100644
--- a/commandsv2/src/main/java/org/wpilib/command2/button/Trigger.java
+++ b/commandsv2/src/main/java/org/wpilib/command2/button/Trigger.java
@@ -280,7 +280,7 @@ public Trigger debounce(double seconds, Debouncer.DebounceType type) {
return new Trigger(
m_loop,
new BooleanSupplier() {
- final Debouncer m_debouncer = new Debouncer(seconds, type);
+ private final Debouncer m_debouncer = new Debouncer(seconds, type);
@Override
public boolean getAsBoolean() {
diff --git a/commandsv2/src/main/native/cpp/frc2/command/sysid/SysIdRoutine.cpp b/commandsv2/src/main/native/cpp/frc2/command/sysid/SysIdRoutine.cpp
index 089fdb8c929..07ae68f2dc7 100644
--- a/commandsv2/src/main/native/cpp/frc2/command/sysid/SysIdRoutine.cpp
+++ b/commandsv2/src/main/native/cpp/frc2/command/sysid/SysIdRoutine.cpp
@@ -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);
}
diff --git a/commandsv2/src/main/native/include/wpi/commands2/sysid/SysIdRoutine.hpp b/commandsv2/src/main/native/include/wpi/commands2/sysid/SysIdRoutine.hpp
index 9b78ee611f3..bcfff9a3d52 100644
--- a/commandsv2/src/main/native/include/wpi/commands2/sysid/SysIdRoutine.hpp
+++ b/commandsv2/src/main/native/include/wpi/commands2/sysid/SysIdRoutine.hpp
@@ -23,17 +23,17 @@ using ramp_rate_t = wpi::units::unit_t m_recordState;
+ std::function recordState;
/**
* Create a new configuration for a SysId test routine.
@@ -52,15 +52,15 @@ class Config {
std::optional stepVoltage,
std::optional timeout,
std::function 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 m_drive;
+ std::function drive;
/// Returns measured data (voltages, positions, velocities) of the mechanism
/// motors during test routines.
- std::function m_log;
+ std::function 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 drive,
std::function 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 drive,
std::function 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,13 +176,13 @@ 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
- : [this](wpi::sysid::State state) {
- this->RecordState(state);
- }) {}
+ m_recordState(config.recordState ? config.recordState
+ : [this](wpi::sysid::State state) {
+ this->RecordState(state);
+ }) {}
wpi::cmd::CommandPtr Quasistatic(Direction direction);
wpi::cmd::CommandPtr Dynamic(Direction direction);
diff --git a/commandsv2/src/test/java/org/wpilib/command2/button/NetworkButtonTest.java b/commandsv2/src/test/java/org/wpilib/command2/button/NetworkButtonTest.java
index 94ef8a96947..0ad3492f34f 100644
--- a/commandsv2/src/test/java/org/wpilib/command2/button/NetworkButtonTest.java
+++ b/commandsv2/src/test/java/org/wpilib/command2/button/NetworkButtonTest.java
@@ -15,17 +15,17 @@
import org.wpilib.networktables.NetworkTableInstance;
class NetworkButtonTest extends CommandTestBase {
- NetworkTableInstance m_inst;
+ NetworkTableInstance inst;
@BeforeEach
void setup() {
- m_inst = NetworkTableInstance.create();
- m_inst.startLocal();
+ inst = NetworkTableInstance.create();
+ inst.startLocal();
}
@AfterEach
void teardown() {
- m_inst.close();
+ inst.close();
}
@Test
@@ -33,9 +33,9 @@ void setNetworkButtonTest() {
var scheduler = CommandScheduler.getInstance();
var commandHolder = new MockCommandHolder(true);
var command = commandHolder.getMock();
- var pub = m_inst.getTable("TestTable").getBooleanTopic("Test").publish();
+ var pub = inst.getTable("TestTable").getBooleanTopic("Test").publish();
- var button = new NetworkButton(m_inst, "TestTable", "Test");
+ var button = new NetworkButton(inst, "TestTable", "Test");
pub.set(false);
button.onTrue(command);
scheduler.run();
diff --git a/commandsv2/src/test/java/org/wpilib/command2/sysid/SysIdRoutineTest.java b/commandsv2/src/test/java/org/wpilib/command2/sysid/SysIdRoutineTest.java
index f201147f99f..f7e7bc48369 100644
--- a/commandsv2/src/test/java/org/wpilib/command2/sysid/SysIdRoutineTest.java
+++ b/commandsv2/src/test/java/org/wpilib/command2/sysid/SysIdRoutineTest.java
@@ -32,12 +32,12 @@ interface Mechanism extends Subsystem {
void log(SysIdRoutineLog log);
}
- Mechanism m_mechanism;
- SysIdRoutine m_sysidRoutine;
- Command m_quasistaticForward;
- Command m_quasistaticReverse;
- Command m_dynamicForward;
- Command m_dynamicReverse;
+ Mechanism mechanism;
+ SysIdRoutine sysidRoutine;
+ Command quasistaticForward;
+ Command quasistaticReverse;
+ Command dynamicForward;
+ Command dynamicReverse;
void runCommand(Command command) {
command.initialize();
@@ -52,15 +52,15 @@ void runCommand(Command command) {
void setup() {
HAL.initialize(500, 0);
SimHooks.pauseTiming();
- m_mechanism = mock(Mechanism.class);
- m_sysidRoutine =
+ mechanism = mock(Mechanism.class);
+ sysidRoutine =
new SysIdRoutine(
- new SysIdRoutine.Config(null, null, null, m_mechanism::recordState),
- new SysIdRoutine.Mechanism(m_mechanism::drive, m_mechanism::log, new Subsystem() {}));
- m_quasistaticForward = m_sysidRoutine.quasistatic(SysIdRoutine.Direction.kForward);
- m_quasistaticReverse = m_sysidRoutine.quasistatic(SysIdRoutine.Direction.kReverse);
- m_dynamicForward = m_sysidRoutine.dynamic(SysIdRoutine.Direction.kForward);
- m_dynamicReverse = m_sysidRoutine.dynamic(SysIdRoutine.Direction.kReverse);
+ new SysIdRoutine.Config(null, null, null, mechanism::recordState),
+ new SysIdRoutine.Mechanism(mechanism::drive, mechanism::log, new Subsystem() {}));
+ quasistaticForward = sysidRoutine.quasistatic(SysIdRoutine.Direction.kForward);
+ quasistaticReverse = sysidRoutine.quasistatic(SysIdRoutine.Direction.kReverse);
+ dynamicForward = sysidRoutine.dynamic(SysIdRoutine.Direction.kForward);
+ dynamicReverse = sysidRoutine.dynamic(SysIdRoutine.Direction.kReverse);
}
@AfterEach
@@ -70,74 +70,74 @@ void cleanupAll() {
@Test
void recordStateBookendsMotorLogging() {
- runCommand(m_quasistaticForward);
+ runCommand(quasistaticForward);
- var orderCheck = inOrder(m_mechanism);
+ var orderCheck = inOrder(mechanism);
- orderCheck.verify(m_mechanism).recordState(SysIdRoutineLog.State.QUASISTATIC_FORWARD);
- orderCheck.verify(m_mechanism).drive(any());
- orderCheck.verify(m_mechanism).log(any());
- orderCheck.verify(m_mechanism).recordState(SysIdRoutineLog.State.NONE);
+ orderCheck.verify(mechanism).recordState(SysIdRoutineLog.State.QUASISTATIC_FORWARD);
+ orderCheck.verify(mechanism).drive(any());
+ orderCheck.verify(mechanism).log(any());
+ orderCheck.verify(mechanism).recordState(SysIdRoutineLog.State.NONE);
orderCheck.verifyNoMoreInteractions();
- clearInvocations(m_mechanism);
- orderCheck = inOrder(m_mechanism);
- runCommand(m_dynamicForward);
+ clearInvocations(mechanism);
+ orderCheck = inOrder(mechanism);
+ runCommand(dynamicForward);
- orderCheck.verify(m_mechanism).recordState(SysIdRoutineLog.State.DYNAMIC_FORWARD);
- orderCheck.verify(m_mechanism).drive(any());
- orderCheck.verify(m_mechanism).log(any());
- orderCheck.verify(m_mechanism).recordState(SysIdRoutineLog.State.NONE);
+ orderCheck.verify(mechanism).recordState(SysIdRoutineLog.State.DYNAMIC_FORWARD);
+ orderCheck.verify(mechanism).drive(any());
+ orderCheck.verify(mechanism).log(any());
+ orderCheck.verify(mechanism).recordState(SysIdRoutineLog.State.NONE);
orderCheck.verifyNoMoreInteractions();
}
@Test
void testsDeclareCorrectState() {
- runCommand(m_quasistaticForward);
- verify(m_mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.QUASISTATIC_FORWARD);
+ runCommand(quasistaticForward);
+ verify(mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.QUASISTATIC_FORWARD);
- runCommand(m_quasistaticReverse);
- verify(m_mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.QUASISTATIC_REVERSE);
+ runCommand(quasistaticReverse);
+ verify(mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.QUASISTATIC_REVERSE);
- runCommand(m_dynamicForward);
- verify(m_mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.DYNAMIC_FORWARD);
+ runCommand(dynamicForward);
+ verify(mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.DYNAMIC_FORWARD);
- runCommand(m_dynamicReverse);
- verify(m_mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.DYNAMIC_REVERSE);
+ runCommand(dynamicReverse);
+ verify(mechanism, atLeastOnce()).recordState(SysIdRoutineLog.State.DYNAMIC_REVERSE);
}
@Test
void testsOutputCorrectVoltage() {
- runCommand(m_quasistaticForward);
- var orderCheck = inOrder(m_mechanism);
+ runCommand(quasistaticForward);
+ var orderCheck = inOrder(mechanism);
- orderCheck.verify(m_mechanism, atLeastOnce()).drive(Volts.of(1));
- orderCheck.verify(m_mechanism).drive(Volts.of(0));
- orderCheck.verify(m_mechanism, never()).drive(any());
+ orderCheck.verify(mechanism, atLeastOnce()).drive(Volts.of(1));
+ orderCheck.verify(mechanism).drive(Volts.of(0));
+ orderCheck.verify(mechanism, never()).drive(any());
- clearInvocations(m_mechanism);
- runCommand(m_quasistaticReverse);
- orderCheck = inOrder(m_mechanism);
+ clearInvocations(mechanism);
+ runCommand(quasistaticReverse);
+ orderCheck = inOrder(mechanism);
- orderCheck.verify(m_mechanism, atLeastOnce()).drive(Volts.of(-1));
- orderCheck.verify(m_mechanism).drive(Volts.of(0));
- orderCheck.verify(m_mechanism, never()).drive(any());
+ orderCheck.verify(mechanism, atLeastOnce()).drive(Volts.of(-1));
+ orderCheck.verify(mechanism).drive(Volts.of(0));
+ orderCheck.verify(mechanism, never()).drive(any());
- clearInvocations(m_mechanism);
- runCommand(m_dynamicForward);
- orderCheck = inOrder(m_mechanism);
+ clearInvocations(mechanism);
+ runCommand(dynamicForward);
+ orderCheck = inOrder(mechanism);
- orderCheck.verify(m_mechanism, atLeastOnce()).drive(Volts.of(7));
- orderCheck.verify(m_mechanism).drive(Volts.of(0));
- orderCheck.verify(m_mechanism, never()).drive(any());
+ orderCheck.verify(mechanism, atLeastOnce()).drive(Volts.of(7));
+ orderCheck.verify(mechanism).drive(Volts.of(0));
+ orderCheck.verify(mechanism, never()).drive(any());
- clearInvocations(m_mechanism);
- runCommand(m_dynamicForward);
- orderCheck = inOrder(m_mechanism);
+ clearInvocations(mechanism);
+ runCommand(dynamicForward);
+ orderCheck = inOrder(mechanism);
- runCommand(m_dynamicReverse);
- orderCheck.verify(m_mechanism, atLeastOnce()).drive(Volts.of(-7));
- orderCheck.verify(m_mechanism).drive(Volts.of(0));
- orderCheck.verify(m_mechanism, never()).drive(any());
+ runCommand(dynamicReverse);
+ orderCheck.verify(mechanism, atLeastOnce()).drive(Volts.of(-7));
+ orderCheck.verify(mechanism).drive(Volts.of(0));
+ orderCheck.verify(mechanism, never()).drive(any());
}
}
diff --git a/commandsv3/src/main/java/org/wpilib/command3/Binding.java b/commandsv3/src/main/java/org/wpilib/command3/Binding.java
index 4d79496612e..e138c63dfc1 100644
--- a/commandsv3/src/main/java/org/wpilib/command3/Binding.java
+++ b/commandsv3/src/main/java/org/wpilib/command3/Binding.java
@@ -17,7 +17,7 @@
* instead of giving a fairly useless backtrace of the command framework.
*/
record Binding(BindingScope scope, BindingType type, Command command, StackTraceElement[] frames) {
- public Binding {
+ Binding {
ErrorMessages.requireNonNullParam(scope, "scope", "Binding");
ErrorMessages.requireNonNullParam(type, "type", "Binding");
ErrorMessages.requireNonNullParam(command, "command", "Binding");
diff --git a/commandsv3/src/main/java/org/wpilib/command3/CommandState.java b/commandsv3/src/main/java/org/wpilib/command3/CommandState.java
index 56f1aacb588..351de366210 100644
--- a/commandsv3/src/main/java/org/wpilib/command3/CommandState.java
+++ b/commandsv3/src/main/java/org/wpilib/command3/CommandState.java
@@ -43,19 +43,19 @@ final class CommandState {
m_id = ++s_lastId;
}
- public Command command() {
+ Command command() {
return m_command;
}
- public Command parent() {
+ Command parent() {
return m_parent;
}
- public Coroutine coroutine() {
+ Coroutine coroutine() {
return m_coroutine;
}
- public Binding binding() {
+ Binding binding() {
return m_binding;
}
@@ -65,20 +65,20 @@ public Binding binding() {
*
* @return The runtime, in milliseconds.
*/
- public double lastRuntimeMs() {
+ double lastRuntimeMs() {
return m_lastRuntimeMs;
}
- public void setLastRuntimeMs(double lastRuntimeMs) {
+ void setLastRuntimeMs(double lastRuntimeMs) {
m_lastRuntimeMs = lastRuntimeMs;
m_totalRuntimeMs += lastRuntimeMs;
}
- public double totalRuntimeMs() {
+ double totalRuntimeMs() {
return m_totalRuntimeMs;
}
- public int id() {
+ int id() {
return m_id;
}
diff --git a/commandsv3/src/main/java/org/wpilib/command3/CommandTraceHelper.java b/commandsv3/src/main/java/org/wpilib/command3/CommandTraceHelper.java
index ff8d5c9c55f..66bc1c08ca8 100644
--- a/commandsv3/src/main/java/org/wpilib/command3/CommandTraceHelper.java
+++ b/commandsv3/src/main/java/org/wpilib/command3/CommandTraceHelper.java
@@ -21,7 +21,7 @@ private CommandTraceHelper() {
* @param commandScheduleTrace The trace of when the command was scheduled.
* @return A new array of stack trace elements.
*/
- public static StackTraceElement[] modifyTrace(
+ static StackTraceElement[] modifyTrace(
StackTraceElement[] commandExceptionTrace, StackTraceElement[] commandScheduleTrace) {
List frames = new ArrayList<>();
diff --git a/commandsv3/src/main/java/org/wpilib/command3/Continuation.java b/commandsv3/src/main/java/org/wpilib/command3/Continuation.java
index 82fbb979bdc..ea028da8e3a 100644
--- a/commandsv3/src/main/java/org/wpilib/command3/Continuation.java
+++ b/commandsv3/src/main/java/org/wpilib/command3/Continuation.java
@@ -118,7 +118,7 @@ static final class InternalContinuationError extends Error {
@SuppressWarnings("PMD.AvoidCatchingGenericException")
Continuation(ContinuationScope scope, Runnable target) {
try {
- m_continuation = CONSTRUCTOR.invoke(scope.m_continuationScope, target);
+ m_continuation = CONSTRUCTOR.invoke(scope.continuationScope, target);
m_scope = scope;
} catch (RuntimeException | Error e) {
throw e;
@@ -134,9 +134,9 @@ static final class InternalContinuationError extends Error {
* @throws IllegalStateException if not currently in this continuation's scope
*/
@SuppressWarnings("PMD.AvoidCatchingGenericException")
- public boolean yield() {
+ boolean yield() {
try {
- return (boolean) YIELD.invoke(m_scope.m_continuationScope);
+ return (boolean) YIELD.invoke(m_scope.continuationScope);
} catch (RuntimeException | Error e) {
throw e;
} catch (Throwable t) {
@@ -150,7 +150,7 @@ public boolean yield() {
* continuation is suspended, it will continue from the most recent yield point.
*/
@SuppressWarnings("PMD.AvoidCatchingGenericException")
- public void run() {
+ void run() {
try {
RUN.invoke(m_continuation);
} catch (WrongMethodTypeException | ClassCastException e) {
@@ -169,7 +169,7 @@ public void run() {
* @return whether this continuation is completed
*/
@SuppressWarnings("PMD.AvoidCatchingGenericException")
- public boolean isDone() {
+ boolean isDone() {
try {
return (boolean) IS_DONE.invoke(m_continuation);
} catch (RuntimeException | Error e) {
@@ -187,7 +187,7 @@ public boolean isDone() {
* @param continuation the continuation to mount
*/
@SuppressWarnings("PMD.AvoidCatchingGenericException")
- public static void mountContinuation(Continuation continuation) {
+ static void mountContinuation(Continuation continuation) {
try {
if (continuation == null) {
java_lang_thread_setContinuation.invoke(Thread.currentThread(), null);
@@ -215,7 +215,7 @@ public static void mountContinuation(Continuation continuation) {
*
* @return The continuation mounted on the current thread.
*/
- public static Continuation getMountedContinuation() {
+ static Continuation getMountedContinuation() {
return mountedContinuation.get();
}
diff --git a/commandsv3/src/main/java/org/wpilib/command3/ContinuationScope.java b/commandsv3/src/main/java/org/wpilib/command3/ContinuationScope.java
index 2e4c9bcd832..7cd303605b1 100644
--- a/commandsv3/src/main/java/org/wpilib/command3/ContinuationScope.java
+++ b/commandsv3/src/main/java/org/wpilib/command3/ContinuationScope.java
@@ -10,11 +10,11 @@
import java.util.Objects;
/** A continuation scope. */
-@SuppressWarnings("PMD.AvoidCatchingGenericException")
+@SuppressWarnings({"PMD.AvoidCatchingGenericException", "PMD.AvoidFieldNameMatchingTypeName"})
final class ContinuationScope {
// The underlying jdk.internal.vm.ContinuationScope object
// https://github.com/openjdk/jdk/blob/jdk-21%2B35/src/java.base/share/classes/jdk/internal/vm/ContinuationScope.java
- final Object m_continuationScope;
+ final Object continuationScope;
static final Class> jdk_internal_vm_ContinuationScope;
private static final MethodHandle CONSTRUCTOR;
@@ -42,7 +42,7 @@ final class ContinuationScope {
ContinuationScope(String name) {
Objects.requireNonNull(name);
try {
- m_continuationScope = CONSTRUCTOR.invoke(name);
+ continuationScope = CONSTRUCTOR.invoke(name);
} catch (Throwable e) {
throw new RuntimeException(e);
}
@@ -50,6 +50,6 @@ final class ContinuationScope {
@Override
public String toString() {
- return m_continuationScope.toString();
+ return continuationScope.toString();
}
}
diff --git a/commandsv3/src/test/java/org/wpilib/command3/SchedulerTest.java b/commandsv3/src/test/java/org/wpilib/command3/SchedulerTest.java
index 5e222073a8e..7c0da90e690 100644
--- a/commandsv3/src/test/java/org/wpilib/command3/SchedulerTest.java
+++ b/commandsv3/src/test/java/org/wpilib/command3/SchedulerTest.java
@@ -132,7 +132,7 @@ void nestedMechanisms() {
private final Mechanism m_elevator = new Mechanism("Elevator", m_scheduler);
private final Mechanism m_arm = new Mechanism("Arm", m_scheduler);
- public Command superCommand() {
+ Command superCommand() {
return run(co -> {
co.await(m_elevator.run(Coroutine::park).named("Elevator Subcommand"));
co.await(m_arm.run(Coroutine::park).named("Arm Subcommand"));
diff --git a/cscore/src/main/java/org/wpilib/vision/camera/ImageSource.java b/cscore/src/main/java/org/wpilib/vision/camera/ImageSource.java
index 4b470a61730..688103625ba 100644
--- a/cscore/src/main/java/org/wpilib/vision/camera/ImageSource.java
+++ b/cscore/src/main/java/org/wpilib/vision/camera/ImageSource.java
@@ -137,6 +137,6 @@ public VideoProperty createStringProperty(String name, String value) {
* @param choices Choices
*/
public void setEnumPropertyChoices(VideoProperty property, String[] choices) {
- CameraServerJNI.setSourceEnumPropertyChoices(m_handle, property.m_handle, choices);
+ CameraServerJNI.setSourceEnumPropertyChoices(m_handle, property.handle, choices);
}
}
diff --git a/cscore/src/main/java/org/wpilib/vision/camera/VideoProperty.java b/cscore/src/main/java/org/wpilib/vision/camera/VideoProperty.java
index 788867640b0..93125b83eb7 100644
--- a/cscore/src/main/java/org/wpilib/vision/camera/VideoProperty.java
+++ b/cscore/src/main/java/org/wpilib/vision/camera/VideoProperty.java
@@ -57,7 +57,7 @@ public static Kind getKindFromInt(int kind) {
* @return Property name.
*/
public String getName() {
- return CameraServerJNI.getPropertyName(m_handle);
+ return CameraServerJNI.getPropertyName(handle);
}
/**
@@ -120,7 +120,7 @@ public boolean isEnum() {
* @return Property value.
*/
public int get() {
- return CameraServerJNI.getProperty(m_handle);
+ return CameraServerJNI.getProperty(handle);
}
/**
@@ -129,7 +129,7 @@ public int get() {
* @param value Property value.
*/
public void set(int value) {
- CameraServerJNI.setProperty(m_handle, value);
+ CameraServerJNI.setProperty(handle, value);
}
/**
@@ -138,7 +138,7 @@ public void set(int value) {
* @return Property minimum value.
*/
public int getMin() {
- return CameraServerJNI.getPropertyMin(m_handle);
+ return CameraServerJNI.getPropertyMin(handle);
}
/**
@@ -147,7 +147,7 @@ public int getMin() {
* @return Property maximum value.
*/
public int getMax() {
- return CameraServerJNI.getPropertyMax(m_handle);
+ return CameraServerJNI.getPropertyMax(handle);
}
/**
@@ -156,7 +156,7 @@ public int getMax() {
* @return Property step size.
*/
public int getStep() {
- return CameraServerJNI.getPropertyStep(m_handle);
+ return CameraServerJNI.getPropertyStep(handle);
}
/**
@@ -165,7 +165,7 @@ public int getStep() {
* @return Property default value.
*/
public int getDefault() {
- return CameraServerJNI.getPropertyDefault(m_handle);
+ return CameraServerJNI.getPropertyDefault(handle);
}
/**
@@ -176,7 +176,7 @@ public int getDefault() {
* @return The string property value.
*/
public String getString() {
- return CameraServerJNI.getStringProperty(m_handle);
+ return CameraServerJNI.getStringProperty(handle);
}
/**
@@ -187,7 +187,7 @@ public String getString() {
* @param value String property value.
*/
public void setString(String value) {
- CameraServerJNI.setStringProperty(m_handle, value);
+ CameraServerJNI.setStringProperty(handle, value);
}
/**
@@ -198,19 +198,19 @@ public void setString(String value) {
* @return The possible values for the enum property value.
*/
public String[] getChoices() {
- return CameraServerJNI.getEnumPropertyChoices(m_handle);
+ return CameraServerJNI.getEnumPropertyChoices(handle);
}
VideoProperty(int handle) {
- m_handle = handle;
+ this.handle = handle;
m_kind = getKindFromInt(CameraServerJNI.getPropertyKind(handle));
}
VideoProperty(int handle, Kind kind) {
- m_handle = handle;
+ this.handle = handle;
m_kind = kind;
}
- int m_handle;
+ int handle;
private final Kind m_kind;
}
diff --git a/datalog/src/main/java/org/wpilib/datalog/DoubleLogEntry.java b/datalog/src/main/java/org/wpilib/datalog/DoubleLogEntry.java
index 98e988f06a2..eab1afe44d6 100644
--- a/datalog/src/main/java/org/wpilib/datalog/DoubleLogEntry.java
+++ b/datalog/src/main/java/org/wpilib/datalog/DoubleLogEntry.java
@@ -125,6 +125,6 @@ public synchronized double getLastValue() {
return m_lastValue;
}
- boolean m_hasLastValue;
- double m_lastValue;
+ private boolean m_hasLastValue;
+ private double m_lastValue;
}
diff --git a/datalog/src/main/java/org/wpilib/datalog/FloatLogEntry.java b/datalog/src/main/java/org/wpilib/datalog/FloatLogEntry.java
index cdb51d313de..a0728e7286a 100644
--- a/datalog/src/main/java/org/wpilib/datalog/FloatLogEntry.java
+++ b/datalog/src/main/java/org/wpilib/datalog/FloatLogEntry.java
@@ -125,6 +125,6 @@ public synchronized float getLastValue() {
return m_lastValue;
}
- boolean m_hasLastValue;
- float m_lastValue;
+ private boolean m_hasLastValue;
+ private float m_lastValue;
}
diff --git a/datalog/src/main/java/org/wpilib/datalog/IntegerLogEntry.java b/datalog/src/main/java/org/wpilib/datalog/IntegerLogEntry.java
index 6fd5548599c..065c77427a5 100644
--- a/datalog/src/main/java/org/wpilib/datalog/IntegerLogEntry.java
+++ b/datalog/src/main/java/org/wpilib/datalog/IntegerLogEntry.java
@@ -125,6 +125,6 @@ public synchronized long getLastValue() {
return m_lastValue;
}
- boolean m_hasLastValue;
- long m_lastValue;
+ private boolean m_hasLastValue;
+ private long m_lastValue;
}
diff --git a/datalog/src/test/java/org/wpilib/datalog/DataLogTest.java b/datalog/src/test/java/org/wpilib/datalog/DataLogTest.java
index 1e0f33acfe7..b5dbdba059f 100644
--- a/datalog/src/test/java/org/wpilib/datalog/DataLogTest.java
+++ b/datalog/src/test/java/org/wpilib/datalog/DataLogTest.java
@@ -48,7 +48,7 @@ public ImmutableThing unpack(ByteBuffer bb) {
@Override
public void pack(ByteBuffer bb, ImmutableThing value) {
- bb.put(value.m_x);
+ bb.put(value.x);
}
@Override
@@ -58,23 +58,23 @@ public boolean isImmutable() {
}
static class ImmutableThing implements StructSerializable {
- byte m_x;
+ byte x;
ImmutableThing(int x) {
- m_x = (byte) x;
+ this.x = (byte) x;
}
@Override
public boolean equals(Object obj) {
- return obj instanceof ImmutableThing other && other.m_x == m_x;
+ return obj instanceof ImmutableThing other && other.x == x;
}
@Override
public int hashCode() {
- return Objects.hash(m_x);
+ return Objects.hash(x);
}
- public static final ImmutableThingStruct struct = new ImmutableThingStruct();
+ static final ImmutableThingStruct struct = new ImmutableThingStruct();
}
static class CloneableThingStruct implements Struct {
@@ -105,7 +105,7 @@ public CloneableThing unpack(ByteBuffer bb) {
@Override
public void pack(ByteBuffer bb, CloneableThing value) {
- bb.put(value.m_x);
+ bb.put(value.x);
}
@Override
@@ -119,24 +119,23 @@ public CloneableThing clone(CloneableThing obj) throws CloneNotSupportedExceptio
}
}
- @SuppressWarnings("MemberName")
private static int cloneCalls;
static class CloneableThing implements StructSerializable, Cloneable {
- byte m_x;
+ byte x;
CloneableThing(int x) {
- m_x = (byte) x;
+ this.x = (byte) x;
}
@Override
public boolean equals(Object obj) {
- return obj instanceof CloneableThing other && other.m_x == m_x;
+ return obj instanceof CloneableThing other && other.x == x;
}
@Override
public int hashCode() {
- return Objects.hash(m_x);
+ return Objects.hash(x);
}
@Override
@@ -146,7 +145,7 @@ public CloneableThing clone() throws CloneNotSupportedException {
return thing;
}
- public static final CloneableThingStruct struct = new CloneableThingStruct();
+ static final CloneableThingStruct struct = new CloneableThingStruct();
}
static class ThingStruct implements Struct {
@@ -177,45 +176,43 @@ public Thing unpack(ByteBuffer bb) {
@Override
public void pack(ByteBuffer bb, Thing value) {
- bb.put(value.m_x);
+ bb.put(value.x);
}
}
static class Thing implements StructSerializable {
- byte m_x;
+ byte x;
Thing(int x) {
- m_x = (byte) x;
+ this.x = (byte) x;
}
@Override
public boolean equals(Object obj) {
- return obj instanceof Thing other && other.m_x == m_x;
+ return obj instanceof Thing other && other.x == x;
}
@Override
public int hashCode() {
- return Objects.hash(m_x);
+ return Objects.hash(x);
}
- public static final ThingStruct struct = new ThingStruct();
+ static final ThingStruct struct = new ThingStruct();
}
- @SuppressWarnings("MemberName")
- private ByteArrayOutputStream data;
+ ByteArrayOutputStream data;
- @SuppressWarnings("MemberName")
- private DataLog log;
+ DataLog log;
@BeforeEach
- public void init() {
+ void init() {
data = new ByteArrayOutputStream();
log = new DataLogWriter(data);
cloneCalls = 0;
}
@AfterEach
- public void shutdown() {
+ void shutdown() {
log.close();
}
diff --git a/epilogue-processor/src/main/java/org/wpilib/epilogue/processor/EpilogueGenerator.java b/epilogue-processor/src/main/java/org/wpilib/epilogue/processor/EpilogueGenerator.java
index ed437431bd6..e136a0ce90c 100644
--- a/epilogue-processor/src/main/java/org/wpilib/epilogue/processor/EpilogueGenerator.java
+++ b/epilogue-processor/src/main/java/org/wpilib/epilogue/processor/EpilogueGenerator.java
@@ -6,6 +6,7 @@
import java.io.IOException;
import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -48,7 +49,8 @@ public void writeEpilogueFile(
var centralStore =
m_processingEnv.getFiler().createSourceFile("org.wpilib.epilogue.Epilogue");
- try (var out = new PrintWriter(centralStore.openOutputStream())) {
+ try (var out =
+ new PrintWriter(centralStore.openOutputStream(), false, StandardCharsets.UTF_8)) {
out.println("package org.wpilib.epilogue;");
out.println();
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/OpModeOption.java b/hal/src/main/java/org/wpilib/hardware/hal/OpModeOption.java
index 0e471823d88..c003cc1a7bd 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/OpModeOption.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/OpModeOption.java
@@ -7,22 +7,16 @@
/** 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;
/**
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionFaults.java b/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionFaults.java
index 2a796f06823..a44ffae2a04 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionFaults.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionFaults.java
@@ -8,7 +8,7 @@
* Faults for a PowerDistribution device. These faults are only active while the condition is
* active.
*/
-@SuppressWarnings("MemberName")
+@SuppressWarnings("PMD.PublicFieldNamingConvention")
public class PowerDistributionFaults {
/** Breaker fault on channel 0. */
public final boolean Channel0BreakerFault;
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionStickyFaults.java b/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionStickyFaults.java
index 32eca38281e..37f7727f664 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionStickyFaults.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/PowerDistributionStickyFaults.java
@@ -8,7 +8,7 @@
* Sticky faults for a PowerDistribution device. These faults will remain active until they are
* reset by the user.
*/
-@SuppressWarnings("MemberName")
+@SuppressWarnings("PMD.PublicFieldNamingConvention")
public class PowerDistributionStickyFaults {
/** Breaker fault on channel 0. */
public final boolean Channel0BreakerFault;
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/REVPHFaults.java b/hal/src/main/java/org/wpilib/hardware/hal/REVPHFaults.java
index d61da9c5127..306db2871bf 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/REVPHFaults.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/REVPHFaults.java
@@ -5,7 +5,7 @@
package org.wpilib.hardware.hal;
/** Faults for a REV PH. These faults are only active while the condition is active. */
-@SuppressWarnings("MemberName")
+@SuppressWarnings("PMD.PublicFieldNamingConvention")
public class REVPHFaults {
/** Fault on channel 0. */
public final boolean Channel0Fault;
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/REVPHStickyFaults.java b/hal/src/main/java/org/wpilib/hardware/hal/REVPHStickyFaults.java
index 945d88e5d40..77fd58eef0f 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/REVPHStickyFaults.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/REVPHStickyFaults.java
@@ -5,7 +5,7 @@
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")
+@SuppressWarnings("PMD.PublicFieldNamingConvention")
public class REVPHStickyFaults {
/** An overcurrent event occurred on the compressor output. */
public final boolean CompressorOverCurrent;
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/can/CANReceiveMessage.java b/hal/src/main/java/org/wpilib/hardware/hal/can/CANReceiveMessage.java
index 1be388b017f..d17a80f1dd4 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/can/CANReceiveMessage.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/can/CANReceiveMessage.java
@@ -7,19 +7,15 @@
/** 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. */
diff --git a/hal/src/main/java/org/wpilib/hardware/hal/simulation/AlertDataJNI.java b/hal/src/main/java/org/wpilib/hardware/hal/simulation/AlertDataJNI.java
index 9d65a3898b2..f25055dc7c7 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/simulation/AlertDataJNI.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/simulation/AlertDataJNI.java
@@ -18,19 +18,14 @@ public AlertInfo(int handle, String group, String text, long activeStartTime, in
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
}
diff --git a/javacPlugin/src/main/java/org/wpilib/javacplugin/CoroutineYieldInLoopDetector.java b/javacPlugin/src/main/java/org/wpilib/javacplugin/CoroutineYieldInLoopDetector.java
index e510a8f4db0..cb383560f91 100644
--- a/javacPlugin/src/main/java/org/wpilib/javacplugin/CoroutineYieldInLoopDetector.java
+++ b/javacPlugin/src/main/java/org/wpilib/javacplugin/CoroutineYieldInLoopDetector.java
@@ -68,27 +68,27 @@ public CoroutineYieldInLoopDetector(JavacTask task) {
*/
private static final class LoopState {
/** The loop element being tracked. */
- WhileLoopTree m_loop;
+ WhileLoopTree loop;
/**
* All discovered calls to Coroutine.yield(). Only applies to calls to coroutines in
- * m_availableCoroutines.
+ * `availableCoroutines`.
*/
- final List m_yieldCalls = new ArrayList<>();
+ final List yieldCalls = new ArrayList<>();
/**
* The set of the most local coroutine arguments. eg for nested lambdas, the coroutine arguments
* to the innermost lambda will be present, but none of the coroutine arguments from any of the
* enclosing lambdas.
*/
- final List m_availableCoroutines = new ArrayList<>();
+ final List availableCoroutines = new ArrayList<>();
/**
- * All `while` loops nested inside m_loop. Only applies to direct children; loops in
+ * All `while` loops nested inside `loop`. Only applies to direct children; loops in
* conditionals, switch blocks, and the like will be present, but not loops in other nested
* loops, nor loops declared inside a lambda inside a loop.
*/
- final List m_children = new ArrayList<>();
+ final List children = new ArrayList<>();
}
private final class Scanner extends TreeScanner {
@@ -126,9 +126,9 @@ public LoopState visitMethod(MethodTree node, LoopState loopState) {
// Therefore, we do not copy the available coroutines from the parent state to the new
// child state.
var localState = new LoopState();
- localState.m_availableCoroutines.addAll(coroutineParameters);
+ localState.availableCoroutines.addAll(coroutineParameters);
if (loopState != null) {
- loopState.m_children.add(localState);
+ loopState.children.add(localState);
}
return super.visitMethod(node, localState);
@@ -163,9 +163,9 @@ public LoopState visitLambdaExpression(LambdaExpressionTree node, LoopState loop
// Therefore, we do not copy the available coroutines from the parent state to the new
// child state.
var localState = new LoopState();
- localState.m_availableCoroutines.addAll(coroutineParameters);
+ localState.availableCoroutines.addAll(coroutineParameters);
if (loopState != null) {
- loopState.m_children.add(localState);
+ loopState.children.add(localState);
}
return super.visitLambdaExpression(node, localState);
@@ -184,17 +184,17 @@ public LoopState visitWhileLoop(WhileLoopTree node, LoopState loopState) {
return super.visitWhileLoop(node, loopState);
}
- if (loopState.m_loop == null) {
- loopState.m_loop = node;
+ if (loopState.loop == null) {
+ loopState.loop = node;
var result = super.visitWhileLoop(node, loopState);
printErrors(loopState);
return result;
} else {
// Nested loop; split off a new child with the same available coroutines
var localState = new LoopState();
- localState.m_loop = node;
- localState.m_availableCoroutines.addAll(loopState.m_availableCoroutines);
- loopState.m_children.add(localState);
+ localState.loop = node;
+ localState.availableCoroutines.addAll(loopState.availableCoroutines);
+ loopState.children.add(localState);
// Don't print errors now - we'll handle that when we finish the parent loop
// Otherwise, errors would be printed by the innermost loops first and appear out of order,
@@ -207,20 +207,20 @@ private void printErrors(LoopState state) {
if (state == null) {
return;
}
- if (state.m_availableCoroutines.isEmpty() || state.m_loop == null) {
+ if (state.availableCoroutines.isEmpty() || state.loop == null) {
// Technically, this state should never be reachable.
// But to prevent errors in the compiler plugin from preventing user code from building,
// we silently ignore this bad state.
return;
}
- if (state.m_yieldCalls.isEmpty()) {
+ if (state.yieldCalls.isEmpty()) {
m_trees.printMessage(
- Diagnostic.Kind.ERROR, buildErrorMessageForLoop(state), state.m_loop, m_root);
+ Diagnostic.Kind.ERROR, buildErrorMessageForLoop(state), state.loop, m_root);
}
// Recurse over children
- for (var childLoop : state.m_children) {
+ for (var childLoop : state.children) {
printErrors(childLoop);
}
}
@@ -228,7 +228,7 @@ private void printErrors(LoopState state) {
private CharSequence buildErrorMessageForLoop(LoopState state) {
StringBuilder messageBuilder = new StringBuilder(64).append("Missing call to ");
var suggestedFunctionCalls =
- state.m_availableCoroutines.stream()
+ state.availableCoroutines.stream()
.map(e -> "`" + e.getSimpleName().toString() + ".yield()`")
.toList();
@@ -277,9 +277,9 @@ public LoopState visitMethodInvocation(MethodInvocationTree node, LoopState loop
if (recv instanceof IdentifierTree id) {
var idPath = m_trees.getPath(m_root, id);
var el = m_trees.getElement(idPath);
- if (el instanceof VariableElement ve && loopState.m_availableCoroutines.contains(ve)) {
+ if (el instanceof VariableElement ve && loopState.availableCoroutines.contains(ve)) {
// definitely calling yield on a local (method or lambda argument) coroutine object
- loopState.m_yieldCalls.add(el);
+ loopState.yieldCalls.add(el);
}
}
}
diff --git a/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java b/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java
index f0a0746893b..aeedd02e1b3 100644
--- a/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java
+++ b/ntcore/src/main/java/org/wpilib/networktables/ConnectionInfo.java
@@ -10,25 +10,25 @@ 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.
@@ -41,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;
}
}
diff --git a/shared/java/javastyle.gradle b/shared/java/javastyle.gradle
index b8771616c30..fc4cc47f8c3 100644
--- a/shared/java/javastyle.gradle
+++ b/shared/java/javastyle.gradle
@@ -87,3 +87,6 @@ task javaFormat {
dependsOn(tasks.withType(Pmd))
}
javaFormat.dependsOn 'spotlessApply'
+tasks.withType(Checkstyle) {
+ it.mustRunAfter 'spotlessApply'
+}
\ No newline at end of file
diff --git a/styleguide/checkstyle.xml b/styleguide/checkstyle.xml
index e641c16291e..2ca946b2946 100644
--- a/styleguide/checkstyle.xml
+++ b/styleguide/checkstyle.xml
@@ -168,13 +168,6 @@ module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
-
-
-
-
-
diff --git a/styleguide/pmd-ruleset.xml b/styleguide/pmd-ruleset.xml
index 9bbebd1effa..9ed6eb82ae8 100644
--- a/styleguide/pmd-ruleset.xml
+++ b/styleguide/pmd-ruleset.xml
@@ -70,7 +70,6 @@
-
@@ -143,4 +142,40 @@
]]>
+
+
+
+
+ 3
+
+
+
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+
+
+
+
diff --git a/wpilibc/src/test/native/cpp/TimedRobotTest.cpp b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp
index fb372dc6602..f68fc4f4dbb 100644
--- a/wpilibc/src/test/native/cpp/TimedRobotTest.cpp
+++ b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp
@@ -32,55 +32,55 @@ class TimedRobotTest : public ::testing::Test {
class MockRobot : public TimedRobot {
public:
- std::atomic m_simulationInitCount{0};
- std::atomic m_disabledInitCount{0};
- std::atomic m_autonomousInitCount{0};
- std::atomic m_teleopInitCount{0};
- std::atomic m_testInitCount{0};
-
- std::atomic m_disabledExitCount{0};
- std::atomic m_autonomousExitCount{0};
- std::atomic m_teleopExitCount{0};
- std::atomic m_testExitCount{0};
-
- std::atomic m_robotPeriodicCount{0};
- std::atomic m_simulationPeriodicCount{0};
- std::atomic m_disabledPeriodicCount{0};
- std::atomic m_autonomousPeriodicCount{0};
- std::atomic m_teleopPeriodicCount{0};
- std::atomic m_testPeriodicCount{0};
+ std::atomic simulationInitCount{0};
+ std::atomic disabledInitCount{0};
+ std::atomic autonomousInitCount{0};
+ std::atomic teleopInitCount{0};
+ std::atomic testInitCount{0};
+
+ std::atomic disabledExitCount{0};
+ std::atomic autonomousExitCount{0};
+ std::atomic teleopExitCount{0};
+ std::atomic testExitCount{0};
+
+ std::atomic robotPeriodicCount{0};
+ std::atomic simulationPeriodicCount{0};
+ std::atomic disabledPeriodicCount{0};
+ std::atomic autonomousPeriodicCount{0};
+ std::atomic teleopPeriodicCount{0};
+ std::atomic testPeriodicCount{0};
MockRobot() : TimedRobot{kPeriod} {}
- void SimulationInit() override { m_simulationInitCount++; }
+ void SimulationInit() override { simulationInitCount++; }
- void DisabledInit() override { m_disabledInitCount++; }
+ void DisabledInit() override { disabledInitCount++; }
- void AutonomousInit() override { m_autonomousInitCount++; }
+ void AutonomousInit() override { autonomousInitCount++; }
- void TeleopInit() override { m_teleopInitCount++; }
+ void TeleopInit() override { teleopInitCount++; }
- void UtilityInit() override { m_testInitCount++; }
+ void UtilityInit() override { testInitCount++; }
- void RobotPeriodic() override { m_robotPeriodicCount++; }
+ void RobotPeriodic() override { robotPeriodicCount++; }
- void SimulationPeriodic() override { m_simulationPeriodicCount++; }
+ void SimulationPeriodic() override { simulationPeriodicCount++; }
- void DisabledPeriodic() override { m_disabledPeriodicCount++; }
+ void DisabledPeriodic() override { disabledPeriodicCount++; }
- void AutonomousPeriodic() override { m_autonomousPeriodicCount++; }
+ void AutonomousPeriodic() override { autonomousPeriodicCount++; }
- void TeleopPeriodic() override { m_teleopPeriodicCount++; }
+ void TeleopPeriodic() override { teleopPeriodicCount++; }
- void UtilityPeriodic() override { m_testPeriodicCount++; }
+ void UtilityPeriodic() override { testPeriodicCount++; }
- void DisabledExit() override { m_disabledExitCount++; }
+ void DisabledExit() override { disabledExitCount++; }
- void AutonomousExit() override { m_autonomousExitCount++; }
+ void AutonomousExit() override { autonomousExitCount++; }
- void TeleopExit() override { m_teleopExitCount++; }
+ void TeleopExit() override { teleopExitCount++; }
- void UtilityExit() override { m_testExitCount++; }
+ void UtilityExit() override { testExitCount++; }
};
} // namespace
@@ -93,63 +93,63 @@ TEST_F(TimedRobotTest, DisabledMode) {
wpi::sim::DriverStationSim::SetEnabled(false);
wpi::sim::DriverStationSim::NotifyNewData();
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(0u, robot.m_robotPeriodicCount);
- EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(0u, robot.robotPeriodicCount);
+ EXPECT_EQ(0u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_robotPeriodicCount);
- EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(1u, robot.robotPeriodicCount);
+ EXPECT_EQ(1u, robot.simulationPeriodicCount);
+ EXPECT_EQ(1u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(2u, robot.m_robotPeriodicCount);
- EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(2u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(2u, robot.robotPeriodicCount);
+ EXPECT_EQ(2u, robot.simulationPeriodicCount);
+ EXPECT_EQ(2u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
robot.EndCompetition();
robotThread.join();
@@ -165,63 +165,63 @@ TEST_F(TimedRobotTest, AutonomousMode) {
wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_AUTONOMOUS);
wpi::sim::DriverStationSim::NotifyNewData();
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(0u, robot.m_robotPeriodicCount);
- EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(0u, robot.robotPeriodicCount);
+ EXPECT_EQ(0u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_robotPeriodicCount);
- EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(1u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(1u, robot.robotPeriodicCount);
+ EXPECT_EQ(1u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(1u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(2u, robot.m_robotPeriodicCount);
- EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(2u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(2u, robot.robotPeriodicCount);
+ EXPECT_EQ(2u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(2u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
robot.EndCompetition();
robotThread.join();
@@ -237,63 +237,63 @@ TEST_F(TimedRobotTest, TeleopMode) {
wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED);
wpi::sim::DriverStationSim::NotifyNewData();
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(0u, robot.m_robotPeriodicCount);
- EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(0u, robot.robotPeriodicCount);
+ EXPECT_EQ(0u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(1u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(1u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_robotPeriodicCount);
- EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(1u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(1u, robot.robotPeriodicCount);
+ EXPECT_EQ(1u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(1u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(1u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(1u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(2u, robot.m_robotPeriodicCount);
- EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(2u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(2u, robot.robotPeriodicCount);
+ EXPECT_EQ(2u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(2u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
robot.EndCompetition();
robotThread.join();
@@ -308,85 +308,85 @@ TEST_F(TimedRobotTest, TestMode) {
wpi::sim::DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_UTILITY);
wpi::sim::DriverStationSim::NotifyNewData();
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(0u, robot.m_robotPeriodicCount);
- EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(0u, robot.m_testPeriodicCount);
+ EXPECT_EQ(0u, robot.robotPeriodicCount);
+ EXPECT_EQ(0u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(1u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(1u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_robotPeriodicCount);
- EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(1u, robot.m_testPeriodicCount);
+ EXPECT_EQ(1u, robot.robotPeriodicCount);
+ EXPECT_EQ(1u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(1u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(1u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(1u, robot.testInitCount);
- EXPECT_EQ(2u, robot.m_robotPeriodicCount);
- EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(2u, robot.m_testPeriodicCount);
+ EXPECT_EQ(2u, robot.robotPeriodicCount);
+ EXPECT_EQ(2u, robot.simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(2u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::DriverStationSim::SetEnabled(false);
wpi::sim::DriverStationSim::NotifyNewData();
wpi::sim::StepTiming(20_ms); // Wait for Notifiers
- EXPECT_EQ(1u, robot.m_simulationInitCount);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(1u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.simulationInitCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(1u, robot.testInitCount);
- EXPECT_EQ(3u, robot.m_robotPeriodicCount);
- EXPECT_EQ(3u, robot.m_simulationPeriodicCount);
- EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
- EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
- EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
- EXPECT_EQ(2u, robot.m_testPeriodicCount);
+ EXPECT_EQ(3u, robot.robotPeriodicCount);
+ EXPECT_EQ(3u, robot.simulationPeriodicCount);
+ EXPECT_EQ(1u, robot.disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.teleopPeriodicCount);
+ EXPECT_EQ(2u, robot.testPeriodicCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(1u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(1u, robot.testExitCount);
robot.EndCompetition();
robotThread.join();
@@ -402,27 +402,27 @@ TEST_F(TimedRobotTest, ModeChange) {
wpi::sim::DriverStationSim::SetEnabled(false);
wpi::sim::DriverStationSim::NotifyNewData();
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(0u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(0u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
// Transition to autonomous
wpi::sim::DriverStationSim::SetEnabled(true);
@@ -431,15 +431,15 @@ TEST_F(TimedRobotTest, ModeChange) {
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_autonomousInitCount);
- EXPECT_EQ(0u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.autonomousInitCount);
+ EXPECT_EQ(0u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_disabledExitCount);
- EXPECT_EQ(0u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(1u, robot.disabledExitCount);
+ EXPECT_EQ(0u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
// Transition to teleop
wpi::sim::DriverStationSim::SetEnabled(true);
@@ -448,15 +448,15 @@ TEST_F(TimedRobotTest, ModeChange) {
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_autonomousInitCount);
- EXPECT_EQ(1u, robot.m_teleopInitCount);
- EXPECT_EQ(0u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.autonomousInitCount);
+ EXPECT_EQ(1u, robot.teleopInitCount);
+ EXPECT_EQ(0u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_disabledExitCount);
- EXPECT_EQ(1u, robot.m_autonomousExitCount);
- EXPECT_EQ(0u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(1u, robot.disabledExitCount);
+ EXPECT_EQ(1u, robot.autonomousExitCount);
+ EXPECT_EQ(0u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
// Transition to test
wpi::sim::DriverStationSim::SetEnabled(true);
@@ -465,15 +465,15 @@ TEST_F(TimedRobotTest, ModeChange) {
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_autonomousInitCount);
- EXPECT_EQ(1u, robot.m_teleopInitCount);
- EXPECT_EQ(1u, robot.m_testInitCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.autonomousInitCount);
+ EXPECT_EQ(1u, robot.teleopInitCount);
+ EXPECT_EQ(1u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_disabledExitCount);
- EXPECT_EQ(1u, robot.m_autonomousExitCount);
- EXPECT_EQ(1u, robot.m_teleopExitCount);
- EXPECT_EQ(0u, robot.m_testExitCount);
+ EXPECT_EQ(1u, robot.disabledExitCount);
+ EXPECT_EQ(1u, robot.autonomousExitCount);
+ EXPECT_EQ(1u, robot.teleopExitCount);
+ EXPECT_EQ(0u, robot.testExitCount);
// Transition to disabled
wpi::sim::DriverStationSim::SetEnabled(false);
@@ -481,15 +481,15 @@ TEST_F(TimedRobotTest, ModeChange) {
wpi::sim::StepTiming(kPeriod);
- EXPECT_EQ(2u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_autonomousInitCount);
- EXPECT_EQ(1u, robot.m_teleopInitCount);
- EXPECT_EQ(1u, robot.m_testInitCount);
+ EXPECT_EQ(2u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.autonomousInitCount);
+ EXPECT_EQ(1u, robot.teleopInitCount);
+ EXPECT_EQ(1u, robot.testInitCount);
- EXPECT_EQ(1u, robot.m_disabledExitCount);
- EXPECT_EQ(1u, robot.m_autonomousExitCount);
- EXPECT_EQ(1u, robot.m_teleopExitCount);
- EXPECT_EQ(1u, robot.m_testExitCount);
+ EXPECT_EQ(1u, robot.disabledExitCount);
+ EXPECT_EQ(1u, robot.autonomousExitCount);
+ EXPECT_EQ(1u, robot.teleopExitCount);
+ EXPECT_EQ(1u, robot.testExitCount);
robot.EndCompetition();
robotThread.join();
@@ -507,20 +507,20 @@ TEST_F(TimedRobotTest, AddPeriodic) {
wpi::sim::DriverStationSim::SetEnabled(false);
wpi::sim::DriverStationSim::NotifyNewData();
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
EXPECT_EQ(0u, callbackCount);
wpi::sim::StepTiming(kPeriod / 2.0);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
EXPECT_EQ(1u, callbackCount);
wpi::sim::StepTiming(kPeriod / 2.0);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.disabledPeriodicCount);
EXPECT_EQ(2u, callbackCount);
robot.EndCompetition();
@@ -546,32 +546,32 @@ TEST_F(TimedRobotTest, AddPeriodicWithOffset) {
wpi::sim::DriverStationSim::SetEnabled(false);
wpi::sim::DriverStationSim::NotifyNewData();
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
EXPECT_EQ(0u, callbackCount);
wpi::sim::StepTiming(kPeriod * 3.0 / 8.0);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
EXPECT_EQ(0u, callbackCount);
wpi::sim::StepTiming(kPeriod * 3.0 / 8.0);
- EXPECT_EQ(0u, robot.m_disabledInitCount);
- EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.disabledInitCount);
+ EXPECT_EQ(0u, robot.disabledPeriodicCount);
EXPECT_EQ(1u, callbackCount);
wpi::sim::StepTiming(kPeriod / 4.0);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.disabledPeriodicCount);
EXPECT_EQ(1u, callbackCount);
wpi::sim::StepTiming(kPeriod / 4.0);
- EXPECT_EQ(1u, robot.m_disabledInitCount);
- EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(1u, robot.disabledInitCount);
+ EXPECT_EQ(1u, robot.disabledPeriodicCount);
EXPECT_EQ(2u, callbackCount);
robot.EndCompetition();
diff --git a/wpilibj/src/main/java/org/wpilib/driverstation/internal/DriverStationBackend.java b/wpilibj/src/main/java/org/wpilib/driverstation/internal/DriverStationBackend.java
index cd74c2c555d..42286583aca 100644
--- a/wpilibj/src/main/java/org/wpilib/driverstation/internal/DriverStationBackend.java
+++ b/wpilibj/src/main/java/org/wpilib/driverstation/internal/DriverStationBackend.java
@@ -65,68 +65,68 @@ private static int availableToCount(long available) {
}
private static final class HALJoystickTouchpadFinger {
- public float m_x;
- public float m_y;
- public boolean m_down;
+ float x;
+ float y;
+ boolean down;
}
private static class HALJoystickTouchpad {
- public final HALJoystickTouchpadFinger[] m_fingers =
+ final HALJoystickTouchpadFinger[] fingers =
new HALJoystickTouchpadFinger[DriverStationJNI.MAX_JOYSTICK_TOUCHPAD_FINGERS];
- public int m_count;
+ int count;
HALJoystickTouchpad() {
- for (int i = 0; i < m_fingers.length; i++) {
- m_fingers[i] = new HALJoystickTouchpadFinger();
+ for (int i = 0; i < fingers.length; i++) {
+ fingers[i] = new HALJoystickTouchpadFinger();
}
}
}
private static class HALJoystickTouchpads {
- public final HALJoystickTouchpad[] m_touchpads =
+ final HALJoystickTouchpad[] touchpads =
new HALJoystickTouchpad[DriverStationJNI.MAX_JOYSTICK_TOUCHPADS];
- public int m_count;
+ int count;
HALJoystickTouchpads() {
- for (int i = 0; i < m_touchpads.length; i++) {
- m_touchpads[i] = new HALJoystickTouchpad();
+ for (int i = 0; i < touchpads.length; i++) {
+ touchpads[i] = new HALJoystickTouchpad();
}
}
}
private static final class HALJoystickButtons {
- public long m_buttons;
- public long m_available;
+ long buttons;
+ long available;
}
private static class HALJoystickAxes {
- public final float[] m_axes;
- public int m_available;
+ final float[] axes;
+ int available;
HALJoystickAxes(int count) {
- m_axes = new float[count];
+ axes = new float[count];
}
}
private static class HALJoystickAxesRaw {
- public final short[] m_axes;
+ final short[] axes;
@SuppressWarnings("unused")
- public int m_available;
+ int available;
HALJoystickAxesRaw(int count) {
- m_axes = new short[count];
+ axes = new short[count];
}
}
private static class HALJoystickPOVs {
- public final byte[] m_povs;
- public int m_available;
+ final byte[] povs;
+ int available;
HALJoystickPOVs(int count) {
- m_povs = new byte[count];
+ povs = new byte[count];
for (int i = 0; i < count; i++) {
- m_povs[i] = 0;
+ povs[i] = 0;
}
}
}
@@ -273,32 +273,31 @@ private void sendMatchData() {
private static class JoystickLogSender {
JoystickLogSender(DataLog log, int stick, long timestamp) {
- m_stick = stick;
+ this.stick = stick;
- m_logButtons = new BooleanArrayLogEntry(log, "DS:joystick" + stick + "/buttons", timestamp);
- m_logAxes = new FloatArrayLogEntry(log, "DS:joystick" + stick + "/axes", timestamp);
- m_logPOVs = new IntegerArrayLogEntry(log, "DS:joystick" + stick + "/povs", timestamp);
+ logButtons = new BooleanArrayLogEntry(log, "DS:joystick" + stick + "/buttons", timestamp);
+ logAxes = new FloatArrayLogEntry(log, "DS:joystick" + stick + "/axes", timestamp);
+ logPOVs = new IntegerArrayLogEntry(log, "DS:joystick" + stick + "/povs", timestamp);
- appendButtons(m_joystickButtons[m_stick], timestamp);
- appendAxes(m_joystickAxes[m_stick], timestamp);
- appendPOVs(m_joystickPOVs[m_stick], timestamp);
+ appendButtons(m_joystickButtons[stick], timestamp);
+ appendAxes(m_joystickAxes[stick], timestamp);
+ appendPOVs(m_joystickPOVs[stick], timestamp);
}
- public void send(long timestamp) {
- HALJoystickButtons buttons = m_joystickButtons[m_stick];
- if (buttons.m_available != m_prevButtons.m_available
- || buttons.m_buttons != m_prevButtons.m_buttons) {
+ void send(long timestamp) {
+ HALJoystickButtons buttons = m_joystickButtons[stick];
+ if (buttons.available != prevButtons.available || buttons.buttons != prevButtons.buttons) {
appendButtons(buttons, timestamp);
}
- HALJoystickAxes axes = m_joystickAxes[m_stick];
- int available = axes.m_available;
+ HALJoystickAxes axes = m_joystickAxes[stick];
+ int available = axes.available;
boolean needToLog = false;
- if (available != m_prevAxes.m_available) {
+ if (available != prevAxes.available) {
needToLog = true;
} else {
- for (int i = 0; i < m_prevAxes.m_axes.length; i++) {
- if (axes.m_axes[i] != m_prevAxes.m_axes[i]) {
+ for (int i = 0; i < prevAxes.axes.length; i++) {
+ if (axes.axes[i] != prevAxes.axes[i]) {
needToLog = true;
break;
}
@@ -308,14 +307,14 @@ public void send(long timestamp) {
appendAxes(axes, timestamp);
}
- HALJoystickPOVs povs = m_joystickPOVs[m_stick];
- available = m_joystickPOVs[m_stick].m_available;
+ HALJoystickPOVs povs = m_joystickPOVs[stick];
+ available = m_joystickPOVs[stick].available;
needToLog = false;
- if (available != m_prevPOVs.m_available) {
+ if (available != prevPOVs.available) {
needToLog = true;
} else {
- for (int i = 0; i < m_prevPOVs.m_povs.length; i++) {
- if (povs.m_povs[i] != m_prevPOVs.m_povs[i]) {
+ for (int i = 0; i < prevPOVs.povs.length; i++) {
+ if (povs.povs[i] != prevPOVs.povs[i]) {
needToLog = true;
break;
}
@@ -327,102 +326,101 @@ public void send(long timestamp) {
}
void appendButtons(HALJoystickButtons buttons, long timestamp) {
- int count = availableToCount(buttons.m_available);
- if (m_sizedButtons == null || m_sizedButtons.length != count) {
- m_sizedButtons = new boolean[count];
+ int count = availableToCount(buttons.available);
+ if (sizedButtons == null || sizedButtons.length != count) {
+ sizedButtons = new boolean[count];
}
- long buttonsValue = buttons.m_buttons;
+ long buttonsValue = buttons.buttons;
for (int i = 0; i < count; i++) {
- m_sizedButtons[i] = (buttonsValue & (1L << i)) != 0;
+ sizedButtons[i] = (buttonsValue & (1L << i)) != 0;
}
- m_logButtons.append(m_sizedButtons, timestamp);
- m_prevButtons.m_available = buttons.m_available;
- m_prevButtons.m_buttons = buttons.m_buttons;
+ logButtons.append(sizedButtons, timestamp);
+ prevButtons.available = buttons.available;
+ prevButtons.buttons = buttons.buttons;
}
void appendAxes(HALJoystickAxes axes, long timestamp) {
- int count = availableToCount(axes.m_available);
- if (m_sizedAxes == null || m_sizedAxes.length != count) {
- m_sizedAxes = new float[count];
+ int count = availableToCount(axes.available);
+ if (sizedAxes == null || sizedAxes.length != count) {
+ sizedAxes = new float[count];
}
- System.arraycopy(axes.m_axes, 0, m_sizedAxes, 0, count);
- m_logAxes.append(m_sizedAxes, timestamp);
- m_prevAxes.m_available = axes.m_available;
- System.arraycopy(axes.m_axes, 0, m_prevAxes.m_axes, 0, count);
+ System.arraycopy(axes.axes, 0, sizedAxes, 0, count);
+ logAxes.append(sizedAxes, timestamp);
+ prevAxes.available = axes.available;
+ System.arraycopy(axes.axes, 0, prevAxes.axes, 0, count);
}
void appendPOVs(HALJoystickPOVs povs, long timestamp) {
- int count = availableToCount(povs.m_available);
- if (m_sizedPOVs == null || m_sizedPOVs.length != count) {
- m_sizedPOVs = new long[count];
+ int count = availableToCount(povs.available);
+ if (sizedPOVs == null || sizedPOVs.length != count) {
+ sizedPOVs = new long[count];
}
for (int i = 0; i < count; i++) {
- m_sizedPOVs[i] = povs.m_povs[i];
+ sizedPOVs[i] = povs.povs[i];
}
- m_logPOVs.append(m_sizedPOVs, timestamp);
- m_prevPOVs.m_available = povs.m_available;
- System.arraycopy(povs.m_povs, 0, m_prevPOVs.m_povs, 0, count);
+ logPOVs.append(sizedPOVs, timestamp);
+ prevPOVs.available = povs.available;
+ System.arraycopy(povs.povs, 0, prevPOVs.povs, 0, count);
}
- final int m_stick;
- boolean[] m_sizedButtons;
- float[] m_sizedAxes;
- long[] m_sizedPOVs;
- final HALJoystickButtons m_prevButtons = new HALJoystickButtons();
- final HALJoystickAxes m_prevAxes = new HALJoystickAxes(DriverStationJNI.MAX_JOYSTICK_AXES);
- final HALJoystickPOVs m_prevPOVs = new HALJoystickPOVs(DriverStationJNI.MAX_JOYSTICK_POVS);
- final BooleanArrayLogEntry m_logButtons;
- final FloatArrayLogEntry m_logAxes;
- final IntegerArrayLogEntry m_logPOVs;
+ final int stick;
+ boolean[] sizedButtons;
+ float[] sizedAxes;
+ long[] sizedPOVs;
+ final HALJoystickButtons prevButtons = new HALJoystickButtons();
+ final HALJoystickAxes prevAxes = new HALJoystickAxes(DriverStationJNI.MAX_JOYSTICK_AXES);
+ final HALJoystickPOVs prevPOVs = new HALJoystickPOVs(DriverStationJNI.MAX_JOYSTICK_POVS);
+ final BooleanArrayLogEntry logButtons;
+ final FloatArrayLogEntry logAxes;
+ final IntegerArrayLogEntry logPOVs;
}
private static class DataLogSender {
DataLogSender(DataLog log, boolean logJoysticks, long timestamp) {
- m_logControlWord =
- StructLogEntry.create(log, "DS:controlWord", ControlWord.struct, timestamp);
+ logControlWord = StructLogEntry.create(log, "DS:controlWord", ControlWord.struct, timestamp);
// append initial control word value
- m_logControlWord.append(m_controlWordCache, timestamp);
- m_oldControlWord.update(m_controlWordCache);
+ logControlWord.append(m_controlWordCache, timestamp);
+ oldControlWord.update(m_controlWordCache);
// append initial opmode value
- m_logOpMode = new StringLogEntry(log, "DS:opMode", timestamp);
- m_logOpMode.append(m_opModeCache, timestamp);
+ logOpMode = new StringLogEntry(log, "DS:opMode", timestamp);
+ logOpMode.append(m_opModeCache, timestamp);
if (logJoysticks) {
- m_joysticks = new JoystickLogSender[JOYSTICK_PORTS];
+ joysticks = new JoystickLogSender[JOYSTICK_PORTS];
for (int i = 0; i < JOYSTICK_PORTS; i++) {
- m_joysticks[i] = new JoystickLogSender(log, i, timestamp);
+ joysticks[i] = new JoystickLogSender(log, i, timestamp);
}
} else {
- m_joysticks = new JoystickLogSender[0];
+ joysticks = new JoystickLogSender[0];
}
}
- public void send(long timestamp) {
+ void send(long timestamp) {
// append control word value changes
- if (!m_controlWordCache.equals(m_oldControlWord)) {
+ if (!m_controlWordCache.equals(oldControlWord)) {
// append opmode value changes
long opModeId = m_controlWordCache.getOpModeId();
- if (opModeId != m_oldControlWord.getOpModeId()) {
- m_logOpMode.append(m_opModeCache, timestamp);
+ if (opModeId != oldControlWord.getOpModeId()) {
+ logOpMode.append(m_opModeCache, timestamp);
}
- m_logControlWord.append(m_controlWordCache, timestamp);
- m_oldControlWord.update(m_controlWordCache);
+ logControlWord.append(m_controlWordCache, timestamp);
+ oldControlWord.update(m_controlWordCache);
}
// append joystick value changes
- for (JoystickLogSender joystick : m_joysticks) {
+ for (JoystickLogSender joystick : joysticks) {
joystick.send(timestamp);
}
}
- final ControlWord m_oldControlWord = new ControlWord();
- final StructLogEntry m_logControlWord;
- final StringLogEntry m_logOpMode;
+ final ControlWord oldControlWord = new ControlWord();
+ final StructLogEntry logControlWord;
+ final StringLogEntry logOpMode;
- final JoystickLogSender[] m_joysticks;
+ final JoystickLogSender[] joysticks;
}
// Joystick User Data
@@ -594,8 +592,8 @@ public static boolean getStickButton(final int stick, final int button) {
m_cacheDataMutex.lock();
try {
- if ((m_joystickButtons[stick].m_available & mask) != 0) {
- return (m_joystickButtons[stick].m_buttons & mask) != 0;
+ if ((m_joystickButtons[stick].available & mask) != 0) {
+ return (m_joystickButtons[stick].buttons & mask) != 0;
}
} finally {
m_cacheDataMutex.unlock();
@@ -625,8 +623,8 @@ public static Optional getStickButtonIfAvailable(final int stick, final
m_cacheDataMutex.lock();
try {
- if ((m_joystickButtons[stick].m_available & mask) != 0) {
- return Optional.of((m_joystickButtons[stick].m_buttons & mask) != 0);
+ if ((m_joystickButtons[stick].available & mask) != 0) {
+ return Optional.of((m_joystickButtons[stick].buttons & mask) != 0);
}
} finally {
m_cacheDataMutex.unlock();
@@ -653,7 +651,7 @@ public static boolean getStickButtonPressed(final int stick, final int button) {
m_cacheDataMutex.lock();
try {
- if ((m_joystickButtons[stick].m_available & mask) != 0) {
+ if ((m_joystickButtons[stick].available & mask) != 0) {
// If button was pressed, clear flag and return true
if ((m_joystickButtonsPressed[stick] & mask) != 0) {
m_joystickButtonsPressed[stick] &= ~mask;
@@ -690,7 +688,7 @@ public static boolean getStickButtonReleased(final int stick, final int button)
m_cacheDataMutex.lock();
try {
- if ((m_joystickButtons[stick].m_available & mask) != 0) {
+ if ((m_joystickButtons[stick].available & mask) != 0) {
// If button was released, clear flag and return true
if ((m_joystickButtonsReleased[stick] & mask) != 0) {
m_joystickButtonsReleased[stick] &= ~mask;
@@ -728,8 +726,8 @@ public static double getStickAxis(int stick, int axis) {
m_cacheDataMutex.lock();
try {
- if ((m_joystickAxes[stick].m_available & mask) != 0) {
- return m_joystickAxes[stick].m_axes[axis];
+ if ((m_joystickAxes[stick].available & mask) != 0) {
+ return m_joystickAxes[stick].axes[axis];
}
} finally {
m_cacheDataMutex.unlock();
@@ -761,12 +759,12 @@ public static TouchpadFinger getStickTouchpadFinger(int stick, int touchpad, int
int touchpadCount;
m_cacheDataMutex.lock();
try {
- touchpadCount = m_joystickTouchpads[stick].m_count;
+ touchpadCount = m_joystickTouchpads[stick].count;
if (touchpad < touchpadCount) {
- HALJoystickTouchpad tp = m_joystickTouchpads[stick].m_touchpads[touchpad];
- if (finger < tp.m_count) {
+ HALJoystickTouchpad tp = m_joystickTouchpads[stick].touchpads[touchpad];
+ if (finger < tp.count) {
return new TouchpadFinger(
- tp.m_fingers[finger].m_down, tp.m_fingers[finger].m_x, tp.m_fingers[finger].m_y);
+ tp.fingers[finger].down, tp.fingers[finger].x, tp.fingers[finger].y);
}
}
} finally {
@@ -807,10 +805,10 @@ public static boolean getStickTouchpadFingerAvailable(int stick, int touchpad, i
int touchpadCount;
m_cacheDataMutex.lock();
try {
- touchpadCount = m_joystickTouchpads[stick].m_count;
+ touchpadCount = m_joystickTouchpads[stick].count;
if (touchpad < touchpadCount) {
- HALJoystickTouchpad tp = m_joystickTouchpads[stick].m_touchpads[touchpad];
- if (finger < tp.m_count) {
+ HALJoystickTouchpad tp = m_joystickTouchpads[stick].touchpads[touchpad];
+ if (finger < tp.count) {
return true;
}
}
@@ -841,8 +839,8 @@ public static OptionalDouble getStickAxisIfAvailable(int stick, int axis) {
m_cacheDataMutex.lock();
try {
- if ((m_joystickAxes[stick].m_available & mask) != 0) {
- return OptionalDouble.of(m_joystickAxes[stick].m_axes[axis]);
+ if ((m_joystickAxes[stick].available & mask) != 0) {
+ return OptionalDouble.of(m_joystickAxes[stick].axes[axis]);
}
} finally {
m_cacheDataMutex.unlock();
@@ -870,8 +868,8 @@ public static POVDirection getStickPOV(int stick, int pov) {
m_cacheDataMutex.lock();
try {
- if ((m_joystickPOVs[stick].m_available & mask) != 0) {
- return POVDirection.of(m_joystickPOVs[stick].m_povs[pov]);
+ if ((m_joystickPOVs[stick].available & mask) != 0) {
+ return POVDirection.of(m_joystickPOVs[stick].povs[pov]);
}
} finally {
m_cacheDataMutex.unlock();
@@ -894,7 +892,7 @@ public static long getStickButtons(final int stick) {
m_cacheDataMutex.lock();
try {
- return m_joystickButtons[stick].m_buttons;
+ return m_joystickButtons[stick].buttons;
} finally {
m_cacheDataMutex.unlock();
}
@@ -923,7 +921,7 @@ public static int getStickAxesAvailable(int stick) {
m_cacheDataMutex.lock();
try {
- return m_joystickAxes[stick].m_available;
+ return m_joystickAxes[stick].available;
} finally {
m_cacheDataMutex.unlock();
}
@@ -952,7 +950,7 @@ public static int getStickPOVsAvailable(int stick) {
m_cacheDataMutex.lock();
try {
- return m_joystickPOVs[stick].m_available;
+ return m_joystickPOVs[stick].available;
} finally {
m_cacheDataMutex.unlock();
}
@@ -981,7 +979,7 @@ public static long getStickButtonsAvailable(int stick) {
m_cacheDataMutex.lock();
try {
- return m_joystickButtons[stick].m_available;
+ return m_joystickButtons[stick].available;
} finally {
m_cacheDataMutex.unlock();
}
@@ -1695,26 +1693,26 @@ public static void refreshData() {
for (byte stick = 0; stick < JOYSTICK_PORTS; stick++) {
DriverStationJNI.getAllJoystickData(
stick,
- m_joystickAxesCache[stick].m_axes,
- m_joystickAxesRawCache[stick].m_axes,
- m_joystickPOVsCache[stick].m_povs,
+ m_joystickAxesCache[stick].axes,
+ m_joystickAxesRawCache[stick].axes,
+ m_joystickPOVsCache[stick].povs,
m_touchpadFingersCache,
m_metadataCache);
- m_joystickAxesCache[stick].m_available = (int) m_metadataCache[0];
- m_joystickAxesRawCache[stick].m_available = (int) m_metadataCache[0];
- m_joystickPOVsCache[stick].m_available = (int) m_metadataCache[1];
- m_joystickButtonsCache[stick].m_available = m_metadataCache[2];
- m_joystickButtonsCache[stick].m_buttons = m_metadataCache[3];
- m_joystickTouchpadsCache[stick].m_count = (int) m_metadataCache[4];
- for (int i = 0; i < m_joystickTouchpadsCache[stick].m_count; i++) {
+ m_joystickAxesCache[stick].available = (int) m_metadataCache[0];
+ m_joystickAxesRawCache[stick].available = (int) m_metadataCache[0];
+ m_joystickPOVsCache[stick].available = (int) m_metadataCache[1];
+ m_joystickButtonsCache[stick].available = m_metadataCache[2];
+ m_joystickButtonsCache[stick].buttons = m_metadataCache[3];
+ m_joystickTouchpadsCache[stick].count = (int) m_metadataCache[4];
+ for (int i = 0; i < m_joystickTouchpadsCache[stick].count; i++) {
long metadata = m_metadataCache[5 + i];
- m_joystickTouchpadsCache[stick].m_touchpads[i].m_fingers[0].m_down = (metadata & 0x1) != 0;
- m_joystickTouchpadsCache[stick].m_touchpads[i].m_fingers[1].m_down = (metadata & 0x2) != 0;
- m_joystickTouchpadsCache[stick].m_touchpads[i].m_count = (int) (metadata >> 2 & 0x3);
- for (int j = 0; j < m_joystickTouchpadsCache[stick].m_touchpads[i].m_count; j++) {
- m_joystickTouchpadsCache[stick].m_touchpads[i].m_fingers[j].m_x =
+ m_joystickTouchpadsCache[stick].touchpads[i].fingers[0].down = (metadata & 0x1) != 0;
+ m_joystickTouchpadsCache[stick].touchpads[i].fingers[1].down = (metadata & 0x2) != 0;
+ m_joystickTouchpadsCache[stick].touchpads[i].count = (int) (metadata >> 2 & 0x3);
+ for (int j = 0; j < m_joystickTouchpadsCache[stick].touchpads[i].count; j++) {
+ m_joystickTouchpadsCache[stick].touchpads[i].fingers[j].x =
m_touchpadFingersCache[i * 4 + j * 2 + 0];
- m_joystickTouchpadsCache[stick].m_touchpads[i].m_fingers[j].m_y =
+ m_joystickTouchpadsCache[stick].touchpads[i].fingers[j].y =
m_touchpadFingersCache[i * 4 + j * 2 + 1];
}
}
@@ -1737,11 +1735,11 @@ public static void refreshData() {
for (int i = 0; i < JOYSTICK_PORTS; i++) {
// If buttons weren't pressed and are now, set flags in m_buttonsPressed
m_joystickButtonsPressed[i] |=
- ~m_joystickButtons[i].m_buttons & m_joystickButtonsCache[i].m_buttons;
+ ~m_joystickButtons[i].buttons & m_joystickButtonsCache[i].buttons;
// If buttons were pressed and aren't now, set flags in m_buttonsReleased
m_joystickButtonsReleased[i] |=
- m_joystickButtons[i].m_buttons & ~m_joystickButtonsCache[i].m_buttons;
+ m_joystickButtons[i].buttons & ~m_joystickButtonsCache[i].buttons;
}
// move cache to actual data
diff --git a/wpilibj/src/main/java/org/wpilib/framework/RobotBase.java b/wpilibj/src/main/java/org/wpilib/framework/RobotBase.java
index 16aef6abe9d..a73a6aa67a6 100644
--- a/wpilibj/src/main/java/org/wpilib/framework/RobotBase.java
+++ b/wpilibj/src/main/java/org/wpilib/framework/RobotBase.java
@@ -131,7 +131,7 @@ protected RobotBase() {
false,
event -> {
if (event.is(NetworkTableEvent.Kind.CONNECTED)) {
- HAL.reportUsage("NT/" + event.connInfo.remote_id, "");
+ HAL.reportUsage("NT/" + event.connInfo.remoteId, "");
}
});
}
diff --git a/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java b/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java
index 446ee60fd40..abd58246d25 100644
--- a/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java
+++ b/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java
@@ -23,7 +23,6 @@
*/
public class TimedRobot extends IterativeRobotBase {
/** Default loop period. */
- @SuppressWarnings("MemberName")
public static final double DEFAULT_PERIOD = 0.02;
// The C pointer to the notifier object. We don't use it directly, it is
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/accelerometer/ADXL345_I2C.java b/wpilibj/src/main/java/org/wpilib/hardware/accelerometer/ADXL345_I2C.java
index 8473e5c4a27..dc9c69375df 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/accelerometer/ADXL345_I2C.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/accelerometer/ADXL345_I2C.java
@@ -57,7 +57,6 @@ public enum Axis {
}
/** Container type for accelerations from all axes. */
- @SuppressWarnings("MemberName")
public static class AllAxes {
/** Acceleration along the X axis in g-forces. */
public double x;
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/discrete/AnalogInput.java b/wpilibj/src/main/java/org/wpilib/hardware/discrete/AnalogInput.java
index 3a4b05df891..aa487962eda 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/discrete/AnalogInput.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/discrete/AnalogInput.java
@@ -17,7 +17,7 @@
* Each analog channel is read from hardware as a 12-bit number representing 0V to 3.3V.
*/
public class AnalogInput implements Sendable, AutoCloseable {
- int m_port; // explicit no modifier, private and package accessible.
+ private int m_port;
private int m_channel;
/**
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/expansionhub/ExpansionHub.java b/wpilibj/src/main/java/org/wpilib/hardware/expansionhub/ExpansionHub.java
index 61605096c35..be1115ad48b 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/expansionhub/ExpansionHub.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/expansionhub/ExpansionHub.java
@@ -13,16 +13,16 @@
/** This class controls a REV ExpansionHub plugged in over USB to Systemcore. */
public class ExpansionHub implements AutoCloseable {
private static class DataStore implements AutoCloseable {
- public final int m_usbId;
- private int m_refCount;
- private int m_reservedMotorMask;
- private int m_reservedServoMask;
- private final Object m_reserveLock = new Object();
+ final int usbId;
+ int refCount;
+ int reservedMotorMask;
+ int reservedServoMask;
+ final Object reserveLock = new Object();
private final BooleanSubscriber m_hubConnectedSubscriber;
DataStore(int usbId) {
- m_usbId = usbId;
+ this.usbId = usbId;
m_storeMap[usbId] = this;
NetworkTableInstance systemServer = SystemServer.getSystemServer();
@@ -43,16 +43,16 @@ private static class DataStore implements AutoCloseable {
@Override
public void close() {
- m_storeMap[m_usbId] = null;
+ m_storeMap[usbId] = null;
}
- public void addRef() {
- m_refCount++;
+ void addRef() {
+ refCount++;
}
- public void removeRef() {
- m_refCount--;
- if (m_refCount == 0) {
+ void removeRef() {
+ refCount--;
+ if (refCount == 0) {
this.close();
}
}
@@ -113,19 +113,19 @@ boolean checkServoChannel(int channel) {
boolean checkAndReserveServo(int channel) {
int mask = 1 << channel;
- synchronized (m_dataStore.m_reserveLock) {
- if ((m_dataStore.m_reservedServoMask & mask) != 0) {
+ synchronized (m_dataStore.reserveLock) {
+ if ((m_dataStore.reservedServoMask & mask) != 0) {
return false;
}
- m_dataStore.m_reservedServoMask |= mask;
+ m_dataStore.reservedServoMask |= mask;
return true;
}
}
void unreserveServo(int channel) {
int mask = 1 << channel;
- synchronized (m_dataStore.m_reserveLock) {
- m_dataStore.m_reservedServoMask &= ~mask;
+ synchronized (m_dataStore.reserveLock) {
+ m_dataStore.reservedServoMask &= ~mask;
}
}
@@ -135,24 +135,24 @@ boolean checkMotorChannel(int channel) {
boolean checkAndReserveMotor(int channel) {
int mask = 1 << channel;
- synchronized (m_dataStore.m_reserveLock) {
- if ((m_dataStore.m_reservedMotorMask & mask) != 0) {
+ synchronized (m_dataStore.reserveLock) {
+ if ((m_dataStore.reservedMotorMask & mask) != 0) {
return false;
}
- m_dataStore.m_reservedMotorMask |= mask;
+ m_dataStore.reservedMotorMask |= mask;
return true;
}
}
void unreserveMotor(int channel) {
int mask = 1 << channel;
- synchronized (m_dataStore.m_reserveLock) {
- m_dataStore.m_reservedMotorMask &= ~mask;
+ synchronized (m_dataStore.reserveLock) {
+ m_dataStore.reservedMotorMask &= ~mask;
}
}
void reportUsage(String device, String data) {
- HAL.reportUsage("ExpansionHub[" + m_dataStore.m_usbId + "]/" + device, data);
+ HAL.reportUsage("ExpansionHub[" + m_dataStore.usbId + "]/" + device, data);
}
/**
@@ -164,7 +164,7 @@ void reportUsage(String device, String data) {
* @return Servo object
*/
public ExpansionHubServo makeServo(int channel) {
- return new ExpansionHubServo(m_dataStore.m_usbId, channel);
+ return new ExpansionHubServo(m_dataStore.usbId, channel);
}
/**
@@ -176,7 +176,7 @@ public ExpansionHubServo makeServo(int channel) {
* @return Motor object
*/
public ExpansionHubMotor makeMotor(int channel) {
- return new ExpansionHubMotor(m_dataStore.m_usbId, channel);
+ return new ExpansionHubMotor(m_dataStore.usbId, channel);
}
/**
@@ -194,6 +194,6 @@ public boolean isHubConnected() {
* @return The USB ID
*/
public int getUsbId() {
- return m_dataStore.m_usbId;
+ return m_dataStore.usbId;
}
}
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLED.java b/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLED.java
index 3d9d89acf5d..381ceec3399 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLED.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLED.java
@@ -144,11 +144,7 @@ public void setLength(int length) {
*/
public void setData(AddressableLEDBuffer buffer) {
AddressableLEDJNI.setData(
- m_start,
- m_colorOrder.value,
- buffer.m_buffer,
- 0,
- 3 * Math.min(m_length, buffer.getLength()));
+ m_start, m_colorOrder.value, buffer.buffer, 0, 3 * Math.min(m_length, buffer.getLength()));
}
/**
@@ -159,6 +155,6 @@ public void setData(AddressableLEDBuffer buffer) {
* @param buffer the buffer to write
*/
public static void setGlobalData(int start, ColorOrder colorOrder, AddressableLEDBuffer buffer) {
- AddressableLEDJNI.setData(start, colorOrder.value, buffer.m_buffer);
+ AddressableLEDJNI.setData(start, colorOrder.value, buffer.buffer);
}
}
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLEDBuffer.java b/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLEDBuffer.java
index 641e10b7cce..dfd1c9c6048 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLEDBuffer.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/led/AddressableLEDBuffer.java
@@ -6,7 +6,7 @@
/** Buffer storage for Addressable LEDs. */
public class AddressableLEDBuffer implements LEDReader, LEDWriter {
- byte[] m_buffer;
+ byte[] buffer;
/**
* Constructs a new LED buffer with the specified length.
@@ -14,7 +14,7 @@ public class AddressableLEDBuffer implements LEDReader, LEDWriter {
* @param length The length of the buffer in pixels
*/
public AddressableLEDBuffer(int length) {
- m_buffer = new byte[length * 3];
+ buffer = new byte[length * 3];
}
/**
@@ -27,9 +27,9 @@ public AddressableLEDBuffer(int length) {
*/
@Override
public void setRGB(int index, int r, int g, int b) {
- m_buffer[index * 3] = (byte) r;
- m_buffer[(index * 3) + 1] = (byte) g;
- m_buffer[(index * 3) + 2] = (byte) b;
+ buffer[index * 3] = (byte) r;
+ buffer[(index * 3) + 1] = (byte) g;
+ buffer[(index * 3) + 2] = (byte) b;
}
/**
@@ -39,7 +39,7 @@ public void setRGB(int index, int r, int g, int b) {
*/
@Override
public int getLength() {
- return m_buffer.length / 3;
+ return buffer.length / 3;
}
/**
@@ -50,7 +50,7 @@ public int getLength() {
*/
@Override
public int getRed(int index) {
- return m_buffer[index * 3] & 0xFF;
+ return buffer[index * 3] & 0xFF;
}
/**
@@ -61,7 +61,7 @@ public int getRed(int index) {
*/
@Override
public int getGreen(int index) {
- return m_buffer[index * 3 + 1] & 0xFF;
+ return buffer[index * 3 + 1] & 0xFF;
}
/**
@@ -72,7 +72,7 @@ public int getGreen(int index) {
*/
@Override
public int getBlue(int index) {
- return m_buffer[index * 3 + 2] & 0xFF;
+ return buffer[index * 3 + 2] & 0xFF;
}
/**
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticHub.java b/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticHub.java
index 35e5e4a12b2..3224d95771e 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticHub.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticHub.java
@@ -17,22 +17,22 @@
/** Module class for controlling a REV Robotics Pneumatic Hub. */
public class PneumaticHub implements PneumaticsBase {
private static class DataStore implements AutoCloseable {
- public final int m_module;
- public final int m_handle;
- private final int m_busId;
- private int m_refCount;
- private int m_reservedMask;
- private boolean m_compressorReserved;
- public final int[] m_oneShotDurMs = new int[PortsJNI.getNumREVPHChannels()];
- private final Object m_reserveLock = new Object();
+ final int module;
+ final int handle;
+ final int busId;
+ int refCount;
+ int reservedMask;
+ boolean compressorReserved;
+ final int[] oneShotDurMs = new int[PortsJNI.getNumREVPHChannels()];
+ final Object reserveLock = new Object();
DataStore(int busId, int module) {
- m_handle = REVPHJNI.initialize(busId, module);
- m_module = module;
- m_busId = busId;
+ handle = REVPHJNI.initialize(busId, module);
+ this.module = module;
+ this.busId = busId;
m_handleMaps[busId].put(module, this);
- final REVPHVersion version = REVPHJNI.getVersion(m_handle);
+ final REVPHVersion version = REVPHJNI.getVersion(handle);
final String fwVersion =
version.firmwareMajor + "." + version.firmwareMinor + "." + version.firmwareFix;
@@ -48,17 +48,17 @@ private static class DataStore implements AutoCloseable {
@Override
public void close() {
- REVPHJNI.free(m_handle);
- m_handleMaps[m_busId].remove(m_module);
+ REVPHJNI.free(handle);
+ m_handleMaps[busId].remove(module);
}
- public void addRef() {
- m_refCount++;
+ void addRef() {
+ refCount++;
}
- public void removeRef() {
- m_refCount--;
- if (m_refCount == 0) {
+ void removeRef() {
+ refCount--;
+ if (refCount == 0) {
this.close();
}
}
@@ -123,7 +123,7 @@ public PneumaticHub(int busId) {
*/
public PneumaticHub(int busId, int module) {
m_dataStore = getForModule(busId, module);
- m_handle = m_dataStore.m_handle;
+ m_handle = m_dataStore.handle;
}
@Override
@@ -163,17 +163,17 @@ public int getSolenoids() {
@Override
public int getModuleNumber() {
- return m_dataStore.m_module;
+ return m_dataStore.module;
}
@Override
public void fireOneShot(int index) {
- REVPHJNI.fireOneShot(m_handle, index, m_dataStore.m_oneShotDurMs[index]);
+ REVPHJNI.fireOneShot(m_handle, index, m_dataStore.oneShotDurMs[index]);
}
@Override
public void setOneShotDuration(int index, int durMs) {
- m_dataStore.m_oneShotDurMs[index] = durMs;
+ m_dataStore.oneShotDurMs[index] = durMs;
}
@Override
@@ -183,53 +183,53 @@ public boolean checkSolenoidChannel(int channel) {
@Override
public int checkAndReserveSolenoids(int mask) {
- synchronized (m_dataStore.m_reserveLock) {
- if ((m_dataStore.m_reservedMask & mask) != 0) {
- return m_dataStore.m_reservedMask & mask;
+ synchronized (m_dataStore.reserveLock) {
+ if ((m_dataStore.reservedMask & mask) != 0) {
+ return m_dataStore.reservedMask & mask;
}
- m_dataStore.m_reservedMask |= mask;
+ m_dataStore.reservedMask |= mask;
return 0;
}
}
@Override
public void unreserveSolenoids(int mask) {
- synchronized (m_dataStore.m_reserveLock) {
- m_dataStore.m_reservedMask &= ~mask;
+ synchronized (m_dataStore.reserveLock) {
+ m_dataStore.reservedMask &= ~mask;
}
}
@Override
public Solenoid makeSolenoid(int channel) {
- return new Solenoid(m_dataStore.m_module, PneumaticsModuleType.REV_PH, channel);
+ return new Solenoid(m_dataStore.module, PneumaticsModuleType.REV_PH, channel);
}
@Override
public DoubleSolenoid makeDoubleSolenoid(int forwardChannel, int reverseChannel) {
return new DoubleSolenoid(
- m_dataStore.m_module, PneumaticsModuleType.REV_PH, forwardChannel, reverseChannel);
+ m_dataStore.module, PneumaticsModuleType.REV_PH, forwardChannel, reverseChannel);
}
@Override
public Compressor makeCompressor() {
- return new Compressor(m_dataStore.m_module, PneumaticsModuleType.REV_PH);
+ return new Compressor(m_dataStore.module, PneumaticsModuleType.REV_PH);
}
@Override
public boolean reserveCompressor() {
- synchronized (m_dataStore.m_reserveLock) {
- if (m_dataStore.m_compressorReserved) {
+ synchronized (m_dataStore.reserveLock) {
+ if (m_dataStore.compressorReserved) {
return false;
}
- m_dataStore.m_compressorReserved = true;
+ m_dataStore.compressorReserved = true;
return true;
}
}
@Override
public void unreserveCompressor() {
- synchronized (m_dataStore.m_reserveLock) {
- m_dataStore.m_compressorReserved = false;
+ synchronized (m_dataStore.reserveLock) {
+ m_dataStore.compressorReserved = false;
}
}
@@ -428,6 +428,6 @@ public double getSolenoidsVoltage() {
@Override
public void reportUsage(String device, String data) {
- HAL.reportUsage("PH[" + m_dataStore.m_module + "]/" + device, data);
+ HAL.reportUsage("PH[" + m_dataStore.module + "]/" + device, data);
}
}
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticsControlModule.java b/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticsControlModule.java
index da16079f776..a31f7199b53 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticsControlModule.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/pneumatic/PneumaticsControlModule.java
@@ -14,34 +14,34 @@
/** Module class for controlling a Cross The Road Electronics Pneumatics Control Module. */
public class PneumaticsControlModule implements PneumaticsBase {
private static class DataStore implements AutoCloseable {
- public final int m_module;
- public final int m_handle;
- private final int m_busId;
- private int m_refCount;
- private int m_reservedMask;
- private boolean m_compressorReserved;
- private final Object m_reserveLock = new Object();
+ final int module;
+ final int handle;
+ final int busId;
+ int refCount;
+ int reservedMask;
+ boolean compressorReserved;
+ final Object reserveLock = new Object();
DataStore(int busId, int module) {
- m_handle = CTREPCMJNI.initialize(busId, module);
- m_module = module;
- m_busId = busId;
+ handle = CTREPCMJNI.initialize(busId, module);
+ this.module = module;
+ this.busId = busId;
m_handleMaps[busId].put(module, this);
}
@Override
public void close() {
- CTREPCMJNI.free(m_handle);
- m_handleMaps[m_busId].remove(m_module);
+ CTREPCMJNI.free(handle);
+ m_handleMaps[busId].remove(module);
}
- public void addRef() {
- m_refCount++;
+ void addRef() {
+ refCount++;
}
- public void removeRef() {
- m_refCount--;
- if (m_refCount == 0) {
+ void removeRef() {
+ refCount--;
+ if (refCount == 0) {
this.close();
}
}
@@ -96,7 +96,7 @@ public PneumaticsControlModule(int busId) {
*/
public PneumaticsControlModule(int busId, int module) {
m_dataStore = getForModule(busId, module);
- m_handle = m_dataStore.m_handle;
+ m_handle = m_dataStore.handle;
}
@Override
@@ -196,7 +196,7 @@ public int getSolenoids() {
@Override
public int getModuleNumber() {
- return m_dataStore.m_module;
+ return m_dataStore.module;
}
@Override
@@ -247,53 +247,53 @@ public boolean checkSolenoidChannel(int channel) {
@Override
public int checkAndReserveSolenoids(int mask) {
- synchronized (m_dataStore.m_reserveLock) {
- if ((m_dataStore.m_reservedMask & mask) != 0) {
- return m_dataStore.m_reservedMask & mask;
+ synchronized (m_dataStore.reserveLock) {
+ if ((m_dataStore.reservedMask & mask) != 0) {
+ return m_dataStore.reservedMask & mask;
}
- m_dataStore.m_reservedMask |= mask;
+ m_dataStore.reservedMask |= mask;
return 0;
}
}
@Override
public void unreserveSolenoids(int mask) {
- synchronized (m_dataStore.m_reserveLock) {
- m_dataStore.m_reservedMask &= ~mask;
+ synchronized (m_dataStore.reserveLock) {
+ m_dataStore.reservedMask &= ~mask;
}
}
@Override
public Solenoid makeSolenoid(int channel) {
- return new Solenoid(m_dataStore.m_module, PneumaticsModuleType.CTRE_PCM, channel);
+ return new Solenoid(m_dataStore.module, PneumaticsModuleType.CTRE_PCM, channel);
}
@Override
public DoubleSolenoid makeDoubleSolenoid(int forwardChannel, int reverseChannel) {
return new DoubleSolenoid(
- m_dataStore.m_module, PneumaticsModuleType.CTRE_PCM, forwardChannel, reverseChannel);
+ m_dataStore.module, PneumaticsModuleType.CTRE_PCM, forwardChannel, reverseChannel);
}
@Override
public Compressor makeCompressor() {
- return new Compressor(m_dataStore.m_module, PneumaticsModuleType.CTRE_PCM);
+ return new Compressor(m_dataStore.module, PneumaticsModuleType.CTRE_PCM);
}
@Override
public boolean reserveCompressor() {
- synchronized (m_dataStore.m_reserveLock) {
- if (m_dataStore.m_compressorReserved) {
+ synchronized (m_dataStore.reserveLock) {
+ if (m_dataStore.compressorReserved) {
return false;
}
- m_dataStore.m_compressorReserved = true;
+ m_dataStore.compressorReserved = true;
return true;
}
}
@Override
public void unreserveCompressor() {
- synchronized (m_dataStore.m_reserveLock) {
- m_dataStore.m_compressorReserved = false;
+ synchronized (m_dataStore.reserveLock) {
+ m_dataStore.compressorReserved = false;
}
}
@@ -366,6 +366,6 @@ public double getPressure(int channel) {
@Override
public void reportUsage(String device, String data) {
- HAL.reportUsage("PCM[" + m_dataStore.m_module + "]/" + device, data);
+ HAL.reportUsage("PCM[" + m_dataStore.module + "]/" + device, data);
}
}
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/range/SharpIR.java b/wpilibj/src/main/java/org/wpilib/hardware/range/SharpIR.java
index 261446caaa8..1f5b0c4efb2 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/range/SharpIR.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/range/SharpIR.java
@@ -27,8 +27,12 @@ public class SharpIR implements Sendable, AutoCloseable {
private SimDevice m_simDevice;
private SimDouble m_simRange;
+ @SuppressWarnings("PMD.InternalFieldNamingConvention")
private final double m_A;
+
+ @SuppressWarnings("PMD.InternalFieldNamingConvention")
private final double m_B;
+
private final double m_min; // m
private final double m_max; // m
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/rotation/DutyCycle.java b/wpilibj/src/main/java/org/wpilib/hardware/rotation/DutyCycle.java
index 69815d09a71..80422a941d1 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/rotation/DutyCycle.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/rotation/DutyCycle.java
@@ -17,8 +17,7 @@
* These can be attached to any SmartIO.
*/
public class DutyCycle implements Sendable, AutoCloseable {
- // Explicitly package private
- final int m_handle;
+ private final int m_handle;
private final int m_channel;
/**
diff --git a/wpilibj/src/main/java/org/wpilib/hardware/rotation/Encoder.java b/wpilibj/src/main/java/org/wpilib/hardware/rotation/Encoder.java
index 1d9da0f531c..2a23e5448fa 100644
--- a/wpilibj/src/main/java/org/wpilib/hardware/rotation/Encoder.java
+++ b/wpilibj/src/main/java/org/wpilib/hardware/rotation/Encoder.java
@@ -30,7 +30,7 @@
public class Encoder implements CounterBase, Sendable, AutoCloseable {
private final EncodingType m_encodingType;
- int m_encoder; // the HAL encoder object
+ private int m_encoder; // the HAL encoder object
/**
* Common initialization code for Encoders. This code allocates resources for Encoders and is
diff --git a/wpilibj/src/main/java/org/wpilib/internal/PeriodicPriorityQueue.java b/wpilibj/src/main/java/org/wpilib/internal/PeriodicPriorityQueue.java
index 2d4eeca958b..389117d3e9e 100644
--- a/wpilibj/src/main/java/org/wpilib/internal/PeriodicPriorityQueue.java
+++ b/wpilibj/src/main/java/org/wpilib/internal/PeriodicPriorityQueue.java
@@ -109,7 +109,7 @@ public void addAll(Collection callbacks) {
* @param func The function whose callbacks should be removed.
*/
public void remove(Runnable func) {
- m_queue.removeIf(callback -> callback.m_func.equals(func));
+ m_queue.removeIf(callback -> callback.func.equals(func));
}
/**
@@ -163,7 +163,7 @@ public boolean runCallbacks(int notifier) {
"No callbacks to run! Did you make sure to call add() first?");
}
- NotifierJNI.setNotifierAlarm(notifier, callback.m_expirationTime, 0, true, true);
+ NotifierJNI.setNotifierAlarm(notifier, callback.expirationTime, 0, true, true);
try {
WPIUtilJNI.waitForObject(notifier);
@@ -173,30 +173,28 @@ public boolean runCallbacks(int notifier) {
m_loopStartTimeMicros = RobotController.getMonotonicTime();
- callback.m_func.run();
+ callback.func.run();
// Increment the expiration time by the number of full periods it's behind
// plus one to avoid rapid repeat fires from a large loop overrun. We
// assume m_loopStartTime ≥ expirationTime rather than checking for it since
// the callback wouldn't be running otherwise.
- callback.m_expirationTime +=
- callback.m_period
- + (m_loopStartTimeMicros - callback.m_expirationTime)
- / callback.m_period
- * callback.m_period;
+ callback.expirationTime +=
+ callback.period
+ + (m_loopStartTimeMicros - callback.expirationTime) / callback.period * callback.period;
m_queue.add(callback);
// Process all other callbacks that are ready to run
- while (m_queue.peek().m_expirationTime <= m_loopStartTimeMicros) {
+ while (m_queue.peek().expirationTime <= m_loopStartTimeMicros) {
callback = m_queue.poll();
- callback.m_func.run();
+ callback.func.run();
- callback.m_expirationTime +=
- callback.m_period
- + (m_loopStartTimeMicros - callback.m_expirationTime)
- / callback.m_period
- * callback.m_period;
+ callback.expirationTime +=
+ callback.period
+ + (m_loopStartTimeMicros - callback.expirationTime)
+ / callback.period
+ * callback.period;
m_queue.add(callback);
}
@@ -223,13 +221,13 @@ public long getLoopStartTime() {
*/
public static class Callback implements Comparable {
/** The function to execute when the callback fires. */
- public final Runnable m_func;
+ public final Runnable func;
/** The period at which to run the callback in microseconds. */
- public final long m_period;
+ public final long period;
/** The next scheduled execution time in monotonic timestamp microseconds. */
- public long m_expirationTime;
+ public long expirationTime;
/**
* Construct a callback container.
@@ -240,13 +238,13 @@ public static class Callback implements Comparable {
* @param offset The offset from the common starting time in microseconds.
*/
public Callback(Runnable func, long startTime, long period, long offset) {
- this.m_func = func;
- this.m_period = period;
- this.m_expirationTime =
+ this.func = func;
+ this.period = period;
+ this.expirationTime =
startTime
+ offset
- + (1 + (RobotController.getMonotonicTime() - startTime - offset) / this.m_period)
- * this.m_period;
+ + (1 + (RobotController.getMonotonicTime() - startTime - offset) / this.period)
+ * this.period;
}
/**
@@ -280,7 +278,7 @@ public Callback(Runnable func, long timestamp, double periodSeconds) {
*/
@Override
public boolean equals(Object rhs) {
- return rhs instanceof Callback callback && m_expirationTime == callback.m_expirationTime;
+ return rhs instanceof Callback callback && expirationTime == callback.expirationTime;
}
/**
@@ -290,7 +288,7 @@ public boolean equals(Object rhs) {
*/
@Override
public int hashCode() {
- return Long.hashCode(m_expirationTime);
+ return Long.hashCode(expirationTime);
}
/**
@@ -306,7 +304,7 @@ public int hashCode() {
public int compareTo(Callback rhs) {
// Elements with sooner expiration times are sorted as lesser. The head of
// Java's PriorityQueue is the least element.
- return Long.compare(m_expirationTime, rhs.m_expirationTime);
+ return Long.compare(expirationTime, rhs.expirationTime);
}
}
}
diff --git a/wpilibj/src/main/java/org/wpilib/simulation/AlertSim.java b/wpilibj/src/main/java/org/wpilib/simulation/AlertSim.java
index b3eee54011a..f31ce4ed1cf 100644
--- a/wpilibj/src/main/java/org/wpilib/simulation/AlertSim.java
+++ b/wpilibj/src/main/java/org/wpilib/simulation/AlertSim.java
@@ -31,23 +31,18 @@ public static class AlertInfo {
}
/** The handle of the alert. */
- @SuppressWarnings("MemberName")
public final int handle;
/** The group of the alert. */
- @SuppressWarnings("MemberName")
public final String group;
/** The text of the alert. */
- @SuppressWarnings("MemberName")
public final String text;
/** The time the alert became active. 0 if not active. */
- @SuppressWarnings("MemberName")
public final long activeStartTime;
/** The level of the alert (HIGH, MEDIUM, or LOW). */
- @SuppressWarnings("MemberName")
public final Level level;
/**
diff --git a/wpilibj/src/main/java/org/wpilib/simulation/DifferentialDrivetrainSim.java b/wpilibj/src/main/java/org/wpilib/simulation/DifferentialDrivetrainSim.java
index a3d3354f3ab..c046928ec9d 100644
--- a/wpilibj/src/main/java/org/wpilib/simulation/DifferentialDrivetrainSim.java
+++ b/wpilibj/src/main/java/org/wpilib/simulation/DifferentialDrivetrainSim.java
@@ -359,7 +359,7 @@ enum State {
LEFT_POSITION(5),
RIGHT_POSITION(6);
- public final int value;
+ final int value;
State(int i) {
this.value = i;
diff --git a/wpilibj/src/main/java/org/wpilib/smartdashboard/Field2d.java b/wpilibj/src/main/java/org/wpilib/smartdashboard/Field2d.java
index 8d0dd609400..3344023a865 100644
--- a/wpilibj/src/main/java/org/wpilib/smartdashboard/Field2d.java
+++ b/wpilibj/src/main/java/org/wpilib/smartdashboard/Field2d.java
@@ -97,7 +97,7 @@ public synchronized Pose2d getRobotPose() {
*/
public synchronized FieldObject2d getObject(String name) {
for (FieldObject2d obj : m_objects) {
- if (obj.m_name.equals(name)) {
+ if (obj.name.equals(name)) {
return obj;
}
}
@@ -105,7 +105,7 @@ public synchronized FieldObject2d getObject(String name) {
m_objects.add(obj);
if (m_table != null) {
synchronized (obj) {
- obj.m_entry = m_table.getDoubleArrayTopic(name).getEntry(new double[] {});
+ obj.entry = m_table.getDoubleArrayTopic(name).getEntry(new double[] {});
}
}
return obj;
@@ -128,7 +128,7 @@ public void initSendable(NTSendableBuilder builder) {
m_table = builder.getTable();
for (FieldObject2d obj : m_objects) {
synchronized (obj) {
- obj.m_entry = m_table.getDoubleArrayTopic(obj.m_name).getEntry(new double[] {});
+ obj.entry = m_table.getDoubleArrayTopic(obj.name).getEntry(new double[] {});
obj.updateEntry(true);
}
}
diff --git a/wpilibj/src/main/java/org/wpilib/smartdashboard/FieldObject2d.java b/wpilibj/src/main/java/org/wpilib/smartdashboard/FieldObject2d.java
index bc0882565ba..10d6aba2271 100644
--- a/wpilibj/src/main/java/org/wpilib/smartdashboard/FieldObject2d.java
+++ b/wpilibj/src/main/java/org/wpilib/smartdashboard/FieldObject2d.java
@@ -24,13 +24,13 @@ public class FieldObject2d implements AutoCloseable {
* @param name name
*/
FieldObject2d(String name) {
- m_name = name;
+ this.name = name;
}
@Override
public void close() {
- if (m_entry != null) {
- m_entry.close();
+ if (entry != null) {
+ entry.close();
}
}
@@ -128,7 +128,7 @@ void updateEntry() {
}
synchronized void updateEntry(boolean setDefault) {
- if (m_entry == null) {
+ if (entry == null) {
return;
}
@@ -143,18 +143,18 @@ synchronized void updateEntry(boolean setDefault) {
}
if (setDefault) {
- m_entry.setDefault(arr);
+ entry.setDefault(arr);
} else {
- m_entry.set(arr);
+ entry.set(arr);
}
}
private synchronized void updateFromEntry() {
- if (m_entry == null) {
+ if (entry == null) {
return;
}
- double[] arr = m_entry.get(null);
+ double[] arr = entry.get(null);
if (arr != null) {
if ((arr.length % 3) != 0) {
return;
@@ -167,7 +167,7 @@ private synchronized void updateFromEntry() {
}
}
- String m_name;
- DoubleArrayEntry m_entry;
+ String name;
+ DoubleArrayEntry entry;
private final List m_poses = new ArrayList<>();
}
diff --git a/wpilibj/src/main/java/org/wpilib/smartdashboard/ListenerExecutor.java b/wpilibj/src/main/java/org/wpilib/smartdashboard/ListenerExecutor.java
index 2d07029549d..b30ce8e387f 100644
--- a/wpilibj/src/main/java/org/wpilib/smartdashboard/ListenerExecutor.java
+++ b/wpilibj/src/main/java/org/wpilib/smartdashboard/ListenerExecutor.java
@@ -29,7 +29,7 @@ public void execute(Runnable task) {
}
/** Runs all posted tasks. Called periodically from main thread. */
- public void runListenerTasks() {
+ void runListenerTasks() {
// Locally copy tasks from internal list; minimizes blocking time
Collection tasks;
synchronized (m_lock) {
diff --git a/wpilibj/src/main/java/org/wpilib/smartdashboard/SendableBuilderImpl.java b/wpilibj/src/main/java/org/wpilib/smartdashboard/SendableBuilderImpl.java
index 5080e9b7204..87a52e31cec 100644
--- a/wpilibj/src/main/java/org/wpilib/smartdashboard/SendableBuilderImpl.java
+++ b/wpilibj/src/main/java/org/wpilib/smartdashboard/SendableBuilderImpl.java
@@ -64,6 +64,7 @@ private interface TimedConsumer {
void accept(T value, long time);
}
+ @SuppressWarnings("PMD.PublicFieldNamingConvention")
private static final class Property
implements AutoCloseable {
@Override
diff --git a/wpilibj/src/main/java/org/wpilib/system/Watchdog.java b/wpilibj/src/main/java/org/wpilib/system/Watchdog.java
index 7aa3f88d3b2..a012bb543a8 100644
--- a/wpilibj/src/main/java/org/wpilib/system/Watchdog.java
+++ b/wpilibj/src/main/java/org/wpilib/system/Watchdog.java
@@ -33,9 +33,9 @@ public class Watchdog implements Closeable, Comparable {
private final Runnable m_callback;
private double m_lastTimeoutPrint; // s
- boolean m_isExpired;
+ private boolean m_isExpired;
- boolean m_suppressTimeoutMessage;
+ private boolean m_suppressTimeoutMessage;
private final Tracer m_tracer;
diff --git a/wpilibj/src/test/java/org/wpilib/event/NetworkBooleanEventTest.java b/wpilibj/src/test/java/org/wpilib/event/NetworkBooleanEventTest.java
index 5ab08a52600..95ff3c470f4 100644
--- a/wpilibj/src/test/java/org/wpilib/event/NetworkBooleanEventTest.java
+++ b/wpilibj/src/test/java/org/wpilib/event/NetworkBooleanEventTest.java
@@ -13,17 +13,17 @@
import org.wpilib.networktables.NetworkTableInstance;
class NetworkBooleanEventTest {
- NetworkTableInstance m_inst;
+ NetworkTableInstance inst;
@BeforeEach
void setup() {
- m_inst = NetworkTableInstance.create();
- m_inst.startLocal();
+ inst = NetworkTableInstance.create();
+ inst.startLocal();
}
@AfterEach
void teardown() {
- m_inst.close();
+ inst.close();
}
@Test
@@ -31,9 +31,9 @@ void testNetworkBooleanEvent() {
var loop = new EventLoop();
var counter = new AtomicInteger(0);
- var pub = m_inst.getTable("TestTable").getBooleanTopic("Test").publish();
+ var pub = inst.getTable("TestTable").getBooleanTopic("Test").publish();
- new NetworkBooleanEvent(loop, m_inst, "TestTable", "Test").ifHigh(counter::incrementAndGet);
+ new NetworkBooleanEvent(loop, inst, "TestTable", "Test").ifHigh(counter::incrementAndGet);
pub.set(false);
loop.poll();
assertEquals(0, counter.get());
diff --git a/wpilibj/src/test/java/org/wpilib/framework/OpModeRobotTest.java b/wpilibj/src/test/java/org/wpilib/framework/OpModeRobotTest.java
index 74c4c5fcf0a..d73afc6da8e 100644
--- a/wpilibj/src/test/java/org/wpilib/framework/OpModeRobotTest.java
+++ b/wpilibj/src/test/java/org/wpilib/framework/OpModeRobotTest.java
@@ -22,41 +22,42 @@
import org.wpilib.util.Color;
@ResourceLock("timing")
+@SuppressWarnings("PMD.PublicMemberInNonPublicType")
class OpModeRobotTest {
static final double kPeriod = 0.02;
public static class MockOpMode implements OpMode {
- public final AtomicInteger m_disabledPeriodicCount = new AtomicInteger(0);
- public final AtomicInteger m_startCount = new AtomicInteger(0);
- public final AtomicInteger m_periodicCount = new AtomicInteger(0);
- public final AtomicInteger m_endCount = new AtomicInteger(0);
- public final AtomicInteger m_closeCount = new AtomicInteger(0);
+ public final AtomicInteger disabledPeriodicCount = new AtomicInteger(0);
+ public final AtomicInteger startCount = new AtomicInteger(0);
+ public final AtomicInteger periodicCount = new AtomicInteger(0);
+ public final AtomicInteger endCount = new AtomicInteger(0);
+ public final AtomicInteger closeCount = new AtomicInteger(0);
MockOpMode() {}
@Override
public void close() {
- m_closeCount.incrementAndGet();
+ closeCount.incrementAndGet();
}
@Override
public void disabledPeriodic() {
- m_disabledPeriodicCount.incrementAndGet();
+ disabledPeriodicCount.incrementAndGet();
}
@Override
public void start() {
- m_startCount.incrementAndGet();
+ startCount.incrementAndGet();
}
@Override
public void periodic() {
- m_periodicCount.incrementAndGet();
+ periodicCount.incrementAndGet();
}
@Override
public void end() {
- m_endCount.incrementAndGet();
+ endCount.incrementAndGet();
}
}
@@ -66,9 +67,9 @@ public static class OneArgOpMode implements OpMode {
}
static class MockRobot extends OpModeRobot {
- public final AtomicInteger m_driverStationConnectedCount = new AtomicInteger(0);
- public final AtomicInteger m_nonePeriodicCount = new AtomicInteger(0);
- public final AtomicInteger m_robotPeriodicCount = new AtomicInteger(0);
+ public final AtomicInteger driverStationConnectedCount = new AtomicInteger(0);
+ public final AtomicInteger nonePeriodicCount = new AtomicInteger(0);
+ public final AtomicInteger robotPeriodicCount = new AtomicInteger(0);
MockRobot() {
super();
@@ -76,17 +77,17 @@ static class MockRobot extends OpModeRobot {
@Override
public void driverStationConnected() {
- m_driverStationConnectedCount.incrementAndGet();
+ driverStationConnectedCount.incrementAndGet();
}
@Override
public void nonePeriodic() {
- m_nonePeriodicCount.incrementAndGet();
+ nonePeriodicCount.incrementAndGet();
}
@Override
public void robotPeriodic() {
- m_robotPeriodicCount.incrementAndGet();
+ robotPeriodicCount.incrementAndGet();
}
}
@@ -243,7 +244,7 @@ class MyMockRobot extends MockRobot {
// Time step to get periodic calls on 20 ms robot loop
SimHooks.stepTiming(0.11); // 110ms
- assertEquals(5, robot.m_nonePeriodicCount.get());
+ assertEquals(5, robot.nonePeriodicCount.get());
robot.endCompetition();
robotThread.join();
@@ -266,15 +267,15 @@ class MyMockRobot extends MockRobot {
SimHooks.waitForProgramStart();
// RobotPeriodic should be called regardless of state
- assertEquals(0, robot.m_robotPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
// Step timing to allow callbacks to execute
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_robotPeriodicCount.get());
+ assertEquals(1, robot.robotPeriodicCount.get());
// Additional time steps should continue calling robotPeriodic
SimHooks.stepTiming(kPeriod);
- assertEquals(2, robot.m_robotPeriodicCount.get());
+ assertEquals(2, robot.robotPeriodicCount.get());
robot.endCompetition();
robotThread.join();
diff --git a/wpilibj/src/test/java/org/wpilib/framework/TimedRobotTest.java b/wpilibj/src/test/java/org/wpilib/framework/TimedRobotTest.java
index c90e0a83b97..0035f14c49e 100644
--- a/wpilibj/src/test/java/org/wpilib/framework/TimedRobotTest.java
+++ b/wpilibj/src/test/java/org/wpilib/framework/TimedRobotTest.java
@@ -19,23 +19,23 @@ class TimedRobotTest {
static final double kPeriod = 0.02;
static class MockRobot extends TimedRobot {
- public final AtomicInteger m_simulationInitCount = new AtomicInteger(0);
- public final AtomicInteger m_disabledInitCount = new AtomicInteger(0);
- public final AtomicInteger m_autonomousInitCount = new AtomicInteger(0);
- public final AtomicInteger m_teleopInitCount = new AtomicInteger(0);
- public final AtomicInteger m_utilityInitCount = new AtomicInteger(0);
-
- public final AtomicInteger m_robotPeriodicCount = new AtomicInteger(0);
- public final AtomicInteger m_simulationPeriodicCount = new AtomicInteger(0);
- public final AtomicInteger m_disabledPeriodicCount = new AtomicInteger(0);
- public final AtomicInteger m_autonomousPeriodicCount = new AtomicInteger(0);
- public final AtomicInteger m_teleopPeriodicCount = new AtomicInteger(0);
- public final AtomicInteger m_utilityPeriodicCount = new AtomicInteger(0);
-
- public final AtomicInteger m_disabledExitCount = new AtomicInteger(0);
- public final AtomicInteger m_autonomousExitCount = new AtomicInteger(0);
- public final AtomicInteger m_teleopExitCount = new AtomicInteger(0);
- public final AtomicInteger m_utilityExitCount = new AtomicInteger(0);
+ final AtomicInteger simulationInitCount = new AtomicInteger(0);
+ final AtomicInteger disabledInitCount = new AtomicInteger(0);
+ final AtomicInteger autonomousInitCount = new AtomicInteger(0);
+ final AtomicInteger teleopInitCount = new AtomicInteger(0);
+ final AtomicInteger utilityInitCount = new AtomicInteger(0);
+
+ final AtomicInteger robotPeriodicCount = new AtomicInteger(0);
+ final AtomicInteger simulationPeriodicCount = new AtomicInteger(0);
+ final AtomicInteger disabledPeriodicCount = new AtomicInteger(0);
+ final AtomicInteger autonomousPeriodicCount = new AtomicInteger(0);
+ final AtomicInteger teleopPeriodicCount = new AtomicInteger(0);
+ final AtomicInteger utilityPeriodicCount = new AtomicInteger(0);
+
+ final AtomicInteger disabledExitCount = new AtomicInteger(0);
+ final AtomicInteger autonomousExitCount = new AtomicInteger(0);
+ final AtomicInteger teleopExitCount = new AtomicInteger(0);
+ final AtomicInteger utilityExitCount = new AtomicInteger(0);
MockRobot() {
super(kPeriod);
@@ -43,77 +43,77 @@ static class MockRobot extends TimedRobot {
@Override
public void simulationInit() {
- m_simulationInitCount.addAndGet(1);
+ simulationInitCount.addAndGet(1);
}
@Override
public void disabledInit() {
- m_disabledInitCount.addAndGet(1);
+ disabledInitCount.addAndGet(1);
}
@Override
public void autonomousInit() {
- m_autonomousInitCount.addAndGet(1);
+ autonomousInitCount.addAndGet(1);
}
@Override
public void teleopInit() {
- m_teleopInitCount.addAndGet(1);
+ teleopInitCount.addAndGet(1);
}
@Override
public void utilityInit() {
- m_utilityInitCount.addAndGet(1);
+ utilityInitCount.addAndGet(1);
}
@Override
public void robotPeriodic() {
- m_robotPeriodicCount.addAndGet(1);
+ robotPeriodicCount.addAndGet(1);
}
@Override
public void simulationPeriodic() {
- m_simulationPeriodicCount.addAndGet(1);
+ simulationPeriodicCount.addAndGet(1);
}
@Override
public void disabledPeriodic() {
- m_disabledPeriodicCount.addAndGet(1);
+ disabledPeriodicCount.addAndGet(1);
}
@Override
public void autonomousPeriodic() {
- m_autonomousPeriodicCount.addAndGet(1);
+ autonomousPeriodicCount.addAndGet(1);
}
@Override
public void teleopPeriodic() {
- m_teleopPeriodicCount.addAndGet(1);
+ teleopPeriodicCount.addAndGet(1);
}
@Override
public void utilityPeriodic() {
- m_utilityPeriodicCount.addAndGet(1);
+ utilityPeriodicCount.addAndGet(1);
}
@Override
public void disabledExit() {
- m_disabledExitCount.addAndGet(1);
+ disabledExitCount.addAndGet(1);
}
@Override
public void autonomousExit() {
- m_autonomousExitCount.addAndGet(1);
+ autonomousExitCount.addAndGet(1);
}
@Override
public void teleopExit() {
- m_teleopExitCount.addAndGet(1);
+ teleopExitCount.addAndGet(1);
}
@Override
public void utilityExit() {
- m_utilityExitCount.addAndGet(1);
+ utilityExitCount.addAndGet(1);
}
}
@@ -141,63 +141,63 @@ void disabledModeTest() {
DriverStationSim.setEnabled(false);
DriverStationSim.notifyNewData();
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(0, robot.m_robotPeriodicCount.get());
- assertEquals(0, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
+ assertEquals(0, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(1, robot.m_robotPeriodicCount.get());
- assertEquals(1, robot.m_simulationPeriodicCount.get());
- assertEquals(1, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(1, robot.robotPeriodicCount.get());
+ assertEquals(1, robot.simulationPeriodicCount.get());
+ assertEquals(1, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(2, robot.m_robotPeriodicCount.get());
- assertEquals(2, robot.m_simulationPeriodicCount.get());
- assertEquals(2, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(2, robot.robotPeriodicCount.get());
+ assertEquals(2, robot.simulationPeriodicCount.get());
+ assertEquals(2, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
robot.endCompetition();
try {
@@ -222,63 +222,63 @@ void autonomousModeTest() {
DriverStationSim.setRobotMode(RobotMode.AUTONOMOUS);
DriverStationSim.notifyNewData();
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(0, robot.m_robotPeriodicCount.get());
- assertEquals(0, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
+ assertEquals(0, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(1, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(1, robot.m_robotPeriodicCount.get());
- assertEquals(1, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(1, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(1, robot.robotPeriodicCount.get());
+ assertEquals(1, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(1, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(1, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(2, robot.m_robotPeriodicCount.get());
- assertEquals(2, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(2, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(2, robot.robotPeriodicCount.get());
+ assertEquals(2, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(2, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
robot.endCompetition();
try {
@@ -303,63 +303,63 @@ void teleopModeTest() {
DriverStationSim.setRobotMode(RobotMode.TELEOPERATED);
DriverStationSim.notifyNewData();
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(0, robot.m_robotPeriodicCount.get());
- assertEquals(0, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
+ assertEquals(0, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(1, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(1, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(1, robot.m_robotPeriodicCount.get());
- assertEquals(1, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(1, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(1, robot.robotPeriodicCount.get());
+ assertEquals(1, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(1, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(1, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(1, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(2, robot.m_robotPeriodicCount.get());
- assertEquals(2, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(2, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(2, robot.robotPeriodicCount.get());
+ assertEquals(2, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(2, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
robot.endCompetition();
try {
@@ -384,86 +384,86 @@ void utilityModeTest() {
DriverStationSim.setRobotMode(RobotMode.UTILITY);
DriverStationSim.notifyNewData();
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(0, robot.m_robotPeriodicCount.get());
- assertEquals(0, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(0, robot.m_utilityPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
+ assertEquals(0, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(0, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(1, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(1, robot.utilityInitCount.get());
- assertEquals(1, robot.m_robotPeriodicCount.get());
- assertEquals(1, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(1, robot.m_utilityPeriodicCount.get());
+ assertEquals(1, robot.robotPeriodicCount.get());
+ assertEquals(1, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(1, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(1, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(1, robot.utilityInitCount.get());
- assertEquals(2, robot.m_robotPeriodicCount.get());
- assertEquals(2, robot.m_simulationPeriodicCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(2, robot.m_utilityPeriodicCount.get());
+ assertEquals(2, robot.robotPeriodicCount.get());
+ assertEquals(2, robot.simulationPeriodicCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(2, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
DriverStationSim.setEnabled(false);
DriverStationSim.notifyNewData();
SimHooks.stepTiming(0.02);
- assertEquals(1, robot.m_simulationInitCount.get());
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(1, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.simulationInitCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(1, robot.utilityInitCount.get());
- assertEquals(3, robot.m_robotPeriodicCount.get());
- assertEquals(3, robot.m_simulationPeriodicCount.get());
- assertEquals(1, robot.m_disabledPeriodicCount.get());
- assertEquals(0, robot.m_autonomousPeriodicCount.get());
- assertEquals(0, robot.m_teleopPeriodicCount.get());
- assertEquals(2, robot.m_utilityPeriodicCount.get());
+ assertEquals(3, robot.robotPeriodicCount.get());
+ assertEquals(3, robot.simulationPeriodicCount.get());
+ assertEquals(1, robot.disabledPeriodicCount.get());
+ assertEquals(0, robot.autonomousPeriodicCount.get());
+ assertEquals(0, robot.teleopPeriodicCount.get());
+ assertEquals(2, robot.utilityPeriodicCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(1, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(1, robot.utilityExitCount.get());
robot.endCompetition();
try {
@@ -488,27 +488,27 @@ void modeChangeTest() {
DriverStationSim.setEnabled(false);
DriverStationSim.notifyNewData();
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(0, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(0, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(0, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
// Transition to autonomous
DriverStationSim.setEnabled(true);
@@ -517,15 +517,15 @@ void modeChangeTest() {
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_autonomousInitCount.get());
- assertEquals(0, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(1, robot.autonomousInitCount.get());
+ assertEquals(0, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(1, robot.m_disabledExitCount.get());
- assertEquals(0, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(1, robot.disabledExitCount.get());
+ assertEquals(0, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
// Transition to teleop
DriverStationSim.setEnabled(true);
@@ -534,15 +534,15 @@ void modeChangeTest() {
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_autonomousInitCount.get());
- assertEquals(1, robot.m_teleopInitCount.get());
- assertEquals(0, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(1, robot.autonomousInitCount.get());
+ assertEquals(1, robot.teleopInitCount.get());
+ assertEquals(0, robot.utilityInitCount.get());
- assertEquals(1, robot.m_disabledExitCount.get());
- assertEquals(1, robot.m_autonomousExitCount.get());
- assertEquals(0, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(1, robot.disabledExitCount.get());
+ assertEquals(1, robot.autonomousExitCount.get());
+ assertEquals(0, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
// Transition to utility
DriverStationSim.setEnabled(true);
@@ -551,15 +551,15 @@ void modeChangeTest() {
SimHooks.stepTiming(kPeriod);
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_autonomousInitCount.get());
- assertEquals(1, robot.m_teleopInitCount.get());
- assertEquals(1, robot.m_utilityInitCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(1, robot.autonomousInitCount.get());
+ assertEquals(1, robot.teleopInitCount.get());
+ assertEquals(1, robot.utilityInitCount.get());
- assertEquals(1, robot.m_disabledExitCount.get());
- assertEquals(1, robot.m_autonomousExitCount.get());
- assertEquals(1, robot.m_teleopExitCount.get());
- assertEquals(0, robot.m_utilityExitCount.get());
+ assertEquals(1, robot.disabledExitCount.get());
+ assertEquals(1, robot.autonomousExitCount.get());
+ assertEquals(1, robot.teleopExitCount.get());
+ assertEquals(0, robot.utilityExitCount.get());
// Transition to disabled
DriverStationSim.setEnabled(false);
@@ -567,15 +567,15 @@ void modeChangeTest() {
SimHooks.stepTiming(kPeriod);
- assertEquals(2, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_autonomousInitCount.get());
- assertEquals(1, robot.m_teleopInitCount.get());
- assertEquals(1, robot.m_utilityInitCount.get());
+ assertEquals(2, robot.disabledInitCount.get());
+ assertEquals(1, robot.autonomousInitCount.get());
+ assertEquals(1, robot.teleopInitCount.get());
+ assertEquals(1, robot.utilityInitCount.get());
- assertEquals(1, robot.m_disabledExitCount.get());
- assertEquals(1, robot.m_autonomousExitCount.get());
- assertEquals(1, robot.m_teleopExitCount.get());
- assertEquals(1, robot.m_utilityExitCount.get());
+ assertEquals(1, robot.disabledExitCount.get());
+ assertEquals(1, robot.autonomousExitCount.get());
+ assertEquals(1, robot.teleopExitCount.get());
+ assertEquals(1, robot.utilityExitCount.get());
robot.endCompetition();
try {
@@ -602,20 +602,20 @@ void addPeriodicTest() {
DriverStationSim.setEnabled(false);
DriverStationSim.notifyNewData();
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
assertEquals(0, callbackCount.get());
SimHooks.stepTiming(kPeriod / 2.0);
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
assertEquals(1, callbackCount.get());
SimHooks.stepTiming(kPeriod / 2.0);
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_disabledPeriodicCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(1, robot.disabledPeriodicCount.get());
assertEquals(2, callbackCount.get());
robot.endCompetition();
@@ -652,32 +652,32 @@ void addPeriodicWithOffsetTest() {
DriverStationSim.setEnabled(false);
DriverStationSim.notifyNewData();
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
assertEquals(0, callbackCount.get());
SimHooks.stepTiming(kPeriod * 3.0 / 8.0);
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
assertEquals(0, callbackCount.get());
SimHooks.stepTiming(kPeriod * 3.0 / 8.0);
- assertEquals(0, robot.m_disabledInitCount.get());
- assertEquals(0, robot.m_disabledPeriodicCount.get());
+ assertEquals(0, robot.disabledInitCount.get());
+ assertEquals(0, robot.disabledPeriodicCount.get());
assertEquals(1, callbackCount.get());
SimHooks.stepTiming(kPeriod / 4.0);
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_disabledPeriodicCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(1, robot.disabledPeriodicCount.get());
assertEquals(1, callbackCount.get());
SimHooks.stepTiming(kPeriod / 4.0);
- assertEquals(1, robot.m_disabledInitCount.get());
- assertEquals(1, robot.m_disabledPeriodicCount.get());
+ assertEquals(1, robot.disabledInitCount.get());
+ assertEquals(1, robot.disabledPeriodicCount.get());
assertEquals(2, callbackCount.get());
robot.endCompetition();
diff --git a/wpilibj/src/test/java/org/wpilib/framework/TimesliceRobotTest.java b/wpilibj/src/test/java/org/wpilib/framework/TimesliceRobotTest.java
index 17fcdbafde3..20ac0f4c4a4 100644
--- a/wpilibj/src/test/java/org/wpilib/framework/TimesliceRobotTest.java
+++ b/wpilibj/src/test/java/org/wpilib/framework/TimesliceRobotTest.java
@@ -17,7 +17,7 @@
class TimesliceRobotTest {
static class MockRobot extends TimesliceRobot {
- public final AtomicInteger m_robotPeriodicCount = new AtomicInteger(0);
+ final AtomicInteger robotPeriodicCount = new AtomicInteger(0);
MockRobot() {
super(0.002, 0.005);
@@ -25,7 +25,7 @@ static class MockRobot extends TimesliceRobot {
@Override
public void robotPeriodic() {
- m_robotPeriodicCount.addAndGet(1);
+ robotPeriodicCount.addAndGet(1);
}
}
@@ -70,25 +70,25 @@ void scheduleTest() {
// robotPeriodic()).
SimHooks.stepTiming(0.005);
- assertEquals(0, robot.m_robotPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
assertEquals(0, callbackCount1.get());
assertEquals(0, callbackCount2.get());
// Step to 1.5 ms
SimHooks.stepTiming(0.0015);
- assertEquals(0, robot.m_robotPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
assertEquals(0, callbackCount1.get());
assertEquals(0, callbackCount2.get());
// Step to 2.25 ms
SimHooks.stepTiming(0.00075);
- assertEquals(0, robot.m_robotPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
assertEquals(1, callbackCount1.get());
assertEquals(0, callbackCount2.get());
// Step to 2.75 ms
SimHooks.stepTiming(0.0005);
- assertEquals(0, robot.m_robotPeriodicCount.get());
+ assertEquals(0, robot.robotPeriodicCount.get());
assertEquals(1, callbackCount1.get());
assertEquals(1, callbackCount2.get());
diff --git a/wpilibj/src/test/java/org/wpilib/hardware/led/AddressableLEDBufferTest.java b/wpilibj/src/test/java/org/wpilib/hardware/led/AddressableLEDBufferTest.java
index 101b261db34..cacf90b06f3 100644
--- a/wpilibj/src/test/java/org/wpilib/hardware/led/AddressableLEDBufferTest.java
+++ b/wpilibj/src/test/java/org/wpilib/hardware/led/AddressableLEDBufferTest.java
@@ -24,9 +24,9 @@ void hsvConvertTest(int h, int s, int v, int r, int g, int b) {
var buffer = new AddressableLEDBuffer(1);
buffer.setHSV(0, h, s, v);
assertAll(
- () -> assertEquals((byte) r, buffer.m_buffer[0], "R value didn't match"),
- () -> assertEquals((byte) g, buffer.m_buffer[1], "G value didn't match"),
- () -> assertEquals((byte) b, buffer.m_buffer[2], "B value didn't match"));
+ () -> assertEquals((byte) r, buffer.buffer[0], "R value didn't match"),
+ () -> assertEquals((byte) g, buffer.buffer[1], "G value didn't match"),
+ () -> assertEquals((byte) b, buffer.buffer[2], "B value didn't match"));
}
static Stream hsvToRgbProvider() {
diff --git a/wpilibj/src/test/java/org/wpilib/hardware/led/LEDPatternTest.java b/wpilibj/src/test/java/org/wpilib/hardware/led/LEDPatternTest.java
index b78efe99c59..26cc7591f73 100644
--- a/wpilibj/src/test/java/org/wpilib/hardware/led/LEDPatternTest.java
+++ b/wpilibj/src/test/java/org/wpilib/hardware/led/LEDPatternTest.java
@@ -39,10 +39,10 @@
import org.wpilib.util.Color8Bit;
class LEDPatternTest {
- long m_mockTime;
+ long mockTime;
// Applies a pattern of White, Yellow, Purple to LED triplets
- LEDPattern m_whiteYellowPurple =
+ LEDPattern whiteYellowPurple =
(reader, writer) -> {
for (int led = 0; led < reader.getLength(); led++) {
switch (led % 3) {
@@ -64,8 +64,8 @@ class LEDPatternTest {
@BeforeEach
void setUp() {
- m_mockTime = 0;
- RobotController.setTimeSource(() -> m_mockTime);
+ mockTime = 0;
+ RobotController.setTimeSource(() -> mockTime);
}
@AfterEach
@@ -224,7 +224,7 @@ void scrollForward() {
var scroll = base.scrollAtRelativeVelocity(Value.per(Microsecond).of(1 / 256.0));
for (int time = 0; time < 500; time++) {
- m_mockTime = time;
+ mockTime = time;
scroll.applyTo(buffer);
for (int led = 0; led < buffer.getLength(); led++) {
@@ -258,7 +258,7 @@ void scrollBackward() {
var scroll = base.scrollAtRelativeVelocity(Value.per(Microsecond).of(-1 / 256.0));
for (int time = 0; time < 500; time++) {
- m_mockTime = time;
+ mockTime = time;
scroll.applyTo(buffer);
for (int led = 0; led < buffer.getLength(); led++) {
@@ -294,7 +294,7 @@ void scrollAbsoluteVelocityForward() {
var scroll = base.scrollAtAbsoluteVelocity(MetersPerSecond.of(16), Centimeters.of(2));
for (int time = 0; time < 500; time++) {
- m_mockTime = time * 1_250; // 1.25ms per LED
+ mockTime = time * 1_250; // 1.25ms per LED
scroll.applyTo(buffer);
for (int led = 0; led < buffer.getLength(); led++) {
@@ -330,7 +330,7 @@ void scrollAbsoluteVelocityBackward() {
var scroll = base.scrollAtAbsoluteVelocity(MetersPerSecond.of(-16), Centimeters.of(2));
for (int time = 0; time < 500; time++) {
- m_mockTime = time * 1_250; // 1.25ms per LED
+ mockTime = time * 1_250; // 1.25ms per LED
scroll.applyTo(buffer);
for (int led = 0; led < buffer.getLength(); led++) {
@@ -459,7 +459,7 @@ void offsetPositive() {
var buffer = new AddressableLEDBuffer(21);
// offset repeats PWY
- var offset = m_whiteYellowPurple.offsetBy(1);
+ var offset = whiteYellowPurple.offsetBy(1);
offset.applyTo(buffer);
for (int led = 0; led < buffer.getLength(); led++) {
@@ -486,7 +486,7 @@ void offsetNegative() {
var buffer = new AddressableLEDBuffer(21);
// offset repeats YPW
- var offset = m_whiteYellowPurple.offsetBy(-1);
+ var offset = whiteYellowPurple.offsetBy(-1);
offset.applyTo(buffer);
for (int led = 0; led < buffer.getLength(); led++) {
@@ -513,7 +513,7 @@ void offsetZero() {
var buffer = new AddressableLEDBuffer(21);
// offset copies the base pattern, WYP
- var offset = m_whiteYellowPurple.offsetBy(0);
+ var offset = whiteYellowPurple.offsetBy(0);
offset.applyTo(buffer);
for (int led = 0; led < buffer.getLength(); led++) {
@@ -543,7 +543,7 @@ void blinkSymmetric() {
var buffer = new AddressableLEDBuffer(1);
for (int t = 0; t < 8; t++) {
- m_mockTime = t * 1_000_000L; // time travel 1 second
+ mockTime = t * 1_000_000L; // time travel 1 second
pattern.applyTo(buffer);
Color color = buffer.getLED(0);
@@ -575,7 +575,7 @@ void blinkAsymmetric() {
var buffer = new AddressableLEDBuffer(1);
for (int t = 0; t < 8; t++) {
- m_mockTime = t * 1_000_000L; // time travel 1 second
+ mockTime = t * 1_000_000L; // time travel 1 second
pattern.applyTo(buffer);
Color color = buffer.getLED(0);
@@ -627,31 +627,31 @@ void breathe() {
var buffer = new AddressableLEDBuffer(1);
{
- m_mockTime = 0; // start
+ mockTime = 0; // start
pattern.applyTo(buffer);
assertColorEquals(WHITE, buffer.getLED(0));
}
{
- m_mockTime = 1; // midway (down)
+ mockTime = 1; // midway (down)
pattern.applyTo(buffer);
assertColorEquals(midGray, buffer.getLED(0));
}
{
- m_mockTime = 2; // bottom
+ mockTime = 2; // bottom
pattern.applyTo(buffer);
assertColorEquals(BLACK, buffer.getLED(0));
}
{
- m_mockTime = 3; // midway (up)
+ mockTime = 3; // midway (up)
pattern.applyTo(buffer);
assertColorEquals(midGray, buffer.getLED(0));
}
{
- m_mockTime = 4; // back to start
+ mockTime = 4; // back to start
pattern.applyTo(buffer);
assertColorEquals(WHITE, buffer.getLED(0));
}
@@ -871,7 +871,7 @@ void relativeScrollingMask() {
var buffer = new AddressableLEDBuffer(8);
{
- m_mockTime = 0; // start
+ mockTime = 0; // start
pattern.applyTo(buffer);
assertColorEquals(RED, buffer.getLED(0));
assertColorEquals(RED, buffer.getLED(1));
@@ -884,7 +884,7 @@ void relativeScrollingMask() {
}
{
- m_mockTime = 1;
+ mockTime = 1;
pattern.applyTo(buffer);
assertColorEquals(BLACK, buffer.getLED(0));
assertColorEquals(RED, buffer.getLED(1));
@@ -897,7 +897,7 @@ void relativeScrollingMask() {
}
{
- m_mockTime = 2;
+ mockTime = 2;
pattern.applyTo(buffer);
assertColorEquals(BLACK, buffer.getLED(0));
assertColorEquals(BLACK, buffer.getLED(1));
@@ -910,7 +910,7 @@ void relativeScrollingMask() {
}
{
- m_mockTime = 3;
+ mockTime = 3;
pattern.applyTo(buffer);
assertColorEquals(BLACK, buffer.getLED(0));
assertColorEquals(BLACK, buffer.getLED(1));
@@ -936,7 +936,7 @@ void absoluteScrollingMask() {
var buffer = new AddressableLEDBuffer(8);
{
- m_mockTime = 0; // start
+ mockTime = 0; // start
pattern.applyTo(buffer);
assertColorEquals(RED, buffer.getLED(0));
assertColorEquals(RED, buffer.getLED(1));
@@ -949,7 +949,7 @@ void absoluteScrollingMask() {
}
{
- m_mockTime = 1;
+ mockTime = 1;
pattern.applyTo(buffer);
assertColorEquals(BLACK, buffer.getLED(0));
assertColorEquals(RED, buffer.getLED(1));
@@ -962,7 +962,7 @@ void absoluteScrollingMask() {
}
{
- m_mockTime = 2;
+ mockTime = 2;
pattern.applyTo(buffer);
assertColorEquals(BLACK, buffer.getLED(0));
assertColorEquals(BLACK, buffer.getLED(1));
@@ -975,7 +975,7 @@ void absoluteScrollingMask() {
}
{
- m_mockTime = 3;
+ mockTime = 3;
pattern.applyTo(buffer);
assertColorEquals(BLACK, buffer.getLED(0));
assertColorEquals(BLACK, buffer.getLED(1));
diff --git a/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator.java b/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator.java
index 9e7d659feb4..38be8da77e9 100644
--- a/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator.java
+++ b/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator.java
@@ -421,7 +421,7 @@ private VisionUpdate(Pose2d visionPose, Pose2d odometryPose) {
* @param pose The pose to compensate.
* @return The compensated pose.
*/
- public Pose2d compensate(Pose2d pose) {
+ Pose2d compensate(Pose2d pose) {
var delta = pose.minus(this.odometryPose);
return this.visionPose.plus(delta);
}
diff --git a/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator3d.java b/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator3d.java
index b6482fbb19d..536466640cc 100644
--- a/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator3d.java
+++ b/wpimath/src/main/java/org/wpilib/math/estimator/PoseEstimator3d.java
@@ -436,7 +436,7 @@ private VisionUpdate(Pose3d visionPose, Pose3d odometryPose) {
* @param pose The pose to compensate.
* @return The compensated pose.
*/
- public Pose3d compensate(Pose3d pose) {
+ Pose3d compensate(Pose3d pose) {
var delta = pose.minus(this.odometryPose);
return this.visionPose.plus(delta);
}
diff --git a/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateAxis.java b/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateAxis.java
index 7bddc949e8b..14862933c1f 100644
--- a/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateAxis.java
+++ b/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateAxis.java
@@ -17,7 +17,7 @@ public class CoordinateAxis {
private static final CoordinateAxis m_u = new CoordinateAxis(0.0, 0.0, 1.0);
private static final CoordinateAxis m_d = new CoordinateAxis(0.0, 0.0, -1.0);
- final Vector m_axis;
+ final Vector axis;
/**
* Constructs a coordinate system axis within the NWU coordinate system and normalizes it.
@@ -28,7 +28,7 @@ public class CoordinateAxis {
*/
public CoordinateAxis(double x, double y, double z) {
double norm = Math.sqrt(x * x + y * y + z * z);
- m_axis = VecBuilder.fill(x / norm, y / norm, z / norm);
+ axis = VecBuilder.fill(x / norm, y / norm, z / norm);
}
/**
diff --git a/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateSystem.java b/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateSystem.java
index b5198fe0b50..4e478d2d725 100644
--- a/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateSystem.java
+++ b/wpimath/src/main/java/org/wpilib/math/geometry/CoordinateSystem.java
@@ -34,9 +34,9 @@ public CoordinateSystem(
// NWU coordinate system. Each column vector in the change of basis matrix is
// one of the old basis vectors mapped to its representation in the new basis.
var R = new Matrix<>(Nat.N3(), Nat.N3());
- R.assignBlock(0, 0, positiveX.m_axis);
- R.assignBlock(0, 1, positiveY.m_axis);
- R.assignBlock(0, 2, positiveZ.m_axis);
+ R.assignBlock(0, 0, positiveX.axis);
+ R.assignBlock(0, 1, positiveY.axis);
+ R.assignBlock(0, 2, positiveZ.axis);
// If determinant is -1, coordinate system is left-handed
if (Math.abs(R.det() + 1.0) < 1e-9) {
diff --git a/wpimath/src/test/java/org/wpilib/math/controller/LTVDifferentialDriveControllerTest.java b/wpimath/src/test/java/org/wpilib/math/controller/LTVDifferentialDriveControllerTest.java
index 1282b0db59e..906df67041b 100644
--- a/wpimath/src/test/java/org/wpilib/math/controller/LTVDifferentialDriveControllerTest.java
+++ b/wpimath/src/test/java/org/wpilib/math/controller/LTVDifferentialDriveControllerTest.java
@@ -32,19 +32,19 @@ class LTVDifferentialDriveControllerTest {
/** States of the drivetrain system. */
static class State {
/// X position in global coordinate frame.
- public static final int kX = 0;
+ static final int kX = 0;
/// Y position in global coordinate frame.
- public static final int kY = 1;
+ static final int kY = 1;
/// Heading in global coordinate frame.
- public static final int kHeading = 2;
+ static final int kHeading = 2;
/// Left encoder velocity.
- public static final int kLeftVelocity = 3;
+ static final int kLeftVelocity = 3;
/// Right encoder velocity.
- public static final int kRightVelocity = 4;
+ static final int kRightVelocity = 4;
}
private static final double kLinearV = 3.02; // V/(m/s)
diff --git a/wpimath/src/test/java/org/wpilib/math/controller/LinearSystemLoopTest.java b/wpimath/src/test/java/org/wpilib/math/controller/LinearSystemLoopTest.java
index f9ab499cb47..90c16534267 100644
--- a/wpimath/src/test/java/org/wpilib/math/controller/LinearSystemLoopTest.java
+++ b/wpimath/src/test/java/org/wpilib/math/controller/LinearSystemLoopTest.java
@@ -26,7 +26,7 @@ class LinearSystemLoopTest {
private static final double kPositionStddev = 0.0001;
private static final Random random = new Random();
- LinearSystem m_plant =
+ LinearSystem plant =
Models.elevatorFromPhysicalConstants(DCMotor.getVex775Pro(2), 5, 0.0181864, 1.0);
@SuppressWarnings("unchecked")
@@ -34,7 +34,7 @@ class LinearSystemLoopTest {
new KalmanFilter<>(
Nat.N2(),
Nat.N1(),
- (LinearSystem) m_plant.slice(0),
+ (LinearSystem) plant.slice(0),
VecBuilder.fill(0.05, 1.0),
VecBuilder.fill(0.0001),
kDt);
@@ -42,7 +42,7 @@ class LinearSystemLoopTest {
@SuppressWarnings("unchecked")
LinearQuadraticRegulator m_controller =
new LinearQuadraticRegulator<>(
- (LinearSystem) m_plant.slice(0),
+ (LinearSystem) plant.slice(0),
VecBuilder.fill(0.02, 0.4),
VecBuilder.fill(12.0),
0.005);
@@ -50,7 +50,7 @@ class LinearSystemLoopTest {
@SuppressWarnings("unchecked")
private final LinearSystemLoop m_loop =
new LinearSystemLoop<>(
- (LinearSystem) m_plant.slice(0), m_controller, m_observer, 12, 0.005);
+ (LinearSystem) plant.slice(0), m_controller, m_observer, 12, 0.005);
private static void updateTwoState(
LinearSystem plant, LinearSystemLoop loop, double noise) {
@@ -80,7 +80,7 @@ void testStateSpaceEnabled() {
m_loop.setNextR(VecBuilder.fill(state.position, state.velocity));
updateTwoState(
- (LinearSystem) m_plant.slice(0),
+ (LinearSystem) plant.slice(0),
m_loop,
(random.nextGaussian()) * kPositionStddev);
var u = m_loop.getU(0);
diff --git a/wpimath/src/test/java/org/wpilib/math/linalg/DARETest.java b/wpimath/src/test/java/org/wpilib/math/linalg/DARETest.java
index f29b7d4eef6..88bee0c4474 100644
--- a/wpimath/src/test/java/org/wpilib/math/linalg/DARETest.java
+++ b/wpimath/src/test/java/org/wpilib/math/linalg/DARETest.java
@@ -19,8 +19,7 @@ class DARETest extends UtilityClassTest {
super(DARE.class);
}
- public static void assertMatrixEqual(
- Matrix A, Matrix B) {
+ static void assertMatrixEqual(Matrix A, Matrix B) {
for (int i = 0; i < A.getNumRows(); i++) {
for (int j = 0; j < A.getNumCols(); j++) {
assertEquals(A.get(i, j), B.get(i, j), 1e-4);
diff --git a/wpimath/src/test/java/org/wpilib/math/trajectory/ExponentialProfileTest.java b/wpimath/src/test/java/org/wpilib/math/trajectory/ExponentialProfileTest.java
index 2cf6e3ccc5e..cf44104c564 100644
--- a/wpimath/src/test/java/org/wpilib/math/trajectory/ExponentialProfileTest.java
+++ b/wpimath/src/test/java/org/wpilib/math/trajectory/ExponentialProfileTest.java
@@ -198,9 +198,9 @@ void largeNegativeInitialVelocity() {
@SuppressWarnings("PMD.TestClassWithoutTestCases")
static class TestCase {
- public final ExponentialProfile.State initial;
- public final ExponentialProfile.State goal;
- public final ExponentialProfile.State inflectionPoint;
+ final ExponentialProfile.State initial;
+ final ExponentialProfile.State goal;
+ final ExponentialProfile.State inflectionPoint;
TestCase(
ExponentialProfile.State initial,
diff --git a/wpiunits/src/test/java/org/wpilib/units/ExampleUnit.java b/wpiunits/src/test/java/org/wpilib/units/ExampleUnit.java
index 9c940f6f72d..e4311178130 100644
--- a/wpiunits/src/test/java/org/wpilib/units/ExampleUnit.java
+++ b/wpiunits/src/test/java/org/wpilib/units/ExampleUnit.java
@@ -22,7 +22,7 @@ class ExampleUnit extends Unit {
super(null, baseUnitEquivalent, name, symbol);
}
- public double convertFrom(double magnitude, ExampleUnit otherUnit) {
+ double convertFrom(double magnitude, ExampleUnit otherUnit) {
return fromBaseUnits(otherUnit.toBaseUnits(magnitude));
}
diff --git a/wpiutil/src/main/java/org/wpilib/util/sendable/SendableRegistry.java b/wpiutil/src/main/java/org/wpilib/util/sendable/SendableRegistry.java
index 9af0a187871..41b9640793e 100644
--- a/wpiutil/src/main/java/org/wpilib/util/sendable/SendableRegistry.java
+++ b/wpiutil/src/main/java/org/wpilib/util/sendable/SendableRegistry.java
@@ -15,6 +15,7 @@
*/
@SuppressWarnings("PMD.AvoidCatchingGenericException")
public final class SendableRegistry {
+ @SuppressWarnings("PMD.PublicFieldNamingConvention")
private static class Component implements AutoCloseable {
Component() {}
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/DynamicStruct.java b/wpiutil/src/main/java/org/wpilib/util/struct/DynamicStruct.java
index c37031b640a..b6c0698644d 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/DynamicStruct.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/DynamicStruct.java
@@ -389,8 +389,8 @@ public String getStringField(StructFieldDescriptor field) {
if (!m_desc.isValid()) {
throw new IllegalStateException("struct descriptor is not valid");
}
- byte[] bytes = new byte[field.m_arraySize];
- m_data.position(field.m_offset).get(bytes, 0, field.m_arraySize);
+ byte[] bytes = new byte[field.getArraySize()];
+ m_data.position(field.offset).get(bytes, 0, field.getArraySize());
// Find last non zero character
int stringLength = bytes.length;
for (; stringLength > 0; stringLength--) {
@@ -464,10 +464,10 @@ public boolean setStringField(StructFieldDescriptor field, String value) {
throw new IllegalStateException("struct descriptor is not valid");
}
ByteBuffer bb = StandardCharsets.UTF_8.encode(value);
- int len = Math.min(bb.remaining(), field.m_arraySize);
+ int len = Math.min(bb.remaining(), field.getArraySize());
boolean copiedFull = len == bb.remaining();
- m_data.position(field.m_offset).put(bb.limit(len));
- for (int i = len; i < field.m_arraySize; i++) {
+ m_data.position(field.offset).put(bb.limit(len));
+ for (int i = len; i < field.getArraySize(); i++) {
m_data.put((byte) 0);
}
return copiedFull;
@@ -494,12 +494,12 @@ public DynamicStruct getStructField(StructFieldDescriptor field, int arrIndex) {
if (!m_desc.isValid()) {
throw new IllegalStateException("struct descriptor is not valid");
}
- if (arrIndex < 0 || arrIndex >= field.m_arraySize) {
+ if (arrIndex < 0 || arrIndex >= field.getArraySize()) {
throw new ArrayIndexOutOfBoundsException(
- "arrIndex (" + arrIndex + ") is larger than array size (" + field.m_arraySize + ")");
+ "arrIndex (" + arrIndex + ") is larger than array size (" + field.getArraySize() + ")");
}
StructDescriptor struct = field.getStruct();
- return wrap(struct, m_data.position(field.m_offset + arrIndex * struct.m_size));
+ return wrap(struct, m_data.position(field.offset + arrIndex * struct.size));
}
/**
@@ -544,12 +544,12 @@ public void setStructField(StructFieldDescriptor field, DynamicStruct value, int
if (!value.getDescriptor().isValid()) {
throw new IllegalStateException("value's struct descriptor is not valid");
}
- if (arrIndex < 0 || arrIndex >= field.m_arraySize) {
+ if (arrIndex < 0 || arrIndex >= field.getArraySize()) {
throw new ArrayIndexOutOfBoundsException(
- "arrIndex (" + arrIndex + ") is larger than array size (" + field.m_arraySize + ")");
+ "arrIndex (" + arrIndex + ") is larger than array size (" + field.getArraySize() + ")");
}
m_data
- .position(field.m_offset + arrIndex * struct.m_size)
+ .position(field.offset + arrIndex * struct.size)
.put(value.m_data.position(0).limit(value.getDescriptor().getSize()));
}
@@ -574,28 +574,28 @@ private long getFieldImpl(StructFieldDescriptor field, int arrIndex) {
if (!m_desc.isValid()) {
throw new IllegalStateException("struct descriptor is not valid");
}
- if (arrIndex < 0 || arrIndex >= field.m_arraySize) {
+ if (arrIndex < 0 || arrIndex >= field.getArraySize()) {
throw new ArrayIndexOutOfBoundsException(
- "arrIndex (" + arrIndex + ") is larger than array size (" + field.m_arraySize + ")");
+ "arrIndex (" + arrIndex + ") is larger than array size (" + field.getArraySize() + ")");
}
long val =
- switch (field.m_size) {
- case 1 -> m_data.get(field.m_offset + arrIndex);
- case 2 -> m_data.getShort(field.m_offset + arrIndex * 2);
- case 4 -> m_data.getInt(field.m_offset + arrIndex * 4);
- case 8 -> m_data.getLong(field.m_offset + arrIndex * 8);
+ switch (field.size) {
+ case 1 -> m_data.get(field.offset + arrIndex);
+ case 2 -> m_data.getShort(field.offset + arrIndex * 2);
+ case 4 -> m_data.getInt(field.offset + arrIndex * 4);
+ case 8 -> m_data.getLong(field.offset + arrIndex * 8);
default -> throw new IllegalStateException("invalid field size");
};
if (field.isUint() || field.getType() == StructFieldType.BOOL) {
// for unsigned fields, we can simply logical shift and mask
- return (val >>> field.m_bitShift) & field.getBitMask();
+ return (val >>> field.bitShift) & field.getBitMask();
} else {
// to get sign extension, shift so the sign bit within the bitfield goes to the long's sign
// bit (also clearing all higher bits), then shift back down (also clearing all lower bits);
// since upper and lower bits are cleared with the shifts, the bitmask is unnecessary
- return (val << (64 - field.m_bitShift - field.getBitWidth())) >> (64 - field.getBitWidth());
+ return (val << (64 - field.bitShift - field.getBitWidth())) >> (64 - field.getBitWidth());
}
}
@@ -606,48 +606,48 @@ private void setFieldImpl(StructFieldDescriptor field, long value, int arrIndex)
if (!m_desc.isValid()) {
throw new IllegalStateException("struct descriptor is not valid");
}
- if (arrIndex < 0 || arrIndex >= field.m_arraySize) {
+ if (arrIndex < 0 || arrIndex >= field.getArraySize()) {
throw new ArrayIndexOutOfBoundsException(
- "arrIndex (" + arrIndex + ") is larger than array size (" + field.m_arraySize + ")");
+ "arrIndex (" + arrIndex + ") is larger than array size (" + field.getArraySize() + ")");
}
// common case is no bit shift and no masking
if (!field.isBitField()) {
- switch (field.m_size) {
- case 1 -> m_data.put(field.m_offset + arrIndex, (byte) value);
- case 2 -> m_data.putShort(field.m_offset + arrIndex * 2, (short) value);
- case 4 -> m_data.putInt(field.m_offset + arrIndex * 4, (int) value);
- case 8 -> m_data.putLong(field.m_offset + arrIndex * 8, value);
+ switch (field.size) {
+ case 1 -> m_data.put(field.offset + arrIndex, (byte) value);
+ case 2 -> m_data.putShort(field.offset + arrIndex * 2, (short) value);
+ case 4 -> m_data.putInt(field.offset + arrIndex * 4, (int) value);
+ case 8 -> m_data.putLong(field.offset + arrIndex * 8, value);
default -> throw new IllegalStateException("invalid field size");
}
return;
}
// handle bit shifting and masking into current value
- switch (field.m_size) {
+ switch (field.size) {
case 1 -> {
- byte val = m_data.get(field.m_offset + arrIndex);
- val &= (byte) ~(field.getBitMask() << field.m_bitShift);
- val |= (byte) ((value & field.getBitMask()) << field.m_bitShift);
- m_data.put(field.m_offset + arrIndex, val);
+ byte val = m_data.get(field.offset + arrIndex);
+ val &= (byte) ~(field.getBitMask() << field.bitShift);
+ val |= (byte) ((value & field.getBitMask()) << field.bitShift);
+ m_data.put(field.offset + arrIndex, val);
}
case 2 -> {
- short val = m_data.getShort(field.m_offset + arrIndex * 2);
- val &= (short) ~(field.getBitMask() << field.m_bitShift);
- val |= (short) ((value & field.getBitMask()) << field.m_bitShift);
- m_data.putShort(field.m_offset + arrIndex * 2, val);
+ short val = m_data.getShort(field.offset + arrIndex * 2);
+ val &= (short) ~(field.getBitMask() << field.bitShift);
+ val |= (short) ((value & field.getBitMask()) << field.bitShift);
+ m_data.putShort(field.offset + arrIndex * 2, val);
}
case 4 -> {
- int val = m_data.getInt(field.m_offset + arrIndex * 4);
- val &= (int) ~(field.getBitMask() << field.m_bitShift);
- val |= (int) ((value & field.getBitMask()) << field.m_bitShift);
- m_data.putInt(field.m_offset + arrIndex * 4, val);
+ int val = m_data.getInt(field.offset + arrIndex * 4);
+ val &= (int) ~(field.getBitMask() << field.bitShift);
+ val |= (int) ((value & field.getBitMask()) << field.bitShift);
+ m_data.putInt(field.offset + arrIndex * 4, val);
}
case 8 -> {
- long val = m_data.getLong(field.m_offset + arrIndex * 8);
- val &= ~(field.getBitMask() << field.m_bitShift);
- val |= (value & field.getBitMask()) << field.m_bitShift;
- m_data.putLong(field.m_offset + arrIndex * 8, val);
+ long val = m_data.getLong(field.offset + arrIndex * 8);
+ val &= ~(field.getBitMask() << field.bitShift);
+ val |= (value & field.getBitMask()) << field.bitShift;
+ m_data.putLong(field.offset + arrIndex * 8, val);
}
default -> throw new IllegalStateException("invalid field size");
}
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptor.java b/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptor.java
index f493d0224a5..8745c38d15b 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptor.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptor.java
@@ -33,7 +33,7 @@ public String getName() {
* @return schema
*/
public String getSchema() {
- return m_schema;
+ return schema;
}
/**
@@ -43,7 +43,7 @@ public String getSchema() {
* @return true if valid
*/
public boolean isValid() {
- return m_valid;
+ return valid;
}
/**
@@ -53,10 +53,10 @@ public boolean isValid() {
* @throws IllegalStateException if descriptor is invalid
*/
public int getSize() {
- if (!m_valid) {
+ if (!valid) {
throw new IllegalStateException("descriptor is invalid");
}
- return m_size;
+ return size;
}
/**
@@ -66,7 +66,7 @@ public int getSize() {
* @return field descriptor, or nullptr if not found
*/
public StructFieldDescriptor findFieldByName(String name) {
- return m_fieldsByName.get(name);
+ return fieldsByName.get(name);
}
/**
@@ -75,12 +75,12 @@ public StructFieldDescriptor findFieldByName(String name) {
* @return field descriptors
*/
public List getFields() {
- return m_fields;
+ return fields;
}
boolean checkCircular(Stack stack) {
stack.push(this);
- for (StructDescriptor ref : m_references) {
+ for (StructDescriptor ref : references) {
if (stack.contains(ref)) {
return false;
}
@@ -96,46 +96,46 @@ void calculateOffsets(Stack stack) {
int offset = 0;
int shift = 0;
int prevBitfieldSize = 0;
- for (StructFieldDescriptor field : m_fields) {
+ for (StructFieldDescriptor field : fields) {
if (!field.isBitField()) {
shift = 0; // reset shift on non-bitfield element
offset += prevBitfieldSize; // finish bitfield if active
prevBitfieldSize = 0; // previous is now not bitfield
- field.m_offset = offset;
+ field.offset = offset;
StructDescriptor struct = field.getStruct();
if (struct != null) {
if (!struct.isValid()) {
- m_valid = false;
+ valid = false;
return;
}
- field.m_size = struct.m_size;
+ field.size = struct.size;
}
- offset += field.m_size * field.m_arraySize;
+ offset += field.size * field.getArraySize();
} else {
int bitWidth = field.getBitWidth();
if (field.getType() == StructFieldType.BOOL
&& prevBitfieldSize != 0
&& (shift + 1) <= (prevBitfieldSize * 8)) {
// bool takes on size of preceding bitfield type (if it fits)
- field.m_size = prevBitfieldSize;
- } else if (field.m_size != prevBitfieldSize || (shift + bitWidth) > (field.m_size * 8)) {
+ field.size = prevBitfieldSize;
+ } else if (field.size != prevBitfieldSize || (shift + bitWidth) > (field.size * 8)) {
shift = 0;
offset += prevBitfieldSize;
}
- prevBitfieldSize = field.m_size;
- field.m_offset = offset;
- field.m_bitShift = shift;
+ prevBitfieldSize = field.size;
+ field.offset = offset;
+ field.bitShift = shift;
shift += bitWidth;
}
}
// update struct size
- m_size = offset + prevBitfieldSize;
- m_valid = true;
+ size = offset + prevBitfieldSize;
+ valid = true;
// now that we're valid, referring types may be too
stack.push(this);
- for (StructDescriptor ref : m_references) {
+ for (StructDescriptor ref : references) {
if (stack.contains(ref)) {
throw new IllegalStateException(
"internal error (inconsistent data): circular struct reference between "
@@ -149,10 +149,10 @@ void calculateOffsets(Stack stack) {
}
private final String m_name;
- String m_schema;
- final Set m_references = new HashSet<>();
- final List m_fields = new ArrayList<>();
- final Map m_fieldsByName = new HashMap<>();
- int m_size;
- boolean m_valid;
+ String schema;
+ final Set references = new HashSet<>();
+ final List fields = new ArrayList<>();
+ final Map fieldsByName = new HashMap<>();
+ int size;
+ boolean valid;
}
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptorDatabase.java b/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptorDatabase.java
index ee89de38a9b..9060f140b35 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptorDatabase.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/StructDescriptorDatabase.java
@@ -37,8 +37,8 @@ public StructDescriptor add(String name, String schema) throws BadSchemaExceptio
// turn parsed schema into descriptors
StructDescriptor theStruct = m_structs.computeIfAbsent(name, StructDescriptor::new);
- theStruct.m_schema = schema;
- theStruct.m_fields.clear();
+ theStruct.schema = schema;
+ theStruct.fields.clear();
boolean isValid = true;
for (ParsedDeclaration decl : parsed.declarations) {
StructFieldType type = StructFieldType.fromString(decl.typeString);
@@ -89,7 +89,7 @@ public StructDescriptor add(String name, String schema) throws BadSchemaExceptio
}
// add to cross-references for when the struct does become valid
- aStruct.m_references.add(theStruct);
+ aStruct.references.add(theStruct);
structDesc = aStruct;
}
@@ -104,14 +104,14 @@ public StructDescriptor add(String name, String schema) throws BadSchemaExceptio
decl.bitWidth,
decl.enumValues,
structDesc);
- if (theStruct.m_fieldsByName.put(decl.name, fieldDesc) != null) {
+ if (theStruct.fieldsByName.put(decl.name, fieldDesc) != null) {
throw new BadSchemaException(decl.name, "duplicate field name");
}
- theStruct.m_fields.add(fieldDesc);
+ theStruct.fields.add(fieldDesc);
}
- theStruct.m_valid = isValid;
+ theStruct.valid = isValid;
Stack stack = new Stack<>();
if (isValid) {
// we have all the info needed, so calculate field offset & shift
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldDescriptor.java b/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldDescriptor.java
index d624b7d4b77..f1b0fe57c1d 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldDescriptor.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/StructFieldDescriptor.java
@@ -36,8 +36,8 @@ private static long toBitMask(int size, int bitWidth) {
StructDescriptor structDesc) {
m_parent = parent;
m_name = name;
- m_size = size;
- m_arraySize = arraySize;
+ this.size = size;
+ this.m_arraySize = arraySize;
m_enum = enumValues;
m_struct = structDesc;
m_bitMask = toBitMask(size, bitWidth);
@@ -96,7 +96,7 @@ public boolean isUint() {
* @return number of bytes
*/
public int getSize() {
- return m_size;
+ return size;
}
/**
@@ -105,7 +105,7 @@ public int getSize() {
* @return number of bytes from the start of the struct
*/
public int getOffset() {
- return m_offset;
+ return offset;
}
/**
@@ -114,7 +114,7 @@ public int getOffset() {
* @return number of bits
*/
public int getBitWidth() {
- return m_bitWidth == 0 ? m_size * 8 : m_bitWidth;
+ return m_bitWidth == 0 ? size * 8 : m_bitWidth;
}
/**
@@ -133,7 +133,7 @@ public long getBitMask() {
* @return number of bits
*/
public int getBitShift() {
- return m_bitShift;
+ return bitShift;
}
/**
@@ -224,18 +224,18 @@ public long getIntMax() {
* @return true if bitfield
*/
public boolean isBitField() {
- return (m_bitShift != 0 || m_bitWidth != (m_size * 8)) && m_struct == null;
+ return (bitShift != 0 || m_bitWidth != (size * 8)) && m_struct == null;
}
private final StructDescriptor m_parent;
private final String m_name;
- int m_size;
- int m_offset;
- final int m_arraySize; // 1 for non-arrays
+ int size;
+ int offset;
+ private final int m_arraySize; // 1 for non-arrays
private final Map m_enum;
private final StructDescriptor m_struct; // null for non-structs
private final long m_bitMask;
private final StructFieldType m_type;
private final int m_bitWidth;
- int m_bitShift;
+ int bitShift;
}
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/parser/Lexer.java b/wpiutil/src/main/java/org/wpilib/util/struct/parser/Lexer.java
index a1757de6df3..11b8ba37985 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/parser/Lexer.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/parser/Lexer.java
@@ -25,7 +25,7 @@ public TokenKind scan() {
do {
get();
} while (m_current == ' ' || m_current == '\t' || m_current == '\n' || m_current == '\r');
- m_tokenStart = m_pos - 1;
+ m_tokenStart = pos - 1;
return switch (m_current) {
case '[' -> TokenKind.LEFT_BRACKET;
@@ -56,7 +56,7 @@ public String getTokenText() {
if (m_tokenStart >= m_in.length()) {
return "";
}
- return m_in.substring(m_tokenStart, m_pos);
+ return m_in.substring(m_tokenStart, pos);
}
/**
@@ -85,19 +85,19 @@ private TokenKind scanIdentifier() {
}
private void get() {
- if (m_pos < m_in.length()) {
- m_current = m_in.charAt(m_pos);
+ if (pos < m_in.length()) {
+ m_current = m_in.charAt(pos);
} else {
m_current = '\0';
}
- ++m_pos;
+ ++pos;
}
private void unget() {
- if (m_pos > 0) {
- m_pos--;
- if (m_pos < m_in.length()) {
- m_current = m_in.charAt(m_pos);
+ if (pos > 0) {
+ pos--;
+ if (pos < m_in.length()) {
+ m_current = m_in.charAt(pos);
} else {
m_current = '\0';
}
@@ -106,8 +106,8 @@ private void unget() {
}
}
- final String m_in;
- char m_current;
- int m_tokenStart;
- int m_pos;
+ private final String m_in;
+ private char m_current;
+ private int m_tokenStart;
+ int pos;
}
diff --git a/wpiutil/src/main/java/org/wpilib/util/struct/parser/Parser.java b/wpiutil/src/main/java/org/wpilib/util/struct/parser/Parser.java
index 807806b996b..62cc68144d8 100644
--- a/wpiutil/src/main/java/org/wpilib/util/struct/parser/Parser.java
+++ b/wpiutil/src/main/java/org/wpilib/util/struct/parser/Parser.java
@@ -78,7 +78,7 @@ private ParsedDeclaration parseDeclaration() throws ParseException {
decl.arraySize = value;
} else {
throw new ParseException(
- m_lexer.m_pos, "array size '" + valueStr + "' is not a positive integer");
+ m_lexer.pos, "array size '" + valueStr + "' is not a positive integer");
}
getNextToken();
expect(TokenKind.RIGHT_BRACKET);
@@ -97,7 +97,7 @@ private ParsedDeclaration parseDeclaration() throws ParseException {
decl.bitWidth = value;
} else {
throw new ParseException(
- m_lexer.m_pos, "bitfield width '" + valueStr + "' is not a positive integer");
+ m_lexer.pos, "bitfield width '" + valueStr + "' is not a positive integer");
}
getNextToken();
}
@@ -127,7 +127,7 @@ private Map parseEnum() throws ParseException {
try {
value = Long.parseLong(valueStr);
} catch (NumberFormatException e) {
- throw new ParseException(m_lexer.m_pos, "could not parse enum value '" + valueStr + "'");
+ throw new ParseException(m_lexer.pos, "could not parse enum value '" + valueStr + "'");
}
map.put(name, value);
getNextToken();
@@ -148,10 +148,10 @@ private TokenKind getNextToken() {
private void expect(TokenKind kind) throws ParseException {
if (m_token != kind) {
throw new ParseException(
- m_lexer.m_pos, "expected " + kind + ", got '" + m_lexer.getTokenText() + "'");
+ m_lexer.pos, "expected " + kind + ", got '" + m_lexer.getTokenText() + "'");
}
}
- final Lexer m_lexer;
- TokenKind m_token;
+ private final Lexer m_lexer;
+ private TokenKind m_token;
}
diff --git a/wpiutil/src/test/java/org/wpilib/util/ConstructorMatchTest.java b/wpiutil/src/test/java/org/wpilib/util/ConstructorMatchTest.java
index 389f7951589..b9c3aeaa620 100644
--- a/wpiutil/src/test/java/org/wpilib/util/ConstructorMatchTest.java
+++ b/wpiutil/src/test/java/org/wpilib/util/ConstructorMatchTest.java
@@ -11,7 +11,11 @@
import java.util.Optional;
import org.junit.jupiter.api.Test;
-@SuppressWarnings({"PMD.TestClassWithoutTestCases", "RedundantModifier"})
+@SuppressWarnings({
+ "PMD.TestClassWithoutTestCases",
+ "RedundantModifier",
+ "PMD.PublicMemberInNonPublicType"
+})
class ConstructorMatchTest {
public static class TestClass {
public TestClass() {}
diff --git a/wpiutil/src/test/java/org/wpilib/util/cleanup/CleanupPoolTest.java b/wpiutil/src/test/java/org/wpilib/util/cleanup/CleanupPoolTest.java
index 688fe803fe3..960f8cb52d4 100644
--- a/wpiutil/src/test/java/org/wpilib/util/cleanup/CleanupPoolTest.java
+++ b/wpiutil/src/test/java/org/wpilib/util/cleanup/CleanupPoolTest.java
@@ -14,11 +14,11 @@
class CleanupPoolTest {
static class AutoCloseableObject implements AutoCloseable {
- public boolean m_closed;
+ boolean closed;
@Override
public void close() {
- m_closed = true;
+ closed = true;
}
}
@@ -36,7 +36,7 @@ public void close() {
}
static class FailingAutoCloseableObject implements AutoCloseable {
- public static final String message = "This is an expected failure";
+ static final String message = "This is an expected failure";
@Override
public void close() {
@@ -58,7 +58,7 @@ void cleanupStackWorks() {
}
for (AutoCloseableObject autoCloseableObject : objects) {
- assertTrue(autoCloseableObject.m_closed);
+ assertTrue(autoCloseableObject.closed);
}
}
@@ -82,7 +82,7 @@ void cleanupStackWithExceptionNotInCloseWorks() {
}
for (AutoCloseableObject autoCloseableObject : objects) {
- assertTrue(autoCloseableObject.m_closed);
+ assertTrue(autoCloseableObject.closed);
}
}
@@ -101,7 +101,7 @@ void cleanupStackWithExceptionInCloseWorks() {
}
for (AutoCloseableObject autoCloseableObject : objects) {
- assertTrue(autoCloseableObject.m_closed);
+ assertTrue(autoCloseableObject.closed);
}
}
@@ -123,9 +123,9 @@ void cleanupStackRemovalWorks() {
int idx = 0;
for (AutoCloseableObject autoCloseableObject : objects) {
if (idx == 0) {
- assertFalse(autoCloseableObject.m_closed);
+ assertFalse(autoCloseableObject.closed);
} else {
- assertTrue(autoCloseableObject.m_closed);
+ assertTrue(autoCloseableObject.closed);
}
idx++;
}
diff --git a/wpiutil/src/test/java/org/wpilib/util/cleanup/ReflectionCleanupTest.java b/wpiutil/src/test/java/org/wpilib/util/cleanup/ReflectionCleanupTest.java
index 786e8e5c9c6..0faace0e3f4 100644
--- a/wpiutil/src/test/java/org/wpilib/util/cleanup/ReflectionCleanupTest.java
+++ b/wpiutil/src/test/java/org/wpilib/util/cleanup/ReflectionCleanupTest.java
@@ -11,20 +11,20 @@
class ReflectionCleanupTest {
static class CleanupClass implements AutoCloseable {
- public boolean m_closed;
+ boolean closed;
@Override
public void close() {
- m_closed = true;
+ closed = true;
}
}
@SuppressWarnings("PMD.TestClassWithoutTestCases")
static class CleanupTest implements ReflectionCleanup {
- public CleanupClass m_class1 = new CleanupClass();
- public CleanupClass m_class2 = new CleanupClass();
- public Object m_nonCleanupObject = new Object();
- public Object m_nullCleanupObject;
+ CleanupClass class1 = new CleanupClass();
+ CleanupClass class2 = new CleanupClass();
+ Object nonCleanupObject = new Object();
+ Object nullCleanupObject;
@Override
public void close() {
@@ -33,8 +33,8 @@ public void close() {
}
static class CleanupTest2 extends CleanupTest {
- @SkipCleanup public CleanupClass m_class3 = new CleanupClass();
- public CleanupClass m_class4 = new CleanupClass();
+ @SkipCleanup CleanupClass class3 = new CleanupClass();
+ CleanupClass class4 = new CleanupClass();
@Override
public void close() {
@@ -46,17 +46,17 @@ public void close() {
void cleanupClosesAllFields() {
CleanupTest test = new CleanupTest();
test.close();
- assertTrue(test.m_class1.m_closed);
- assertTrue(test.m_class2.m_closed);
+ assertTrue(test.class1.closed);
+ assertTrue(test.class2.closed);
}
@Test
void cleanupOnlyClosesExplicitClassAndSkipWorks() {
CleanupTest2 test = new CleanupTest2();
test.close();
- assertFalse(test.m_class1.m_closed);
- assertFalse(test.m_class2.m_closed);
- assertFalse(test.m_class3.m_closed);
- assertTrue(test.m_class4.m_closed);
+ assertFalse(test.class1.closed);
+ assertFalse(test.class2.closed);
+ assertFalse(test.class3.closed);
+ assertTrue(test.class4.closed);
}
}
diff --git a/wpiutil/src/test/java/org/wpilib/util/struct/DynamicStructTest.java b/wpiutil/src/test/java/org/wpilib/util/struct/DynamicStructTest.java
index b0c2fdb0197..b46cc308beb 100644
--- a/wpiutil/src/test/java/org/wpilib/util/struct/DynamicStructTest.java
+++ b/wpiutil/src/test/java/org/wpilib/util/struct/DynamicStructTest.java
@@ -20,11 +20,10 @@
@SuppressWarnings("AvoidEscapedUnicodeCharacters")
class DynamicStructTest {
- @SuppressWarnings("MemberName")
- private StructDescriptorDatabase db;
+ StructDescriptorDatabase db;
@BeforeEach
- public void init() {
+ void init() {
db = new StructDescriptorDatabase();
}
diff --git a/wpiutil/src/test/java/org/wpilib/util/struct/StructGeneratorTest.java b/wpiutil/src/test/java/org/wpilib/util/struct/StructGeneratorTest.java
index 86f2324d2ea..12698736803 100644
--- a/wpiutil/src/test/java/org/wpilib/util/struct/StructGeneratorTest.java
+++ b/wpiutil/src/test/java/org/wpilib/util/struct/StructGeneratorTest.java
@@ -15,11 +15,11 @@
class StructGeneratorTest {
public record CustomRecord(int int32, boolean bool, double float64, char character, short int16)
implements StructSerializable {
- public static CustomRecord create() {
+ static CustomRecord create() {
return new CustomRecord(42, true, Math.PI, 'a', (short) 16);
}
- public static final Struct struct = genRecord(CustomRecord.class);
+ static final Struct struct = genRecord(CustomRecord.class);
@Override
public final boolean equals(Object arg) {
@@ -42,37 +42,37 @@ public final int hashCode() {
}
}
- public enum CustomEnum implements StructSerializable {
+ enum CustomEnum implements StructSerializable {
A(8),
B(16),
C(32),
D(64);
- public final int value;
+ final int value;
CustomEnum(int value) {
this.value = value;
}
- public static final Struct struct = genEnum(CustomEnum.class);
+ static final Struct struct = genEnum(CustomEnum.class);
}
- public enum AnimalEnum implements StructSerializable {
+ enum AnimalEnum implements StructSerializable {
Dog,
Cat;
- public static final Struct struct = genEnum(AnimalEnum.class);
+ static final Struct struct = genEnum(AnimalEnum.class);
}
public record HigherOrderRecord(
CustomRecord procRecord, CustomEnum procEnum, AnimalEnum animal, long i64, byte uint8)
implements StructSerializable {
- public static HigherOrderRecord create() {
+ static HigherOrderRecord create() {
return new HigherOrderRecord(
CustomRecord.create(), CustomEnum.A, AnimalEnum.Dog, 1234567890123456789L, (byte) 100);
}
- public static final Struct struct = genRecord(HigherOrderRecord.class);
+ static final Struct struct = genRecord(HigherOrderRecord.class);
@Override
public final boolean equals(Object arg) {
From 557de6ca96b921cc9867c82d7288f4e73e01577b Mon Sep 17 00:00:00 2001
From: Gold856 <117957790+Gold856@users.noreply.github.com>
Date: Fri, 20 Mar 2026 21:52:21 -0400
Subject: [PATCH 4/4] Remove m_ from all examples
---
.../DifferentialDrivePoseEstimator/robot.py | 2 +-
.../SwerveDrivePoseEstimator/swervemodule.py | 16 +--
shared/java/javastyle.gradle | 2 +-
styleguide/pmd-ruleset.xml | 2 +-
.../examples/ArcadeDriveGamepad/cpp/Robot.cpp | 22 +--
.../cpp/examples/ArmSimulation/cpp/Robot.cpp | 12 +-
.../ArmSimulation/cpp/subsystems/Arm.cpp | 38 +++---
.../examples/ArmSimulation/include/Robot.hpp | 4 +-
.../ArmSimulation/include/subsystems/Arm.hpp | 30 ++--
.../DifferentialDriveBot/cpp/Drivetrain.cpp | 24 ++--
.../DifferentialDriveBot/cpp/Robot.cpp | 19 ++-
.../include/Drivetrain.hpp | 48 +++----
.../cpp/Drivetrain.cpp | 86 ++++++------
.../cpp/Robot.cpp | 23 ++--
.../include/Drivetrain.hpp | 65 +++++----
.../DriveDistanceOffboard/cpp/Robot.cpp | 12 +-
.../cpp/RobotContainer.cpp | 22 +--
.../cpp/subsystems/DriveSubsystem.cpp | 94 ++++++-------
.../include/ExampleSmartMotorController.hpp | 6 +-
.../DriveDistanceOffboard/include/Robot.hpp | 4 +-
.../include/RobotContainer.hpp | 13 +-
.../include/subsystems/DriveSubsystem.hpp | 23 ++--
.../examples/DutyCycleEncoder/cpp/Robot.cpp | 10 +-
.../ElevatorExponentialProfile/cpp/Robot.cpp | 34 ++---
.../cpp/Robot.cpp | 14 +-
.../cpp/subsystems/Elevator.cpp | 32 ++---
.../include/Robot.hpp | 4 +-
.../include/subsystems/Elevator.hpp | 54 ++++----
.../ElevatorProfiledPID/cpp/Robot.cpp | 31 ++---
.../examples/ElevatorSimulation/cpp/Robot.cpp | 12 +-
.../cpp/subsystems/Elevator.cpp | 28 ++--
.../ElevatorSimulation/include/Robot.hpp | 4 +-
.../include/subsystems/Elevator.hpp | 49 ++++---
.../ElevatorTrapezoidProfile/cpp/Robot.cpp | 30 ++--
.../main/cpp/examples/Encoder/cpp/Robot.cpp | 12 +-
.../cpp/examples/GettingStarted/cpp/Robot.cpp | 35 +++--
.../src/main/cpp/examples/Gyro/cpp/Robot.cpp | 24 ++--
.../examples/HatchbotInlined/cpp/Robot.cpp | 12 +-
.../HatchbotInlined/cpp/RobotContainer.cpp | 30 ++--
.../cpp/subsystems/DriveSubsystem.cpp | 43 +++---
.../cpp/subsystems/HatchSubsystem.cpp | 10 +-
.../HatchbotInlined/include/Robot.hpp | 4 +-
.../include/RobotContainer.hpp | 13 +-
.../include/subsystems/DriveSubsystem.hpp | 18 +--
.../include/subsystems/HatchSubsystem.hpp | 2 +-
.../HatchbotTraditional/cpp/Robot.cpp | 12 +-
.../cpp/RobotContainer.cpp | 31 ++---
.../cpp/commands/DefaultDrive.cpp | 8 +-
.../cpp/commands/DriveDistance.cpp | 12 +-
.../cpp/commands/GrabHatch.cpp | 4 +-
.../cpp/commands/HalveDriveVelocity.cpp | 6 +-
.../cpp/commands/ReleaseHatch.cpp | 4 +-
.../cpp/subsystems/DriveSubsystem.cpp | 43 +++---
.../cpp/subsystems/HatchSubsystem.cpp | 10 +-
.../HatchbotTraditional/include/Robot.hpp | 4 +-
.../include/RobotContainer.hpp | 14 +-
.../include/commands/DefaultDrive.hpp | 6 +-
.../include/commands/DriveDistance.hpp | 6 +-
.../include/commands/GrabHatch.hpp | 2 +-
.../include/commands/HalveDriveVelocity.hpp | 2 +-
.../include/commands/ReleaseHatch.hpp | 2 +-
.../include/subsystems/DriveSubsystem.hpp | 18 +--
.../include/subsystems/HatchSubsystem.hpp | 2 +-
.../examples/MecanumBot/cpp/Drivetrain.cpp | 63 +++++----
.../cpp/examples/MecanumBot/cpp/Robot.cpp | 26 ++--
.../MecanumBot/include/Drivetrain.hpp | 52 +++----
.../cpp/examples/MecanumDrive/cpp/Robot.cpp | 38 +++---
.../cpp/Drivetrain.cpp | 62 ++++-----
.../MecanumDrivePoseEstimator/cpp/Robot.cpp | 26 ++--
.../include/Drivetrain.hpp | 54 ++++----
.../cpp/examples/Mechanism2d/cpp/Robot.cpp | 37 +++--
.../cpp/RapidReactCommandBot.cpp | 26 ++--
.../RapidReactCommandBot/cpp/Robot.cpp | 12 +-
.../cpp/subsystems/Drive.cpp | 62 ++++-----
.../cpp/subsystems/Intake.cpp | 8 +-
.../cpp/subsystems/Pneumatics.cpp | 6 +-
.../cpp/subsystems/Shooter.cpp | 20 +--
.../cpp/subsystems/Storage.cpp | 4 +-
.../include/RapidReactCommandBot.hpp | 13 +-
.../RapidReactCommandBot/include/Robot.hpp | 4 +-
.../include/subsystems/Drive.hpp | 32 ++---
.../include/subsystems/Intake.hpp | 8 +-
.../include/subsystems/Pneumatics.hpp | 6 +-
.../include/subsystems/Shooter.hpp | 14 +-
.../include/subsystems/Storage.hpp | 6 +-
.../cpp/examples/RomiReference/cpp/Robot.cpp | 12 +-
.../RomiReference/cpp/RobotContainer.cpp | 16 +--
.../cpp/commands/DriveDistance.cpp | 10 +-
.../RomiReference/cpp/commands/DriveTime.cpp | 14 +-
.../cpp/commands/TeleopArcadeDrive.cpp | 8 +-
.../cpp/commands/TurnDegrees.cpp | 14 +-
.../RomiReference/cpp/commands/TurnTime.cpp | 14 +-
.../cpp/subsystems/Drivetrain.cpp | 36 ++---
.../examples/RomiReference/include/Robot.hpp | 4 +-
.../RomiReference/include/RobotContainer.hpp | 18 +--
.../include/commands/DriveDistance.hpp | 10 +-
.../include/commands/DriveTime.hpp | 12 +-
.../include/commands/TeleopArcadeDrive.hpp | 6 +-
.../include/commands/TurnDegrees.hpp | 10 +-
.../include/commands/TurnTime.hpp | 12 +-
.../include/subsystems/Drivetrain.hpp | 16 +--
.../cpp/Drivetrain.cpp | 60 ++++----
.../cpp/Robot.cpp | 41 +++---
.../include/Drivetrain.hpp | 66 ++++-----
.../cpp/examples/StateSpaceArm/cpp/Robot.cpp | 54 ++++----
.../examples/StateSpaceElevator/cpp/Robot.cpp | 56 ++++----
.../examples/StateSpaceFlywheel/cpp/Robot.cpp | 36 ++---
.../StateSpaceFlywheelSysId/cpp/Robot.cpp | 36 ++---
.../cpp/examples/SwerveBot/cpp/Drivetrain.cpp | 21 ++-
.../main/cpp/examples/SwerveBot/cpp/Robot.cpp | 32 ++---
.../examples/SwerveBot/cpp/SwerveModule.cpp | 55 ++++----
.../examples/SwerveBot/include/Drivetrain.hpp | 44 +++---
.../SwerveBot/include/SwerveModule.hpp | 16 +--
.../cpp/Drivetrain.cpp | 24 ++--
.../SwerveDrivePoseEstimator/cpp/Robot.cpp | 26 ++--
.../cpp/SwerveModule.cpp | 55 ++++----
.../include/Drivetrain.hpp | 34 ++---
.../include/SwerveModule.hpp | 16 +--
.../cpp/examples/SysIdRoutine/cpp/Robot.cpp | 10 +-
.../SysIdRoutine/cpp/SysIdRoutineBot.cpp | 50 ++++---
.../SysIdRoutine/cpp/subsystems/Drive.cpp | 19 ++-
.../SysIdRoutine/cpp/subsystems/Shooter.cpp | 16 +--
.../examples/SysIdRoutine/include/Robot.hpp | 4 +-
.../SysIdRoutine/include/SysIdRoutineBot.hpp | 6 +-
.../SysIdRoutine/include/subsystems/Drive.hpp | 40 +++---
.../include/subsystems/Shooter.hpp | 24 ++--
.../examples/TankDriveGamepad/cpp/Robot.cpp | 22 +--
.../main/cpp/examples/UnitTest/cpp/Robot.cpp | 14 +-
.../UnitTest/cpp/subsystems/Intake.cpp | 12 +-
.../cpp/examples/UnitTest/include/Robot.hpp | 4 +-
.../UnitTest/include/subsystems/Intake.hpp | 8 +-
.../cpp/examples/XRPReference/cpp/Robot.cpp | 12 +-
.../XRPReference/cpp/RobotContainer.cpp | 28 ++--
.../cpp/commands/DriveDistance.cpp | 10 +-
.../XRPReference/cpp/commands/DriveTime.cpp | 14 +-
.../cpp/commands/TeleopArcadeDrive.cpp | 8 +-
.../XRPReference/cpp/commands/TurnDegrees.cpp | 14 +-
.../XRPReference/cpp/commands/TurnTime.cpp | 14 +-
.../XRPReference/cpp/subsystems/Arm.cpp | 2 +-
.../cpp/subsystems/Drivetrain.cpp | 36 ++---
.../examples/XRPReference/include/Robot.hpp | 4 +-
.../XRPReference/include/RobotContainer.hpp | 18 +--
.../include/commands/DriveDistance.hpp | 10 +-
.../include/commands/DriveTime.hpp | 12 +-
.../include/commands/TeleopArcadeDrive.hpp | 6 +-
.../include/commands/TurnDegrees.hpp | 10 +-
.../include/commands/TurnTime.hpp | 12 +-
.../XRPReference/include/subsystems/Arm.hpp | 2 +-
.../include/subsystems/Drivetrain.hpp | 16 +--
.../main/cpp/examples/Xrptimed/cpp/Robot.cpp | 16 +--
.../cpp/examples/Xrptimed/include/Robot.hpp | 14 +-
.../snippets/ADXLAccelerometers/cpp/Robot.cpp | 8 +-
.../AccelerometerCollision/cpp/Robot.cpp | 18 +--
.../AccelerometerFilter/cpp/Robot.cpp | 9 +-
.../cpp/snippets/AddressableLED/cpp/Robot.cpp | 8 +-
.../snippets/AddressableLED/include/Robot.hpp | 10 +-
.../AnalogAccelerometer/cpp/Robot.cpp | 8 +-
.../cpp/snippets/AnalogEncoder/cpp/Robot.cpp | 6 +-
.../cpp/snippets/AnalogInput/cpp/Robot.cpp | 6 +-
.../AnalogPotentiometer/cpp/Robot.cpp | 8 +-
.../main/cpp/snippets/CANPDP/cpp/Robot.cpp | 16 +--
.../DigitalCommunication/cpp/Robot.cpp | 8 +-
.../DigitalCommunication/include/Robot.hpp | 8 +-
.../cpp/snippets/DigitalInput/cpp/Robot.cpp | 4 +-
.../snippets/DutyCycleEncoder/cpp/Robot.cpp | 8 +-
.../cpp/snippets/DutyCycleInput/cpp/Robot.cpp | 6 +-
.../main/cpp/snippets/Encoder/cpp/Robot.cpp | 26 ++--
.../cpp/snippets/EncoderDrive/cpp/Robot.cpp | 6 +-
.../cpp/snippets/EncoderHoming/cpp/Robot.cpp | 14 +-
.../main/cpp/snippets/EventLoop/cpp/Robot.cpp | 48 ++++---
.../FlywheelBangBangController/cpp/Robot.cpp | 38 +++---
.../cpp/snippets/LimitSwitch/cpp/Robot.cpp | 22 +--
.../cpp/snippets/MotorControl/cpp/Robot.cpp | 12 +-
.../cpp/snippets/OnboardIMU/cpp/Robot.cpp | 16 +--
.../ProfiledPIDFeedforward/cpp/Robot.cpp | 23 ++--
.../cpp/snippets/SelectCommand/cpp/Robot.cpp | 12 +-
.../SelectCommand/cpp/RobotContainer.cpp | 10 +-
.../snippets/SelectCommand/include/Robot.hpp | 4 +-
.../SelectCommand/include/RobotContainer.hpp | 15 +-
.../main/cpp/snippets/Solenoid/cpp/Robot.cpp | 37 +++--
.../cpp/snippets/Solenoid/include/Robot.hpp | 10 +-
.../cpp/templates/commandv2/cpp/Robot.cpp | 10 +-
.../commandv2/cpp/RobotContainer.cpp | 8 +-
.../commandv2/cpp/commands/ExampleCommand.cpp | 4 +-
.../cpp/templates/commandv2/include/Robot.hpp | 4 +-
.../commandv2/include/RobotContainer.hpp | 4 +-
.../include/commands/ExampleCommand.hpp | 2 +-
.../templates/commandv2skeleton/cpp/Robot.cpp | 10 +-
.../commandv2skeleton/include/Robot.hpp | 4 +-
.../templates/opmode/cpp/opmode/MyAuto.cpp | 2 +-
.../templates/opmode/cpp/opmode/MyTeleop.cpp | 2 +-
.../opmode/include/opmode/MyAuto.hpp | 2 +-
.../opmode/include/opmode/MyTeleop.hpp | 2 +-
.../templates/robotbaseskeleton/cpp/Robot.cpp | 4 +-
.../robotbaseskeleton/include/Robot.hpp | 2 +-
.../main/cpp/templates/timed/cpp/Robot.cpp | 16 +--
.../cpp/templates/timed/include/Robot.hpp | 4 +-
.../cpp/templates/timeslice/cpp/Robot.cpp | 16 +--
.../cpp/templates/timeslice/include/Robot.hpp | 4 +-
.../ArmSimulation/cpp/ArmSimulationTest.cpp | 48 +++----
.../cpp/ElevatorSimulationTest.cpp | 48 +++----
.../cpp/DigitalCommunicationTest.cpp | 50 +++----
.../cpp/I2CCommunicationTest.cpp | 30 ++--
.../examples/arcadedrivegamepad/Robot.java | 18 +--
.../wpilib/examples/armsimulation/Robot.java | 18 +--
.../armsimulation/subsystems/Arm.java | 79 ++++++-----
.../differentialdrivebot/Drivetrain.java | 63 ++++-----
.../examples/differentialdrivebot/Robot.java | 17 ++-
.../Drivetrain.java | 129 +++++++++---------
.../differentialdriveposeestimator/Robot.java | 26 ++--
.../ExampleSmartMotorController.java | 6 +-
.../examples/drivedistanceoffboard/Robot.java | 16 +--
.../drivedistanceoffboard/RobotContainer.java | 24 ++--
.../subsystems/DriveSubsystem.java | 100 +++++++-------
.../examples/dutycycleencoder/Robot.java | 20 +--
.../elevatorexponentialprofile/Robot.java | 32 ++---
.../elevatorexponentialsimulation/Robot.java | 20 +--
.../subsystems/Elevator.java | 66 ++++-----
.../examples/elevatorprofiledpid/Robot.java | 30 ++--
.../examples/elevatorsimulation/Robot.java | 18 +--
.../subsystems/Elevator.java | 58 ++++----
.../elevatortrapezoidprofile/Robot.java | 30 ++--
.../org/wpilib/examples/encoder/Robot.java | 12 +-
.../wpilib/examples/gettingstarted/Robot.java | 28 ++--
.../java/org/wpilib/examples/gyro/Robot.java | 22 +--
.../examples/hatchbotinlined/Robot.java | 16 +--
.../hatchbotinlined/RobotContainer.java | 41 +++---
.../subsystems/DriveSubsystem.java | 44 +++---
.../subsystems/HatchSubsystem.java | 8 +-
.../examples/hatchbottraditional/Robot.java | 16 +--
.../hatchbottraditional/RobotContainer.java | 42 +++---
.../commands/DefaultDrive.java | 16 +--
.../commands/DriveDistance.java | 24 ++--
.../commands/GrabHatch.java | 8 +-
.../commands/HalveDriveVelocity.java | 8 +-
.../subsystems/DriveSubsystem.java | 44 +++---
.../subsystems/HatchSubsystem.java | 8 +-
.../examples/mecanumbot/Drivetrain.java | 96 ++++++-------
.../org/wpilib/examples/mecanumbot/Robot.java | 21 ++-
.../wpilib/examples/mecanumdrive/Robot.java | 20 +--
.../mecanumdriveposeestimator/Drivetrain.java | 103 +++++++-------
.../mecanumdriveposeestimator/Robot.java | 21 ++-
.../wpilib/examples/mechanism2d/Robot.java | 31 ++---
.../RapidReactCommandBot.java | 36 +++--
.../examples/rapidreactcommandbot/Robot.java | 16 +--
.../subsystems/Drive.java | 65 +++++----
.../subsystems/Intake.java | 12 +-
.../subsystems/Pneumatics.java | 10 +-
.../subsystems/Shooter.java | 28 ++--
.../subsystems/Storage.java | 10 +-
.../wpilib/examples/romireference/Robot.java | 16 +--
.../romireference/RobotContainer.java | 22 +--
.../romireference/commands/ArcadeDrive.java | 14 +-
.../romireference/commands/DriveDistance.java | 22 +--
.../romireference/commands/DriveTime.java | 24 ++--
.../romireference/commands/TurnDegrees.java | 26 ++--
.../romireference/commands/TurnTime.java | 24 ++--
.../romireference/subsystems/Drivetrain.java | 46 +++----
.../Drivetrain.java | 103 +++++++-------
.../Robot.java | 39 +++---
.../wpilib/examples/statespacearm/Robot.java | 45 +++---
.../examples/statespaceelevator/Robot.java | 49 +++----
.../examples/statespaceflywheel/Robot.java | 40 +++---
.../statespaceflywheelsysid/Robot.java | 40 +++---
.../wpilib/examples/swervebot/Drivetrain.java | 62 ++++-----
.../org/wpilib/examples/swervebot/Robot.java | 20 +--
.../examples/swervebot/SwerveModule.java | 56 ++++----
.../swervedriveposeestimator/Drivetrain.java | 67 +++++----
.../swervedriveposeestimator/Robot.java | 21 ++-
.../SwerveModule.java | 56 ++++----
.../wpilib/examples/sysidroutine/Robot.java | 16 +--
.../sysidroutine/SysIdRoutineBot.java | 64 ++++-----
.../sysidroutine/subsystems/Drive.java | 46 +++----
.../sysidroutine/subsystems/Shooter.java | 39 +++---
.../examples/tankdrivegamepad/Robot.java | 18 +--
.../org/wpilib/examples/unittest/Robot.java | 18 +--
.../examples/unittest/subsystems/Intake.java | 24 ++--
.../wpilib/examples/xrpreference/Robot.java | 16 +--
.../examples/xrpreference/RobotContainer.java | 36 ++---
.../xrpreference/commands/ArcadeDrive.java | 14 +-
.../xrpreference/commands/DriveDistance.java | 22 +--
.../xrpreference/commands/DriveTime.java | 24 ++--
.../xrpreference/commands/TurnDegrees.java | 26 ++--
.../xrpreference/commands/TurnTime.java | 24 ++--
.../examples/xrpreference/subsystems/Arm.java | 6 +-
.../xrpreference/subsystems/Drivetrain.java | 46 +++----
.../org/wpilib/examples/xrptimed/Robot.java | 28 ++--
.../accelerometercollision/Robot.java | 18 +--
.../snippets/accelerometerfilter/Robot.java | 8 +-
.../wpilib/snippets/addressableled/Robot.java | 22 +--
.../snippets/adxlaccelerometers/Robot.java | 8 +-
.../snippets/analogaccelerometer/Robot.java | 8 +-
.../wpilib/snippets/analogencoder/Robot.java | 8 +-
.../wpilib/snippets/analoginput/Robot.java | 6 +-
.../snippets/analogpotentiometer/Robot.java | 10 +-
.../org/wpilib/snippets/canpdp/Robot.java | 16 +--
.../snippets/digitalcommunication/Robot.java | 24 ++--
.../wpilib/snippets/digitalinput/Robot.java | 4 +-
.../snippets/dutycycleencoder/Robot.java | 10 +-
.../wpilib/snippets/dutycycleinput/Robot.java | 8 +-
.../org/wpilib/snippets/encoder/Robot.java | 28 ++--
.../wpilib/snippets/encoderdrive/Robot.java | 28 ++--
.../wpilib/snippets/encoderhoming/Robot.java | 14 +-
.../org/wpilib/snippets/eventloop/Robot.java | 44 +++---
.../flywheelbangbangcontroller/Robot.java | 36 +++--
.../org/wpilib/snippets/httpcamera/Robot.java | 8 +-
.../snippets/i2ccommunication/Robot.java | 6 +-
.../snippets/intermediatevision/Robot.java | 8 +-
.../wpilib/snippets/limitswitch/Robot.java | 22 +--
.../wpilib/snippets/motorcontrol/Robot.java | 18 +--
.../org/wpilib/snippets/onboardimu/Robot.java | 16 +--
.../profiledpidfeedforward/Robot.java | 20 +--
.../wpilib/snippets/selectcommand/Robot.java | 16 +--
.../selectcommand/RobotContainer.java | 4 +-
.../org/wpilib/snippets/solenoid/Robot.java | 44 +++---
.../org/wpilib/templates/commandv2/Robot.java | 16 +--
.../templates/commandv2/RobotContainer.java | 11 +-
.../commandv2/commands/ExampleCommand.java | 4 +-
.../templates/commandv2skeleton/Robot.java | 16 +--
.../educational/EducationalRobot.java | 6 +-
.../templates/opmode/opmode/MyAuto.java | 4 +-
.../templates/opmode/opmode/MyTeleop.java | 4 +-
.../templates/robotbaseskeleton/Robot.java | 6 +-
.../wpilib/templates/romicommandv2/Robot.java | 16 +--
.../romicommandv2/RobotContainer.java | 6 +-
.../commands/ExampleCommand.java | 4 +-
.../subsystems/RomiDrivetrain.java | 28 ++--
.../romieducational/EducationalRobot.java | 6 +-
.../romieducational/RomiDrivetrain.java | 30 ++--
.../org/wpilib/templates/romitimed/Robot.java | 22 +--
.../templates/romitimed/RomiDrivetrain.java | 28 ++--
.../org/wpilib/templates/timed/Robot.java | 18 +--
.../org/wpilib/templates/timeslice/Robot.java | 18 +--
.../wpilib/templates/xrpcommandv2/Robot.java | 16 +--
.../xrpcommandv2/RobotContainer.java | 6 +-
.../xrpcommandv2/commands/ExampleCommand.java | 4 +-
.../subsystems/XRPDrivetrain.java | 28 ++--
.../xrpeducational/EducationalRobot.java | 6 +-
.../xrpeducational/XRPDrivetrain.java | 28 ++--
.../org/wpilib/templates/xrptimed/Robot.java | 22 +--
.../templates/xrptimed/XRPDrivetrain.java | 28 ++--
.../armsimulation/ArmSimulationTest.java | 62 ++++-----
.../ElevatorSimulationTest.java | 62 ++++-----
.../unittest/subsystems/IntakeTest.java | 34 ++---
.../DigitalCommunicationTest.java | 58 ++++----
.../I2CCommunicationTest.java | 52 +++----
346 files changed, 3876 insertions(+), 3978 deletions(-)
diff --git a/robotpyExamples/DifferentialDrivePoseEstimator/robot.py b/robotpyExamples/DifferentialDrivePoseEstimator/robot.py
index 5cde89e2b18..301aef0a803 100644
--- a/robotpyExamples/DifferentialDrivePoseEstimator/robot.py
+++ b/robotpyExamples/DifferentialDrivePoseEstimator/robot.py
@@ -17,7 +17,7 @@ def __init__(self) -> None:
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)
diff --git a/robotpyExamples/SwerveDrivePoseEstimator/swervemodule.py b/robotpyExamples/SwerveDrivePoseEstimator/swervemodule.py
index 5f0aa9e2109..2d74f282bb2 100644
--- a/robotpyExamples/SwerveDrivePoseEstimator/swervemodule.py
+++ b/robotpyExamples/SwerveDrivePoseEstimator/swervemodule.py
@@ -112,21 +112,17 @@ def setDesiredVelocity(self, desiredVelocity: wpimath.SwerveModuleVelocity) -> N
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
- )
-
- driveFeedforward = self.driveFeedforward.calculate(velocity.velocity)
+ ) + 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)
diff --git a/shared/java/javastyle.gradle b/shared/java/javastyle.gradle
index fc4cc47f8c3..cd3d1fc1973 100644
--- a/shared/java/javastyle.gradle
+++ b/shared/java/javastyle.gradle
@@ -89,4 +89,4 @@ task javaFormat {
javaFormat.dependsOn 'spotlessApply'
tasks.withType(Checkstyle) {
it.mustRunAfter 'spotlessApply'
-}
\ No newline at end of file
+}
diff --git a/styleguide/pmd-ruleset.xml b/styleguide/pmd-ruleset.xml
index 9ed6eb82ae8..217dd85b400 100644
--- a/styleguide/pmd-ruleset.xml
+++ b/styleguide/pmd-ruleset.xml
@@ -12,7 +12,7 @@
.*/Timestamped.*\.java
.*/units/measure/.*\.java
- .*/*IntegrationTests.*
+ .*/*Examples.*
.*/*JNI.*
.*/math/proto.*
.*/command3/proto.*
diff --git a/wpilibcExamples/src/main/cpp/examples/ArcadeDriveGamepad/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ArcadeDriveGamepad/cpp/Robot.cpp
index d0cd3b477e2..2737143403a 100644
--- a/wpilibcExamples/src/main/cpp/examples/ArcadeDriveGamepad/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ArcadeDriveGamepad/cpp/Robot.cpp
@@ -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());
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/Robot.cpp
index ef04ceb39e1..612235f61f0 100644
--- a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/Robot.cpp
@@ -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
diff --git a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/subsystems/Arm.cpp b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/subsystems/Arm.cpp
index 0d2e4f98008..73b639b2da0 100644
--- a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/subsystems/Arm.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/cpp/subsystems/Arm.cpp
@@ -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);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.hpp
index 3db15311468..0165bdaa073 100644
--- a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/Robot.hpp
@@ -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;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/subsystems/Arm.hpp b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/subsystems/Arm.hpp
index 3abba312fc6..49160fac4fe 100644
--- a/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/subsystems/Arm.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/ArmSimulation/include/subsystems/Arm.hpp
@@ -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::Mechanism2d mech2d{60, 60};
+ wpi::MechanismRoot2d* armBase = mech2d.GetRoot("ArmBase", 30, 30);
+ wpi::MechanismLigament2d* armTower =
+ armBase->Append(
"Arm Tower", 30, -90_deg, 6,
wpi::util::Color8Bit{wpi::util::Color::BLUE});
- wpi::MechanismLigament2d* m_arm = m_armBase->Append(
- "Arm", 30, m_armSim.GetAngle(), 6,
+ wpi::MechanismLigament2d* arm = armBase->Append(
+ "Arm", 30, armSim.GetAngle(), 6,
wpi::util::Color8Bit{wpi::util::Color::YELLOW});
};
diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Drivetrain.cpp
index 1e8d8033b3b..130e3913f9b 100644
--- a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Drivetrain.cpp
@@ -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()});
}
diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Robot.cpp
index 07240594927..c90cf424b27 100644
--- a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/cpp/Robot.cpp
@@ -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()) *
- Drivetrain::kMaxVelocity;
+ 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 m_velocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_rotLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter velocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter rotLimiter{3 / 1_s};
- Drivetrain m_drive;
+ Drivetrain drive;
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.hpp
index 66865080b6a..238d1d2dd80 100644
--- a/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDriveBot/include/Drivetrain.hpp
@@ -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 /
- kEncoderResolution);
- m_rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
- kEncoderResolution);
+ leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
+ kEncoderResolution);
+ 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 m_feedforward{
+ wpi::math::SimpleMotorFeedforward feedforward{
1_V, 3_V / 1_mps};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Drivetrain.cpp
index ddf698a202b..8a48593c8f1 100644
--- a/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Drivetrain.cpp
@@ -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());
-
- m_leftLeader.SetVoltage(wpi::units::volt_t{leftOutput} + leftFeedforward);
- m_rightLeader.SetVoltage(wpi::units::volt_t{rightOutput} + rightFeedforward);
+ 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());
+
+ 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,32 +114,30 @@ 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,
- wpi::Timer::GetTimestamp());
+ poseEstimator.AddVisionMeasurement(visionMeasurement2d,
+ wpi::Timer::GetTimestamp());
}
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()} *
- wpi::RobotController::GetInputVoltage(),
- wpi::units::volt_t{m_rightLeader.GetThrottle()} *
- wpi::RobotController::GetInputVoltage());
- m_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());
+ drivetrainSimulator.SetInputs(wpi::units::volt_t{leftLeader.GetThrottle()} *
+ wpi::RobotController::GetInputVoltage(),
+ wpi::units::volt_t{rightLeader.GetThrottle()} *
+ wpi::RobotController::GetInputVoltage());
+ drivetrainSimulator.Update(20_ms);
+
+ 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());
}
diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Robot.cpp
index 2a71a00e0f9..df3626f038f 100644
--- a/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/cpp/Robot.cpp
@@ -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()) *
- Drivetrain::kMaxVelocity;
+ 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 m_velocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_rotLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter velocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter rotLimiter{3 / 1_s};
- Drivetrain m_drive;
+ Drivetrain drive;
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/include/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/include/Drivetrain.hpp
index e047396a596..694415b61f1 100644
--- a/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/include/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/DifferentialDrivePoseEstimator/include/Drivetrain.hpp
@@ -114,64 +114,63 @@ class Drivetrain {
static constexpr std::array 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 m_feedforward{
+ wpi::math::SimpleMotorFeedforward 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};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp
index 0dc98a27e52..ee3bc8fd01c 100644
--- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp
@@ -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();
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp
index 6d39814f000..0cbc94bc430 100644
--- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/RobotContainer.cpp
@@ -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() {
diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/subsystems/DriveSubsystem.cpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/subsystems/DriveSubsystem.cpp
index 6dc25fce99c..07c6ad73ced 100644
--- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/subsystems/DriveSubsystem.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/subsystems/DriveSubsystem.cpp
@@ -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::State nextLeft,
wpi::math::TrapezoidProfile::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 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 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 currentTime = timer.Get();
+
+ 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 = 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); });
}
diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/ExampleSmartMotorController.hpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/ExampleSmartMotorController.hpp
index ffbc6670877..aafa85b6c09 100644
--- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/ExampleSmartMotorController.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/ExampleSmartMotorController.hpp
@@ -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;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.hpp
index 0e9c4263059..48afbcff88f 100644
--- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/Robot.hpp
@@ -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 m_autonomousCommand;
+ std::optional autonomousCommand;
- RobotContainer m_container;
+ RobotContainer container;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp
index 98daed3f92b..8b388c870ea 100644
--- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/RobotContainer.hpp
@@ -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();
};
diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.hpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.hpp
index d03185828c1..d291b1f5774 100644
--- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/include/subsystems/DriveSubsystem.hpp
@@ -95,25 +95,24 @@ class DriveSubsystem : public wpi::cmd::SubsystemBase {
wpi::units::meter_t distance);
private:
- wpi::math::TrapezoidProfile m_profile{
+ wpi::math::TrapezoidProfile 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 m_feedforward;
+ wpi::math::SimpleMotorFeedforward 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); }};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp
index d8c58f2ab0a..4af02f14b71 100644
--- a/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/DutyCycleEncoder/cpp/Robot.cpp
@@ -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
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialProfile/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialProfile/cpp/Robot.cpp
index 41e0502a1be..8dc89f92161 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialProfile/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialProfile/cpp/Robot.cpp
@@ -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 m_feedforward{
+ wpi::Joystick joystick{1};
+ ExampleSmartMotorController motor{1};
+ wpi::math::SimpleMotorFeedforward 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
- m_profile{{10_V, 1_V / 1_mps, 1_V / 1_mps_sq}};
+ wpi::math::ExponentialProfile profile{
+ {10_V, 1_V / 1_mps, 1_V / 1_mps_sq}};
wpi::math::ExponentialProfile::State
- m_goal;
+ goal;
wpi::math::ExponentialProfile::State
- m_setpoint;
+ setpoint;
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/Robot.cpp
index 30ac839b982..1f406d59062 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/Robot.cpp
@@ -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
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/subsystems/Elevator.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/subsystems/Elevator.cpp
index 82e249ce3c1..71a60e64d70 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/subsystems/Elevator.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/cpp/subsystems/Elevator.cpp
@@ -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::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);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.hpp
index 6a1add72889..4f4ee9cb916 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/Robot.hpp
@@ -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;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/subsystems/Elevator.hpp b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/subsystems/Elevator.hpp
index 07828f57dd7..4d7a0c880b9 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/subsystems/Elevator.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorExponentialSimulation/include/subsystems/Elevator.hpp
@@ -31,45 +31,45 @@ 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::Constraints m_constraints{
+ wpi::units::volts>::Constraints constraints{
Constants::kElevatorMaxV, Constants::kElevatorkV, Constants::kElevatorkA};
- wpi::math::ExponentialProfile
- m_profile{m_constraints};
+ wpi::math::ExponentialProfile profile{
+ constraints};
wpi::math::ExponentialProfile::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,
- Constants::kEncoderBChannel};
- wpi::PWMSparkMax m_motor{Constants::kMotorPort};
- wpi::sim::PWMMotorControllerSim m_motorSim{m_motor};
+ wpi::Encoder encoder{Constants::kEncoderAChannel,
+ Constants::kEncoderBChannel};
+ 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,
- Constants::kElevatorGearing,
- Constants::kCarriageMass,
- Constants::kElevatorDrumRadius,
- Constants::kMinElevatorHeight,
- Constants::kMaxElevatorHeight,
- true,
- 0_m,
- {0.005}};
- wpi::sim::EncoderSim m_encoderSim{m_encoder};
+ wpi::sim::ElevatorSim elevatorSim{elevatorGearbox,
+ Constants::kElevatorGearing,
+ Constants::kCarriageMass,
+ Constants::kElevatorDrumRadius,
+ Constants::kMinElevatorHeight,
+ Constants::kMaxElevatorHeight,
+ true,
+ 0_m,
+ {0.005}};
+ 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(
- "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(
+ "Elevator", elevatorSim.GetPosition().value(), 90_deg);
};
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp
index c605aca2264..af72778efb9 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorProfiledPID/cpp/Robot.cpp
@@ -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::Constraints m_constraints{
+ wpi::math::TrapezoidProfile::Constraints constraints{
kMaxVelocity, kMaxAcceleration};
- wpi::math::ProfiledPIDController m_controller{
- kP, kI, kD, m_constraints, kDt};
- wpi::math::ElevatorFeedforward m_feedforward{kS, kG, kV};
+ wpi::math::ProfiledPIDController controller{
+ kP, kI, kD, constraints, kDt};
+ wpi::math::ElevatorFeedforward feedforward{kS, kG, kV};
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/Robot.cpp
index d71256a8cee..58fdedde09a 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/Robot.cpp
@@ -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
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/subsystems/Elevator.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/subsystems/Elevator.cpp
index 2f9f595e660..0ea914fe3b6 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/subsystems/Elevator.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/cpp/subsystems/Elevator.cpp
@@ -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);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.hpp
index 4dfa94cb274..dd47cf34f49 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/Robot.hpp
@@ -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;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/subsystems/Elevator.hpp b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/subsystems/Elevator.hpp
index 3fdf7269cd5..925eddef4c6 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/subsystems/Elevator.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorSimulation/include/subsystems/Elevator.hpp
@@ -30,40 +30,39 @@ 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::Constraints m_constraints{
+ wpi::math::TrapezoidProfile::Constraints constraints{
2.45_mps, 2.45_mps_sq};
- wpi::math::ProfiledPIDController m_controller{
+ wpi::math::ProfiledPIDController 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,
- Constants::kEncoderBChannel};
- wpi::PWMSparkMax m_motor{Constants::kMotorPort};
- wpi::sim::PWMMotorControllerSim m_motorSim{m_motor};
+ wpi::Encoder encoder{Constants::kEncoderAChannel,
+ Constants::kEncoderBChannel};
+ 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,
- Constants::kElevatorGearing,
- Constants::kCarriageMass,
- Constants::kElevatorDrumRadius,
- Constants::kMinElevatorHeight,
- Constants::kMaxElevatorHeight,
- true,
- 0_m,
- {0.01}};
- wpi::sim::EncoderSim m_encoderSim{m_encoder};
+ wpi::sim::ElevatorSim elevatorSim{elevatorGearbox,
+ Constants::kElevatorGearing,
+ Constants::kCarriageMass,
+ Constants::kElevatorDrumRadius,
+ Constants::kMinElevatorHeight,
+ Constants::kMaxElevatorHeight,
+ true,
+ 0_m,
+ {0.01}};
+ 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(
- "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(
+ "Elevator", elevatorSim.GetPosition().value(), 90_deg);
};
diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp
index 4903f487558..d7ed37c4a92 100644
--- a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp
@@ -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 m_feedforward{
+ wpi::Joystick joystick{1};
+ ExampleSmartMotorController motor{1};
+ wpi::math::SimpleMotorFeedforward 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 m_profile{
+ wpi::math::TrapezoidProfile profile{
{1.75_mps, 0.75_mps_sq}};
- wpi::math::TrapezoidProfile::State m_goal;
- wpi::math::TrapezoidProfile::State m_setpoint;
+ wpi::math::TrapezoidProfile::State goal;
+ wpi::math::TrapezoidProfile::State setpoint;
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp
index 60d5d313114..245a6c9e4b7 100644
--- a/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/Encoder/cpp/Robot.cpp
@@ -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
diff --git a/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp
index 71ad9ec71ee..1ccd9ccb7f8 100644
--- a/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/GettingStarted/cpp/Robot.cpp
@@ -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
diff --git a/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp
index 75cfbc66122..23631e2207b 100644
--- a/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/Gyro/cpp/Robot.cpp
@@ -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
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp
index 9fc2a216c40..f39fcb031e4 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/Robot.cpp
@@ -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;
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp
index 052f1a5cc54..b79c16cecc5 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/RobotContainer.cpp
@@ -11,41 +11,41 @@ RobotContainer::RobotContainer() {
// Add commands to the autonomous command chooser
// Note that we do *not* move ownership into the chooser
- m_chooser.SetDefaultOption("Simple Auto", m_simpleAuto.get());
- m_chooser.AddOption("Complex Auto", m_complexAuto.get());
+ chooser.SetDefaultOption("Simple Auto", simpleAuto.get());
+ chooser.AddOption("Complex Auto", complexAuto.get());
// Put the chooser on the dashboard
- wpi::SmartDashboard::PutData("Autonomous", &m_chooser);
+ wpi::SmartDashboard::PutData("Autonomous", &chooser);
// Put subsystems to dashboard.
- wpi::SmartDashboard::PutData("Drivetrain", &m_drive);
- wpi::SmartDashboard::PutData("HatchSubsystem", &m_hatch);
+ wpi::SmartDashboard::PutData("Drivetrain", &drive);
+ wpi::SmartDashboard::PutData("HatchSubsystem", &hatch);
// Configure the button bindings
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
// Grab the hatch when the 'East Face' button is pressed.
- m_driverController.EastFace().OnTrue(m_hatch.GrabHatchCommand());
+ driverController.EastFace().OnTrue(hatch.GrabHatchCommand());
// Release the hatch when the 'West Face' button is pressed.
- m_driverController.WestFace().OnTrue(m_hatch.ReleaseHatchCommand());
+ driverController.WestFace().OnTrue(hatch.ReleaseHatchCommand());
// While holding Right Bumper, drive at half velocity
- m_driverController.RightBumper()
- .OnTrue(wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {}))
- .OnFalse(wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(1.0); }, {}));
+ driverController.RightBumper()
+ .OnTrue(wpi::cmd::RunOnce([this] { drive.SetMaxOutput(0.5); }, {}))
+ .OnFalse(wpi::cmd::RunOnce([this] { drive.SetMaxOutput(1.0); }, {}));
}
wpi::cmd::Command* RobotContainer::GetAutonomousCommand() {
// Runs the chosen command in autonomous
- return m_chooser.GetSelected();
+ return chooser.GetSelected();
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/DriveSubsystem.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/DriveSubsystem.cpp
index 8bae9bdad2a..feaa942b87e 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/DriveSubsystem.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/DriveSubsystem.cpp
@@ -9,26 +9,26 @@
using namespace DriveConstants;
DriveSubsystem::DriveSubsystem()
- : m_left1{kLeftMotor1Port},
- m_left2{kLeftMotor2Port},
- m_right1{kRightMotor1Port},
- m_right2{kRightMotor2Port},
- m_leftEncoder{kLeftEncoderPorts[0], kLeftEncoderPorts[1]},
- m_rightEncoder{kRightEncoderPorts[0], kRightEncoderPorts[1]} {
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_left1);
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_right1);
-
- m_left1.AddFollower(m_left2);
- m_right1.AddFollower(m_right2);
+ : left1{kLeftMotor1Port},
+ left2{kLeftMotor2Port},
+ right1{kRightMotor1Port},
+ right2{kRightMotor2Port},
+ leftEncoder{kLeftEncoderPorts[0], kLeftEncoderPorts[1]},
+ rightEncoder{kRightEncoderPorts[0], kRightEncoderPorts[1]} {
+ wpi::util::SendableRegistry::AddChild(&drive, &left1);
+ wpi::util::SendableRegistry::AddChild(&drive, &right1);
+
+ left1.AddFollower(left2);
+ right1.AddFollower(right2);
// 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_right1.SetInverted(true);
+ right1.SetInverted(true);
// Set the distance per pulse for the encoders
- m_leftEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
- m_rightEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
+ leftEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
+ rightEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
}
void DriveSubsystem::Periodic() {
@@ -36,20 +36,20 @@ void DriveSubsystem::Periodic() {
}
void DriveSubsystem::ArcadeDrive(double fwd, double rot) {
- m_drive.ArcadeDrive(fwd, rot);
+ drive.ArcadeDrive(fwd, rot);
}
void DriveSubsystem::ResetEncoders() {
- m_leftEncoder.Reset();
- m_rightEncoder.Reset();
+ leftEncoder.Reset();
+ rightEncoder.Reset();
}
double DriveSubsystem::GetAverageEncoderDistance() {
- return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
+ return (leftEncoder.GetDistance() + rightEncoder.GetDistance()) / 2.0;
}
void DriveSubsystem::SetMaxOutput(double maxOutput) {
- m_drive.SetMaxOutput(maxOutput);
+ drive.SetMaxOutput(maxOutput);
}
void DriveSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
@@ -57,8 +57,7 @@ void DriveSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
// Publish encoder distances to telemetry.
builder.AddDoubleProperty(
- "leftDistance", [this] { return m_leftEncoder.GetDistance(); }, nullptr);
+ "leftDistance", [this] { return leftEncoder.GetDistance(); }, nullptr);
builder.AddDoubleProperty(
- "rightDistance", [this] { return m_rightEncoder.GetDistance(); },
- nullptr);
+ "rightDistance", [this] { return rightEncoder.GetDistance(); }, nullptr);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/HatchSubsystem.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/HatchSubsystem.cpp
index be653352f4d..445959ecd81 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/HatchSubsystem.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/subsystems/HatchSubsystem.cpp
@@ -9,19 +9,19 @@
using namespace HatchConstants;
HatchSubsystem::HatchSubsystem()
- : m_hatchSolenoid{0, wpi::PneumaticsModuleType::CTRE_PCM,
- kHatchSolenoidPorts[0], kHatchSolenoidPorts[1]} {}
+ : hatchSolenoid{0, wpi::PneumaticsModuleType::CTRE_PCM,
+ kHatchSolenoidPorts[0], kHatchSolenoidPorts[1]} {}
wpi::cmd::CommandPtr HatchSubsystem::GrabHatchCommand() {
// implicitly require `this`
return this->RunOnce(
- [this] { m_hatchSolenoid.Set(wpi::DoubleSolenoid::FORWARD); });
+ [this] { hatchSolenoid.Set(wpi::DoubleSolenoid::FORWARD); });
}
wpi::cmd::CommandPtr HatchSubsystem::ReleaseHatchCommand() {
// implicitly require `this`
return this->RunOnce(
- [this] { m_hatchSolenoid.Set(wpi::DoubleSolenoid::REVERSE); });
+ [this] { hatchSolenoid.Set(wpi::DoubleSolenoid::REVERSE); });
}
void HatchSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
@@ -30,6 +30,6 @@ void HatchSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
// Publish the solenoid state to telemetry.
builder.AddBooleanProperty(
"extended",
- [this] { return m_hatchSolenoid.Get() == wpi::DoubleSolenoid::FORWARD; },
+ [this] { return hatchSolenoid.Get() == wpi::DoubleSolenoid::FORWARD; },
nullptr);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.hpp
index 377ae1bfc2f..c59dc48dc32 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/Robot.hpp
@@ -23,7 +23,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.
- wpi::cmd::Command* m_autonomousCommand = nullptr;
+ wpi::cmd::Command* autonomousCommand = nullptr;
- RobotContainer m_container;
+ RobotContainer container;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/RobotContainer.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/RobotContainer.hpp
index 27b5326b3e7..d614f2b2f42 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/RobotContainer.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/RobotContainer.hpp
@@ -30,23 +30,22 @@ 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;
- HatchSubsystem m_hatch;
+ DriveSubsystem drive;
+ HatchSubsystem hatch;
// Commands owned by RobotContainer
// The autonomous routines
- wpi::cmd::CommandPtr m_simpleAuto = autos::SimpleAuto(&m_drive);
- wpi::cmd::CommandPtr m_complexAuto = autos::ComplexAuto(&m_drive, &m_hatch);
+ wpi::cmd::CommandPtr simpleAuto = autos::SimpleAuto(&drive);
+ wpi::cmd::CommandPtr complexAuto = autos::ComplexAuto(&drive, &hatch);
// The chooser for the autonomous routines
- wpi::SendableChooser m_chooser;
+ wpi::SendableChooser chooser;
void ConfigureButtonBindings();
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/DriveSubsystem.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/DriveSubsystem.hpp
index 0367dd24090..f3c23f6ac38 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/DriveSubsystem.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/DriveSubsystem.hpp
@@ -56,19 +56,19 @@ class DriveSubsystem : public wpi::cmd::SubsystemBase {
// declared private and exposed only through public methods.
// The motor controllers
- wpi::PWMSparkMax m_left1;
- wpi::PWMSparkMax m_left2;
- wpi::PWMSparkMax m_right1;
- wpi::PWMSparkMax m_right2;
+ wpi::PWMSparkMax left1;
+ wpi::PWMSparkMax left2;
+ wpi::PWMSparkMax right1;
+ wpi::PWMSparkMax right2;
// The robot's drive
- wpi::DifferentialDrive m_drive{
- [&](double output) { m_left1.SetThrottle(output); },
- [&](double output) { m_right1.SetThrottle(output); }};
+ wpi::DifferentialDrive drive{
+ [&](double output) { left1.SetThrottle(output); },
+ [&](double output) { right1.SetThrottle(output); }};
// The left-side drive encoder
- wpi::Encoder m_leftEncoder;
+ wpi::Encoder leftEncoder;
// The right-side drive encoder
- wpi::Encoder m_rightEncoder;
+ wpi::Encoder rightEncoder;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/HatchSubsystem.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/HatchSubsystem.hpp
index d1fd94643cc..0be87fc9076 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/HatchSubsystem.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/include/subsystems/HatchSubsystem.hpp
@@ -31,5 +31,5 @@ class HatchSubsystem : public wpi::cmd::SubsystemBase {
private:
// Components (e.g. motor controllers and sensors) should generally be
// declared private and exposed only through public methods.
- wpi::DoubleSolenoid m_hatchSolenoid;
+ wpi::DoubleSolenoid hatchSolenoid;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp
index 9fc2a216c40..f39fcb031e4 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp
@@ -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;
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/RobotContainer.cpp
index b984ddf91b1..4014810c721 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/RobotContainer.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/RobotContainer.cpp
@@ -15,22 +15,22 @@ RobotContainer::RobotContainer() {
// Initialize all of your commands and subsystems here
// Add commands to the autonomous command chooser
- m_chooser.SetDefaultOption("Simple Auto", &m_simpleAuto);
- m_chooser.AddOption("Complex Auto", &m_complexAuto);
+ chooser.SetDefaultOption("Simple Auto", &simpleAuto);
+ chooser.AddOption("Complex Auto", &complexAuto);
// Put the chooser on the dashboard
- wpi::SmartDashboard::PutData("Autonomous", &m_chooser);
+ wpi::SmartDashboard::PutData("Autonomous", &chooser);
// Put subsystems to dashboard.
- wpi::SmartDashboard::PutData("Drivetrain", &m_drive);
- wpi::SmartDashboard::PutData("HatchSubsystem", &m_hatch);
+ wpi::SmartDashboard::PutData("Drivetrain", &drive);
+ wpi::SmartDashboard::PutData("HatchSubsystem", &hatch);
// Configure the button bindings
ConfigureButtonBindings();
// Set up default drive command
- m_drive.SetDefaultCommand(DefaultDrive(
- &m_drive, [this] { return -m_driverController.GetLeftY(); },
- [this] { return -m_driverController.GetRightX(); }));
+ drive.SetDefaultCommand(DefaultDrive(
+ &drive, [this] { return -driverController.GetLeftY(); },
+ [this] { return -driverController.GetRightX(); }));
}
void RobotContainer::ConfigureButtonBindings() {
@@ -40,18 +40,17 @@ void RobotContainer::ConfigureButtonBindings() {
// the scheduler thus, no memory leaks!
// Grab the hatch when the 'South Face' button is pressed.
- wpi::cmd::GamepadButton(&m_driverController, wpi::Gamepad::Button::SOUTH_FACE)
- .OnTrue(GrabHatch(&m_hatch).ToPtr());
+ wpi::cmd::GamepadButton(&driverController, wpi::Gamepad::Button::SOUTH_FACE)
+ .OnTrue(GrabHatch(&hatch).ToPtr());
// Release the hatch when the 'East Face' button is pressed.
- wpi::cmd::GamepadButton(&m_driverController, wpi::Gamepad::Button::EAST_FACE)
- .OnTrue(ReleaseHatch(&m_hatch).ToPtr());
+ wpi::cmd::GamepadButton(&driverController, wpi::Gamepad::Button::EAST_FACE)
+ .OnTrue(ReleaseHatch(&hatch).ToPtr());
// While holding the bumper button, drive at half velocity
- wpi::cmd::GamepadButton(&m_driverController,
- wpi::Gamepad::Button::RIGHT_BUMPER)
- .WhileTrue(HalveDriveVelocity(&m_drive).ToPtr());
+ wpi::cmd::GamepadButton(&driverController, wpi::Gamepad::Button::RIGHT_BUMPER)
+ .WhileTrue(HalveDriveVelocity(&drive).ToPtr());
}
wpi::cmd::Command* RobotContainer::GetAutonomousCommand() {
// Runs the chosen command in autonomous
- return m_chooser.GetSelected();
+ return chooser.GetSelected();
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp
index fce831d9c37..13ebd9d7867 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DefaultDrive.cpp
@@ -9,12 +9,12 @@
DefaultDrive::DefaultDrive(DriveSubsystem* subsystem,
std::function forward,
std::function rotation)
- : m_drive{subsystem},
- m_forward{std::move(forward)},
- m_rotation{std::move(rotation)} {
+ : drive{subsystem},
+ forward{std::move(forward)},
+ rotation{std::move(rotation)} {
AddRequirements(subsystem);
}
void DefaultDrive::Execute() {
- m_drive->ArcadeDrive(m_forward(), m_rotation());
+ drive->ArcadeDrive(forward(), rotation());
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DriveDistance.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DriveDistance.cpp
index d86e797bf83..9b32feb8845 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DriveDistance.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/DriveDistance.cpp
@@ -8,23 +8,23 @@
DriveDistance::DriveDistance(double inches, double velocity,
DriveSubsystem* subsystem)
- : m_drive(subsystem), m_distance(inches), m_velocity(velocity) {
+ : drive(subsystem), distance(inches), velocity(velocity) {
AddRequirements(subsystem);
}
void DriveDistance::Initialize() {
- m_drive->ResetEncoders();
- m_drive->ArcadeDrive(m_velocity, 0);
+ drive->ResetEncoders();
+ drive->ArcadeDrive(velocity, 0);
}
void DriveDistance::Execute() {
- m_drive->ArcadeDrive(m_velocity, 0);
+ drive->ArcadeDrive(velocity, 0);
}
void DriveDistance::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
+ drive->ArcadeDrive(0, 0);
}
bool DriveDistance::IsFinished() {
- return std::abs(m_drive->GetAverageEncoderDistance()) >= m_distance;
+ return std::abs(drive->GetAverageEncoderDistance()) >= distance;
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp
index 001229cc953..e6ebe5b3dd3 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/GrabHatch.cpp
@@ -4,12 +4,12 @@
#include "commands/GrabHatch.hpp"
-GrabHatch::GrabHatch(HatchSubsystem* subsystem) : m_hatch(subsystem) {
+GrabHatch::GrabHatch(HatchSubsystem* subsystem) : hatch(subsystem) {
AddRequirements(subsystem);
}
void GrabHatch::Initialize() {
- m_hatch->GrabHatch();
+ hatch->GrabHatch();
}
bool GrabHatch::IsFinished() {
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/HalveDriveVelocity.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/HalveDriveVelocity.cpp
index 4278ad5c9f6..6df4ff982c0 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/HalveDriveVelocity.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/HalveDriveVelocity.cpp
@@ -5,12 +5,12 @@
#include "commands/HalveDriveVelocity.hpp"
HalveDriveVelocity::HalveDriveVelocity(DriveSubsystem* subsystem)
- : m_drive(subsystem) {}
+ : drive(subsystem) {}
void HalveDriveVelocity::Initialize() {
- m_drive->SetMaxOutput(0.5);
+ drive->SetMaxOutput(0.5);
}
void HalveDriveVelocity::End(bool interrupted) {
- m_drive->SetMaxOutput(1);
+ drive->SetMaxOutput(1);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/ReleaseHatch.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/ReleaseHatch.cpp
index 4dbca0e7efd..c05ecf04ec1 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/ReleaseHatch.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/commands/ReleaseHatch.cpp
@@ -4,12 +4,12 @@
#include "commands/ReleaseHatch.hpp"
-ReleaseHatch::ReleaseHatch(HatchSubsystem* subsystem) : m_hatch(subsystem) {
+ReleaseHatch::ReleaseHatch(HatchSubsystem* subsystem) : hatch(subsystem) {
AddRequirements(subsystem);
}
void ReleaseHatch::Initialize() {
- m_hatch->ReleaseHatch();
+ hatch->ReleaseHatch();
}
bool ReleaseHatch::IsFinished() {
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/DriveSubsystem.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/DriveSubsystem.cpp
index 8bae9bdad2a..feaa942b87e 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/DriveSubsystem.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/DriveSubsystem.cpp
@@ -9,26 +9,26 @@
using namespace DriveConstants;
DriveSubsystem::DriveSubsystem()
- : m_left1{kLeftMotor1Port},
- m_left2{kLeftMotor2Port},
- m_right1{kRightMotor1Port},
- m_right2{kRightMotor2Port},
- m_leftEncoder{kLeftEncoderPorts[0], kLeftEncoderPorts[1]},
- m_rightEncoder{kRightEncoderPorts[0], kRightEncoderPorts[1]} {
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_left1);
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_right1);
-
- m_left1.AddFollower(m_left2);
- m_right1.AddFollower(m_right2);
+ : left1{kLeftMotor1Port},
+ left2{kLeftMotor2Port},
+ right1{kRightMotor1Port},
+ right2{kRightMotor2Port},
+ leftEncoder{kLeftEncoderPorts[0], kLeftEncoderPorts[1]},
+ rightEncoder{kRightEncoderPorts[0], kRightEncoderPorts[1]} {
+ wpi::util::SendableRegistry::AddChild(&drive, &left1);
+ wpi::util::SendableRegistry::AddChild(&drive, &right1);
+
+ left1.AddFollower(left2);
+ right1.AddFollower(right2);
// 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_right1.SetInverted(true);
+ right1.SetInverted(true);
// Set the distance per pulse for the encoders
- m_leftEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
- m_rightEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
+ leftEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
+ rightEncoder.SetDistancePerPulse(kEncoderDistancePerPulse);
}
void DriveSubsystem::Periodic() {
@@ -36,20 +36,20 @@ void DriveSubsystem::Periodic() {
}
void DriveSubsystem::ArcadeDrive(double fwd, double rot) {
- m_drive.ArcadeDrive(fwd, rot);
+ drive.ArcadeDrive(fwd, rot);
}
void DriveSubsystem::ResetEncoders() {
- m_leftEncoder.Reset();
- m_rightEncoder.Reset();
+ leftEncoder.Reset();
+ rightEncoder.Reset();
}
double DriveSubsystem::GetAverageEncoderDistance() {
- return (m_leftEncoder.GetDistance() + m_rightEncoder.GetDistance()) / 2.0;
+ return (leftEncoder.GetDistance() + rightEncoder.GetDistance()) / 2.0;
}
void DriveSubsystem::SetMaxOutput(double maxOutput) {
- m_drive.SetMaxOutput(maxOutput);
+ drive.SetMaxOutput(maxOutput);
}
void DriveSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
@@ -57,8 +57,7 @@ void DriveSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
// Publish encoder distances to telemetry.
builder.AddDoubleProperty(
- "leftDistance", [this] { return m_leftEncoder.GetDistance(); }, nullptr);
+ "leftDistance", [this] { return leftEncoder.GetDistance(); }, nullptr);
builder.AddDoubleProperty(
- "rightDistance", [this] { return m_rightEncoder.GetDistance(); },
- nullptr);
+ "rightDistance", [this] { return rightEncoder.GetDistance(); }, nullptr);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/HatchSubsystem.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/HatchSubsystem.cpp
index 1a3e6bc9863..3a4c02fc01a 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/HatchSubsystem.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/subsystems/HatchSubsystem.cpp
@@ -9,15 +9,15 @@
using namespace HatchConstants;
HatchSubsystem::HatchSubsystem()
- : m_hatchSolenoid{0, wpi::PneumaticsModuleType::CTRE_PCM,
- kHatchSolenoidPorts[0], kHatchSolenoidPorts[1]} {}
+ : hatchSolenoid{0, wpi::PneumaticsModuleType::CTRE_PCM,
+ kHatchSolenoidPorts[0], kHatchSolenoidPorts[1]} {}
void HatchSubsystem::GrabHatch() {
- m_hatchSolenoid.Set(wpi::DoubleSolenoid::FORWARD);
+ hatchSolenoid.Set(wpi::DoubleSolenoid::FORWARD);
}
void HatchSubsystem::ReleaseHatch() {
- m_hatchSolenoid.Set(wpi::DoubleSolenoid::REVERSE);
+ hatchSolenoid.Set(wpi::DoubleSolenoid::REVERSE);
}
void HatchSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
@@ -26,6 +26,6 @@ void HatchSubsystem::InitSendable(wpi::util::SendableBuilder& builder) {
// Publish the solenoid state to telemetry.
builder.AddBooleanProperty(
"extended",
- [this] { return m_hatchSolenoid.Get() == wpi::DoubleSolenoid::FORWARD; },
+ [this] { return hatchSolenoid.Get() == wpi::DoubleSolenoid::FORWARD; },
nullptr);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.hpp
index 377ae1bfc2f..c59dc48dc32 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/Robot.hpp
@@ -23,7 +23,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.
- wpi::cmd::Command* m_autonomousCommand = nullptr;
+ wpi::cmd::Command* autonomousCommand = nullptr;
- RobotContainer m_container;
+ RobotContainer container;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/RobotContainer.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/RobotContainer.hpp
index ff38bc36b9b..4a82e45432d 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/RobotContainer.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/RobotContainer.hpp
@@ -31,19 +31,19 @@ class RobotContainer {
// The robot's subsystems and commands are defined here...
// The robot's subsystems
- DriveSubsystem m_drive;
- HatchSubsystem m_hatch;
+ DriveSubsystem drive;
+ HatchSubsystem hatch;
// The autonomous routines
- DriveDistance m_simpleAuto{AutoConstants::kAutoDriveDistanceInches,
- AutoConstants::kAutoDriveVelocity, &m_drive};
- ComplexAuto m_complexAuto{&m_drive, &m_hatch};
+ DriveDistance simpleAuto{AutoConstants::kAutoDriveDistanceInches,
+ AutoConstants::kAutoDriveVelocity, &drive};
+ ComplexAuto complexAuto{&drive, &hatch};
// The chooser for the autonomous routines
- wpi::SendableChooser m_chooser;
+ wpi::SendableChooser chooser;
// The driver's controller
- wpi::Gamepad m_driverController{OIConstants::kDriverControllerPort};
+ wpi::Gamepad driverController{OIConstants::kDriverControllerPort};
void ConfigureButtonBindings();
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DefaultDrive.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DefaultDrive.hpp
index a45a1b2ce32..3c7ed8a9a0c 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DefaultDrive.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DefaultDrive.hpp
@@ -33,7 +33,7 @@ class DefaultDrive
void Execute() override;
private:
- DriveSubsystem* m_drive;
- std::function m_forward;
- std::function m_rotation;
+ DriveSubsystem* drive;
+ std::function forward;
+ std::function rotation;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DriveDistance.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DriveDistance.hpp
index 756f127138e..72138d7d837 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DriveDistance.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/DriveDistance.hpp
@@ -29,7 +29,7 @@ class DriveDistance
bool IsFinished() override;
private:
- DriveSubsystem* m_drive;
- double m_distance;
- double m_velocity;
+ DriveSubsystem* drive;
+ double distance;
+ double velocity;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/GrabHatch.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/GrabHatch.hpp
index d01746d4989..87ba12ab0d2 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/GrabHatch.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/GrabHatch.hpp
@@ -24,5 +24,5 @@ class GrabHatch : public wpi::cmd::CommandHelper {
bool IsFinished() override;
private:
- HatchSubsystem* m_hatch;
+ HatchSubsystem* hatch;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/HalveDriveVelocity.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/HalveDriveVelocity.hpp
index 7440ba265d4..ab23156729c 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/HalveDriveVelocity.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/HalveDriveVelocity.hpp
@@ -18,5 +18,5 @@ class HalveDriveVelocity
void End(bool interrupted) override;
private:
- DriveSubsystem* m_drive;
+ DriveSubsystem* drive;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/ReleaseHatch.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/ReleaseHatch.hpp
index f6e14c70e66..d5b4730bf37 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/ReleaseHatch.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/commands/ReleaseHatch.hpp
@@ -25,5 +25,5 @@ class ReleaseHatch
bool IsFinished() override;
private:
- HatchSubsystem* m_hatch;
+ HatchSubsystem* hatch;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/DriveSubsystem.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/DriveSubsystem.hpp
index 0367dd24090..f3c23f6ac38 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/DriveSubsystem.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/DriveSubsystem.hpp
@@ -56,19 +56,19 @@ class DriveSubsystem : public wpi::cmd::SubsystemBase {
// declared private and exposed only through public methods.
// The motor controllers
- wpi::PWMSparkMax m_left1;
- wpi::PWMSparkMax m_left2;
- wpi::PWMSparkMax m_right1;
- wpi::PWMSparkMax m_right2;
+ wpi::PWMSparkMax left1;
+ wpi::PWMSparkMax left2;
+ wpi::PWMSparkMax right1;
+ wpi::PWMSparkMax right2;
// The robot's drive
- wpi::DifferentialDrive m_drive{
- [&](double output) { m_left1.SetThrottle(output); },
- [&](double output) { m_right1.SetThrottle(output); }};
+ wpi::DifferentialDrive drive{
+ [&](double output) { left1.SetThrottle(output); },
+ [&](double output) { right1.SetThrottle(output); }};
// The left-side drive encoder
- wpi::Encoder m_leftEncoder;
+ wpi::Encoder leftEncoder;
// The right-side drive encoder
- wpi::Encoder m_rightEncoder;
+ wpi::Encoder rightEncoder;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/HatchSubsystem.hpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/HatchSubsystem.hpp
index 7560a28c81a..0908b1162f4 100644
--- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/HatchSubsystem.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/include/subsystems/HatchSubsystem.hpp
@@ -30,5 +30,5 @@ class HatchSubsystem : public wpi::cmd::SubsystemBase {
private:
// Components (e.g. motor controllers and sensors) should generally be
// declared private and exposed only through public methods.
- wpi::DoubleSolenoid m_hatchSolenoid;
+ wpi::DoubleSolenoid hatchSolenoid;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Drivetrain.cpp
index 76d35011da6..2d7b6daaf11 100644
--- a/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Drivetrain.cpp
@@ -8,48 +8,48 @@
wpi::math::MecanumDriveWheelPositions Drivetrain::GetCurrentWheelDistances()
const {
- return {wpi::units::meter_t{m_frontLeftEncoder.GetDistance()},
- wpi::units::meter_t{m_frontRightEncoder.GetDistance()},
- wpi::units::meter_t{m_backLeftEncoder.GetDistance()},
- wpi::units::meter_t{m_backRightEncoder.GetDistance()}};
+ return {wpi::units::meter_t{frontLeftEncoder.GetDistance()},
+ wpi::units::meter_t{frontRightEncoder.GetDistance()},
+ wpi::units::meter_t{backLeftEncoder.GetDistance()},
+ wpi::units::meter_t{backRightEncoder.GetDistance()}};
}
wpi::math::MecanumDriveWheelVelocities Drivetrain::GetCurrentWheelVelocities()
const {
- return {wpi::units::meters_per_second_t{m_frontLeftEncoder.GetRate()},
- wpi::units::meters_per_second_t{m_frontRightEncoder.GetRate()},
- wpi::units::meters_per_second_t{m_backLeftEncoder.GetRate()},
- wpi::units::meters_per_second_t{m_backRightEncoder.GetRate()}};
+ return {wpi::units::meters_per_second_t{frontLeftEncoder.GetRate()},
+ wpi::units::meters_per_second_t{frontRightEncoder.GetRate()},
+ wpi::units::meters_per_second_t{backLeftEncoder.GetRate()},
+ wpi::units::meters_per_second_t{backRightEncoder.GetRate()}};
}
void Drivetrain::SetVelocities(
const wpi::math::MecanumDriveWheelVelocities& wheelVelocities) {
const auto frontLeftFeedforward =
- m_feedforward.Calculate(wheelVelocities.frontLeft);
+ feedforward.Calculate(wheelVelocities.frontLeft);
const auto frontRightFeedforward =
- m_feedforward.Calculate(wheelVelocities.frontRight);
+ feedforward.Calculate(wheelVelocities.frontRight);
const auto backLeftFeedforward =
- m_feedforward.Calculate(wheelVelocities.rearLeft);
+ feedforward.Calculate(wheelVelocities.rearLeft);
const auto backRightFeedforward =
- m_feedforward.Calculate(wheelVelocities.rearRight);
+ feedforward.Calculate(wheelVelocities.rearRight);
- const double frontLeftOutput = m_frontLeftPIDController.Calculate(
- m_frontLeftEncoder.GetRate(), wheelVelocities.frontLeft.value());
- const double frontRightOutput = m_frontRightPIDController.Calculate(
- m_frontRightEncoder.GetRate(), wheelVelocities.frontRight.value());
- const double backLeftOutput = m_backLeftPIDController.Calculate(
- m_backLeftEncoder.GetRate(), wheelVelocities.rearLeft.value());
- const double backRightOutput = m_backRightPIDController.Calculate(
- m_backRightEncoder.GetRate(), wheelVelocities.rearRight.value());
+ const double frontLeftOutput = frontLeftPIDController.Calculate(
+ frontLeftEncoder.GetRate(), wheelVelocities.frontLeft.value());
+ const double frontRightOutput = frontRightPIDController.Calculate(
+ frontRightEncoder.GetRate(), wheelVelocities.frontRight.value());
+ const double backLeftOutput = backLeftPIDController.Calculate(
+ backLeftEncoder.GetRate(), wheelVelocities.rearLeft.value());
+ const double backRightOutput = backRightPIDController.Calculate(
+ backRightEncoder.GetRate(), wheelVelocities.rearRight.value());
- m_frontLeftMotor.SetVoltage(wpi::units::volt_t{frontLeftOutput} +
- frontLeftFeedforward);
- m_frontRightMotor.SetVoltage(wpi::units::volt_t{frontRightOutput} +
- frontRightFeedforward);
- m_backLeftMotor.SetVoltage(wpi::units::volt_t{backLeftOutput} +
- backLeftFeedforward);
- m_backRightMotor.SetVoltage(wpi::units::volt_t{backRightOutput} +
- backRightFeedforward);
+ frontLeftMotor.SetVoltage(wpi::units::volt_t{frontLeftOutput} +
+ frontLeftFeedforward);
+ frontRightMotor.SetVoltage(wpi::units::volt_t{frontRightOutput} +
+ frontRightFeedforward);
+ backLeftMotor.SetVoltage(wpi::units::volt_t{backLeftOutput} +
+ backLeftFeedforward);
+ backRightMotor.SetVoltage(wpi::units::volt_t{backRightOutput} +
+ backRightFeedforward);
}
void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
@@ -58,14 +58,13 @@ void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
wpi::units::second_t period) {
wpi::math::ChassisVelocities chassisVelocities{xVelocity, yVelocity, rot};
if (fieldRelative) {
- chassisVelocities =
- chassisVelocities.ToRobotRelative(m_imu.GetRotation2d());
+ chassisVelocities = chassisVelocities.ToRobotRelative(imu.GetRotation2d());
}
SetVelocities(
- m_kinematics.ToWheelVelocities(chassisVelocities.Discretize(period))
+ kinematics.ToWheelVelocities(chassisVelocities.Discretize(period))
.Desaturate(kMaxVelocity));
}
void Drivetrain::UpdateOdometry() {
- m_odometry.Update(m_imu.GetRotation2d(), GetCurrentWheelDistances());
+ odometry.Update(imu.GetRotation2d(), GetCurrentWheelDistances());
}
diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Robot.cpp
index 34bde68ea8d..fd0d5cf8ed1 100644
--- a/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/MecanumBot/cpp/Robot.cpp
@@ -11,43 +11,41 @@ class Robot : public wpi::TimedRobot {
public:
void AutonomousPeriodic() override {
DriveWithJoystick(false);
- m_mecanum.UpdateOdometry();
+ mecanum.UpdateOdometry();
}
void TeleopPeriodic() override { DriveWithJoystick(true); }
private:
- wpi::Gamepad m_controller{0};
- Drivetrain m_mecanum;
+ wpi::Gamepad controller{0};
+ Drivetrain mecanum;
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0
// to 1.
- wpi::math::SlewRateLimiter m_xVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_yVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_rotLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter xVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter yVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter rotLimiter{3 / 1_s};
void DriveWithJoystick(bool fieldRelative) {
// Get the x velocity. We are inverting this because gamepads return
// negative values when we push forward.
- const auto xVelocity =
- -m_xVelocityLimiter.Calculate(m_controller.GetLeftY()) *
- Drivetrain::kMaxVelocity;
+ const auto xVelocity = -xVelocityLimiter.Calculate(controller.GetLeftY()) *
+ Drivetrain::kMaxVelocity;
// Get the y velocity or sideways/strafe velocity. We are inverting this
// because we want a positive value when we pull to the left. Gamepads
// return positive values when you pull to the right by default.
- const auto yVelocity =
- -m_yVelocityLimiter.Calculate(m_controller.GetLeftX()) *
- Drivetrain::kMaxVelocity;
+ const auto yVelocity = -yVelocityLimiter.Calculate(controller.GetLeftX()) *
+ 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_mecanum.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
+ mecanum.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumBot/include/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/MecanumBot/include/Drivetrain.hpp
index dc18c7e4e48..601e6213d7a 100644
--- a/wpilibcExamples/src/main/cpp/examples/MecanumBot/include/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/MecanumBot/include/Drivetrain.hpp
@@ -22,12 +22,12 @@
class Drivetrain {
public:
Drivetrain() {
- m_imu.ResetYaw();
+ imu.ResetYaw();
// 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_frontRightMotor.SetInverted(true);
- m_backRightMotor.SetInverted(true);
+ frontRightMotor.SetInverted(true);
+ backRightMotor.SetInverted(true);
}
wpi::math::MecanumDriveWheelPositions GetCurrentWheelDistances() const;
@@ -46,37 +46,37 @@ class Drivetrain {
std::numbers::pi}; // 1/2 rotation per second
private:
- wpi::PWMSparkMax m_frontLeftMotor{1};
- wpi::PWMSparkMax m_frontRightMotor{2};
- wpi::PWMSparkMax m_backLeftMotor{3};
- wpi::PWMSparkMax m_backRightMotor{4};
+ wpi::PWMSparkMax frontLeftMotor{1};
+ wpi::PWMSparkMax frontRightMotor{2};
+ wpi::PWMSparkMax backLeftMotor{3};
+ wpi::PWMSparkMax backRightMotor{4};
- wpi::Encoder m_frontLeftEncoder{0, 1};
- wpi::Encoder m_frontRightEncoder{2, 3};
- wpi::Encoder m_backLeftEncoder{4, 5};
- wpi::Encoder m_backRightEncoder{6, 7};
+ wpi::Encoder frontLeftEncoder{0, 1};
+ wpi::Encoder frontRightEncoder{2, 3};
+ wpi::Encoder backLeftEncoder{4, 5};
+ wpi::Encoder backRightEncoder{6, 7};
- wpi::math::Translation2d m_frontLeftLocation{0.381_m, 0.381_m};
- wpi::math::Translation2d m_frontRightLocation{0.381_m, -0.381_m};
- wpi::math::Translation2d m_backLeftLocation{-0.381_m, 0.381_m};
- wpi::math::Translation2d m_backRightLocation{-0.381_m, -0.381_m};
+ wpi::math::Translation2d frontLeftLocation{0.381_m, 0.381_m};
+ wpi::math::Translation2d frontRightLocation{0.381_m, -0.381_m};
+ wpi::math::Translation2d backLeftLocation{-0.381_m, 0.381_m};
+ wpi::math::Translation2d backRightLocation{-0.381_m, -0.381_m};
- wpi::math::PIDController m_frontLeftPIDController{1.0, 0.0, 0.0};
- wpi::math::PIDController m_frontRightPIDController{1.0, 0.0, 0.0};
- wpi::math::PIDController m_backLeftPIDController{1.0, 0.0, 0.0};
- wpi::math::PIDController m_backRightPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController frontLeftPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController frontRightPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController backLeftPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController backRightPIDController{1.0, 0.0, 0.0};
- wpi::OnboardIMU m_imu{wpi::OnboardIMU::FLAT};
+ wpi::OnboardIMU imu{wpi::OnboardIMU::FLAT};
- wpi::math::MecanumDriveKinematics m_kinematics{
- m_frontLeftLocation, m_frontRightLocation, m_backLeftLocation,
- m_backRightLocation};
+ wpi::math::MecanumDriveKinematics kinematics{
+ frontLeftLocation, frontRightLocation, backLeftLocation,
+ backRightLocation};
- wpi::math::MecanumDriveOdometry m_odometry{
- m_kinematics, m_imu.GetRotation2d(), GetCurrentWheelDistances()};
+ wpi::math::MecanumDriveOdometry odometry{kinematics, imu.GetRotation2d(),
+ GetCurrentWheelDistances()};
// Gains are for example purposes only - must be determined for your own
// robot!
- wpi::math::SimpleMotorFeedforward m_feedforward{
+ wpi::math::SimpleMotorFeedforward feedforward{
1_V, 3_V / 1_mps};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp
index 5bc01edabf9..8b52aba0751 100644
--- a/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/MecanumDrive/cpp/Robot.cpp
@@ -16,15 +16,15 @@
class Robot : public wpi::TimedRobot {
public:
Robot() {
- wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_frontLeft);
- wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_rearLeft);
- wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_frontRight);
- wpi::util::SendableRegistry::AddChild(&m_robotDrive, &m_rearRight);
+ wpi::util::SendableRegistry::AddChild(&robotDrive, &frontLeft);
+ wpi::util::SendableRegistry::AddChild(&robotDrive, &rearLeft);
+ wpi::util::SendableRegistry::AddChild(&robotDrive, &frontRight);
+ wpi::util::SendableRegistry::AddChild(&robotDrive, &rearRight);
// Invert the right side motors. You may need to change or remove this to
// match your robot.
- m_frontRight.SetInverted(true);
- m_rearRight.SetInverted(true);
+ frontRight.SetInverted(true);
+ rearRight.SetInverted(true);
}
/**
@@ -34,8 +34,8 @@ class Robot : public wpi::TimedRobot {
/* Use the joystick Y axis for forward movement, X axis for lateral
* movement, and Z axis for rotation.
*/
- m_robotDrive.DriveCartesian(-m_joystick.GetY(), -m_joystick.GetX(),
- -m_joystick.GetZ(), m_imu.GetRotation2d());
+ robotDrive.DriveCartesian(-joystick.GetY(), -joystick.GetX(),
+ -joystick.GetZ(), imu.GetRotation2d());
}
private:
@@ -47,18 +47,18 @@ class Robot : public wpi::TimedRobot {
wpi::OnboardIMU::FLAT;
static constexpr int kJoystickPort = 0;
- wpi::PWMSparkMax m_frontLeft{kFrontLeftMotorPort};
- wpi::PWMSparkMax m_rearLeft{kRearLeftMotorPort};
- wpi::PWMSparkMax m_frontRight{kFrontRightMotorPort};
- wpi::PWMSparkMax m_rearRight{kRearRightMotorPort};
- wpi::MecanumDrive m_robotDrive{
- [&](double output) { m_frontLeft.SetThrottle(output); },
- [&](double output) { m_rearLeft.SetThrottle(output); },
- [&](double output) { m_frontRight.SetThrottle(output); },
- [&](double output) { m_rearRight.SetThrottle(output); }};
+ wpi::PWMSparkMax frontLeft{kFrontLeftMotorPort};
+ wpi::PWMSparkMax rearLeft{kRearLeftMotorPort};
+ wpi::PWMSparkMax frontRight{kFrontRightMotorPort};
+ wpi::PWMSparkMax rearRight{kRearRightMotorPort};
+ wpi::MecanumDrive robotDrive{
+ [&](double output) { frontLeft.SetThrottle(output); },
+ [&](double output) { rearLeft.SetThrottle(output); },
+ [&](double output) { frontRight.SetThrottle(output); },
+ [&](double output) { rearRight.SetThrottle(output); }};
- wpi::OnboardIMU m_imu{kIMUMountOrientation};
- wpi::Joystick m_joystick{kJoystickPort};
+ wpi::OnboardIMU imu{kIMUMountOrientation};
+ wpi::Joystick joystick{kJoystickPort};
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Drivetrain.cpp
index 70019bc7940..86f8ce08e4d 100644
--- a/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Drivetrain.cpp
@@ -9,42 +9,42 @@
wpi::math::MecanumDriveWheelPositions Drivetrain::GetCurrentWheelDistances()
const {
- return {wpi::units::meter_t{m_frontLeftEncoder.GetDistance()},
- wpi::units::meter_t{m_frontRightEncoder.GetDistance()},
- wpi::units::meter_t{m_backLeftEncoder.GetDistance()},
- wpi::units::meter_t{m_backRightEncoder.GetDistance()}};
+ return {wpi::units::meter_t{frontLeftEncoder.GetDistance()},
+ wpi::units::meter_t{frontRightEncoder.GetDistance()},
+ wpi::units::meter_t{backLeftEncoder.GetDistance()},
+ wpi::units::meter_t{backRightEncoder.GetDistance()}};
}
wpi::math::MecanumDriveWheelVelocities Drivetrain::GetCurrentWheelVelocities()
const {
- return {wpi::units::meters_per_second_t{m_frontLeftEncoder.GetRate()},
- wpi::units::meters_per_second_t{m_frontRightEncoder.GetRate()},
- wpi::units::meters_per_second_t{m_backLeftEncoder.GetRate()},
- wpi::units::meters_per_second_t{m_backRightEncoder.GetRate()}};
+ return {wpi::units::meters_per_second_t{frontLeftEncoder.GetRate()},
+ wpi::units::meters_per_second_t{frontRightEncoder.GetRate()},
+ wpi::units::meters_per_second_t{backLeftEncoder.GetRate()},
+ wpi::units::meters_per_second_t{backRightEncoder.GetRate()}};
}
void Drivetrain::SetVelocities(
const wpi::math::MecanumDriveWheelVelocities& wheelVelocities) {
std::function
- calcAndSetVelocities = [&m_feedforward = m_feedforward](
- wpi::units::meters_per_second_t velocity,
- const auto& encoder, auto& controller,
- auto& motor) {
- auto feedforward = m_feedforward.Calculate(velocity);
- double output =
- controller.Calculate(encoder.GetRate(), velocity.value());
- motor.SetVoltage(wpi::units::volt_t{output} + feedforward);
- };
+ calcAndSetVelocities =
+ [&feedforward = feedforward](wpi::units::meters_per_second_t velocity,
+ const auto& encoder, auto& controller,
+ auto& motor) {
+ auto ff = feedforward.Calculate(velocity);
+ double output =
+ controller.Calculate(encoder.GetRate(), velocity.value());
+ motor.SetVoltage(wpi::units::volt_t{output} + ff);
+ };
- calcAndSetVelocities(wheelVelocities.frontLeft, m_frontLeftEncoder,
- m_frontLeftPIDController, m_frontLeftMotor);
- calcAndSetVelocities(wheelVelocities.frontRight, m_frontRightEncoder,
- m_frontRightPIDController, m_frontRightMotor);
- calcAndSetVelocities(wheelVelocities.rearLeft, m_backLeftEncoder,
- m_backLeftPIDController, m_backLeftMotor);
- calcAndSetVelocities(wheelVelocities.rearRight, m_backRightEncoder,
- m_backRightPIDController, m_backRightMotor);
+ calcAndSetVelocities(wheelVelocities.frontLeft, frontLeftEncoder,
+ frontLeftPIDController, frontLeftMotor);
+ calcAndSetVelocities(wheelVelocities.frontRight, frontRightEncoder,
+ frontRightPIDController, frontRightMotor);
+ calcAndSetVelocities(wheelVelocities.rearLeft, backLeftEncoder,
+ backLeftPIDController, backLeftMotor);
+ calcAndSetVelocities(wheelVelocities.rearRight, backRightEncoder,
+ backRightPIDController, backRightMotor);
}
void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
@@ -54,23 +54,23 @@ void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
wpi::math::ChassisVelocities chassisVelocities{xVelocity, yVelocity, rot};
if (fieldRelative) {
chassisVelocities = chassisVelocities.ToRobotRelative(
- m_poseEstimator.GetEstimatedPosition().Rotation());
+ poseEstimator.GetEstimatedPosition().Rotation());
}
SetVelocities(
- m_kinematics.ToWheelVelocities(chassisVelocities.Discretize(period))
+ kinematics.ToWheelVelocities(chassisVelocities.Discretize(period))
.Desaturate(kMaxVelocity));
}
void Drivetrain::UpdateOdometry() {
- m_poseEstimator.Update(
- m_imu.GetRotation2d(),
+ poseEstimator.Update(
+ imu.GetRotation2d(),
GetCurrentWheelDistances()); // TODO(Ryan): fixup when sim implemented
// Also apply vision measurements. We use 0.3 seconds in the past as an
// example -- on a real robot, this must be calculated based either on latency
// or timestamps.
- m_poseEstimator.AddVisionMeasurement(
+ poseEstimator.AddVisionMeasurement(
ExampleGlobalMeasurementSensor::GetEstimatedGlobalPose(
- m_poseEstimator.GetEstimatedPosition()),
+ poseEstimator.GetEstimatedPosition()),
wpi::Timer::GetTimestamp() - 0.3_s);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Robot.cpp
index 34bde68ea8d..fd0d5cf8ed1 100644
--- a/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/cpp/Robot.cpp
@@ -11,43 +11,41 @@ class Robot : public wpi::TimedRobot {
public:
void AutonomousPeriodic() override {
DriveWithJoystick(false);
- m_mecanum.UpdateOdometry();
+ mecanum.UpdateOdometry();
}
void TeleopPeriodic() override { DriveWithJoystick(true); }
private:
- wpi::Gamepad m_controller{0};
- Drivetrain m_mecanum;
+ wpi::Gamepad controller{0};
+ Drivetrain mecanum;
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0
// to 1.
- wpi::math::SlewRateLimiter m_xVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_yVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_rotLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter xVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter yVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter rotLimiter{3 / 1_s};
void DriveWithJoystick(bool fieldRelative) {
// Get the x velocity. We are inverting this because gamepads return
// negative values when we push forward.
- const auto xVelocity =
- -m_xVelocityLimiter.Calculate(m_controller.GetLeftY()) *
- Drivetrain::kMaxVelocity;
+ const auto xVelocity = -xVelocityLimiter.Calculate(controller.GetLeftY()) *
+ Drivetrain::kMaxVelocity;
// Get the y velocity or sideways/strafe velocity. We are inverting this
// because we want a positive value when we pull to the left. Gamepads
// return positive values when you pull to the right by default.
- const auto yVelocity =
- -m_yVelocityLimiter.Calculate(m_controller.GetLeftX()) *
- Drivetrain::kMaxVelocity;
+ const auto yVelocity = -yVelocityLimiter.Calculate(controller.GetLeftX()) *
+ 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_mecanum.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
+ mecanum.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/include/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/include/Drivetrain.hpp
index 8715083f16f..dee0009cd5b 100644
--- a/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/include/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/MecanumDrivePoseEstimator/include/Drivetrain.hpp
@@ -22,12 +22,12 @@
class Drivetrain {
public:
Drivetrain() {
- m_imu.ResetYaw();
+ imu.ResetYaw();
// 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_frontRightMotor.SetInverted(true);
- m_backRightMotor.SetInverted(true);
+ frontRightMotor.SetInverted(true);
+ backRightMotor.SetInverted(true);
}
wpi::math::MecanumDriveWheelPositions GetCurrentWheelDistances() const;
@@ -45,40 +45,40 @@ class Drivetrain {
std::numbers::pi}; // 1/2 rotation per second
private:
- wpi::PWMSparkMax m_frontLeftMotor{1};
- wpi::PWMSparkMax m_frontRightMotor{2};
- wpi::PWMSparkMax m_backLeftMotor{3};
- wpi::PWMSparkMax m_backRightMotor{4};
+ wpi::PWMSparkMax frontLeftMotor{1};
+ wpi::PWMSparkMax frontRightMotor{2};
+ wpi::PWMSparkMax backLeftMotor{3};
+ wpi::PWMSparkMax backRightMotor{4};
- wpi::Encoder m_frontLeftEncoder{0, 1};
- wpi::Encoder m_frontRightEncoder{2, 3};
- wpi::Encoder m_backLeftEncoder{4, 5};
- wpi::Encoder m_backRightEncoder{6, 7};
+ wpi::Encoder frontLeftEncoder{0, 1};
+ wpi::Encoder frontRightEncoder{2, 3};
+ wpi::Encoder backLeftEncoder{4, 5};
+ wpi::Encoder backRightEncoder{6, 7};
- wpi::math::Translation2d m_frontLeftLocation{0.381_m, 0.381_m};
- wpi::math::Translation2d m_frontRightLocation{0.381_m, -0.381_m};
- wpi::math::Translation2d m_backLeftLocation{-0.381_m, 0.381_m};
- wpi::math::Translation2d m_backRightLocation{-0.381_m, -0.381_m};
+ wpi::math::Translation2d frontLeftLocation{0.381_m, 0.381_m};
+ wpi::math::Translation2d frontRightLocation{0.381_m, -0.381_m};
+ wpi::math::Translation2d backLeftLocation{-0.381_m, 0.381_m};
+ wpi::math::Translation2d backRightLocation{-0.381_m, -0.381_m};
- wpi::math::PIDController m_frontLeftPIDController{1.0, 0.0, 0.0};
- wpi::math::PIDController m_frontRightPIDController{1.0, 0.0, 0.0};
- wpi::math::PIDController m_backLeftPIDController{1.0, 0.0, 0.0};
- wpi::math::PIDController m_backRightPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController frontLeftPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController frontRightPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController backLeftPIDController{1.0, 0.0, 0.0};
+ wpi::math::PIDController backRightPIDController{1.0, 0.0, 0.0};
- wpi::OnboardIMU m_imu{wpi::OnboardIMU::FLAT};
+ wpi::OnboardIMU imu{wpi::OnboardIMU::FLAT};
- wpi::math::MecanumDriveKinematics m_kinematics{
- m_frontLeftLocation, m_frontRightLocation, m_backLeftLocation,
- m_backRightLocation};
+ wpi::math::MecanumDriveKinematics kinematics{
+ frontLeftLocation, frontRightLocation, backLeftLocation,
+ backRightLocation};
// Gains are for example purposes only - must be determined for your own
// robot!
- wpi::math::SimpleMotorFeedforward m_feedforward{
+ wpi::math::SimpleMotorFeedforward feedforward{
1_V, 3_V / 1_mps};
// Gains are for example purposes only - must be determined for your own
// robot!
- wpi::math::MecanumDrivePoseEstimator m_poseEstimator{
- m_kinematics, m_imu.GetRotation2d(), GetCurrentWheelDistances(),
- wpi::math::Pose2d{}, {0.1, 0.1, 0.1}, {0.1, 0.1, 0.1}};
+ wpi::math::MecanumDrivePoseEstimator poseEstimator{
+ kinematics, imu.GetRotation2d(), GetCurrentWheelDistances(),
+ wpi::math::Pose2d{}, {0.1, 0.1, 0.1}, {0.1, 0.1, 0.1}};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp
index 2d965a1dd58..39fc5715a23 100644
--- a/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/Mechanism2d/cpp/Robot.cpp
@@ -30,43 +30,40 @@ class Robot : public wpi::TimedRobot {
public:
Robot() {
- m_elevatorEncoder.SetDistancePerPulse(kMetersPerPulse);
+ elevatorEncoder.SetDistancePerPulse(kMetersPerPulse);
// publish to dashboard
- wpi::SmartDashboard::PutData("Mech2d", &m_mech);
+ wpi::SmartDashboard::PutData("Mech2d", &mech);
}
void RobotPeriodic() override {
// update the dashboard mechanism's state
- m_elevator->SetLength(kElevatorMinimumLength +
- m_elevatorEncoder.GetDistance());
- m_wrist->SetAngle(wpi::units::degree_t{m_wristPotentiometer.Get()});
+ elevator->SetLength(kElevatorMinimumLength + elevatorEncoder.GetDistance());
+ wrist->SetAngle(wpi::units::degree_t{wristPotentiometer.Get()});
}
void TeleopPeriodic() override {
- m_elevatorMotor.SetThrottle(m_joystick.GetRawAxis(0));
- m_wristMotor.SetThrottle(m_joystick.GetRawAxis(1));
+ elevatorMotor.SetThrottle(joystick.GetRawAxis(0));
+ wristMotor.SetThrottle(joystick.GetRawAxis(1));
}
private:
- wpi::PWMSparkMax m_elevatorMotor{0};
- wpi::PWMSparkMax m_wristMotor{1};
- wpi::Encoder m_elevatorEncoder{0, 1};
- wpi::AnalogPotentiometer m_wristPotentiometer{1, 90};
- wpi::Joystick m_joystick{0};
+ wpi::PWMSparkMax elevatorMotor{0};
+ wpi::PWMSparkMax wristMotor{1};
+ wpi::Encoder elevatorEncoder{0, 1};
+ wpi::AnalogPotentiometer wristPotentiometer{1, 90};
+ wpi::Joystick joystick{0};
// the main mechanism object
- wpi::Mechanism2d m_mech{3, 3};
+ wpi::Mechanism2d mech{3, 3};
// the mechanism root node
- wpi::MechanismRoot2d* m_root = m_mech.GetRoot("climber", 2, 0);
+ wpi::MechanismRoot2d* root = mech.GetRoot("climber", 2, 0);
// MechanismLigament2d objects represent each "section"/"stage" of the
// mechanism, and are based off the root node or another ligament object
- wpi::MechanismLigament2d* m_elevator =
- m_root->Append("elevator", 1, 90_deg);
- wpi::MechanismLigament2d* m_wrist =
- m_elevator->Append(
- "wrist", 0.5, 90_deg, 6,
- wpi::util::Color8Bit{wpi::util::Color::PURPLE});
+ wpi::MechanismLigament2d* elevator =
+ root->Append("elevator", 1, 90_deg);
+ wpi::MechanismLigament2d* wrist = elevator->Append(
+ "wrist", 0.5, 90_deg, 6, wpi::util::Color8Bit{wpi::util::Color::PURPLE});
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp
index 371179f7fd2..e3272a9e1e8 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/RapidReactCommandBot.cpp
@@ -13,37 +13,35 @@ void RapidReactCommandBot::ConfigureBindings() {
// Automatically run the storage motor whenever the ball storage is not full,
// and turn it off whenever it fills. Uses subsystem-hosted trigger to
// improve readability and make inter-subsystem communication easier.
- m_storage.HasCargo.WhileFalse(m_storage.RunCommand());
+ storage.HasCargo.WhileFalse(storage.RunCommand());
// Automatically disable and retract the intake whenever the ball storage is
// full.
- m_storage.HasCargo.OnTrue(m_intake.RetractCommand());
+ storage.HasCargo.OnTrue(intake.RetractCommand());
// Control the drive with split-stick arcade controls
- m_drive.SetDefaultCommand(m_drive.ArcadeDriveCommand(
- [this] { return -m_driverController.GetLeftY(); },
- [this] { return -m_driverController.GetRightX(); }));
+ drive.SetDefaultCommand(drive.ArcadeDriveCommand(
+ [this] { return -driverController.GetLeftY(); },
+ [this] { return -driverController.GetRightX(); }));
// Deploy the intake with the West Face button
- m_driverController.WestFace().OnTrue(m_intake.IntakeCommand());
+ driverController.WestFace().OnTrue(intake.IntakeCommand());
// Retract the intake with the North Face button
- m_driverController.NorthFace().OnTrue(m_intake.RetractCommand());
+ driverController.NorthFace().OnTrue(intake.RetractCommand());
// Fire the shooter with the South Face button
- m_driverController.SouthFace().OnTrue(
- wpi::cmd::Parallel(
- m_shooter.ShootCommand(ShooterConstants::kShooterTarget),
- m_storage.RunCommand())
+ driverController.SouthFace().OnTrue(
+ wpi::cmd::Parallel(shooter.ShootCommand(ShooterConstants::kShooterTarget),
+ storage.RunCommand())
// Since we composed this inline we should give it a name
.WithName("Shoot"));
// Toggle compressor with the Start button
- m_driverController.Start().ToggleOnTrue(
- m_pneumatics.DisableCompressorCommand());
+ driverController.Start().ToggleOnTrue(pneumatics.DisableCompressorCommand());
}
wpi::cmd::CommandPtr RapidReactCommandBot::GetAutonomousCommand() {
- return m_drive
+ return drive
.DriveDistanceCommand(AutoConstants::kDriveDistance,
AutoConstants::kDriveVelocity)
.WithTimeout(AutoConstants::kTimeout);
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp
index ef39cfe6dd7..c86a0f0cb21 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp
@@ -6,7 +6,7 @@
Robot::Robot() {
// Configure default commands and condition bindings on robot startup
- m_robot.ConfigureBindings();
+ robot.ConfigureBindings();
}
void Robot::RobotPeriodic() {
@@ -23,11 +23,11 @@ void Robot::DisabledInit() {}
void Robot::DisabledPeriodic() {}
void Robot::AutonomousInit() {
- m_autonomousCommand = m_robot.GetAutonomousCommand();
+ autonomousCommand = robot.GetAutonomousCommand();
- if (m_autonomousCommand) {
+ if (autonomousCommand) {
wpi::cmd::CommandScheduler::GetInstance().Schedule(
- m_autonomousCommand.value());
+ autonomousCommand.value());
}
}
@@ -38,8 +38,8 @@ 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();
+ if (autonomousCommand) {
+ autonomousCommand->Cancel();
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Drive.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Drive.cpp
index c5104a5ce33..ebc86448453 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Drive.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Drive.cpp
@@ -10,34 +10,34 @@
#include "wpi/system/RobotController.hpp"
Drive::Drive() {
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_leftLeader);
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_rightLeader);
+ wpi::util::SendableRegistry::AddChild(&drive, &leftLeader);
+ wpi::util::SendableRegistry::AddChild(&drive, &rightLeader);
- 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);
// Sets the distance per pulse for the encoders
- m_leftEncoder.SetDistancePerPulse(DriveConstants::kEncoderDistancePerPulse);
- m_rightEncoder.SetDistancePerPulse(DriveConstants::kEncoderDistancePerPulse);
+ leftEncoder.SetDistancePerPulse(DriveConstants::kEncoderDistancePerPulse);
+ rightEncoder.SetDistancePerPulse(DriveConstants::kEncoderDistancePerPulse);
// Set the controller to be continuous (because it is an angle controller)
- m_controller.EnableContinuousInput(-180_deg, 180_deg);
+ controller.EnableContinuousInput(-180_deg, 180_deg);
// Set the controller tolerance - the delta tolerance ensures the robot is
// stationary at the setpoint before it is considered as having reached the
// reference
- m_controller.SetTolerance(DriveConstants::kTurnTolerance,
- DriveConstants::kTurnRateTolerance);
+ controller.SetTolerance(DriveConstants::kTurnTolerance,
+ DriveConstants::kTurnRateTolerance);
}
wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function fwd,
std::function rot) {
return Run([this, fwd = std::move(fwd), rot = std::move(rot)] {
- m_drive.ArcadeDrive(fwd(), rot());
+ drive.ArcadeDrive(fwd(), rot());
})
.WithName("ArcadeDrive");
}
@@ -46,34 +46,32 @@ wpi::cmd::CommandPtr Drive::DriveDistanceCommand(wpi::units::meter_t distance,
double velocity) {
return RunOnce([this] {
// Reset encoders at the start of the command
- m_leftEncoder.Reset();
- m_rightEncoder.Reset();
+ leftEncoder.Reset();
+ rightEncoder.Reset();
})
// Drive forward at specified velocity
- .AndThen(Run([this, velocity] { m_drive.ArcadeDrive(velocity, 0.0); }))
+ .AndThen(Run([this, velocity] { drive.ArcadeDrive(velocity, 0.0); }))
.Until([this, distance] {
return wpi::units::math::max(
- wpi::units::meter_t(m_leftEncoder.GetDistance()),
- wpi::units::meter_t(m_rightEncoder.GetDistance())) >=
- distance;
+ wpi::units::meter_t(leftEncoder.GetDistance()),
+ wpi::units::meter_t(rightEncoder.GetDistance())) >= distance;
})
// Stop the drive when the command ends
- .FinallyDo([this](bool interrupted) { m_drive.StopMotor(); });
+ .FinallyDo([this](bool interrupted) { drive.StopMotor(); });
}
wpi::cmd::CommandPtr Drive::TurnToAngleCommand(wpi::units::degree_t angle) {
- return StartRun(
- [this] { m_controller.Reset(m_imu.GetRotation2d().Degrees()); },
- [this, angle] {
- m_drive.ArcadeDrive(
- 0, m_controller.Calculate(m_imu.GetRotation2d().Degrees(),
- angle) +
- // Divide feedforward voltage by battery voltage to
- // normalize it to [-1, 1]
- m_feedforward.Calculate(
- m_controller.GetSetpoint().velocity) /
- wpi::RobotController::GetBatteryVoltage());
- })
- .Until([this] { return m_controller.AtGoal(); })
- .FinallyDo([this] { m_drive.ArcadeDrive(0, 0); });
+ return StartRun([this] { controller.Reset(imu.GetRotation2d().Degrees()); },
+ [this, angle] {
+ drive.ArcadeDrive(
+ 0, controller.Calculate(imu.GetRotation2d().Degrees(),
+ angle) +
+ // Divide feedforward voltage by battery voltage
+ // to normalize it to [-1, 1]
+ feedforward.Calculate(
+ controller.GetSetpoint().velocity) /
+ wpi::RobotController::GetBatteryVoltage());
+ })
+ .Until([this] { return controller.AtGoal(); })
+ .FinallyDo([this] { drive.ArcadeDrive(0, 0); });
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Intake.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Intake.cpp
index bf6e51f9044..1246a1883c3 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Intake.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Intake.cpp
@@ -5,15 +5,15 @@
#include "subsystems/Intake.hpp"
wpi::cmd::CommandPtr Intake::IntakeCommand() {
- return RunOnce([this] { m_piston.Set(wpi::DoubleSolenoid::FORWARD); })
- .AndThen(Run([this] { m_motor.SetThrottle(1.0); }))
+ return RunOnce([this] { piston.Set(wpi::DoubleSolenoid::FORWARD); })
+ .AndThen(Run([this] { motor.SetThrottle(1.0); }))
.WithName("Intake");
}
wpi::cmd::CommandPtr Intake::RetractCommand() {
return RunOnce([this] {
- m_motor.Disable();
- m_piston.Set(wpi::DoubleSolenoid::REVERSE);
+ motor.Disable();
+ piston.Set(wpi::DoubleSolenoid::REVERSE);
})
.WithName("Retract");
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Pneumatics.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Pneumatics.cpp
index ddd3ac76bee..a9bd132f0e6 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Pneumatics.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Pneumatics.cpp
@@ -10,18 +10,18 @@ wpi::cmd::CommandPtr Pneumatics::DisableCompressorCommand() {
return StartEnd(
[&] {
// Disable closed-loop mode on the compressor.
- m_compressor.Disable();
+ compressor.Disable();
},
[&] {
// Enable closed-loop mode based on the digital pressure switch
// connected to the PCM/PH. The switch is open when the pressure is over
// ~120 PSI.
- m_compressor.EnableDigital();
+ compressor.EnableDigital();
});
}
wpi::units::pounds_per_square_inch_t Pneumatics::GetPressure() {
// Get the pressure (in PSI) from an analog pressure sensor connected to
// the RIO.
- return wpi::units::pounds_per_square_inch_t{m_pressureTransducer.Get()};
+ return wpi::units::pounds_per_square_inch_t{pressureTransducer.Get()};
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp
index 0373c6b59da..3f011971fdb 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Shooter.cpp
@@ -7,13 +7,13 @@
#include "wpi/commands2/Commands.hpp"
Shooter::Shooter() {
- m_shooterFeedback.SetTolerance(ShooterConstants::kShooterTolerance.value());
- m_shooterEncoder.SetDistancePerPulse(
+ shooterFeedback.SetTolerance(ShooterConstants::kShooterTolerance.value());
+ shooterEncoder.SetDistancePerPulse(
ShooterConstants::kEncoderDistancePerPulse);
SetDefaultCommand(RunOnce([this] {
- m_shooterMotor.Disable();
- m_feederMotor.Disable();
+ shooterMotor.Disable();
+ feederMotor.Disable();
})
.AndThen(Run([] {}))
.WithName("Idle"));
@@ -25,15 +25,15 @@ wpi::cmd::CommandPtr Shooter::ShootCommand(
// Run the shooter flywheel at the desired setpoint using
// feedforward and feedback
Run([this, setpoint] {
- m_shooterMotor.SetVoltage(
- m_shooterFeedforward.Calculate(setpoint) +
- wpi::units::volt_t(m_shooterFeedback.Calculate(
- m_shooterEncoder.GetRate(), setpoint.value())));
+ shooterMotor.SetVoltage(
+ shooterFeedforward.Calculate(setpoint) +
+ wpi::units::volt_t(shooterFeedback.Calculate(
+ shooterEncoder.GetRate(), setpoint.value())));
}),
// Wait until the shooter has reached the setpoint, and then
// run the feeder
wpi::cmd::WaitUntil([this] {
- return m_shooterFeedback.AtSetpoint();
- }).AndThen([this] { m_feederMotor.SetThrottle(1.0); }))
+ return shooterFeedback.AtSetpoint();
+ }).AndThen([this] { feederMotor.SetThrottle(1.0); }))
.WithName("Shoot");
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Storage.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Storage.cpp
index 6ff8553290a..eb56bcf51d6 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Storage.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/subsystems/Storage.cpp
@@ -6,9 +6,9 @@
Storage::Storage() {
SetDefaultCommand(
- RunOnce([this] { m_motor.Disable(); }).AndThen([] {}).WithName("Idle"));
+ RunOnce([this] { motor.Disable(); }).AndThen([] {}).WithName("Idle"));
}
wpi::cmd::CommandPtr Storage::RunCommand() {
- return Run([this] { m_motor.SetThrottle(1.0); }).WithName("Run");
+ return Run([this] { motor.SetThrottle(1.0); }).WithName("Run");
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.hpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.hpp
index c8aa9ad9ff3..e60b4413ac8 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/RapidReactCommandBot.hpp
@@ -41,13 +41,12 @@ class RapidReactCommandBot {
private:
// The robot's subsystems
- Drive m_drive;
- Intake m_intake;
- Shooter m_shooter;
- Storage m_storage;
- Pneumatics m_pneumatics;
+ Drive drive;
+ Intake intake;
+ Shooter shooter;
+ Storage storage;
+ Pneumatics pneumatics;
// The driver's controller
- wpi::cmd::CommandGamepad m_driverController{
- OIConstants::kDriverControllerPort};
+ wpi::cmd::CommandGamepad driverController{OIConstants::kDriverControllerPort};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.hpp
index 151282ce6fd..5ca3e746943 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/Robot.hpp
@@ -24,6 +24,6 @@ class Robot : public wpi::TimedRobot {
void UtilityPeriodic() override;
private:
- RapidReactCommandBot m_robot;
- std::optional m_autonomousCommand;
+ RapidReactCommandBot robot;
+ std::optional autonomousCommand;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Drive.hpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Drive.hpp
index 8ac5b46f1b6..d0ee5d0a377 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Drive.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Drive.hpp
@@ -49,29 +49,29 @@ class Drive : public wpi::cmd::SubsystemBase {
wpi::cmd::CommandPtr TurnToAngleCommand(wpi::units::degree_t angle);
private:
- wpi::PWMSparkMax m_leftLeader{DriveConstants::kLeftMotor1Port};
- wpi::PWMSparkMax m_leftFollower{DriveConstants::kLeftMotor2Port};
- wpi::PWMSparkMax m_rightLeader{DriveConstants::kRightMotor1Port};
- wpi::PWMSparkMax m_rightFollower{DriveConstants::kRightMotor2Port};
+ wpi::PWMSparkMax leftLeader{DriveConstants::kLeftMotor1Port};
+ wpi::PWMSparkMax leftFollower{DriveConstants::kLeftMotor2Port};
+ wpi::PWMSparkMax rightLeader{DriveConstants::kRightMotor1Port};
+ wpi::PWMSparkMax rightFollower{DriveConstants::kRightMotor2Port};
- wpi::DifferentialDrive m_drive{
- [&](double output) { m_leftLeader.SetThrottle(output); },
- [&](double output) { m_rightLeader.SetThrottle(output); }};
+ wpi::DifferentialDrive drive{
+ [&](double output) { leftLeader.SetThrottle(output); },
+ [&](double output) { rightLeader.SetThrottle(output); }};
- wpi::Encoder m_leftEncoder{DriveConstants::kLeftEncoderPorts[0],
- DriveConstants::kLeftEncoderPorts[1],
- DriveConstants::kLeftEncoderReversed};
- wpi::Encoder m_rightEncoder{DriveConstants::kRightEncoderPorts[0],
- DriveConstants::kRightEncoderPorts[1],
- DriveConstants::kRightEncoderReversed};
+ wpi::Encoder leftEncoder{DriveConstants::kLeftEncoderPorts[0],
+ DriveConstants::kLeftEncoderPorts[1],
+ DriveConstants::kLeftEncoderReversed};
+ wpi::Encoder rightEncoder{DriveConstants::kRightEncoderPorts[0],
+ DriveConstants::kRightEncoderPorts[1],
+ DriveConstants::kRightEncoderReversed};
- wpi::OnboardIMU m_imu{wpi::OnboardIMU::FLAT};
+ wpi::OnboardIMU imu{wpi::OnboardIMU::FLAT};
- wpi::math::ProfiledPIDController m_controller{
+ wpi::math::ProfiledPIDController controller{
DriveConstants::kTurnP,
DriveConstants::kTurnI,
DriveConstants::kTurnD,
{DriveConstants::kMaxTurnRate, DriveConstants::kMaxTurnAcceleration}};
- wpi::math::SimpleMotorFeedforward m_feedforward{
+ wpi::math::SimpleMotorFeedforward feedforward{
DriveConstants::ks, DriveConstants::kv, DriveConstants::ka};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Intake.hpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Intake.hpp
index d8b393dc10f..7c5f182d854 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Intake.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Intake.hpp
@@ -24,10 +24,10 @@ class Intake : public wpi::cmd::SubsystemBase {
wpi::cmd::CommandPtr RetractCommand();
private:
- wpi::PWMSparkMax m_motor{IntakeConstants::kMotorPort};
+ wpi::PWMSparkMax motor{IntakeConstants::kMotorPort};
// Double solenoid connected to two channels of a PCM with the default CAN ID
- wpi::DoubleSolenoid m_piston{0, wpi::PneumaticsModuleType::CTRE_PCM,
- IntakeConstants::kSolenoidPorts[0],
- IntakeConstants::kSolenoidPorts[1]};
+ wpi::DoubleSolenoid piston{0, wpi::PneumaticsModuleType::CTRE_PCM,
+ IntakeConstants::kSolenoidPorts[0],
+ IntakeConstants::kSolenoidPorts[1]};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Pneumatics.hpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Pneumatics.hpp
index 6f6763f5a49..c42e61b5547 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Pneumatics.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Pneumatics.hpp
@@ -34,9 +34,9 @@ class Pneumatics : wpi::cmd::SubsystemBase {
// pressure is 250r-25
static constexpr double kScale = 250;
static constexpr double kOffset = -25;
- wpi::AnalogPotentiometer m_pressureTransducer{/* the AnalogIn port*/ 2,
- kScale, kOffset};
+ wpi::AnalogPotentiometer pressureTransducer{/* the AnalogIn port*/ 2, kScale,
+ kOffset};
// Compressor connected to a PH with a default CAN ID
- wpi::Compressor m_compressor{0, wpi::PneumaticsModuleType::CTRE_PCM};
+ wpi::Compressor compressor{0, wpi::PneumaticsModuleType::CTRE_PCM};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Shooter.hpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Shooter.hpp
index df6496d2541..9bb4d30e427 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Shooter.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Shooter.hpp
@@ -30,13 +30,13 @@ class Shooter : public wpi::cmd::SubsystemBase {
wpi::cmd::CommandPtr ShootCommand(wpi::units::turns_per_second_t setpoint);
private:
- wpi::PWMSparkMax m_shooterMotor{ShooterConstants::kShooterMotorPort};
- wpi::PWMSparkMax m_feederMotor{ShooterConstants::kFeederMotorPort};
+ wpi::PWMSparkMax shooterMotor{ShooterConstants::kShooterMotorPort};
+ wpi::PWMSparkMax feederMotor{ShooterConstants::kFeederMotorPort};
- wpi::Encoder m_shooterEncoder{ShooterConstants::kEncoderPorts[0],
- ShooterConstants::kEncoderPorts[1],
- ShooterConstants::kEncoderReversed};
- wpi::math::SimpleMotorFeedforward m_shooterFeedforward{
+ wpi::Encoder shooterEncoder{ShooterConstants::kEncoderPorts[0],
+ ShooterConstants::kEncoderPorts[1],
+ ShooterConstants::kEncoderReversed};
+ wpi::math::SimpleMotorFeedforward shooterFeedforward{
ShooterConstants::kS, ShooterConstants::kV};
- wpi::math::PIDController m_shooterFeedback{ShooterConstants::kP, 0.0, 0.0};
+ wpi::math::PIDController shooterFeedback{ShooterConstants::kP, 0.0, 0.0};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Storage.hpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Storage.hpp
index 40227711da8..52facc1f429 100644
--- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Storage.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/include/subsystems/Storage.hpp
@@ -18,9 +18,9 @@ class Storage : wpi::cmd::SubsystemBase {
wpi::cmd::CommandPtr RunCommand();
/** Whether the ball storage is full. */
- wpi::cmd::Trigger HasCargo{[this] { return m_ballSensor.Get(); }};
+ wpi::cmd::Trigger HasCargo{[this] { return ballSensor.Get(); }};
private:
- wpi::PWMSparkMax m_motor{StorageConstants::kMotorPort};
- wpi::DigitalInput m_ballSensor{StorageConstants::kBallSensorPort};
+ wpi::PWMSparkMax motor{StorageConstants::kMotorPort};
+ wpi::DigitalInput ballSensor{StorageConstants::kBallSensorPort};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp
index 2ec33e67708..dd9c9161d43 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/Robot.cpp
@@ -34,10 +34,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);
}
}
@@ -48,9 +48,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;
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp
index 793af12753b..88a44eb0af8 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/RobotContainer.cpp
@@ -15,20 +15,20 @@ RobotContainer::RobotContainer() {
void RobotContainer::ConfigureButtonBindings() {
// Also set default commands here
- m_drive.SetDefaultCommand(TeleopArcadeDrive(
- &m_drive, [this] { return -m_controller.GetRawAxis(1); },
- [this] { return -m_controller.GetRawAxis(2); }));
+ drive.SetDefaultCommand(TeleopArcadeDrive(
+ &drive, [this] { return -controller.GetRawAxis(1); },
+ [this] { return -controller.GetRawAxis(2); }));
// Example of how to use the onboard IO
- m_onboardButtonA.OnTrue(wpi::cmd::Print("Button A Pressed"))
+ onboardButtonA.OnTrue(wpi::cmd::Print("Button A Pressed"))
.OnFalse(wpi::cmd::Print("Button A Released"));
// Setup SmartDashboard options.
- m_chooser.SetDefaultOption("Auto Routine Distance", &m_autoDistance);
- m_chooser.AddOption("Auto Routine Time", &m_autoTime);
- wpi::SmartDashboard::PutData("Auto Selector", &m_chooser);
+ chooser.SetDefaultOption("Auto Routine Distance", &autoDistance);
+ chooser.AddOption("Auto Routine Time", &autoTime);
+ wpi::SmartDashboard::PutData("Auto Selector", &chooser);
}
wpi::cmd::Command* RobotContainer::GetAutonomousCommand() {
- return m_chooser.GetSelected();
+ return chooser.GetSelected();
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveDistance.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveDistance.cpp
index a34b01b1afe..d3d186cff2d 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveDistance.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveDistance.cpp
@@ -7,18 +7,18 @@
#include "wpi/units/math.hpp"
void DriveDistance::Initialize() {
- m_drive->ArcadeDrive(0, 0);
- m_drive->ResetEncoders();
+ drive->ArcadeDrive(0, 0);
+ drive->ResetEncoders();
}
void DriveDistance::Execute() {
- m_drive->ArcadeDrive(m_velocity, 0);
+ drive->ArcadeDrive(velocity, 0);
}
void DriveDistance::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
+ drive->ArcadeDrive(0, 0);
}
bool DriveDistance::IsFinished() {
- return wpi::units::math::abs(m_drive->GetAverageDistance()) >= m_distance;
+ return wpi::units::math::abs(drive->GetAverageDistance()) >= distance;
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveTime.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveTime.cpp
index f1be542fdd1..68adcd297b0 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveTime.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/DriveTime.cpp
@@ -5,20 +5,20 @@
#include "commands/DriveTime.hpp"
void DriveTime::Initialize() {
- m_timer.Start();
- m_drive->ArcadeDrive(0, 0);
+ timer.Start();
+ drive->ArcadeDrive(0, 0);
}
void DriveTime::Execute() {
- m_drive->ArcadeDrive(m_velocity, 0);
+ drive->ArcadeDrive(velocity, 0);
}
void DriveTime::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
- m_timer.Stop();
- m_timer.Reset();
+ drive->ArcadeDrive(0, 0);
+ timer.Stop();
+ timer.Reset();
}
bool DriveTime::IsFinished() {
- return m_timer.HasElapsed(m_duration);
+ return timer.HasElapsed(duration);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TeleopArcadeDrive.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TeleopArcadeDrive.cpp
index 5a9f0bdd243..3df5d9d85e0 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TeleopArcadeDrive.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TeleopArcadeDrive.cpp
@@ -11,12 +11,12 @@
TeleopArcadeDrive::TeleopArcadeDrive(
Drivetrain* subsystem, std::function xaxisVelocitySupplier,
std::function zaxisRotateSuppplier)
- : m_drive{subsystem},
- m_xaxisVelocitySupplier{std::move(xaxisVelocitySupplier)},
- m_zaxisRotateSupplier{std::move(zaxisRotateSuppplier)} {
+ : drive{subsystem},
+ xaxisVelocitySupplier{std::move(xaxisVelocitySupplier)},
+ zaxisRotateSupplier{std::move(zaxisRotateSuppplier)} {
AddRequirements(subsystem);
}
void TeleopArcadeDrive::Execute() {
- m_drive->ArcadeDrive(m_xaxisVelocitySupplier(), m_zaxisRotateSupplier());
+ drive->ArcadeDrive(xaxisVelocitySupplier(), zaxisRotateSupplier());
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnDegrees.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnDegrees.cpp
index bb19d62fa72..27a25e1591b 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnDegrees.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnDegrees.cpp
@@ -10,16 +10,16 @@
void TurnDegrees::Initialize() {
// Set motors to stop, read encoder values for starting point
- m_drive->ArcadeDrive(0, 0);
- m_drive->ResetEncoders();
+ drive->ArcadeDrive(0, 0);
+ drive->ResetEncoders();
}
void TurnDegrees::Execute() {
- m_drive->ArcadeDrive(0, m_velocity);
+ drive->ArcadeDrive(0, velocity);
}
void TurnDegrees::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
+ drive->ArcadeDrive(0, 0);
}
bool TurnDegrees::IsFinished() {
@@ -30,11 +30,11 @@ bool TurnDegrees::IsFinished() {
static auto inchPerDegree = (5.551_in * std::numbers::pi) / 360_deg;
// Compare distance traveled from start to distance based on degree turn.
- return GetAverageTurningDistance() >= inchPerDegree * m_angle;
+ return GetAverageTurningDistance() >= inchPerDegree * angle;
}
wpi::units::meter_t TurnDegrees::GetAverageTurningDistance() {
- auto l = wpi::units::math::abs(m_drive->GetLeftDistance());
- auto r = wpi::units::math::abs(m_drive->GetRightDistance());
+ auto l = wpi::units::math::abs(drive->GetLeftDistance());
+ auto r = wpi::units::math::abs(drive->GetRightDistance());
return (l + r) / 2;
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnTime.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnTime.cpp
index fb040614755..88e8f63bf7f 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnTime.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/commands/TurnTime.cpp
@@ -5,20 +5,20 @@
#include "commands/TurnTime.hpp"
void TurnTime::Initialize() {
- m_timer.Start();
- m_drive->ArcadeDrive(0, 0);
+ timer.Start();
+ drive->ArcadeDrive(0, 0);
}
void TurnTime::Execute() {
- m_drive->ArcadeDrive(0, m_velocity);
+ drive->ArcadeDrive(0, velocity);
}
void TurnTime::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
- m_timer.Stop();
- m_timer.Reset();
+ drive->ArcadeDrive(0, 0);
+ timer.Stop();
+ timer.Reset();
}
bool TurnTime::IsFinished() {
- return m_timer.HasElapsed(m_duration);
+ return timer.HasElapsed(duration);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp
index 91369791c17..e447cbf3793 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/cpp/subsystems/Drivetrain.cpp
@@ -15,18 +15,18 @@ using namespace DriveConstants;
// The Romi has onboard encoders that are hardcoded
// to use DIO pins 4/5 and 6/7 for the left and right
Drivetrain::Drivetrain() {
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_leftMotor);
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_rightMotor);
+ wpi::util::SendableRegistry::AddChild(&drive, &leftMotor);
+ wpi::util::SendableRegistry::AddChild(&drive, &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);
- m_leftEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
- kCountsPerRevolution);
- m_rightEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
- kCountsPerRevolution);
+ leftEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
+ kCountsPerRevolution);
+ rightEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
+ kCountsPerRevolution);
ResetEncoders();
}
@@ -35,28 +35,28 @@ void Drivetrain::Periodic() {
}
void Drivetrain::ArcadeDrive(double xaxisVelocity, double zaxisRotate) {
- m_drive.ArcadeDrive(xaxisVelocity, zaxisRotate);
+ drive.ArcadeDrive(xaxisVelocity, zaxisRotate);
}
void Drivetrain::ResetEncoders() {
- m_leftEncoder.Reset();
- m_rightEncoder.Reset();
+ leftEncoder.Reset();
+ rightEncoder.Reset();
}
int Drivetrain::GetLeftEncoderCount() {
- return m_leftEncoder.Get();
+ return leftEncoder.Get();
}
int Drivetrain::GetRightEncoderCount() {
- return m_rightEncoder.Get();
+ return rightEncoder.Get();
}
wpi::units::meter_t Drivetrain::GetLeftDistance() {
- return wpi::units::meter_t{m_leftEncoder.GetDistance()};
+ return wpi::units::meter_t{leftEncoder.GetDistance()};
}
wpi::units::meter_t Drivetrain::GetRightDistance() {
- return wpi::units::meter_t{m_rightEncoder.GetDistance()};
+ return wpi::units::meter_t{rightEncoder.GetDistance()};
}
wpi::units::meter_t Drivetrain::GetAverageDistance() {
@@ -64,17 +64,17 @@ wpi::units::meter_t Drivetrain::GetAverageDistance() {
}
wpi::units::radian_t Drivetrain::GetGyroAngleX() {
- return m_gyro.GetAngleX();
+ return gyro.GetAngleX();
}
wpi::units::radian_t Drivetrain::GetGyroAngleY() {
- return m_gyro.GetAngleY();
+ return gyro.GetAngleY();
}
wpi::units::radian_t Drivetrain::GetGyroAngleZ() {
- return m_gyro.GetAngleZ();
+ return gyro.GetAngleZ();
}
void Drivetrain::ResetGyro() {
- m_gyro.Reset();
+ gyro.Reset();
}
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.hpp
index 2d2e802c163..afb6d52b149 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/Robot.hpp
@@ -23,6 +23,6 @@ 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.
- wpi::cmd::Command* m_autonomousCommand = nullptr;
- RobotContainer m_container;
+ wpi::cmd::Command* autonomousCommand = nullptr;
+ RobotContainer container;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/RobotContainer.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/RobotContainer.hpp
index cd97b5fa508..b9a410b3384 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/RobotContainer.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/RobotContainer.hpp
@@ -41,21 +41,21 @@ class RobotContainer {
private:
// Assumes a gamepad plugged into channel 0
- wpi::Joystick m_controller{0};
- wpi::SendableChooser m_chooser;
+ wpi::Joystick controller{0};
+ wpi::SendableChooser chooser;
// The robot's subsystems
- Drivetrain m_drive;
- wpi::romi::OnBoardIO m_onboardIO{wpi::romi::OnBoardIO::ChannelMode::INPUT,
- wpi::romi::OnBoardIO::ChannelMode::INPUT};
+ Drivetrain drive;
+ wpi::romi::OnBoardIO onboardIO{wpi::romi::OnBoardIO::ChannelMode::INPUT,
+ wpi::romi::OnBoardIO::ChannelMode::INPUT};
// Example button
- wpi::cmd::Trigger m_onboardButtonA{
- [this] { return m_onboardIO.GetButtonAPressed(); }};
+ wpi::cmd::Trigger onboardButtonA{
+ [this] { return onboardIO.GetButtonAPressed(); }};
// Autonomous commands.
- AutonomousDistance m_autoDistance{&m_drive};
- AutonomousTime m_autoTime{&m_drive};
+ AutonomousDistance autoDistance{&drive};
+ AutonomousTime autoTime{&drive};
void ConfigureButtonBindings();
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.hpp
index e5ea1cc2c91..9b2a3f33790 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveDistance.hpp
@@ -22,8 +22,8 @@ class DriveDistance
*/
DriveDistance(double velocity, wpi::units::meter_t distance,
Drivetrain* drive)
- : m_velocity(velocity), m_distance(distance), m_drive(drive) {
- AddRequirements(m_drive);
+ : velocity(velocity), distance(distance), drive(drive) {
+ AddRequirements(drive);
}
void Initialize() override;
@@ -32,7 +32,7 @@ class DriveDistance
bool IsFinished() override;
private:
- double m_velocity;
- wpi::units::meter_t m_distance;
- Drivetrain* m_drive;
+ double velocity;
+ wpi::units::meter_t distance;
+ Drivetrain* drive;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.hpp
index f0b05af0d48..fc3a458268d 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/DriveTime.hpp
@@ -22,8 +22,8 @@ class DriveTime : public wpi::cmd::CommandHelper {
* @param drive The drivetrain subsystem on which this command will run
*/
DriveTime(double velocity, wpi::units::second_t time, Drivetrain* drive)
- : m_velocity(velocity), m_duration(time), m_drive(drive) {
- AddRequirements(m_drive);
+ : velocity(velocity), duration(time), drive(drive) {
+ AddRequirements(drive);
}
void Initialize() override;
@@ -32,8 +32,8 @@ class DriveTime : public wpi::cmd::CommandHelper {
bool IsFinished() override;
private:
- double m_velocity;
- wpi::units::second_t m_duration;
- Drivetrain* m_drive;
- wpi::Timer m_timer;
+ double velocity;
+ wpi::units::second_t duration;
+ Drivetrain* drive;
+ wpi::Timer timer;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.hpp
index b5ab55d0a00..b46029f595a 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TeleopArcadeDrive.hpp
@@ -27,7 +27,7 @@ class TeleopArcadeDrive
void Execute() override;
private:
- Drivetrain* m_drive;
- std::function m_xaxisVelocitySupplier;
- std::function m_zaxisRotateSupplier;
+ Drivetrain* drive;
+ std::function xaxisVelocitySupplier;
+ std::function zaxisRotateSupplier;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.hpp
index c1fbbe72a3b..2b049ae67a0 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnDegrees.hpp
@@ -23,8 +23,8 @@ class TurnDegrees
* @param drive The drive subsystem on which this command will run
*/
TurnDegrees(double velocity, wpi::units::degree_t angle, Drivetrain* drive)
- : m_velocity(velocity), m_angle(angle), m_drive(drive) {
- AddRequirements(m_drive);
+ : velocity(velocity), angle(angle), drive(drive) {
+ AddRequirements(drive);
}
void Initialize() override;
@@ -33,9 +33,9 @@ class TurnDegrees
bool IsFinished() override;
private:
- double m_velocity;
- wpi::units::degree_t m_angle;
- Drivetrain* m_drive;
+ double velocity;
+ wpi::units::degree_t angle;
+ Drivetrain* drive;
wpi::units::meter_t GetAverageTurningDistance();
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.hpp
index c7fe21f761b..24e179c8c66 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/commands/TurnTime.hpp
@@ -21,8 +21,8 @@ class TurnTime : public wpi::cmd::CommandHelper {
* @param drive The drive subsystem on which this command will run
*/
TurnTime(double velocity, wpi::units::second_t time, Drivetrain* drive)
- : m_velocity(velocity), m_duration(time), m_drive(drive) {
- AddRequirements(m_drive);
+ : velocity(velocity), duration(time), drive(drive) {
+ AddRequirements(drive);
}
void Initialize() override;
@@ -31,8 +31,8 @@ class TurnTime : public wpi::cmd::CommandHelper {
bool IsFinished() override;
private:
- double m_velocity;
- wpi::units::second_t m_duration;
- Drivetrain* m_drive;
- wpi::Timer m_timer;
+ double velocity;
+ wpi::units::second_t duration;
+ Drivetrain* drive;
+ wpi::Timer timer;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.hpp
index 104584f57f3..d4716e7a439 100644
--- a/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/RomiReference/include/subsystems/Drivetrain.hpp
@@ -99,15 +99,15 @@ class Drivetrain : public wpi::cmd::SubsystemBase {
void ResetGyro();
private:
- wpi::Spark m_leftMotor{0};
- wpi::Spark m_rightMotor{1};
+ wpi::Spark leftMotor{0};
+ wpi::Spark rightMotor{1};
- wpi::Encoder m_leftEncoder{4, 5};
- wpi::Encoder m_rightEncoder{6, 7};
+ wpi::Encoder leftEncoder{4, 5};
+ wpi::Encoder rightEncoder{6, 7};
- wpi::DifferentialDrive m_drive{
- [&](double output) { m_leftMotor.SetThrottle(output); },
- [&](double output) { m_rightMotor.SetThrottle(output); }};
+ wpi::DifferentialDrive drive{
+ [&](double output) { leftMotor.SetThrottle(output); },
+ [&](double output) { rightMotor.SetThrottle(output); }};
- wpi::romi::RomiGyro m_gyro;
+ wpi::romi::RomiGyro gyro;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Drivetrain.cpp
index e32dcf358fe..501edea82c0 100644
--- a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Drivetrain.cpp
@@ -8,33 +8,33 @@
void Drivetrain::SetVelocities(
const wpi::math::DifferentialDriveWheelVelocities& velocities) {
- auto leftFeedforward = m_feedforward.Calculate(velocities.left);
- auto rightFeedforward = m_feedforward.Calculate(velocities.right);
- double leftOutput = m_leftPIDController.Calculate(m_leftEncoder.GetRate(),
- velocities.left.value());
- double rightOutput = m_rightPIDController.Calculate(m_rightEncoder.GetRate(),
- velocities.right.value());
-
- m_leftLeader.SetVoltage(wpi::units::volt_t{leftOutput} + leftFeedforward);
- m_rightLeader.SetVoltage(wpi::units::volt_t{rightOutput} + rightFeedforward);
+ auto leftFeedforward = feedforward.Calculate(velocities.left);
+ auto rightFeedforward = feedforward.Calculate(velocities.right);
+ double leftOutput = leftPIDController.Calculate(leftEncoder.GetRate(),
+ velocities.left.value());
+ double rightOutput = rightPIDController.Calculate(rightEncoder.GetRate(),
+ velocities.right.value());
+
+ 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()});
}
void Drivetrain::ResetOdometry(const wpi::math::Pose2d& pose) {
- m_drivetrainSimulator.SetPose(pose);
- m_odometry.ResetPosition(
- m_imu.GetRotation2d(), wpi::units::meter_t{m_leftEncoder.GetDistance()},
- wpi::units::meter_t{m_rightEncoder.GetDistance()}, pose);
+ drivetrainSimulator.SetPose(pose);
+ odometry.ResetPosition(imu.GetRotation2d(),
+ wpi::units::meter_t{leftEncoder.GetDistance()},
+ wpi::units::meter_t{rightEncoder.GetDistance()}, pose);
}
void Drivetrain::SimulationPeriodic() {
@@ -42,22 +42,20 @@ void Drivetrain::SimulationPeriodic() {
// simulation, and write the simulated positions and velocities to our
// simulated encoder and gyro. We negate the right side so that positive
// voltages make the right side move forward.
- m_drivetrainSimulator.SetInputs(
- wpi::units::volt_t{m_leftLeader.GetThrottle()} *
- wpi::RobotController::GetInputVoltage(),
- wpi::units::volt_t{m_rightLeader.GetThrottle()} *
- wpi::RobotController::GetInputVoltage());
- m_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());
+ drivetrainSimulator.SetInputs(wpi::units::volt_t{leftLeader.GetThrottle()} *
+ wpi::RobotController::GetInputVoltage(),
+ wpi::units::volt_t{rightLeader.GetThrottle()} *
+ wpi::RobotController::GetInputVoltage());
+ drivetrainSimulator.Update(20_ms);
+
+ 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());
}
void Drivetrain::Periodic() {
UpdateOdometry();
- m_fieldSim.SetRobotPose(m_odometry.GetPose());
+ fieldSim.SetRobotPose(odometry.GetPose());
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp
index 410d539cb1c..77670bbb565 100644
--- a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/cpp/Robot.cpp
@@ -13,57 +13,56 @@
class Robot : public wpi::TimedRobot {
public:
Robot() {
- m_trajectory = wpi::math::TrajectoryGenerator::GenerateTrajectory(
+ trajectory = wpi::math::TrajectoryGenerator::GenerateTrajectory(
wpi::math::Pose2d{2_m, 2_m, 0_rad}, {},
wpi::math::Pose2d{6_m, 4_m, 0_rad},
wpi::math::TrajectoryConfig(2_mps, 2_mps_sq));
}
- void RobotPeriodic() override { m_drive.Periodic(); }
+ void RobotPeriodic() override { drive.Periodic(); }
void AutonomousInit() override {
- m_timer.Restart();
- m_drive.ResetOdometry(m_trajectory.InitialPose());
+ timer.Restart();
+ drive.ResetOdometry(trajectory.InitialPose());
}
void AutonomousPeriodic() override {
- auto elapsed = m_timer.Get();
- auto reference = m_trajectory.Sample(elapsed);
- auto velocities = m_feedback.Calculate(m_drive.GetPose(), reference);
- m_drive.Drive(velocities.vx, velocities.omega);
+ auto elapsed = timer.Get();
+ auto reference = trajectory.Sample(elapsed);
+ auto velocities = feedback.Calculate(drive.GetPose(), reference);
+ drive.Drive(velocities.vx, velocities.omega);
}
void TeleopPeriodic() override {
// Get the x velocity. We are inverting this because Xbox controllers return
// negative values when we push forward.
- const auto xVelocity =
- -m_velocityLimiter.Calculate(m_controller.GetLeftY()) *
- Drivetrain::kMaxVelocity;
+ 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). Xbox controllers return positive values when you pull to
// the right by default.
- auto rot = -m_rotLimiter.Calculate(m_controller.GetRightX()) *
+ 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 m_velocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_rotLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter velocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter rotLimiter{3 / 1_s};
- Drivetrain m_drive;
- wpi::math::Trajectory m_trajectory;
- wpi::math::LTVUnicycleController m_feedback{20_ms};
- wpi::Timer m_timer;
+ Drivetrain drive;
+ wpi::math::Trajectory trajectory;
+ wpi::math::LTVUnicycleController feedback{20_ms};
+ wpi::Timer timer;
};
#ifndef RUNNING_WPILIB_TESTS
diff --git a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/include/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/include/Drivetrain.hpp
index 3445331cb93..65ec0340b15 100644
--- a/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/include/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SimpleDifferentialDriveSimulation/include/Drivetrain.hpp
@@ -28,30 +28,30 @@
class Drivetrain {
public:
Drivetrain() {
- m_imu.ResetYaw();
+ imu.ResetYaw();
- 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);
// 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 /
- kEncoderResolution);
- m_rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
- kEncoderResolution);
+ leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
+ kEncoderResolution);
+ rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
+ kEncoderResolution);
- m_leftEncoder.Reset();
- m_rightEncoder.Reset();
+ leftEncoder.Reset();
+ rightEncoder.Reset();
- m_rightLeader.SetInverted(true);
+ rightLeader.SetInverted(true);
- wpi::SmartDashboard::PutData("Field", &m_fieldSim);
+ wpi::SmartDashboard::PutData("Field", &fieldSim);
}
static constexpr wpi::units::meters_per_second_t kMaxVelocity =
@@ -66,7 +66,7 @@ class Drivetrain {
void UpdateOdometry();
void ResetOdometry(const wpi::math::Pose2d& pose);
- wpi::math::Pose2d GetPose() const { return m_odometry.GetPose(); }
+ wpi::math::Pose2d GetPose() const { return odometry.GetPose(); }
void SimulationPeriodic();
void Periodic();
@@ -76,36 +76,36 @@ 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{8.5, 0.0, 0.0};
- wpi::math::PIDController m_rightPIDController{8.5, 0.0, 0.0};
+ wpi::math::PIDController leftPIDController{8.5, 0.0, 0.0};
+ wpi::math::PIDController rightPIDController{8.5, 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 m_feedforward{
+ wpi::math::SimpleMotorFeedforward feedforward{
1_V, 3_V / 1_mps};
// Simulation classes help us simulate our robot
- wpi::sim::EncoderSim m_leftEncoderSim{m_leftEncoder};
- wpi::sim::EncoderSim m_rightEncoderSim{m_rightEncoder};
- wpi::Field2d m_fieldSim;
- wpi::math::LinearSystem<2, 2, 2> m_drivetrainSystem =
+ wpi::sim::EncoderSim leftEncoderSim{leftEncoder};
+ wpi::sim::EncoderSim rightEncoderSim{rightEncoder};
+ wpi::Field2d fieldSim;
+ 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};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp
index 0fd1d0d8058..3188ed7d882 100644
--- a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp
@@ -45,14 +45,14 @@ class Robot : public wpi::TimedRobot {
// States: [position, velocity], in radians and radians per second.
// Inputs (what we can "put in"): [voltage], in volts.
// Outputs (what we can measure): [position], in radians.
- wpi::math::LinearSystem<2, 1, 1> m_armPlant =
+ wpi::math::LinearSystem<2, 1, 1> armPlant =
wpi::math::Models::SingleJointedArmFromPhysicalConstants(
wpi::math::DCMotor::NEO(2), kArmMOI, kArmGearing)
.Slice(0);
// The observer fuses our encoder data and voltage inputs to reject noise.
- wpi::math::KalmanFilter<2, 1, 1> m_observer{
- m_armPlant,
+ wpi::math::KalmanFilter<2, 1, 1> observer{
+ armPlant,
{0.015, 0.17}, // How accurate we think our model is
{0.01}, // How accurate we think our encoder position
// data is. In this case we very highly trust our encoder position
@@ -60,8 +60,8 @@ class Robot : public wpi::TimedRobot {
20_ms};
// A LQR uses feedback to create voltage commands.
- wpi::math::LinearQuadraticRegulator<2, 1> m_controller{
- m_armPlant,
+ wpi::math::LinearQuadraticRegulator<2, 1> controller{
+ armPlant,
// qelms. Velocity error tolerance, in radians and radians per second.
// Decrease this to more heavily penalize state excursion, or make the
// controller behave more aggressively.
@@ -78,65 +78,63 @@ class Robot : public wpi::TimedRobot {
// The state-space loop combines a controller, observer, feedforward and plant
// for easy control.
- wpi::math::LinearSystemLoop<2, 1, 1> m_loop{m_armPlant, m_controller,
- m_observer, 12_V, 20_ms};
+ wpi::math::LinearSystemLoop<2, 1, 1> loop{armPlant, controller, observer,
+ 12_V, 20_ms};
// An encoder set up to measure arm position in radians per second.
- wpi::Encoder m_encoder{kEncoderAChannel, kEncoderBChannel};
+ wpi::Encoder encoder{kEncoderAChannel, kEncoderBChannel};
- wpi::PWMSparkMax m_motor{kMotorPort};
- wpi::Gamepad m_joystick{kJoystickPort};
+ wpi::PWMSparkMax motor{kMotorPort};
+ wpi::Gamepad joystick{kJoystickPort};
- wpi::math::TrapezoidProfile m_profile{
+ wpi::math::TrapezoidProfile profile{
{45_deg_per_s, 90_deg_per_s / 1_s}};
- wpi::math::TrapezoidProfile::State
- m_lastProfiledReference;
+ wpi::math::TrapezoidProfile::State lastProfiledReference;
public:
Robot() {
// We go 2 pi radians per 4096 clicks.
- m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
+ encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
}
void TeleopInit() override {
- m_loop.Reset(
- wpi::math::Vectord<2>{m_encoder.GetDistance(), m_encoder.GetRate()});
+ loop.Reset(wpi::math::Vectord<2>{encoder.GetDistance(), encoder.GetRate()});
- m_lastProfiledReference = {
- wpi::units::radian_t{m_encoder.GetDistance()},
- wpi::units::radians_per_second_t{m_encoder.GetRate()}};
+ lastProfiledReference = {
+ wpi::units::radian_t{encoder.GetDistance()},
+ wpi::units::radians_per_second_t{encoder.GetRate()}};
}
void TeleopPeriodic() override {
// Sets the target position of our arm. This is similar to setting the
// setpoint of a PID controller.
wpi::math::TrapezoidProfile::State goal;
- if (m_joystick.GetRightBumperButton()) {
+ if (joystick.GetRightBumperButton()) {
// We pressed the bumper, so let's set our next reference
goal = {kRaisedPosition, 0_rad_per_s};
} else {
// We released the bumper, so let's spin down
goal = {kLoweredPosition, 0_rad_per_s};
}
- m_lastProfiledReference =
- m_profile.Calculate(20_ms, m_lastProfiledReference, goal);
+ lastProfiledReference =
+ profile.Calculate(20_ms, lastProfiledReference, goal);
- m_loop.SetNextR(
- wpi::math::Vectord<2>{m_lastProfiledReference.position.value(),
- m_lastProfiledReference.velocity.value()});
+ loop.SetNextR(
+ wpi::math::Vectord<2>{lastProfiledReference.position.value(),
+ lastProfiledReference.velocity.value()});
// Correct our Kalman filter's state vector estimate with encoder data.
- m_loop.Correct(wpi::math::Vectord<1>{m_encoder.GetDistance()});
+ loop.Correct(wpi::math::Vectord<1>{encoder.GetDistance()});
// Update our LQR to generate new voltage commands and use the voltages to
// predict the next state with out Kalman filter.
- m_loop.Predict(20_ms);
+ loop.Predict(20_ms);
// Send the new calculated voltage to the motors.
// voltage = duty cycle * battery voltage, so
// duty cycle = voltage / battery voltage
- m_motor.SetVoltage(wpi::units::volt_t{m_loop.U(0)});
+ motor.SetVoltage(wpi::units::volt_t{loop.U(0)});
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp
index 080cb6cb5b7..4660be5297f 100644
--- a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp
@@ -42,14 +42,14 @@ class Robot : public wpi::TimedRobot {
// States: [position, velocity], in meters and meters per second.
// Inputs (what we can "put in"): [voltage], in volts.
// Outputs (what we can measure): [position], in meters.
- wpi::math::LinearSystem<2, 1, 1> m_elevatorPlant =
+ wpi::math::LinearSystem<2, 1, 1> elevatorPlant =
wpi::math::Models::ElevatorFromPhysicalConstants(
wpi::math::DCMotor::NEO(2), kCarriageMass, kDrumRadius, kGearRatio)
.Slice(0);
// The observer fuses our encoder data and voltage inputs to reject noise.
- wpi::math::KalmanFilter<2, 1, 1> m_observer{
- m_elevatorPlant,
+ wpi::math::KalmanFilter<2, 1, 1> observer{
+ elevatorPlant,
{wpi::units::meter_t{2_in}.value(),
wpi::units::meters_per_second_t{40_in / 1_s}
.value()}, // How accurate we think our model is
@@ -59,8 +59,8 @@ class Robot : public wpi::TimedRobot {
20_ms};
// A LQR uses feedback to create voltage commands.
- wpi::math::LinearQuadraticRegulator<2, 1> m_controller{
- m_elevatorPlant,
+ wpi::math::LinearQuadraticRegulator<2, 1> controller{
+ elevatorPlant,
// qelms. State error tolerance, in meters and meters per second.
// Decrease this to more heavily penalize state excursion, or make the
// controller behave more aggressively.
@@ -77,66 +77,64 @@ class Robot : public wpi::TimedRobot {
// The state-space loop combines a controller, observer, feedforward and plant
// for easy control.
- wpi::math::LinearSystemLoop<2, 1, 1> m_loop{m_elevatorPlant, m_controller,
- m_observer, 12_V, 20_ms};
+ wpi::math::LinearSystemLoop<2, 1, 1> loop{elevatorPlant, controller, observer,
+ 12_V, 20_ms};
// An encoder set up to measure elevator height in meters.
- wpi::Encoder m_encoder{kEncoderAChannel, kEncoderBChannel};
+ wpi::Encoder encoder{kEncoderAChannel, kEncoderBChannel};
- wpi::PWMSparkMax m_motor{kMotorPort};
- wpi::Gamepad m_joystick{kJoystickPort};
+ wpi::PWMSparkMax motor{kMotorPort};
+ wpi::Gamepad joystick{kJoystickPort};
- wpi::math::TrapezoidProfile m_profile{{3_fps, 6_fps_sq}};
+ wpi::math::TrapezoidProfile profile{{3_fps, 6_fps_sq}};
- wpi::math::TrapezoidProfile::State
- m_lastProfiledReference;
+ wpi::math::TrapezoidProfile::State lastProfiledReference;
public:
Robot() {
// Circumference = pi * d, so distance per click = pi * d / counts
- m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi * kDrumRadius.value() /
- 4096.0);
+ encoder.SetDistancePerPulse(2.0 * std::numbers::pi * kDrumRadius.value() /
+ 4096.0);
}
void TeleopInit() override {
// Reset our loop to make sure it's in a known state.
- m_loop.Reset(
- wpi::math::Vectord<2>{m_encoder.GetDistance(), m_encoder.GetRate()});
+ loop.Reset(wpi::math::Vectord<2>{encoder.GetDistance(), encoder.GetRate()});
- m_lastProfiledReference = {
- wpi::units::meter_t{m_encoder.GetDistance()},
- wpi::units::meters_per_second_t{m_encoder.GetRate()}};
+ lastProfiledReference = {
+ wpi::units::meter_t{encoder.GetDistance()},
+ wpi::units::meters_per_second_t{encoder.GetRate()}};
}
void TeleopPeriodic() override {
// Sets the target height of our elevator. This is similar to setting the
// setpoint of a PID controller.
wpi::math::TrapezoidProfile::State goal;
- if (m_joystick.GetRightBumperButton()) {
+ if (joystick.GetRightBumperButton()) {
// We pressed the bumper, so let's set our next reference
goal = {kRaisedPosition, 0_fps};
} else {
// We released the bumper, so let's spin down
goal = {kLoweredPosition, 0_fps};
}
- m_lastProfiledReference =
- m_profile.Calculate(20_ms, m_lastProfiledReference, goal);
+ lastProfiledReference =
+ profile.Calculate(20_ms, lastProfiledReference, goal);
- m_loop.SetNextR(
- wpi::math::Vectord<2>{m_lastProfiledReference.position.value(),
- m_lastProfiledReference.velocity.value()});
+ loop.SetNextR(
+ wpi::math::Vectord<2>{lastProfiledReference.position.value(),
+ lastProfiledReference.velocity.value()});
// Correct our Kalman filter's state vector estimate with encoder data.
- m_loop.Correct(wpi::math::Vectord<1>{m_encoder.GetDistance()});
+ loop.Correct(wpi::math::Vectord<1>{encoder.GetDistance()});
// Update our LQR to generate new voltage commands and use the voltages to
// predict the next state with out Kalman filter.
- m_loop.Predict(20_ms);
+ loop.Predict(20_ms);
// Send the new calculated voltage to the motors.
// voltage = duty cycle * battery voltage, so
// duty cycle = voltage / battery voltage
- m_motor.SetVoltage(wpi::units::volt_t{m_loop.U(0)});
+ motor.SetVoltage(wpi::units::volt_t{loop.U(0)});
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
index 06d07b99bd3..8a5bc8c6cf5 100644
--- a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheel/cpp/Robot.cpp
@@ -39,21 +39,21 @@ class Robot : public wpi::TimedRobot {
// States: [velocity], in radians per second.
// Inputs (what we can "put in"): [voltage], in volts.
// Outputs (what we can measure): [velocity], in radians per second.
- wpi::math::LinearSystem<1, 1, 1> m_flywheelPlant =
+ wpi::math::LinearSystem<1, 1, 1> flywheelPlant =
wpi::math::Models::FlywheelFromPhysicalConstants(
wpi::math::DCMotor::NEO(2), kFlywheelMomentOfInertia,
kFlywheelGearing);
// The observer fuses our encoder data and voltage inputs to reject noise.
- wpi::math::KalmanFilter<1, 1, 1> m_observer{
- m_flywheelPlant,
+ wpi::math::KalmanFilter<1, 1, 1> observer{
+ flywheelPlant,
{3.0}, // How accurate we think our model is
{0.01}, // How accurate we think our encoder data is
20_ms};
// A LQR uses feedback to create voltage commands.
- wpi::math::LinearQuadraticRegulator<1, 1> m_controller{
- m_flywheelPlant,
+ wpi::math::LinearQuadraticRegulator<1, 1> controller{
+ flywheelPlant,
// qelms. Velocity error tolerance, in radians per second. Decrease this
// to more heavily penalize state excursion, or make the controller behave
// more aggressively.
@@ -69,47 +69,47 @@ class Robot : public wpi::TimedRobot {
// The state-space loop combines a controller, observer, feedforward and plant
// for easy control.
- wpi::math::LinearSystemLoop<1, 1, 1> m_loop{m_flywheelPlant, m_controller,
- m_observer, 12_V, 20_ms};
+ wpi::math::LinearSystemLoop<1, 1, 1> loop{flywheelPlant, controller, observer,
+ 12_V, 20_ms};
// An encoder set up to measure flywheel velocity in radians per second.
- wpi::Encoder m_encoder{kEncoderAChannel, kEncoderBChannel};
+ wpi::Encoder encoder{kEncoderAChannel, kEncoderBChannel};
- wpi::PWMSparkMax m_motor{kMotorPort};
- wpi::Gamepad m_joystick{kJoystickPort};
+ wpi::PWMSparkMax motor{kMotorPort};
+ wpi::Gamepad joystick{kJoystickPort};
public:
Robot() {
// We go 2 pi radians per 4096 clicks.
- m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
+ encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
}
void TeleopInit() override {
- m_loop.Reset(wpi::math::Vectord<1>{m_encoder.GetRate()});
+ loop.Reset(wpi::math::Vectord<1>{encoder.GetRate()});
}
void TeleopPeriodic() override {
// Sets the target velocity of our flywheel. This is similar to setting the
// setpoint of a PID controller.
- if (m_joystick.GetRightBumperButton()) {
+ if (joystick.GetRightBumperButton()) {
// We pressed the bumper, so let's set our next reference
- m_loop.SetNextR(wpi::math::Vectord<1>{kSpinup.value()});
+ loop.SetNextR(wpi::math::Vectord<1>{kSpinup.value()});
} else {
// We released the bumper, so let's spin down
- m_loop.SetNextR(wpi::math::Vectord<1>{0.0});
+ loop.SetNextR(wpi::math::Vectord<1>{0.0});
}
// Correct our Kalman filter's state vector estimate with encoder data.
- m_loop.Correct(wpi::math::Vectord<1>{m_encoder.GetRate()});
+ loop.Correct(wpi::math::Vectord<1>{encoder.GetRate()});
// Update our LQR to generate new voltage commands and use the voltages to
// predict the next state with out Kalman filter.
- m_loop.Predict(20_ms);
+ loop.Predict(20_ms);
// Send the new calculated voltage to the motors.
// voltage = duty cycle * battery voltage, so
// duty cycle = voltage / battery voltage
- m_motor.SetVoltage(wpi::units::volt_t{m_loop.U(0)});
+ motor.SetVoltage(wpi::units::volt_t{loop.U(0)});
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
index 712dfe4ca80..7668ed89872 100644
--- a/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceFlywheelSysId/cpp/Robot.cpp
@@ -38,19 +38,19 @@ class Robot : public wpi::TimedRobot {
// Outputs (what we can measure): [velocity], in radians per second.
//
// The Kv and Ka constants are found using the FRC Characterization toolsuite.
- wpi::math::LinearSystem<1, 1, 1> m_flywheelPlant =
+ wpi::math::LinearSystem<1, 1, 1> flywheelPlant =
wpi::math::Models::FlywheelFromSysId(kFlywheelKv, kFlywheelKa);
// The observer fuses our encoder data and voltage inputs to reject noise.
- wpi::math::KalmanFilter<1, 1, 1> m_observer{
- m_flywheelPlant,
+ wpi::math::KalmanFilter<1, 1, 1> observer{
+ flywheelPlant,
{3.0}, // How accurate we think our model is
{0.01}, // How accurate we think our encoder data is
20_ms};
// A LQR uses feedback to create voltage commands.
- wpi::math::LinearQuadraticRegulator<1, 1> m_controller{
- m_flywheelPlant,
+ wpi::math::LinearQuadraticRegulator<1, 1> controller{
+ flywheelPlant,
// qelms. Velocity error tolerance, in radians per second. Decrease this
// to more heavily penalize state excursion, or make the controller behave
// more aggressively.
@@ -66,47 +66,47 @@ class Robot : public wpi::TimedRobot {
// The state-space loop combines a controller, observer, feedforward and plant
// for easy control.
- wpi::math::LinearSystemLoop<1, 1, 1> m_loop{m_flywheelPlant, m_controller,
- m_observer, 12_V, 20_ms};
+ wpi::math::LinearSystemLoop<1, 1, 1> loop{flywheelPlant, controller, observer,
+ 12_V, 20_ms};
// An encoder set up to measure flywheel velocity in radians per second.
- wpi::Encoder m_encoder{kEncoderAChannel, kEncoderBChannel};
+ wpi::Encoder encoder{kEncoderAChannel, kEncoderBChannel};
- wpi::PWMSparkMax m_motor{kMotorPort};
- wpi::Gamepad m_joystick{kJoystickPort};
+ wpi::PWMSparkMax motor{kMotorPort};
+ wpi::Gamepad joystick{kJoystickPort};
public:
Robot() {
// We go 2 pi radians per 4096 clicks.
- m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
+ encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
}
void TeleopInit() override {
- m_loop.Reset(wpi::math::Vectord<1>{m_encoder.GetRate()});
+ loop.Reset(wpi::math::Vectord<1>{encoder.GetRate()});
}
void TeleopPeriodic() override {
// Sets the target velocity of our flywheel. This is similar to setting the
// setpoint of a PID controller.
- if (m_joystick.GetRightBumperButton()) {
+ if (joystick.GetRightBumperButton()) {
// We pressed the bumper, so let's set our next reference
- m_loop.SetNextR(wpi::math::Vectord<1>{kSpinup.value()});
+ loop.SetNextR(wpi::math::Vectord<1>{kSpinup.value()});
} else {
// We released the bumper, so let's spin down
- m_loop.SetNextR(wpi::math::Vectord<1>{0.0});
+ loop.SetNextR(wpi::math::Vectord<1>{0.0});
}
// Correct our Kalman filter's state vector estimate with encoder data.
- m_loop.Correct(wpi::math::Vectord<1>{m_encoder.GetRate()});
+ loop.Correct(wpi::math::Vectord<1>{encoder.GetRate()});
// Update our LQR to generate new voltage commands and use the voltages to
// predict the next state with out Kalman filter.
- m_loop.Predict(20_ms);
+ loop.Predict(20_ms);
// Send the new calculated voltage to the motors.
// voltage = duty cycle * battery voltage, so
// duty cycle = voltage / battery voltage
- m_motor.SetVoltage(wpi::units::volt_t{m_loop.U(0)});
+ motor.SetVoltage(wpi::units::volt_t{loop.U(0)});
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Drivetrain.cpp
index 150c4e86e5a..2934ee3753c 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Drivetrain.cpp
@@ -10,21 +10,20 @@ void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
wpi::units::second_t period) {
wpi::math::ChassisVelocities chassisVelocities{xVelocity, yVelocity, rot};
if (fieldRelative) {
- chassisVelocities =
- chassisVelocities.ToRobotRelative(m_imu.GetRotation2d());
+ chassisVelocities = chassisVelocities.ToRobotRelative(imu.GetRotation2d());
}
chassisVelocities = chassisVelocities.Discretize(period);
- auto [fl, fr, bl, br] = m_kinematics.DesaturateWheelVelocities(
- m_kinematics.ToSwerveModuleVelocities(chassisVelocities), kMaxVelocity);
- m_frontLeft.SetDesiredVelocity(fl);
- m_frontRight.SetDesiredVelocity(fr);
- m_backLeft.SetDesiredVelocity(bl);
- m_backRight.SetDesiredVelocity(br);
+ auto [fl, fr, bl, br] = kinematics.DesaturateWheelVelocities(
+ kinematics.ToSwerveModuleVelocities(chassisVelocities), kMaxVelocity);
+ frontLeft.SetDesiredVelocity(fl);
+ frontRight.SetDesiredVelocity(fr);
+ backLeft.SetDesiredVelocity(bl);
+ backRight.SetDesiredVelocity(br);
}
void Drivetrain::UpdateOdometry() {
- m_odometry.Update(m_imu.GetRotation2d(),
- {m_frontLeft.GetPosition(), m_frontRight.GetPosition(),
- m_backLeft.GetPosition(), m_backRight.GetPosition()});
+ odometry.Update(imu.GetRotation2d(),
+ {frontLeft.GetPosition(), frontRight.GetPosition(),
+ backLeft.GetPosition(), backRight.GetPosition()});
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Robot.cpp
index 77e53826371..1bf4630c815 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/Robot.cpp
@@ -12,46 +12,44 @@ class Robot : public wpi::TimedRobot {
public:
void AutonomousPeriodic() override {
DriveWithJoystick(false);
- m_swerve.UpdateOdometry();
+ swerve.UpdateOdometry();
}
void TeleopPeriodic() override { DriveWithJoystick(true); }
private:
- wpi::Gamepad m_controller{0};
- Drivetrain m_swerve;
+ wpi::Gamepad controller{0};
+ Drivetrain swerve;
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0
// to 1.
- wpi::math::SlewRateLimiter m_xVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_yVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_rotLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter xVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter yVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter rotLimiter{3 / 1_s};
void DriveWithJoystick(bool fieldRelative) {
// Get the x velocity. We are inverting this because gamepads return
// negative values when we push forward.
- const auto xVelocity =
- -m_xVelocityLimiter.Calculate(
- wpi::math::ApplyDeadband(m_controller.GetLeftY(), 0.02)) *
- Drivetrain::kMaxVelocity;
+ const auto xVelocity = -xVelocityLimiter.Calculate(wpi::math::ApplyDeadband(
+ controller.GetLeftY(), 0.02)) *
+ Drivetrain::kMaxVelocity;
// Get the y velocity or sideways/strafe velocity. We are inverting this
// because we want a positive value when we pull to the left. Gamepads
// return positive values when you pull to the right by default.
- const auto yVelocity =
- -m_yVelocityLimiter.Calculate(
- wpi::math::ApplyDeadband(m_controller.GetLeftX(), 0.02)) *
- Drivetrain::kMaxVelocity;
+ const auto yVelocity = -yVelocityLimiter.Calculate(wpi::math::ApplyDeadband(
+ controller.GetLeftX(), 0.02)) *
+ 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(wpi::math::ApplyDeadband(
- m_controller.GetRightX(), 0.02)) *
+ const auto rot = -rotLimiter.Calculate(wpi::math::ApplyDeadband(
+ controller.GetRightX(), 0.02)) *
Drivetrain::kMaxAngularVelocity;
- m_swerve.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
+ swerve.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp
index 319b407096f..076b9724993 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveBot/cpp/SwerveModule.cpp
@@ -14,43 +14,42 @@ SwerveModule::SwerveModule(const int driveMotorChannel,
const int driveEncoderChannelB,
const int turningEncoderChannelA,
const int turningEncoderChannelB)
- : m_driveMotor(driveMotorChannel),
- m_turningMotor(turningMotorChannel),
- m_driveEncoder(driveEncoderChannelA, driveEncoderChannelB),
- m_turningEncoder(turningEncoderChannelA, turningEncoderChannelB) {
+ : driveMotor(driveMotorChannel),
+ turningMotor(turningMotorChannel),
+ driveEncoder(driveEncoderChannelA, driveEncoderChannelB),
+ turningEncoder(turningEncoderChannelA, turningEncoderChannelB) {
// Set the distance per pulse for the drive encoder. We can simply use the
// distance traveled for one rotation of the wheel divided by the encoder
// resolution.
- m_driveEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
- kEncoderResolution);
+ driveEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
+ kEncoderResolution);
// Set the distance (in this case, angle) per pulse for the turning encoder.
// This is the the angle through an entire rotation (2 * std::numbers::pi)
// divided by the encoder resolution.
- m_turningEncoder.SetDistancePerPulse(2 * std::numbers::pi /
- kEncoderResolution);
+ turningEncoder.SetDistancePerPulse(2 * std::numbers::pi / kEncoderResolution);
// Limit the PID Controller's input range between -pi and pi and set the input
// to be continuous.
- m_turningPIDController.EnableContinuousInput(
+ turningPIDController.EnableContinuousInput(
-wpi::units::radian_t{std::numbers::pi},
wpi::units::radian_t{std::numbers::pi});
}
wpi::math::SwerveModulePosition SwerveModule::GetPosition() const {
- return {wpi::units::meter_t{m_driveEncoder.GetDistance()},
- wpi::units::radian_t{m_turningEncoder.GetDistance()}};
+ return {wpi::units::meter_t{driveEncoder.GetDistance()},
+ wpi::units::radian_t{turningEncoder.GetDistance()}};
}
wpi::math::SwerveModuleVelocity SwerveModule::GetVelocity() const {
- return {wpi::units::meters_per_second_t{m_driveEncoder.GetRate()},
- wpi::units::radian_t{m_turningEncoder.GetDistance()}};
+ return {wpi::units::meters_per_second_t{driveEncoder.GetRate()},
+ wpi::units::radian_t{turningEncoder.GetDistance()}};
}
void SwerveModule::SetDesiredVelocity(
wpi::math::SwerveModuleVelocity& desiredVelocity) {
wpi::math::Rotation2d encoderRotation{
- wpi::units::radian_t{m_turningEncoder.GetDistance()}};
+ wpi::units::radian_t{turningEncoder.GetDistance()}};
// Optimize the desired velocity to avoid spinning further than 90 degrees,
// then scale velocity by cosine of angle error. This scales down movement
@@ -59,21 +58,21 @@ void SwerveModule::SetDesiredVelocity(
auto velocity =
desiredVelocity.Optimize(encoderRotation).CosineScale(encoderRotation);
- // Calculate the drive output from the drive PID controller.
- const auto driveOutput = m_drivePIDController.Calculate(
- m_driveEncoder.GetRate(), velocity.velocity.value());
+ // Calculate the drive output from the drive PID controller and feedforward.
+ const auto driveOutput =
+ wpi::units::volt_t{drivePIDController.Calculate(
+ driveEncoder.GetRate(), velocity.velocity.value())} +
+ driveFeedforward.Calculate(velocity.velocity);
- const auto driveFeedforward = m_driveFeedforward.Calculate(velocity.velocity);
-
- // Calculate the turning motor output from the turning PID controller.
- const auto turnOutput = m_turningPIDController.Calculate(
- wpi::units::radian_t{m_turningEncoder.GetDistance()},
- velocity.angle.Radians());
-
- const auto turnFeedforward = m_turnFeedforward.Calculate(
- m_turningPIDController.GetSetpoint().velocity);
+ // Calculate the turning motor output from the turning PID controller and
+ // feedforward.
+ const auto turnOutput =
+ wpi::units::volt_t{turningPIDController.Calculate(
+ wpi::units::radian_t{turningEncoder.GetDistance()},
+ velocity.angle.Radians())} +
+ turnFeedforward.Calculate(turningPIDController.GetSetpoint().velocity);
// Set the motor outputs.
- m_driveMotor.SetVoltage(wpi::units::volt_t{driveOutput} + driveFeedforward);
- m_turningMotor.SetVoltage(wpi::units::volt_t{turnOutput} + turnFeedforward);
+ driveMotor.SetVoltage(driveOutput);
+ turningMotor.SetVoltage(turnOutput);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/Drivetrain.hpp
index 261bbaf7056..b6c59696b14 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/Drivetrain.hpp
@@ -17,7 +17,7 @@
*/
class Drivetrain {
public:
- Drivetrain() { m_imu.ResetYaw(); }
+ Drivetrain() { imu.ResetYaw(); }
void Drive(wpi::units::meters_per_second_t xVelocity,
wpi::units::meters_per_second_t yVelocity,
@@ -31,25 +31,25 @@ class Drivetrain {
std::numbers::pi}; // 1/2 rotation per second
private:
- wpi::math::Translation2d m_frontLeftLocation{+0.381_m, +0.381_m};
- wpi::math::Translation2d m_frontRightLocation{+0.381_m, -0.381_m};
- wpi::math::Translation2d m_backLeftLocation{-0.381_m, +0.381_m};
- wpi::math::Translation2d m_backRightLocation{-0.381_m, -0.381_m};
-
- SwerveModule m_frontLeft{1, 2, 0, 1, 2, 3};
- SwerveModule m_frontRight{3, 4, 4, 5, 6, 7};
- SwerveModule m_backLeft{5, 6, 8, 9, 10, 11};
- SwerveModule m_backRight{7, 8, 12, 13, 14, 15};
-
- wpi::OnboardIMU m_imu{wpi::OnboardIMU::FLAT};
-
- wpi::math::SwerveDriveKinematics<4> m_kinematics{
- m_frontLeftLocation, m_frontRightLocation, m_backLeftLocation,
- m_backRightLocation};
-
- wpi::math::SwerveDriveOdometry<4> m_odometry{
- m_kinematics,
- m_imu.GetRotation2d(),
- {m_frontLeft.GetPosition(), m_frontRight.GetPosition(),
- m_backLeft.GetPosition(), m_backRight.GetPosition()}};
+ wpi::math::Translation2d frontLeftLocation{+0.381_m, +0.381_m};
+ wpi::math::Translation2d frontRightLocation{+0.381_m, -0.381_m};
+ wpi::math::Translation2d backLeftLocation{-0.381_m, +0.381_m};
+ wpi::math::Translation2d backRightLocation{-0.381_m, -0.381_m};
+
+ SwerveModule frontLeft{1, 2, 0, 1, 2, 3};
+ SwerveModule frontRight{3, 4, 4, 5, 6, 7};
+ SwerveModule backLeft{5, 6, 8, 9, 10, 11};
+ SwerveModule backRight{7, 8, 12, 13, 14, 15};
+
+ wpi::OnboardIMU imu{wpi::OnboardIMU::FLAT};
+
+ wpi::math::SwerveDriveKinematics<4> kinematics{
+ frontLeftLocation, frontRightLocation, backLeftLocation,
+ backRightLocation};
+
+ wpi::math::SwerveDriveOdometry<4> odometry{
+ kinematics,
+ imu.GetRotation2d(),
+ {frontLeft.GetPosition(), frontRight.GetPosition(),
+ backLeft.GetPosition(), backRight.GetPosition()}};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.hpp b/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.hpp
index 27b3d7c6775..78d68e57243 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveBot/include/SwerveModule.hpp
@@ -36,21 +36,21 @@ class SwerveModule {
static constexpr auto kModuleMaxAngularAcceleration =
std::numbers::pi * 2_rad_per_s / 1_s; // radians per second^2
- wpi::PWMSparkMax m_driveMotor;
- wpi::PWMSparkMax m_turningMotor;
+ wpi::PWMSparkMax driveMotor;
+ wpi::PWMSparkMax turningMotor;
- wpi::Encoder m_driveEncoder;
- wpi::Encoder m_turningEncoder;
+ wpi::Encoder driveEncoder;
+ wpi::Encoder turningEncoder;
- wpi::math::PIDController m_drivePIDController{1.0, 0, 0};
- wpi::math::ProfiledPIDController m_turningPIDController{
+ wpi::math::PIDController drivePIDController{1.0, 0, 0};
+ wpi::math::ProfiledPIDController turningPIDController{
1.0,
0.0,
0.0,
{kModuleMaxAngularVelocity, kModuleMaxAngularAcceleration}};
- wpi::math::SimpleMotorFeedforward m_driveFeedforward{
+ wpi::math::SimpleMotorFeedforward driveFeedforward{
1_V, 3_V / 1_mps};
- wpi::math::SimpleMotorFeedforward m_turnFeedforward{
+ wpi::math::SimpleMotorFeedforward turnFeedforward{
1_V, 0.5_V / 1_rad_per_s};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Drivetrain.cpp
index b29e4567941..ce5561c93d6 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Drivetrain.cpp
@@ -14,28 +14,28 @@ void Drivetrain::Drive(wpi::units::meters_per_second_t xVelocity,
wpi::math::ChassisVelocities chassisVelocities{xVelocity, yVelocity, rot};
if (fieldRelative) {
chassisVelocities = chassisVelocities.ToRobotRelative(
- m_poseEstimator.GetEstimatedPosition().Rotation());
+ poseEstimator.GetEstimatedPosition().Rotation());
}
chassisVelocities = chassisVelocities.Discretize(period);
- auto [fl, fr, bl, br] = m_kinematics.DesaturateWheelVelocities(
- m_kinematics.ToSwerveModuleVelocities(chassisVelocities), kMaxVelocity);
- m_frontLeft.SetDesiredVelocity(fl);
- m_frontRight.SetDesiredVelocity(fr);
- m_backLeft.SetDesiredVelocity(bl);
- m_backRight.SetDesiredVelocity(br);
+ auto [fl, fr, bl, br] = kinematics.DesaturateWheelVelocities(
+ kinematics.ToSwerveModuleVelocities(chassisVelocities), kMaxVelocity);
+ frontLeft.SetDesiredVelocity(fl);
+ frontRight.SetDesiredVelocity(fr);
+ backLeft.SetDesiredVelocity(bl);
+ backRight.SetDesiredVelocity(br);
}
void Drivetrain::UpdateOdometry() {
- m_poseEstimator.Update(m_imu.GetRotation2d(),
- {m_frontLeft.GetPosition(), m_frontRight.GetPosition(),
- m_backLeft.GetPosition(), m_backRight.GetPosition()});
+ poseEstimator.Update(imu.GetRotation2d(),
+ {frontLeft.GetPosition(), frontRight.GetPosition(),
+ backLeft.GetPosition(), backRight.GetPosition()});
// Also apply vision measurements. We use 0.3 seconds in the past as an
// example -- on a real robot, this must be calculated based either on latency
// or timestamps.
- m_poseEstimator.AddVisionMeasurement(
+ poseEstimator.AddVisionMeasurement(
ExampleGlobalMeasurementSensor::GetEstimatedGlobalPose(
- m_poseEstimator.GetEstimatedPosition()),
+ poseEstimator.GetEstimatedPosition()),
wpi::Timer::GetTimestamp() - 0.3_s);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Robot.cpp
index 602cb5a2d6a..c28f4d28078 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/Robot.cpp
@@ -11,43 +11,41 @@ class Robot : public wpi::TimedRobot {
public:
void AutonomousPeriodic() override {
DriveWithJoystick(false);
- m_swerve.UpdateOdometry();
+ swerve.UpdateOdometry();
}
void TeleopPeriodic() override { DriveWithJoystick(true); }
private:
- wpi::Gamepad m_controller{0};
- Drivetrain m_swerve;
+ wpi::Gamepad controller{0};
+ Drivetrain swerve;
// Slew rate limiters to make joystick inputs more gentle; 1/3 sec from 0
// to 1.
- wpi::math::SlewRateLimiter m_xVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_yVelocityLimiter{3 / 1_s};
- wpi::math::SlewRateLimiter m_rotLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter xVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter yVelocityLimiter{3 / 1_s};
+ wpi::math::SlewRateLimiter rotLimiter{3 / 1_s};
void DriveWithJoystick(bool fieldRelative) {
// Get the x velocity. We are inverting this because gamepads return
// negative values when we push forward.
- const auto xVelocity =
- -m_xVelocityLimiter.Calculate(m_controller.GetLeftY()) *
- Drivetrain::kMaxVelocity;
+ const auto xVelocity = -xVelocityLimiter.Calculate(controller.GetLeftY()) *
+ Drivetrain::kMaxVelocity;
// Get the y velocity or sideways/strafe velocity. We are inverting this
// because we want a positive value when we pull to the left. Gamepads
// return positive values when you pull to the right by default.
- const auto yVelocity =
- -m_yVelocityLimiter.Calculate(m_controller.GetLeftX()) *
- Drivetrain::kMaxVelocity;
+ const auto yVelocity = -yVelocityLimiter.Calculate(controller.GetLeftX()) *
+ 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_swerve.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
+ swerve.Drive(xVelocity, yVelocity, rot, fieldRelative, GetPeriod());
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp
index c6c025958ba..06a3db83381 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/cpp/SwerveModule.cpp
@@ -14,43 +14,42 @@ SwerveModule::SwerveModule(const int driveMotorChannel,
const int driveEncoderChannelB,
const int turningEncoderChannelA,
const int turningEncoderChannelB)
- : m_driveMotor(driveMotorChannel),
- m_turningMotor(turningMotorChannel),
- m_driveEncoder(driveEncoderChannelA, driveEncoderChannelB),
- m_turningEncoder(turningEncoderChannelA, turningEncoderChannelB) {
+ : driveMotor(driveMotorChannel),
+ turningMotor(turningMotorChannel),
+ driveEncoder(driveEncoderChannelA, driveEncoderChannelB),
+ turningEncoder(turningEncoderChannelA, turningEncoderChannelB) {
// Set the distance per pulse for the drive encoder. We can simply use the
// distance traveled for one rotation of the wheel divided by the encoder
// resolution.
- m_driveEncoder.SetDistancePerPulse(2 * std::numbers::pi *
- kWheelRadius.value() / kEncoderResolution);
+ driveEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius.value() /
+ kEncoderResolution);
// Set the distance (in this case, angle) per pulse for the turning encoder.
// This is the the angle through an entire rotation (2 * std::numbers::pi)
// divided by the encoder resolution.
- m_turningEncoder.SetDistancePerPulse(2 * std::numbers::pi /
- kEncoderResolution);
+ turningEncoder.SetDistancePerPulse(2 * std::numbers::pi / kEncoderResolution);
// Limit the PID Controller's input range between -pi and pi and set the input
// to be continuous.
- m_turningPIDController.EnableContinuousInput(
+ turningPIDController.EnableContinuousInput(
-wpi::units::radian_t{std::numbers::pi},
wpi::units::radian_t{std::numbers::pi});
}
wpi::math::SwerveModulePosition SwerveModule::GetPosition() const {
- return {wpi::units::meter_t{m_driveEncoder.GetDistance()},
- wpi::units::radian_t{m_turningEncoder.GetDistance()}};
+ return {wpi::units::meter_t{driveEncoder.GetDistance()},
+ wpi::units::radian_t{turningEncoder.GetDistance()}};
}
wpi::math::SwerveModuleVelocity SwerveModule::GetVelocity() const {
- return {wpi::units::meters_per_second_t{m_driveEncoder.GetRate()},
- wpi::units::radian_t{m_turningEncoder.GetDistance()}};
+ return {wpi::units::meters_per_second_t{driveEncoder.GetRate()},
+ wpi::units::radian_t{turningEncoder.GetDistance()}};
}
void SwerveModule::SetDesiredVelocity(
wpi::math::SwerveModuleVelocity& desiredVelocity) {
wpi::math::Rotation2d encoderRotation{
- wpi::units::radian_t{m_turningEncoder.GetDistance()}};
+ wpi::units::radian_t{turningEncoder.GetDistance()}};
// Optimize the desired velocity to avoid spinning further than 90 degrees,
// then scale velocity by cosine of angle error. This scales down movement
@@ -59,21 +58,21 @@ void SwerveModule::SetDesiredVelocity(
auto velocity =
desiredVelocity.Optimize(encoderRotation).CosineScale(encoderRotation);
- // Calculate the drive output from the drive PID controller.
- const auto driveOutput = m_drivePIDController.Calculate(
- m_driveEncoder.GetRate(), velocity.velocity.value());
+ // Calculate the drive output from the drive PID controller and feedforward.
+ const auto driveOutput =
+ wpi::units::volt_t{drivePIDController.Calculate(
+ driveEncoder.GetRate(), velocity.velocity.value())} +
+ driveFeedforward.Calculate(velocity.velocity);
- const auto driveFeedforward = m_driveFeedforward.Calculate(velocity.velocity);
-
- // Calculate the turning motor output from the turning PID controller.
- const auto turnOutput = m_turningPIDController.Calculate(
- wpi::units::radian_t{m_turningEncoder.GetDistance()},
- velocity.angle.Radians());
-
- const auto turnFeedforward = m_turnFeedforward.Calculate(
- m_turningPIDController.GetSetpoint().velocity);
+ // Calculate the turning motor output from the turning PID controller and
+ // feedforward.
+ const auto turnOutput =
+ wpi::units::volt_t{turningPIDController.Calculate(
+ wpi::units::radian_t{turningEncoder.GetDistance()},
+ velocity.angle.Radians())} +
+ turnFeedforward.Calculate(turningPIDController.GetSetpoint().velocity);
// Set the motor outputs.
- m_driveMotor.SetVoltage(wpi::units::volt_t{driveOutput} + driveFeedforward);
- m_turningMotor.SetVoltage(wpi::units::volt_t{turnOutput} + turnFeedforward);
+ driveMotor.SetVoltage(driveOutput);
+ turningMotor.SetVoltage(turnOutput);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/Drivetrain.hpp b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/Drivetrain.hpp
index 211b5698213..f2b50e5521d 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/Drivetrain.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/Drivetrain.hpp
@@ -17,7 +17,7 @@
*/
class Drivetrain {
public:
- Drivetrain() { m_imu.ResetYaw(); }
+ Drivetrain() { imu.ResetYaw(); }
void Drive(wpi::units::meters_per_second_t xVelocity,
wpi::units::meters_per_second_t yVelocity,
@@ -30,29 +30,29 @@ class Drivetrain {
std::numbers::pi}; // 1/2 rotation per second
private:
- wpi::math::Translation2d m_frontLeftLocation{+0.381_m, +0.381_m};
- wpi::math::Translation2d m_frontRightLocation{+0.381_m, -0.381_m};
- wpi::math::Translation2d m_backLeftLocation{-0.381_m, +0.381_m};
- wpi::math::Translation2d m_backRightLocation{-0.381_m, -0.381_m};
+ wpi::math::Translation2d frontLeftLocation{+0.381_m, +0.381_m};
+ wpi::math::Translation2d frontRightLocation{+0.381_m, -0.381_m};
+ wpi::math::Translation2d backLeftLocation{-0.381_m, +0.381_m};
+ wpi::math::Translation2d backRightLocation{-0.381_m, -0.381_m};
- SwerveModule m_frontLeft{1, 2, 0, 1, 2, 3};
- SwerveModule m_frontRight{3, 4, 4, 5, 6, 7};
- SwerveModule m_backLeft{5, 6, 8, 9, 10, 11};
- SwerveModule m_backRight{7, 8, 12, 13, 14, 15};
+ SwerveModule frontLeft{1, 2, 0, 1, 2, 3};
+ SwerveModule frontRight{3, 4, 4, 5, 6, 7};
+ SwerveModule backLeft{5, 6, 8, 9, 10, 11};
+ SwerveModule backRight{7, 8, 12, 13, 14, 15};
- wpi::OnboardIMU m_imu{wpi::OnboardIMU::FLAT};
+ wpi::OnboardIMU imu{wpi::OnboardIMU::FLAT};
- wpi::math::SwerveDriveKinematics<4> m_kinematics{
- m_frontLeftLocation, m_frontRightLocation, m_backLeftLocation,
- m_backRightLocation};
+ wpi::math::SwerveDriveKinematics<4> kinematics{
+ frontLeftLocation, frontRightLocation, backLeftLocation,
+ backRightLocation};
// Gains are for example purposes only - must be determined for your own
// robot!
- wpi::math::SwerveDrivePoseEstimator<4> m_poseEstimator{
- m_kinematics,
+ wpi::math::SwerveDrivePoseEstimator<4> poseEstimator{
+ kinematics,
wpi::math::Rotation2d{},
- {m_frontLeft.GetPosition(), m_frontRight.GetPosition(),
- m_backLeft.GetPosition(), m_backRight.GetPosition()},
+ {frontLeft.GetPosition(), frontRight.GetPosition(),
+ backLeft.GetPosition(), backRight.GetPosition()},
wpi::math::Pose2d{},
{0.1, 0.1, 0.1},
{0.1, 0.1, 0.1}};
diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/SwerveModule.hpp b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/SwerveModule.hpp
index d57b7099722..08787fb9f0d 100644
--- a/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/SwerveModule.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SwerveDrivePoseEstimator/include/SwerveModule.hpp
@@ -36,21 +36,21 @@ class SwerveModule {
static constexpr auto kModuleMaxAngularAcceleration =
std::numbers::pi * 2_rad_per_s / 1_s; // radians per second^2
- wpi::PWMSparkMax m_driveMotor;
- wpi::PWMSparkMax m_turningMotor;
+ wpi::PWMSparkMax driveMotor;
+ wpi::PWMSparkMax turningMotor;
- wpi::Encoder m_driveEncoder;
- wpi::Encoder m_turningEncoder;
+ wpi::Encoder driveEncoder;
+ wpi::Encoder turningEncoder;
- wpi::math::PIDController m_drivePIDController{1.0, 0, 0};
- wpi::math::ProfiledPIDController m_turningPIDController{
+ wpi::math::PIDController drivePIDController{1.0, 0, 0};
+ wpi::math::ProfiledPIDController turningPIDController{
1.0,
0.0,
0.0,
{kModuleMaxAngularVelocity, kModuleMaxAngularAcceleration}};
- wpi::math::SimpleMotorFeedforward m_driveFeedforward{
+ wpi::math::SimpleMotorFeedforward driveFeedforward{
1_V, 3_V / 1_mps};
- wpi::math::SimpleMotorFeedforward m_turnFeedforward{
+ wpi::math::SimpleMotorFeedforward turnFeedforward{
1_V, 0.5_V / 1_rad_per_s};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp
index 3dd2cac83b8..132624950e1 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp
@@ -19,11 +19,11 @@ void Robot::DisabledPeriodic() {}
void Robot::DisabledExit() {}
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());
}
}
@@ -32,8 +32,8 @@ void Robot::AutonomousPeriodic() {}
void Robot::AutonomousExit() {}
void Robot::TeleopInit() {
- if (m_autonomousCommand) {
- m_autonomousCommand->Cancel();
+ if (autonomousCommand) {
+ autonomousCommand->Cancel();
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/SysIdRoutineBot.cpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/SysIdRoutineBot.cpp
index c9f1e144943..a99edb6e530 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/SysIdRoutineBot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/SysIdRoutineBot.cpp
@@ -11,38 +11,36 @@ SysIdRoutineBot::SysIdRoutineBot() {
}
void SysIdRoutineBot::ConfigureBindings() {
- m_drive.SetDefaultCommand(m_drive.ArcadeDriveCommand(
- [this] { return -m_driverController.GetLeftY(); },
- [this] { return -m_driverController.GetRightX(); }));
+ drive.SetDefaultCommand(drive.ArcadeDriveCommand(
+ [this] { return -driverController.GetLeftY(); },
+ [this] { return -driverController.GetRightX(); }));
// Using bumpers as a modifier and combining it with the buttons so that we
// can have both sets of bindings at once
- (m_driverController.SouthFace() && m_driverController.RightBumper())
+ (driverController.SouthFace() && driverController.RightBumper())
+ .WhileTrue(drive.SysIdQuasistatic(wpi::cmd::sysid::Direction::kForward));
+ (driverController.EastFace() && driverController.RightBumper())
+ .WhileTrue(drive.SysIdQuasistatic(wpi::cmd::sysid::Direction::kReverse));
+ (driverController.WestFace() && driverController.RightBumper())
+ .WhileTrue(drive.SysIdDynamic(wpi::cmd::sysid::Direction::kForward));
+ (driverController.NorthFace() && driverController.RightBumper())
+ .WhileTrue(drive.SysIdDynamic(wpi::cmd::sysid::Direction::kReverse));
+
+ shooter.SetDefaultCommand(shooter.RunShooterCommand(
+ [this] { return driverController.GetLeftTriggerAxis(); }));
+
+ (driverController.SouthFace() && driverController.LeftBumper())
.WhileTrue(
- m_drive.SysIdQuasistatic(wpi::cmd::sysid::Direction::kForward));
- (m_driverController.EastFace() && m_driverController.RightBumper())
+ shooter.SysIdQuasistatic(wpi::cmd::sysid::Direction::kForward));
+ (driverController.EastFace() && driverController.LeftBumper())
.WhileTrue(
- m_drive.SysIdQuasistatic(wpi::cmd::sysid::Direction::kReverse));
- (m_driverController.WestFace() && m_driverController.RightBumper())
- .WhileTrue(m_drive.SysIdDynamic(wpi::cmd::sysid::Direction::kForward));
- (m_driverController.NorthFace() && m_driverController.RightBumper())
- .WhileTrue(m_drive.SysIdDynamic(wpi::cmd::sysid::Direction::kReverse));
-
- m_shooter.SetDefaultCommand(m_shooter.RunShooterCommand(
- [this] { return m_driverController.GetLeftTriggerAxis(); }));
-
- (m_driverController.SouthFace() && m_driverController.LeftBumper())
- .WhileTrue(
- m_shooter.SysIdQuasistatic(wpi::cmd::sysid::Direction::kForward));
- (m_driverController.EastFace() && m_driverController.LeftBumper())
- .WhileTrue(
- m_shooter.SysIdQuasistatic(wpi::cmd::sysid::Direction::kReverse));
- (m_driverController.WestFace() && m_driverController.LeftBumper())
- .WhileTrue(m_shooter.SysIdDynamic(wpi::cmd::sysid::Direction::kForward));
- (m_driverController.NorthFace() && m_driverController.LeftBumper())
- .WhileTrue(m_shooter.SysIdDynamic(wpi::cmd::sysid::Direction::kReverse));
+ shooter.SysIdQuasistatic(wpi::cmd::sysid::Direction::kReverse));
+ (driverController.WestFace() && driverController.LeftBumper())
+ .WhileTrue(shooter.SysIdDynamic(wpi::cmd::sysid::Direction::kForward));
+ (driverController.NorthFace() && driverController.LeftBumper())
+ .WhileTrue(shooter.SysIdDynamic(wpi::cmd::sysid::Direction::kReverse));
}
wpi::cmd::CommandPtr SysIdRoutineBot::GetAutonomousCommand() {
- return m_drive.Run([] {});
+ return drive.Run([] {});
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp
index 5c1d2c34e4a..30c0f21365c 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Drive.cpp
@@ -7,32 +7,31 @@
#include "wpi/commands2/Commands.hpp"
Drive::Drive() {
- m_leftMotor.AddFollower(wpi::PWMSparkMax{constants::drive::kLeftMotor2Port});
- m_rightMotor.AddFollower(
- wpi::PWMSparkMax{constants::drive::kRightMotor2Port});
+ leftMotor.AddFollower(wpi::PWMSparkMax{constants::drive::kLeftMotor2Port});
+ rightMotor.AddFollower(wpi::PWMSparkMax{constants::drive::kRightMotor2Port});
- m_rightMotor.SetInverted(true);
+ rightMotor.SetInverted(true);
- m_leftEncoder.SetDistancePerPulse(
+ leftEncoder.SetDistancePerPulse(
constants::drive::kEncoderDistancePerPulse.value());
- m_rightEncoder.SetDistancePerPulse(
+ rightEncoder.SetDistancePerPulse(
constants::drive::kEncoderDistancePerPulse.value());
- m_drive.SetSafetyEnabled(false);
+ drive.SetSafetyEnabled(false);
}
wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function fwd,
std::function rot) {
- return wpi::cmd::Run([this, fwd, rot] { m_drive.ArcadeDrive(fwd(), rot()); },
+ return wpi::cmd::Run([this, fwd, rot] { drive.ArcadeDrive(fwd(), rot()); },
{this})
.WithName("Arcade Drive");
}
wpi::cmd::CommandPtr Drive::SysIdQuasistatic(
wpi::cmd::sysid::Direction direction) {
- return m_sysIdRoutine.Quasistatic(direction);
+ return sysIdRoutine.Quasistatic(direction);
}
wpi::cmd::CommandPtr Drive::SysIdDynamic(wpi::cmd::sysid::Direction direction) {
- return m_sysIdRoutine.Dynamic(direction);
+ return sysIdRoutine.Dynamic(direction);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp
index 06548fe3d84..d21f1a6c644 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/subsystems/Shooter.cpp
@@ -9,7 +9,7 @@
#include "wpi/units/voltage.hpp"
Shooter::Shooter() {
- m_shooterEncoder.SetDistancePerPulse(
+ shooterEncoder.SetDistancePerPulse(
constants::shooter::kEncoderDistancePerPulse.value());
}
@@ -17,12 +17,12 @@ wpi::cmd::CommandPtr Shooter::RunShooterCommand(
std::function shooterVelocity) {
return wpi::cmd::Run(
[this, shooterVelocity] {
- m_shooterMotor.SetVoltage(
- wpi::units::volt_t{m_shooterFeedback.Calculate(
- m_shooterEncoder.GetRate(), shooterVelocity())} +
- m_shooterFeedforward.Calculate(
+ shooterMotor.SetVoltage(
+ wpi::units::volt_t{shooterFeedback.Calculate(
+ shooterEncoder.GetRate(), shooterVelocity())} +
+ shooterFeedforward.Calculate(
wpi::units::turns_per_second_t{shooterVelocity()}));
- m_feederMotor.SetThrottle(constants::shooter::kFeederVelocity);
+ feederMotor.SetThrottle(constants::shooter::kFeederVelocity);
},
{this})
.WithName("Set Shooter Velocity");
@@ -30,10 +30,10 @@ wpi::cmd::CommandPtr Shooter::RunShooterCommand(
wpi::cmd::CommandPtr Shooter::SysIdQuasistatic(
wpi::cmd::sysid::Direction direction) {
- return m_sysIdRoutine.Quasistatic(direction);
+ return sysIdRoutine.Quasistatic(direction);
}
wpi::cmd::CommandPtr Shooter::SysIdDynamic(
wpi::cmd::sysid::Direction direction) {
- return m_sysIdRoutine.Dynamic(direction);
+ return sysIdRoutine.Dynamic(direction);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/Robot.hpp
index 0eb843e390b..0998e52c1c0 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/Robot.hpp
@@ -28,7 +28,7 @@ class Robot : public wpi::TimedRobot {
void UtilityExit() override;
private:
- std::optional m_autonomousCommand;
+ std::optional autonomousCommand;
- SysIdRoutineBot m_container;
+ SysIdRoutineBot container;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/SysIdRoutineBot.hpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/SysIdRoutineBot.hpp
index dd5d208fb04..f86b8b6c342 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/SysIdRoutineBot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/SysIdRoutineBot.hpp
@@ -18,8 +18,8 @@ class SysIdRoutineBot {
private:
void ConfigureBindings();
- wpi::cmd::CommandGamepad m_driverController{
+ wpi::cmd::CommandGamepad driverController{
constants::oi::kDriverControllerPort};
- Drive m_drive;
- Shooter m_shooter;
+ Drive drive;
+ Shooter shooter;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Drive.hpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Drive.hpp
index bf47d517681..ca36bffe884 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Drive.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Drive.hpp
@@ -24,41 +24,41 @@ class Drive : public wpi::cmd::SubsystemBase {
wpi::cmd::CommandPtr SysIdDynamic(wpi::cmd::sysid::Direction direction);
private:
- wpi::PWMSparkMax m_leftMotor{constants::drive::kLeftMotor1Port};
- wpi::PWMSparkMax m_rightMotor{constants::drive::kRightMotor1Port};
- wpi::DifferentialDrive m_drive{
- [this](auto val) { m_leftMotor.SetThrottle(val); },
- [this](auto val) { m_rightMotor.SetThrottle(val); }};
+ wpi::PWMSparkMax leftMotor{constants::drive::kLeftMotor1Port};
+ wpi::PWMSparkMax rightMotor{constants::drive::kRightMotor1Port};
+ wpi::DifferentialDrive drive{
+ [this](auto val) { leftMotor.SetThrottle(val); },
+ [this](auto val) { rightMotor.SetThrottle(val); }};
- wpi::Encoder m_leftEncoder{constants::drive::kLeftEncoderPorts[0],
- constants::drive::kLeftEncoderPorts[1],
- constants::drive::kLeftEncoderReversed};
+ wpi::Encoder leftEncoder{constants::drive::kLeftEncoderPorts[0],
+ constants::drive::kLeftEncoderPorts[1],
+ constants::drive::kLeftEncoderReversed};
- wpi::Encoder m_rightEncoder{constants::drive::kRightEncoderPorts[0],
- constants::drive::kRightEncoderPorts[1],
- constants::drive::kRightEncoderReversed};
+ wpi::Encoder rightEncoder{constants::drive::kRightEncoderPorts[0],
+ constants::drive::kRightEncoderPorts[1],
+ constants::drive::kRightEncoderReversed};
- wpi::cmd::sysid::SysIdRoutine m_sysIdRoutine{
+ wpi::cmd::sysid::SysIdRoutine sysIdRoutine{
wpi::cmd::sysid::Config{std::nullopt, std::nullopt, std::nullopt,
nullptr},
wpi::cmd::sysid::Mechanism{
[this](wpi::units::volt_t driveVoltage) {
- m_leftMotor.SetVoltage(driveVoltage);
- m_rightMotor.SetVoltage(driveVoltage);
+ leftMotor.SetVoltage(driveVoltage);
+ rightMotor.SetVoltage(driveVoltage);
},
[this](wpi::sysid::SysIdRoutineLog* log) {
log->Motor("drive-left")
- .voltage(m_leftMotor.GetThrottle() *
+ .voltage(leftMotor.GetThrottle() *
wpi::RobotController::GetBatteryVoltage())
- .position(wpi::units::meter_t{m_leftEncoder.GetDistance()})
+ .position(wpi::units::meter_t{leftEncoder.GetDistance()})
.velocity(
- wpi::units::meters_per_second_t{m_leftEncoder.GetRate()});
+ wpi::units::meters_per_second_t{leftEncoder.GetRate()});
log->Motor("drive-right")
- .voltage(m_rightMotor.GetThrottle() *
+ .voltage(rightMotor.GetThrottle() *
wpi::RobotController::GetBatteryVoltage())
- .position(wpi::units::meter_t{m_rightEncoder.GetDistance()})
+ .position(wpi::units::meter_t{rightEncoder.GetDistance()})
.velocity(
- wpi::units::meters_per_second_t{m_rightEncoder.GetRate()});
+ wpi::units::meters_per_second_t{rightEncoder.GetRate()});
},
this}};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Shooter.hpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Shooter.hpp
index ce9c3933472..a78950f87cf 100644
--- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Shooter.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/include/subsystems/Shooter.hpp
@@ -25,30 +25,30 @@ class Shooter : public wpi::cmd::SubsystemBase {
wpi::cmd::CommandPtr SysIdDynamic(wpi::cmd::sysid::Direction direction);
private:
- wpi::PWMSparkMax m_shooterMotor{constants::shooter::kShooterMotorPort};
- wpi::PWMSparkMax m_feederMotor{constants::shooter::kFeederMotorPort};
+ wpi::PWMSparkMax shooterMotor{constants::shooter::kShooterMotorPort};
+ wpi::PWMSparkMax feederMotor{constants::shooter::kFeederMotorPort};
- wpi::Encoder m_shooterEncoder{constants::shooter::kEncoderPorts[0],
- constants::shooter::kEncoderPorts[1],
- constants::shooter::kEncoderReversed};
+ wpi::Encoder shooterEncoder{constants::shooter::kEncoderPorts[0],
+ constants::shooter::kEncoderPorts[1],
+ constants::shooter::kEncoderReversed};
- wpi::cmd::sysid::SysIdRoutine m_sysIdRoutine{
+ wpi::cmd::sysid::SysIdRoutine sysIdRoutine{
wpi::cmd::sysid::Config{std::nullopt, std::nullopt, std::nullopt,
nullptr},
wpi::cmd::sysid::Mechanism{
[this](wpi::units::volt_t driveVoltage) {
- m_shooterMotor.SetVoltage(driveVoltage);
+ shooterMotor.SetVoltage(driveVoltage);
},
[this](wpi::sysid::SysIdRoutineLog* log) {
log->Motor("shooter-wheel")
- .voltage(m_shooterMotor.GetThrottle() *
+ .voltage(shooterMotor.GetThrottle() *
wpi::RobotController::GetBatteryVoltage())
- .position(wpi::units::turn_t{m_shooterEncoder.GetDistance()})
+ .position(wpi::units::turn_t{shooterEncoder.GetDistance()})
.velocity(
- wpi::units::turns_per_second_t{m_shooterEncoder.GetRate()});
+ wpi::units::turns_per_second_t{shooterEncoder.GetRate()});
},
this}};
- wpi::math::PIDController m_shooterFeedback{constants::shooter::kP, 0, 0};
- wpi::math::SimpleMotorFeedforward m_shooterFeedforward{
+ wpi::math::PIDController shooterFeedback{constants::shooter::kP, 0, 0};
+ wpi::math::SimpleMotorFeedforward shooterFeedforward{
constants::shooter::kS, constants::shooter::kV, constants::shooter::kA};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/TankDriveGamepad/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/TankDriveGamepad/cpp/Robot.cpp
index a4a8e57d89e..ad87de56f40 100644
--- a/wpilibcExamples/src/main/cpp/examples/TankDriveGamepad/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/TankDriveGamepad/cpp/Robot.cpp
@@ -12,28 +12,28 @@
* Runs the motors with tank 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 tank style
- m_robotDrive.TankDrive(-m_driverController.GetLeftY(),
- -m_driverController.GetRightY());
+ robotDrive.TankDrive(-driverController.GetLeftY(),
+ -driverController.GetRightY());
}
};
diff --git a/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/Robot.cpp
index 3eec6fb6d2f..fe1c7e1466a 100644
--- a/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/Robot.cpp
@@ -9,18 +9,18 @@
*/
void Robot::TeleopPeriodic() {
// Activate the intake while the trigger is held
- if (m_joystick.GetTrigger()) {
- m_intake.Activate(IntakeConstants::kIntakeVelocity);
+ if (joystick.GetTrigger()) {
+ intake.Activate(IntakeConstants::kIntakeVelocity);
} else {
- m_intake.Activate(0);
+ intake.Activate(0);
}
// Toggle deploying the intake when the top button is pressed
- if (m_joystick.GetTop()) {
- if (m_intake.IsDeployed()) {
- m_intake.Retract();
+ if (joystick.GetTop()) {
+ if (intake.IsDeployed()) {
+ intake.Retract();
} else {
- m_intake.Deploy();
+ intake.Deploy();
}
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/subsystems/Intake.cpp b/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/subsystems/Intake.cpp
index 4b929ee93c3..28629e3b57b 100644
--- a/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/subsystems/Intake.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/UnitTest/cpp/subsystems/Intake.cpp
@@ -5,22 +5,22 @@
#include "subsystems/Intake.hpp"
void Intake::Deploy() {
- m_piston.Set(wpi::DoubleSolenoid::Value::FORWARD);
+ piston.Set(wpi::DoubleSolenoid::Value::FORWARD);
}
void Intake::Retract() {
- m_piston.Set(wpi::DoubleSolenoid::Value::REVERSE);
- m_motor.SetThrottle(0); // turn off the motor
+ piston.Set(wpi::DoubleSolenoid::Value::REVERSE);
+ motor.SetThrottle(0); // turn off the motor
}
void Intake::Activate(double velocity) {
if (IsDeployed()) {
- m_motor.SetThrottle(velocity);
+ motor.SetThrottle(velocity);
} else { // if piston isn't open, do nothing
- m_motor.SetThrottle(0);
+ motor.SetThrottle(0);
}
}
bool Intake::IsDeployed() const {
- return m_piston.Get() == wpi::DoubleSolenoid::Value::FORWARD;
+ return piston.Get() == wpi::DoubleSolenoid::Value::FORWARD;
}
diff --git a/wpilibcExamples/src/main/cpp/examples/UnitTest/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/UnitTest/include/Robot.hpp
index 00091b1deba..8faad9e842c 100644
--- a/wpilibcExamples/src/main/cpp/examples/UnitTest/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/UnitTest/include/Robot.hpp
@@ -14,6 +14,6 @@ class Robot : public wpi::TimedRobot {
void TeleopPeriodic() override;
private:
- Intake m_intake;
- wpi::Joystick m_joystick{OperatorConstants::kJoystickIndex};
+ Intake intake;
+ wpi::Joystick joystick{OperatorConstants::kJoystickIndex};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/UnitTest/include/subsystems/Intake.hpp b/wpilibcExamples/src/main/cpp/examples/UnitTest/include/subsystems/Intake.hpp
index 3d0c33b5f1d..00730443f24 100644
--- a/wpilibcExamples/src/main/cpp/examples/UnitTest/include/subsystems/Intake.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/UnitTest/include/subsystems/Intake.hpp
@@ -16,8 +16,8 @@ class Intake {
bool IsDeployed() const;
private:
- wpi::PWMSparkMax m_motor{IntakeConstants::kMotorPort};
- wpi::DoubleSolenoid m_piston{0, wpi::PneumaticsModuleType::CTRE_PCM,
- IntakeConstants::kPistonFwdChannel,
- IntakeConstants::kPistonRevChannel};
+ wpi::PWMSparkMax motor{IntakeConstants::kMotorPort};
+ wpi::DoubleSolenoid piston{0, wpi::PneumaticsModuleType::CTRE_PCM,
+ IntakeConstants::kPistonFwdChannel,
+ IntakeConstants::kPistonRevChannel};
};
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp
index 2ec33e67708..dd9c9161d43 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/Robot.cpp
@@ -34,10 +34,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);
}
}
@@ -48,9 +48,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;
}
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp
index bc68d859674..f7516fe8680 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/RobotContainer.cpp
@@ -16,28 +16,28 @@ RobotContainer::RobotContainer() {
void RobotContainer::ConfigureButtonBindings() {
// Also set default commands here
- m_drive.SetDefaultCommand(TeleopArcadeDrive(
- &m_drive, [this] { return -m_controller.GetRawAxis(1); },
- [this] { return -m_controller.GetRawAxis(2); }));
+ drive.SetDefaultCommand(TeleopArcadeDrive(
+ &drive, [this] { return -controller.GetRawAxis(1); },
+ [this] { return -controller.GetRawAxis(2); }));
// Example of how to use the onboard IO
- m_userButton.OnTrue(wpi::cmd::Print("USER Button Pressed"))
+ userButton.OnTrue(wpi::cmd::Print("USER Button Pressed"))
.OnFalse(wpi::cmd::Print("USER Button Released"));
- wpi::cmd::JoystickButton(&m_controller, 1)
- .OnTrue(wpi::cmd::RunOnce([this] { m_arm.SetAngle(45_deg); }, {}))
- .OnFalse(wpi::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {}));
+ wpi::cmd::JoystickButton(&controller, 1)
+ .OnTrue(wpi::cmd::RunOnce([this] { arm.SetAngle(45_deg); }, {}))
+ .OnFalse(wpi::cmd::RunOnce([this] { arm.SetAngle(0_deg); }, {}));
- wpi::cmd::JoystickButton(&m_controller, 2)
- .OnTrue(wpi::cmd::RunOnce([this] { m_arm.SetAngle(90_deg); }, {}))
- .OnFalse(wpi::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {}));
+ wpi::cmd::JoystickButton(&controller, 2)
+ .OnTrue(wpi::cmd::RunOnce([this] { arm.SetAngle(90_deg); }, {}))
+ .OnFalse(wpi::cmd::RunOnce([this] { arm.SetAngle(0_deg); }, {}));
// Setup SmartDashboard options.
- m_chooser.SetDefaultOption("Auto Routine Distance", &m_autoDistance);
- m_chooser.AddOption("Auto Routine Time", &m_autoTime);
- wpi::SmartDashboard::PutData("Auto Selector", &m_chooser);
+ chooser.SetDefaultOption("Auto Routine Distance", &autoDistance);
+ chooser.AddOption("Auto Routine Time", &autoTime);
+ wpi::SmartDashboard::PutData("Auto Selector", &chooser);
}
wpi::cmd::Command* RobotContainer::GetAutonomousCommand() {
- return m_chooser.GetSelected();
+ return chooser.GetSelected();
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveDistance.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveDistance.cpp
index a34b01b1afe..d3d186cff2d 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveDistance.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveDistance.cpp
@@ -7,18 +7,18 @@
#include "wpi/units/math.hpp"
void DriveDistance::Initialize() {
- m_drive->ArcadeDrive(0, 0);
- m_drive->ResetEncoders();
+ drive->ArcadeDrive(0, 0);
+ drive->ResetEncoders();
}
void DriveDistance::Execute() {
- m_drive->ArcadeDrive(m_velocity, 0);
+ drive->ArcadeDrive(velocity, 0);
}
void DriveDistance::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
+ drive->ArcadeDrive(0, 0);
}
bool DriveDistance::IsFinished() {
- return wpi::units::math::abs(m_drive->GetAverageDistance()) >= m_distance;
+ return wpi::units::math::abs(drive->GetAverageDistance()) >= distance;
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveTime.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveTime.cpp
index f1be542fdd1..68adcd297b0 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveTime.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/DriveTime.cpp
@@ -5,20 +5,20 @@
#include "commands/DriveTime.hpp"
void DriveTime::Initialize() {
- m_timer.Start();
- m_drive->ArcadeDrive(0, 0);
+ timer.Start();
+ drive->ArcadeDrive(0, 0);
}
void DriveTime::Execute() {
- m_drive->ArcadeDrive(m_velocity, 0);
+ drive->ArcadeDrive(velocity, 0);
}
void DriveTime::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
- m_timer.Stop();
- m_timer.Reset();
+ drive->ArcadeDrive(0, 0);
+ timer.Stop();
+ timer.Reset();
}
bool DriveTime::IsFinished() {
- return m_timer.HasElapsed(m_duration);
+ return timer.HasElapsed(duration);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TeleopArcadeDrive.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TeleopArcadeDrive.cpp
index 76d0d8bd4f0..f8006fd8f4c 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TeleopArcadeDrive.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TeleopArcadeDrive.cpp
@@ -9,12 +9,12 @@
TeleopArcadeDrive::TeleopArcadeDrive(
Drivetrain* subsystem, std::function xaxisVelocitySupplier,
std::function zaxisRotateSuppplier)
- : m_drive{subsystem},
- m_xaxisVelocitySupplier{xaxisVelocitySupplier},
- m_zaxisRotateSupplier{zaxisRotateSuppplier} {
+ : drive{subsystem},
+ xaxisVelocitySupplier{xaxisVelocitySupplier},
+ zaxisRotateSupplier{zaxisRotateSuppplier} {
AddRequirements(subsystem);
}
void TeleopArcadeDrive::Execute() {
- m_drive->ArcadeDrive(m_xaxisVelocitySupplier(), m_zaxisRotateSupplier());
+ drive->ArcadeDrive(xaxisVelocitySupplier(), zaxisRotateSupplier());
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnDegrees.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnDegrees.cpp
index 93ebe880d33..b2e09655f5a 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnDegrees.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnDegrees.cpp
@@ -10,16 +10,16 @@
void TurnDegrees::Initialize() {
// Set motors to stop, read encoder values for starting point
- m_drive->ArcadeDrive(0, 0);
- m_drive->ResetEncoders();
+ drive->ArcadeDrive(0, 0);
+ drive->ResetEncoders();
}
void TurnDegrees::Execute() {
- m_drive->ArcadeDrive(0, m_velocity);
+ drive->ArcadeDrive(0, velocity);
}
void TurnDegrees::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
+ drive->ArcadeDrive(0, 0);
}
bool TurnDegrees::IsFinished() {
@@ -30,11 +30,11 @@ bool TurnDegrees::IsFinished() {
static auto inchPerDegree = (6.102_in * std::numbers::pi) / 360_deg;
// Compare distance traveled from start to distance based on degree turn.
- return GetAverageTurningDistance() >= inchPerDegree * m_angle;
+ return GetAverageTurningDistance() >= inchPerDegree * angle;
}
wpi::units::meter_t TurnDegrees::GetAverageTurningDistance() {
- auto l = wpi::units::math::abs(m_drive->GetLeftDistance());
- auto r = wpi::units::math::abs(m_drive->GetRightDistance());
+ auto l = wpi::units::math::abs(drive->GetLeftDistance());
+ auto r = wpi::units::math::abs(drive->GetRightDistance());
return (l + r) / 2;
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnTime.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnTime.cpp
index fb040614755..88e8f63bf7f 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnTime.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/commands/TurnTime.cpp
@@ -5,20 +5,20 @@
#include "commands/TurnTime.hpp"
void TurnTime::Initialize() {
- m_timer.Start();
- m_drive->ArcadeDrive(0, 0);
+ timer.Start();
+ drive->ArcadeDrive(0, 0);
}
void TurnTime::Execute() {
- m_drive->ArcadeDrive(0, m_velocity);
+ drive->ArcadeDrive(0, velocity);
}
void TurnTime::End(bool interrupted) {
- m_drive->ArcadeDrive(0, 0);
- m_timer.Stop();
- m_timer.Reset();
+ drive->ArcadeDrive(0, 0);
+ timer.Stop();
+ timer.Reset();
}
bool TurnTime::IsFinished() {
- return m_timer.HasElapsed(m_duration);
+ return timer.HasElapsed(duration);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Arm.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Arm.cpp
index ad3c122a7e7..4dcd1d5d37b 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Arm.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Arm.cpp
@@ -9,5 +9,5 @@ void Arm::Periodic() {
}
void Arm::SetAngle(wpi::units::radian_t angle) {
- m_armServo.SetAngle(angle);
+ armServo.SetAngle(angle);
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Drivetrain.cpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Drivetrain.cpp
index 8904985febb..f57d0b02af8 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Drivetrain.cpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/cpp/subsystems/Drivetrain.cpp
@@ -15,18 +15,18 @@ using namespace DriveConstants;
// The XRP has onboard encoders that are hardcoded
// to use DIO pins 4/5 and 6/7 for the left and right
Drivetrain::Drivetrain() {
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_leftMotor);
- wpi::util::SendableRegistry::AddChild(&m_drive, &m_rightMotor);
+ wpi::util::SendableRegistry::AddChild(&drive, &leftMotor);
+ wpi::util::SendableRegistry::AddChild(&drive, &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);
- m_leftEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
- kCountsPerRevolution);
- m_rightEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
- kCountsPerRevolution);
+ leftEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
+ kCountsPerRevolution);
+ rightEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
+ kCountsPerRevolution);
ResetEncoders();
}
@@ -35,28 +35,28 @@ void Drivetrain::Periodic() {
}
void Drivetrain::ArcadeDrive(double xaxisVelocity, double zaxisRotate) {
- m_drive.ArcadeDrive(xaxisVelocity, zaxisRotate);
+ drive.ArcadeDrive(xaxisVelocity, zaxisRotate);
}
void Drivetrain::ResetEncoders() {
- m_leftEncoder.Reset();
- m_rightEncoder.Reset();
+ leftEncoder.Reset();
+ rightEncoder.Reset();
}
int Drivetrain::GetLeftEncoderCount() {
- return m_leftEncoder.Get();
+ return leftEncoder.Get();
}
int Drivetrain::GetRightEncoderCount() {
- return m_rightEncoder.Get();
+ return rightEncoder.Get();
}
wpi::units::meter_t Drivetrain::GetLeftDistance() {
- return wpi::units::meter_t{m_leftEncoder.GetDistance()};
+ return wpi::units::meter_t{leftEncoder.GetDistance()};
}
wpi::units::meter_t Drivetrain::GetRightDistance() {
- return wpi::units::meter_t{m_rightEncoder.GetDistance()};
+ return wpi::units::meter_t{rightEncoder.GetDistance()};
}
wpi::units::meter_t Drivetrain::GetAverageDistance() {
@@ -64,17 +64,17 @@ wpi::units::meter_t Drivetrain::GetAverageDistance() {
}
wpi::units::radian_t Drivetrain::GetGyroAngleX() {
- return m_gyro.GetAngleX();
+ return gyro.GetAngleX();
}
wpi::units::radian_t Drivetrain::GetGyroAngleY() {
- return m_gyro.GetAngleY();
+ return gyro.GetAngleY();
}
wpi::units::radian_t Drivetrain::GetGyroAngleZ() {
- return m_gyro.GetAngleZ();
+ return gyro.GetAngleZ();
}
void Drivetrain::ResetGyro() {
- m_gyro.Reset();
+ gyro.Reset();
}
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.hpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.hpp
index 2d2e802c163..afb6d52b149 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/Robot.hpp
@@ -23,6 +23,6 @@ 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.
- wpi::cmd::Command* m_autonomousCommand = nullptr;
- RobotContainer m_container;
+ wpi::cmd::Command* autonomousCommand = nullptr;
+ RobotContainer container;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/RobotContainer.hpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/RobotContainer.hpp
index a82f8a5d9e1..be8a94a5af5 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/RobotContainer.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/RobotContainer.hpp
@@ -42,21 +42,21 @@ class RobotContainer {
private:
// Assumes a gamepad plugged into channel 0
- wpi::Joystick m_controller{0};
- wpi::SendableChooser m_chooser;
+ wpi::Joystick controller{0};
+ wpi::SendableChooser chooser;
// The robot's subsystems
- Drivetrain m_drive;
- Arm m_arm;
- wpi::xrp::XRPOnBoardIO m_onboardIO;
+ Drivetrain drive;
+ Arm arm;
+ wpi::xrp::XRPOnBoardIO onboardIO;
// Example button
- wpi::cmd::Trigger m_userButton{
- [this] { return m_onboardIO.GetUserButtonPressed(); }};
+ wpi::cmd::Trigger userButton{
+ [this] { return onboardIO.GetUserButtonPressed(); }};
// Autonomous commands.
- AutonomousDistance m_autoDistance{&m_drive};
- AutonomousTime m_autoTime{&m_drive};
+ AutonomousDistance autoDistance{&drive};
+ AutonomousTime autoTime{&drive};
void ConfigureButtonBindings();
};
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveDistance.hpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveDistance.hpp
index e5ea1cc2c91..9b2a3f33790 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveDistance.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveDistance.hpp
@@ -22,8 +22,8 @@ class DriveDistance
*/
DriveDistance(double velocity, wpi::units::meter_t distance,
Drivetrain* drive)
- : m_velocity(velocity), m_distance(distance), m_drive(drive) {
- AddRequirements(m_drive);
+ : velocity(velocity), distance(distance), drive(drive) {
+ AddRequirements(drive);
}
void Initialize() override;
@@ -32,7 +32,7 @@ class DriveDistance
bool IsFinished() override;
private:
- double m_velocity;
- wpi::units::meter_t m_distance;
- Drivetrain* m_drive;
+ double velocity;
+ wpi::units::meter_t distance;
+ Drivetrain* drive;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveTime.hpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveTime.hpp
index f0b05af0d48..fc3a458268d 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveTime.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/DriveTime.hpp
@@ -22,8 +22,8 @@ class DriveTime : public wpi::cmd::CommandHelper {
* @param drive The drivetrain subsystem on which this command will run
*/
DriveTime(double velocity, wpi::units::second_t time, Drivetrain* drive)
- : m_velocity(velocity), m_duration(time), m_drive(drive) {
- AddRequirements(m_drive);
+ : velocity(velocity), duration(time), drive(drive) {
+ AddRequirements(drive);
}
void Initialize() override;
@@ -32,8 +32,8 @@ class DriveTime : public wpi::cmd::CommandHelper {
bool IsFinished() override;
private:
- double m_velocity;
- wpi::units::second_t m_duration;
- Drivetrain* m_drive;
- wpi::Timer m_timer;
+ double velocity;
+ wpi::units::second_t duration;
+ Drivetrain* drive;
+ wpi::Timer timer;
};
diff --git a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/TeleopArcadeDrive.hpp b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/TeleopArcadeDrive.hpp
index b5ab55d0a00..b46029f595a 100644
--- a/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/TeleopArcadeDrive.hpp
+++ b/wpilibcExamples/src/main/cpp/examples/XRPReference/include/commands/TeleopArcadeDrive.hpp
@@ -27,7 +27,7 @@ class TeleopArcadeDrive
void Execute() override;
private:
- Drivetrain* m_drive;
- std::function m_xaxisVelocitySupplier;
- std::function