Commit Graph

8259 Commits

Author SHA1 Message Date
Gold856
3f966aa7c6 Clean up unused includes (#8950) 2026-06-09 22:16:26 -07:00
Thad House
72d85be0c2 [ntcore] Add API to get and set user data on NT_Topic (#8962)
Theres many uses where we need to attach data to a topic, and doing it
this way can make it really easy and efficient.
2026-06-08 19:24:15 -07:00
PJ Reiniger
111130d8bb [copybara] Sync with robotpy (#8964)
GitOrigin-RevId: 9dff8f977401e78be0bb6f39cea2328320ab2d95
2026-06-08 19:22:48 -07:00
Thad House
0213ecf382 [build] Update native utils, to switch to new compilers (#8966) 2026-06-08 19:21:33 -07:00
Zach Harel
bdd45c7365 [cmd2] Move .cpp files to subproject source root (#8967)
This matches all of the other subprojects.

Signed-off-by: Zach Harel <zach@zharel.me>
2026-06-08 19:20:48 -07:00
David Vo
44501bf5eb [bazel] Update rules_cc with patches (#8969)
@AustinSchuh's `rules_cc` patches have all been merged upstream. This
updates `rules_cc` to include the relevant patches, removing the need to
patch it here.

This also squashes this warning on every build:

> WARNING: For repository 'rules_cc', the root module requires module
version rules_cc@0.2.13, but got rules_cc@0.2.14 in the resolved
dependency graph. Please update the version in your MODULE.bazel or set
--check_direct_dependencies=off
2026-06-08 19:20:03 -07:00
Thad House
1be5da5bde [wpiutil] Fix Handle.hpp not including cstddef (#8965) 2026-06-07 16:08:11 -07:00
Thad House
06fb36ba8e [hal] Switch IMU to mrclib (#8961) 2026-06-06 16:30:08 -07:00
Thad House
71ed28f768 [hal] Switch SmartIO to mrclib (#8960) 2026-06-06 14:54:49 -07:00
Peter Johnson
edf77fa007 [hal,sim] Add notifier generation counter to WaitForProgramStart (#8947)
This fixes simulation WaitForProgramStart(true) potentially advancing
due to a stale or pre-start notifier created before SetProgramStarted()
was called.
2026-06-06 12:17:14 -07:00
Thad House
6e5171cd8f [hal] Use MrcLib to talk to DS (#8858)
Using MrcLib on the robot is going to be the plan for the future, to
make things easier.

MrcLib is how sim is supported going forward. The desktop version of
mrclib can act as a robot server.

This is set up where the mrclib interface is in shared code. On robot,
that is the only backend used. On desktop, a default sim backend is
used. However, the sim plugin can switch that to the real robot backend,
so the robot code will exactly look like a real robot.
2026-06-06 12:15:17 -07:00
Peter Johnson
ddf9306264 [ntcore] Fix a couple of bugs in NetworkOutgoingQueue (#8953)
Fix SetPeriod() valuePos handling when an ID moves between period queues

In SendValue(), don't append older values, and fix the total size
accounting for the underflow case when a smaller value replaces a larger
value.

Add comprehensive unit tests.
2026-06-05 20:35:11 -07:00
Peter Johnson
88d8369751 [upstream_utils] Update catch2 to 3.15.0 (#8955) 2026-06-05 20:34:20 -07:00
Peter Johnson
96fb033deb [build] Remove cmake Java support (#8952)
This is increasingly difficult to maintain, and has very limited
benefit. Modern coprocessors with enough horsepower to run Java
applications can use the Gradle or Bazel build systems instead.
2026-06-05 15:05:09 -07:00
Vasista Vovveti
d941be905e [ntcore] NetworkClient: Add IsLoopClosing() guard in deferred disconnect timer (#8936)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-05 15:01:44 -07:00
Peter Johnson
e085c3e8b3 [examples,cscore] Don't use assertTimeoutPreemptively in tests (#8951)
Particularly with short timeouts, this results in spurious failures
under high CPU load.
2026-06-05 07:28:51 -07:00
Sam Carlberg
98c03baf54 [javac] Add compiler check for integer division in floating-point contexts (#8885)
Useful for catching bad behavior when doing math or configuring ratios
with integers. Errors can be turned off with
`@SuppressWarnings("IntegerDivision")`

```java
double kV = 12 / 6000; // error: integer division in a floating-point context
double kV = 12. / 6000; // OK
double kV = 12 / 6000.; // OK

int kV = 12 / 6000; // OK, but evaluates to 0

double ratio = 42 / 12; // error: integer division in a floating-point context

@SuppressWarnings("IntegerDivision")
double ratio = 42 / 12; // OK, evaluates to 2
```

```
Execution failed for task ':developerRobot:compileJava'.
> Compilation failed; see the compiler output below.
  /Users/sam/code/wpilib/allwpilib/developerRobot/src/main/java/wpilib/robot/Robot.java:10: error: integer division in a floating-point context
    double kV = 12 / 6000;
                   ^
  1 error
```

Also adds the compiler plugin as a dependency to the developerRobot
project for dev testing
2026-06-04 21:56:22 -07:00
sciencewhiz
8353b95507 Add avahi license to ThirdPartyNotices (#8883) 2026-06-04 21:54:00 -07:00
Benjamin Hall
a41679854b [wpimath] Fix C++ Odometry ResetRotation missing a negation (#8949)
The original implementation was `m_gyroOffset + (rotation -
m_pose.Rotation())`, which means the first `RotateBy` should be using
`-m_pose.Rotation()` (see `ResetPose()`). Java is already correct. This
also adds new tests to catch this particular error.
2026-06-04 17:03:22 -07:00
PJ Reiniger
fdc6fd9cb1 [build][bazel] Combine remote setup CI actions (#8893)
When the bazel remote cache was switched from buildbuddy to a self
hosted server in #8342, I asked that the buildbuddy hooks be remain so
that I could still use their caching service for local builds.

The downside of this was that my forks builds aren't leveraging
buildbuddy, so if I'm fiddling with something heavy like a wpimath
robotpy thing, my CI builds never update a cache and never are warm when
I push fixups.


This PR combines the `setup-bazel-remote` and `setup-build-buddy`
actions which set up the bazel remote cache. Rather than having two
different version, the correct one will be choosen in the following
order:
1. Use wpi's server with write access if the `bazel_remote` information
is set (This basically would only happen on main branch in
`wpilibsuite/allwpilib` since secrets aren't accessible from builds
originating in forks)
2. Use buildbuddy if the key it is present (This would work for my fork
builds)
3. Fall back to the readonly version of wpi's server


As seen
[here](https://github.com/bzlmodRio/allwpilib/actions/runs/25777428163/job/75712863120#step:7:28)
the build in my fork will run with buildbuddy, and my PR's build here
should fall back to readonly mode.
2026-06-03 20:16:42 -07:00
PJ Reiniger
dca59147e1 [robotpy][examples] Split examples and snippets (#8944)
This also updates the bazel scripts to behave more like the C++ and Java
examples, and updates the copybara scripts to be able to sync up
`mostrobotpy`
2026-06-03 19:43:16 -07:00
Benjamin Hall
a734275cc5 [wpimath] Add const qualifier to C++ SwerveModuleVelocity Optimize and CosineScale (#8946)
These two functions were changed to return new objects instead of
modifying in-place, so the `const` qualifier should be added. Otherwise,
users with a const reference to a `SwerveModuleVelocity` need to make a
temporary copy first.
2026-06-03 19:42:05 -07:00
Peter Johnson
3f0d7bc2c4 [wpiutil,hal] Move C++ Handle wrapper to wpiutil (#8935)
Also move WPI_Handle typedef to its own header (util/Handle.h).
2026-06-01 14:57:25 -06:00
Vasista Vovveti
3d982f81dd [ntcore] Update period on added or removed, not XOR (#8941)
`added ^ removed` (XOR) is incorrect for the update guard.
Both `added` and `removed` can be true simultaneously (e.g. subscription
options change), and XOR would incorrectly skip the period update. Fixed
to `added || removed`.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 14:56:23 -06:00
sciencewhiz
a3c18d24a7 [examples] Add mecanum drive snippets (#8931)
shows both polar, and cartesian
2026-05-29 23:10:42 -07:00
Peter Johnson
c597116f02 [hal] HALSIM_StepTiming: Avoid underflow (#8933)
Don't advance time if the only active timer is in the past; just wake up
any notifiers.
2026-05-29 23:10:02 -07:00
Peter Johnson
9adffd356d [hal] Update waitForProgramStart to optionally wait for first notifier (#8932)
This addresses a race condition caused by TimedRobot and other
frameworks not creating their first notifier alarm until after signaling
program start.

Default this to true because it's the most common desired use case when
combined with TimedRobot.
2026-05-29 23:09:25 -07:00
Thad House
635e971a02 [wpilib] Add a default deadband to all gamepads (#8897)
The FTC DS had a deadband. Additionally, the FRC one had an implicit
deadband due to the only 8 bit resolution. We need a deadband by default
now with the high resolution gamepads.
2026-05-29 16:31:48 -07:00
sciencewhiz
40fdb779d8 [examples] Add differential drive snippets (#8927)
Shows tank, arcade, and curvature for wpilib-docs
2026-05-29 15:00:12 -07:00
Tyler Veness
e728ee27f2 [upstream_utils] Upgrade to Sleipnir 0.6.1 (#8930)
This fixes a memory leak on Windows.
2026-05-29 14:59:39 -07:00
Guinea Wheek
50fd29e697 [ntcore] Fix unbounded memory size tracker (#8929)
If a `ClientMessageQueue` is at a
memory limit, `ClientMessageQueueImpl::ClientSetValue` will still
increment `m_valueSize.size` even though no element has actually been
actually been added.

This quickly results in things like topics completely shutting down
under high load, as no new elements can be added as `m_valueSize.size`
explodes to infinity unless `ClearQueue()` is explicitly called. You can
see this pretty easily with the following code, be it in sim or on a
robot:

```cpp
#include "wpi/framework/TimedRobot.hpp"
#include "wpi/smartdashboard/SmartDashboard.hpp"
class Robot : public wpi::TimedRobot {
  public:
  // ...
  uint64_t value{0};
  /**
   * This function is called periodically during all modes
   */
  void RobotPeriodic() override {
    for (int i = 0; i < 1'000'000; i++) {
      value += 1;
      wpi::SmartDashboard::PutNumber("value", value);
    }
  }
}
```

Connecting via your favorite dashboard quickly reveals that no new
values get added after a while. However, with this patch implemented,
values do still continue to increment as updates gradually get serviced.
2026-05-29 11:01:13 -07:00
Sam Carlberg
4fa5dacfc4 [epilogue] Improve support for robot base classes in epilogue (#8886)
Generate an `update` method for any logged Robot class, not just
TimedRobot

Continue to generate a `bind` method for TimedRobot subclasses

Also removes unnecessary import statements for generated loggers, since
they're using fully-qualified names in the generated Epilogue class now.
2026-05-29 00:14:30 -04:00
sciencewhiz
1e12408a7d [examples] add motor safety and invert to motor snip (#8924) 2026-05-28 20:09:07 -07:00
sciencewhiz
14db070c2c [build] Add guard for missing arm64 msvc runtime (#8922) 2026-05-28 20:08:46 -07:00
sciencewhiz
5c3a474a58 Replace references of frc-docs with wpilib-docs (NFC) (#8926) 2026-05-28 09:01:11 -06:00
Tyler Veness
f1d95ee5f8 [upstream_utils] Upgrade to Sleipnir 0.6.0 (#8923) 2026-05-27 21:26:42 -07:00
Jonah Snider
7ff32d7756 [epilogue,ntcore,wpiunits] Use pattern matching switch expressions where possible (#8925)
Use [pattern matching switch
expressions](https://docs.oracle.com/en/java/javase/17/language/pattern-matching-switch.html)
where possible. This is a JVM 21+ feature which wasn't available until
recently.

If you look at the Java bytecode, this improves performance from an O(n)
runtime check of literally each of the `if (x instanceof y)` checks to
instead be an O(1) tableswitch.

---------

Signed-off-by: Jonah Snider <jonah@jonahsnider.com>
2026-05-27 18:06:15 -07:00
Tyler Veness
aedee56e22 [upstream_utils] Add cbegin()/cend()/crbegin()/crend() to SmallVector (#8918)
std::vector has these.
2026-05-26 21:55:50 -07:00
Peter Johnson
ac7a9524f8 [wpigui] Add stdint.h include to PFD (#8920)
Needed for uint8_t.
2026-05-26 21:55:22 -07:00
Thad House
b100586cab [wpilib] Finish gamepad face button rename (#8921) 2026-05-26 21:55:07 -07:00
Tyler Veness
254ca64106 [upstream_utils] Upgrade to LLVM 22.1.6 (#8919) 2026-05-26 16:25:29 -07:00
Peter Johnson
1392db4529 [romi] Fix Romi motor support (#8915)
Since Servo has been removed from WPILib, add a RomiServo to replace it
(similar to XRPServo).

For Romi, move allocation of PWM channels to OnBoardIO since Motor and
Servo share channels.
2026-05-23 17:38:36 -07:00
Peter Johnson
40f9a87e70 [xrp] Fix motor support (#8916)
The protocol layer got out of sync with the rename to throttle.
2026-05-23 17:37:38 -07:00
Sam Carlberg
94fda36e04 [cmd3] Add trigger multi press and continuous bindings (#8901)
`Trigger.multiPress(N, T)` creates a trigger that fires when there are
at least N rising edges within the last T timespan, eg `multiPress(3,
Seconds.of(1.25))` for 3 rising edges within the last 1.25 seconds.

`Trigger.retryWhileTrue` and `retryWhileFalse` will continuously attempt
to schedule a command while the binding condition is met. This is
similar to `whileTrue` and `whileFalse`, but will reschedule the command
if it ends or is canceled while the binding condition is still met,
rather than requiring a new rising edge to reschedule it.
2026-05-23 16:51:45 -07:00
Sam Carlberg
f217dfe747 [cmd3] Make sideload functions scoped and improve docs (#8900)
Notably, this removes the ability to escape command scoping by using a
sideloaded function to schedule another command
2026-05-23 16:50:46 -07:00
crueter
d86378d353 [wpimath,wpiunits] Add PoundSquareInches MOI unit, and improve KilogramMetersSquaredPerSecond definition (#8838)
As discussed in the discord. lb-in^2 is the common imperial MOI unit,
e.g. Onshape uses it.

Also, improved the Java docstring for `KilogramMetersSquaredPerSecond`
to explain what it represents.

---------

Co-authored-by: Benjamin Hall <bhall@ctr-electronics.com>
2026-05-23 16:41:35 -07:00
Gold856
ac41523eb4 [ci] Run wpilibc through asan (#8868) 2026-05-23 16:40:32 -07:00
David Vo
d48f1cd0e5 [bazel] Add mrclib dependency (#8873)
This pulls in the `mrclib` maven repository as shared libraries, as a
prereq for #8858.

Alternative to #8869, which avoids the unnecessary lockfile entry. This
should be a one-to-one replacement for that PR.

Closes #8869

---------

Co-authored-by: PJ Reiniger <pj.reiniger@gmail.com>
2026-05-23 16:39:47 -07:00
Gold856
e88729c67e [ci] Start avahi-daemon in sentinel builds (#8914)
This fixes the mDNS test failures in the sentinel builds.
2026-05-23 15:39:22 -07:00
Daniel Chen
e35ca772fd [cmd3] Make Mechanism an interface (#8303)
Since there is no longer a requirement for Subsystems/Mechanisms to be
registered to the command scheduler via a register() call, Mechanism can
be changed to an interface instead to allow for more flexible
inheritance structures.

Specifically, this would allow compatibility with CTRE swerve (which
previously required implementing Subsystem so that it could extend
CTRE's base class).
2026-05-18 19:30:12 -05:00