Merge branch 'main' into 2027

This commit is contained in:
Peter Johnson
2025-11-01 09:39:08 -07:00
61 changed files with 455 additions and 941 deletions

View File

@@ -1,30 +1,4 @@
[
{
"name": "DMC60",
"Manufacturer": "Digilent",
"DisplayName": "DMC 60",
"ResourceName": "DigilentDMC60",
"pulse_width_ms": {
"max": 2.004,
"deadbandMax": 1.520,
"center": 1.500,
"deadbandMin": 1.480,
"min": 0.997
}
},
{
"name": "Jaguar",
"Manufacturer": "Luminary Micro / Vex Robotics",
"DisplayName": "Jaguar",
"ResourceName": "Jaguar",
"pulse_width_ms": {
"max": 2.310,
"deadbandMax": 1.550,
"center": 1.507,
"deadbandMin": 1.454,
"min": 0.697
}
},
{
"name": "PWMSparkFlex",
"Manufacturer": "REV Robotics",
@@ -103,19 +77,6 @@
"min": 0.997
}
},
{
"name": "SD540",
"Manufacturer": "Mindsensors",
"DisplayName": "SD540",
"ResourceName": "MindsensorsSD540",
"pulse_width_ms": {
"max": 2.05,
"deadbandMax": 1.55,
"center": 1.50,
"deadbandMin": 1.44,
"min": 0.94
}
},
{
"name": "Spark",
"Manufacturer": "REV Robotics",
@@ -142,20 +103,6 @@
"min": 0.989
}
},
{
"name": "Victor",
"Manufacturer": "Vex Robotics",
"DisplayName": "Victor 888",
"ResourceName": "Victor",
"OutputPeriod": 10,
"pulse_width_ms": {
"max": 2.027,
"deadbandMax": 1.525,
"center": 1.507,
"deadbandMin": 1.490,
"min": 1.026
}
},
{
"name": "VictorSP",
"Manufacturer": "Vex Robotics",

View File

@@ -1,46 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_pwm_motor_controllers.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.motorcontrol;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.PWM;
/**
* Digilent DMC 60 Motor Controller.
*
* <p>Note that the DMC 60 uses the following bounds for PWM values. These values should work
* reasonably well for most controllers, but if users experience issues such as asymmetric behavior
* around the deadband or inability to saturate the controller in either direction, calibration is
* recommended. The calibration procedure can be found in the DMC 60 User Manual available from
* Digilent.
*
* <ul>
* <li>2.004ms = full "forward"
* <li>1.520ms = the "high end" of the deadband range
* <li>1.500ms = center of the deadband range (off)
* <li>1.480ms = the "low end" of the deadband range
* <li>0.997ms = full "reverse"
* </ul>
*/
public class DMC60 extends PWMMotorController {
/**
* Constructor.
*
* @param channel The PWM channel that the DMC 60 is attached to. 0-9 are on-board, 10-19
* are on the MXP port
*/
@SuppressWarnings("this-escape")
public DMC60(final int channel) {
super("DMC60", channel);
setBoundsMicroseconds(2004, 1520, 1500, 1480, 997);
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
setSpeed(0.0);
HAL.reportUsage("IO", getChannel(), "DigilentDMC60");
}
}

View File

@@ -1,46 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_pwm_motor_controllers.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.motorcontrol;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.PWM;
/**
* Luminary Micro / Vex Robotics Jaguar Motor Controller.
*
* <p>Note that the Jaguar uses the following bounds for PWM values. These values should work
* reasonably well for most controllers, but if users experience issues such as asymmetric behavior
* around the deadband or inability to saturate the controller in either direction, calibration is
* recommended. The calibration procedure can be found in the Jaguar User Manual available from
* Luminary Micro / Vex Robotics.
*
* <ul>
* <li>2.310ms = full "forward"
* <li>1.550ms = the "high end" of the deadband range
* <li>1.507ms = center of the deadband range (off)
* <li>1.454ms = the "low end" of the deadband range
* <li>0.697ms = full "reverse"
* </ul>
*/
public class Jaguar extends PWMMotorController {
/**
* Constructor.
*
* @param channel The PWM channel that the Jaguar is attached to. 0-9 are on-board, 10-19
* are on the MXP port
*/
@SuppressWarnings("this-escape")
public Jaguar(final int channel) {
super("Jaguar", channel);
setBoundsMicroseconds(2310, 1550, 1507, 1454, 697);
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
setSpeed(0.0);
HAL.reportUsage("IO", getChannel(), "Jaguar");
}
}

View File

@@ -1,46 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_pwm_motor_controllers.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.motorcontrol;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.PWM;
/**
* Mindsensors SD540 Motor Controller.
*
* <p>Note that the SD540 uses the following bounds for PWM values. These values should work
* reasonably well for most controllers, but if users experience issues such as asymmetric behavior
* around the deadband or inability to saturate the controller in either direction, calibration is
* recommended. The calibration procedure can be found in the SD540 User Manual available from
* Mindsensors.
*
* <ul>
* <li>2.050ms = full "forward"
* <li>1.550ms = the "high end" of the deadband range
* <li>1.500ms = center of the deadband range (off)
* <li>1.440ms = the "low end" of the deadband range
* <li>0.940ms = full "reverse"
* </ul>
*/
public class SD540 extends PWMMotorController {
/**
* Constructor.
*
* @param channel The PWM channel that the SD540 is attached to. 0-9 are on-board, 10-19
* are on the MXP port
*/
@SuppressWarnings("this-escape")
public SD540(final int channel) {
super("SD540", channel);
setBoundsMicroseconds(2050, 1550, 1500, 1440, 940);
m_pwm.setOutputPeriod(PWM.OutputPeriod.k5Ms);
setSpeed(0.0);
HAL.reportUsage("IO", getChannel(), "MindsensorsSD540");
}
}

View File

@@ -1,46 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
// THIS FILE WAS AUTO-GENERATED BY ./wpilibj/generate_pwm_motor_controllers.py. DO NOT MODIFY
package edu.wpi.first.wpilibj.motorcontrol;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.PWM;
/**
* Vex Robotics Victor 888 Motor Controller.
*
* <p>Note that the Victor 888 uses the following bounds for PWM values. These values should work
* reasonably well for most controllers, but if users experience issues such as asymmetric behavior
* around the deadband or inability to saturate the controller in either direction, calibration is
* recommended. The calibration procedure can be found in the Victor 888 User Manual available from
* Vex Robotics.
*
* <ul>
* <li>2.027ms = full "forward"
* <li>1.525ms = the "high end" of the deadband range
* <li>1.507ms = center of the deadband range (off)
* <li>1.490ms = the "low end" of the deadband range
* <li>1.026ms = full "reverse"
* </ul>
*/
public class Victor extends PWMMotorController {
/**
* Constructor.
*
* @param channel The PWM channel that the Victor 888 is attached to. 0-9 are on-board, 10-19
* are on the MXP port
*/
@SuppressWarnings("this-escape")
public Victor(final int channel) {
super("Victor", channel);
setBoundsMicroseconds(2027, 1525, 1507, 1490, 1026);
m_pwm.setOutputPeriod(PWM.OutputPeriod.k10Ms);
setSpeed(0.0);
HAL.reportUsage("IO", getChannel(), "Victor");
}
}

View File

@@ -4,9 +4,12 @@
package edu.wpi.first.wpilibj;
import static edu.wpi.first.units.Units.Seconds;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.hal.NotifierJNI;
import edu.wpi.first.units.measure.Frequency;
import edu.wpi.first.units.measure.Time;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
@@ -186,6 +189,15 @@ public class Notifier implements AutoCloseable {
}
}
/**
* Run the callback once after the given delay.
*
* @param delay Time to wait before the callback is called.
*/
public void startSingle(Time delay) {
startSingle(delay.in(Seconds));
}
/**
* Run the callback periodically with the given period.
*
@@ -207,6 +219,32 @@ public class Notifier implements AutoCloseable {
}
}
/**
* Run the callback periodically with the given period.
*
* <p>The user-provided callback should be written so that it completes before the next time it's
* scheduled to run.
*
* @param period Period after which to call the callback starting one period after the call to
* this method.
*/
public void startPeriodic(Time period) {
startPeriodic(period.in(Seconds));
}
/**
* Run the callback periodically with the given frequency.
*
* <p>The user-provided callback should be written so that it completes before the next time it's
* scheduled to run.
*
* @param frequency Frequency at which to call the callback, starting one period after the call to
* this method.
*/
public void startPeriodic(Frequency frequency) {
startPeriodic(frequency.asPeriod());
}
/**
* Stop further callback invocations.
*

View File

@@ -9,6 +9,7 @@ import static edu.wpi.first.units.Units.Seconds;
import edu.wpi.first.hal.DriverStationJNI;
import edu.wpi.first.hal.HAL;
import edu.wpi.first.hal.NotifierJNI;
import edu.wpi.first.units.measure.Frequency;
import edu.wpi.first.units.measure.Time;
import java.util.PriorityQueue;
@@ -82,7 +83,7 @@ public class TimedRobot extends IterativeRobotBase {
/**
* Constructor for TimedRobot.
*
* @param period Period in seconds.
* @param period The period of the robot loop function.
*/
protected TimedRobot(double period) {
super(period);
@@ -93,6 +94,24 @@ public class TimedRobot extends IterativeRobotBase {
HAL.reportUsage("Framework", "TimedRobot");
}
/**
* Constructor for TimedRobot.
*
* @param period The period of the robot loop function.
*/
protected TimedRobot(Time period) {
this(period.in(Seconds));
}
/**
* Constructor for TimedRobot.
*
* @param frequency The frequency of the robot loop function.
*/
protected TimedRobot(Frequency frequency) {
this(frequency.asPeriod());
}
@Override
public void close() {
NotifierJNI.stopNotifier(m_notifier);

View File

@@ -4,6 +4,10 @@
package edu.wpi.first.wpilibj;
import static edu.wpi.first.units.Units.Seconds;
import edu.wpi.first.units.measure.Time;
/**
* A timer class.
*
@@ -46,10 +50,20 @@ public class Timer {
}
/**
* Pause the thread for a specified time. Pause the execution of the thread for a specified period
* of time given in seconds. Motors will continue to run at their last assigned values, and
* sensors will continue to update. Only the task containing the wait will pause until the wait
* time is expired.
* Pause the execution of the thread for a specified period of time. Motors will continue to run
* at their last assigned values, and sensors will continue to update. Only the task containing
* the wait will pause until the wait time is expired.
*
* @param period Length of time to pause
*/
public static void delay(final Time period) {
delay(period.in(Seconds));
}
/**
* Pause the execution of the thread for a specified period of time given in seconds. Motors will
* continue to run at their last assigned values, and sensors will continue to update. Only the
* task containing the wait will pause until the wait time is expired.
*
* @param seconds Length of time to pause
*/
@@ -137,7 +151,17 @@ public class Timer {
/**
* Check if the period specified has passed.
*
* @param seconds The period to check.
* @param period The period to check.
* @return Whether the period has passed.
*/
public boolean hasElapsed(Time period) {
return hasElapsed(period.in(Seconds));
}
/**
* Check if the period specified has passed.
*
* @param seconds The period to check in seconds.
* @return Whether the period has passed.
*/
public boolean hasElapsed(double seconds) {

View File

@@ -4,7 +4,10 @@
package edu.wpi.first.wpilibj;
import static edu.wpi.first.units.Units.Seconds;
import edu.wpi.first.hal.NotifierJNI;
import edu.wpi.first.units.measure.Time;
import java.io.Closeable;
import java.util.PriorityQueue;
import java.util.concurrent.locks.ReentrantLock;
@@ -55,6 +58,16 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
m_tracer = new Tracer();
}
/**
* Watchdog constructor.
*
* @param timeout The watchdog's timeout with microsecond resolution.
* @param callback This function is called when the timeout expires.
*/
public Watchdog(Time timeout, Runnable callback) {
this(timeout.in(Seconds), callback);
}
@Override
public void close() {
disable();

View File

@@ -4,9 +4,11 @@
package edu.wpi.first.wpilibj.event;
import static edu.wpi.first.units.Units.Seconds;
import static edu.wpi.first.util.ErrorMessages.requireNonNullParam;
import edu.wpi.first.math.filter.Debouncer;
import edu.wpi.first.units.measure.Time;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiFunction;
import java.util.function.BooleanSupplier;
@@ -167,7 +169,18 @@ public class BooleanEvent implements BooleanSupplier {
* Creates a new debounced event from this event - it will become active when this event has been
* active for longer than the specified period.
*
* @param seconds The debounce period.
* @param period The debounce period.
* @return The debounced event (rising edges debounced only).
*/
public BooleanEvent debounce(Time period) {
return debounce(period.in(Seconds));
}
/**
* Creates a new debounced event from this event - it will become active when this event has been
* active for longer than the specified period.
*
* @param seconds The debounce period in seconds.
* @return The debounced event (rising edges debounced only).
*/
public BooleanEvent debounce(double seconds) {
@@ -178,7 +191,19 @@ public class BooleanEvent implements BooleanSupplier {
* Creates a new debounced event from this event - it will become active when this event has been
* active for longer than the specified period.
*
* @param seconds The debounce period.
* @param period The debounce period.
* @param type The debounce type.
* @return The debounced event.
*/
public BooleanEvent debounce(Time period, Debouncer.DebounceType type) {
return debounce(period.in(Seconds), type);
}
/**
* Creates a new debounced event from this event - it will become active when this event has been
* active for longer than the specified period.
*
* @param seconds The debounce period in seconds.
* @param type The debounce type.
* @return The debounced event.
*/

View File

@@ -4,11 +4,14 @@
package edu.wpi.first.wpilibj.smartdashboard;
import static edu.wpi.first.units.Units.Meters;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.networktables.NTSendable;
import edu.wpi.first.networktables.NTSendableBuilder;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.units.measure.Distance;
import edu.wpi.first.util.sendable.SendableRegistry;
import java.util.ArrayList;
import java.util.List;
@@ -66,6 +69,17 @@ public class Field2d implements NTSendable, AutoCloseable {
m_objects.get(0).setPose(x, y, rotation);
}
/**
* Set the robot pose from x, y, and rotation.
*
* @param x X location
* @param y Y location
* @param rotation rotation
*/
public synchronized void setRobotPose(Distance x, Distance y, Rotation2d rotation) {
m_objects.get(0).setPose(x.in(Meters), y.in(Meters), rotation);
}
/**
* Get the robot pose.
*

View File

@@ -4,11 +4,14 @@
package edu.wpi.first.wpilibj.smartdashboard;
import static edu.wpi.first.units.Units.Meters;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.trajectory.Trajectory;
import edu.wpi.first.networktables.DoubleArrayEntry;
import edu.wpi.first.units.measure.Distance;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -51,6 +54,17 @@ public class FieldObject2d implements AutoCloseable {
setPose(new Pose2d(x, y, rotation));
}
/**
* Set the pose from x, y, and rotation.
*
* @param x X location
* @param y Y location
* @param rotation rotation
*/
public synchronized void setPose(Distance x, Distance y, Rotation2d rotation) {
setPose(new Pose2d(x.in(Meters), y.in(Meters), rotation));
}
/**
* Get the pose.
*