Commit Graph

730 Commits

Author SHA1 Message Date
Jade
043c155087 Fix a few clangd warnings (#7335) 2024-11-05 09:47:54 -07:00
Peter Johnson
caae5357b7 [wpilibc] Mechanism2d: Store roots by value 2024-10-31 22:04:13 -07:00
Peter Johnson
22e91bfacd [wpilibc] ShuffleboardInstance: Store ShuffleboardTab by value 2024-10-31 22:04:13 -07:00
Peter Johnson
f620141e0d [wpiutil] Replace LLVM StringMap impl with std::map
As string_view operations on std::map<std::string> won't be integrated
until C++26, placeholder implementations are used which are less efficient
in a couple of situations (e.g. insert with hint).
2024-10-31 22:04:13 -07:00
Gold856
40af8db28a [wpilibc] DataLogManager: Rename console log entry to "console" (#7240)
This matches Java.
2024-10-21 06:34:29 -06:00
Étienne Beaulac
796dbd3b86 [wpilib] Add Timer.isRunning() method (#7220) 2024-10-17 17:03:40 -07:00
Ryan Blue
2b1c5aa4fc [wpilibc] Check for invalid handle in destructors (#7212)
Moved-from objects have invalid handles.
2024-10-15 19:56:13 -07:00
Nicholas Armstrong
5d9a553104 [wpilib] DCMotorSim cleanup/enhancement (#7021)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-10-10 22:09:22 -07:00
Sam Carlberg
2085ab3d47 [wpilib] Allow LED pattern gradients to be discontinuous (#7174) 2024-10-10 22:05:33 -07:00
Jade
466a4a52fa [wpilibc] Fix missing symbols on Windows (#7140)
Windows doesn't support direct static variable access across library boundaries in a mixed static/shared environment, so change to accessor functions.
2024-10-01 08:46:06 -06:00
Gold856
ba1b97cd78 [wpilib] ADIS IMUs: Add back null checks (#7117)
* Revert "Move creation of objects to ctor"

This reverts commit b1d8001652.

* [wpilib] ADIS IMUs: Add back null checks
2024-09-22 18:05:09 -07:00
Tyler Veness
554024767e Fix errors from new cpplint.py (#7105) 2024-09-20 17:43:39 -07:00
Gold856
3bbbf86632 [wpiutil, wpilib] Add FileLogger and log console output (#6977) 2024-09-12 22:13:06 -07:00
Jade
cd9922af49 [wpilib] Add getVoltage to PWMMotorController (#6044) 2024-09-07 22:24:51 -07:00
Ryan Blue
496e7c1bba [hal] Refactor C++ handle closing; check for invalid handle before closing (#7016)
Adds a close function pointer template parameter to hal::Handle.  This allows default destructors in many places.
The status parameter has been removed from close functions; in most places it was not used. Where it was, an error is printed instead.
2024-09-07 10:58:15 -07:00
Ryan Blue
dc18f71004 [wpilibc] Refactor AnalogTrigger to use shared_ptr (#7010) 2024-08-28 21:34:28 -07:00
Jonah
173ffca14a [wpilib] Add persistent alerts API (#6735) 2024-08-23 07:05:53 -07:00
Gold856
b12b83aa89 Fix typos with cspell (#6972) 2024-08-17 07:44:34 -07:00
Gold856
0c58426f4c [sim] Add SendableChooserSim (#6763)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
2024-08-15 15:00:10 -07:00
Tyler Veness
8e0d9ac805 Clean up unit UDL usage (#6961) 2024-08-14 10:44:00 -07:00
Gold856
05e955f87e [wpilib] Deprecate Resource (#6952) 2024-08-12 15:26:11 -07:00
Ryan Blue
dd99ff420c [wpilib, hal] DigitalGlitchFilter: Fix sim crash and clean up construction (#6937)
Fixes error when >3 are constructed- in java, m_filterAllocated[index] would be evaluated before the bounds check and throw IndexOutOfBounds, in c++ a vague assertion error would be thrown.

Makes DoAdd static in c++

Makes the error message when HAL_SetFilterSelect fails consistent with java
2024-08-10 23:30:02 -07:00
Ryan Blue
19b478a33b [hal] Expose more FPGA functionality (#6942)
- function to reset user rail fault counters
- function to get comms disable count
- correct docs for user rail count functions
2024-08-10 23:25:02 -07:00
Ryan Blue
01c47e5bcc [wpilibc] Fix default properties for DS NT publisher (#6909) 2024-08-02 19:07:31 -07:00
Ryan Blue
0e9c514ebf [hal, wpilib] Fix REV PH disabled solenoid list (#6887) 2024-07-29 07:59:49 -07:00
Jade
5dcaa6d671 [wpilibc] Add FRC_ReportWarning (#6681) 2024-07-27 20:20:08 -07:00
Gold856
289d45b081 [wpilib] Refactor and clean up ADIS IMU classes (#6719) 2024-07-18 21:09:11 -07:00
Christopher Mahoney
45823abe86 [wpilib] Synchronize C++ and Java versions of BooleanEvent (#6776) 2024-07-18 21:08:28 -07:00
Joseph Eng
602325d608 [wpilibc] Add missing includes to LEDPattern.cpp (#6852) 2024-07-18 21:05:45 -07:00
Tyler Veness
15001afb31 [wpilib] Fix repeat TimedRobot callbacks on loop overrun (#4101)
If one of the *Init() functions takes several multiples of the nominal
loop time, the callbacks after that will run, then increment their
expiration time by the nominal loop time. Since the new expiration time
is still in the past, this will cause the callback to get repeatedly run
in quick succession until its expiration time catches up with the
current time.

This change keeps incrementing the expiration time until it's in the
future, which will avoid repeated runs. This doesn't delay other
callbacks, so they'll get a chance to run once before their expiration
times are corrected.

The other option is correcting all the expiration times at once, which
would starve the other callbacks even longer so that the callback
scheduling returns to a regular cadence sooner. The problem with this
approach is if a previous callback overruns the start of the next
callback, the next callback could potentially never get a chance to run.
2024-07-16 22:56:36 -07:00
Ryan Blue
6a5448322b [wpilib] Add metadata to all dashboard ".type" entries (#6799) 2024-07-02 13:31:50 -07:00
PJ Reiniger
b6bd798f9e [wpilib] Pregenerate PWM motor controllers (#6742)
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
2024-06-18 08:43:08 -06:00
Brendan Raykoff
e884221a8d [wpilib] Propagate PWMMotorController stopMotor() and disable() to followers (#6750) 2024-06-18 07:40:32 -06:00
Ryan Blue
bb8480c690 [wpilib] Include sendable type information in topic metadata (#6741) 2024-06-14 08:12:18 -06:00
Gold856
65c6306047 [wpilib,commands] Use Jinja to generate HID classes (#6274) 2024-06-08 09:59:07 -07:00
Sam Carlberg
ad18fa62ee [wpilib] Add LED pattern API for easily animating addressable LEDs (#6344)
Add LEDReader and LEDWriter helper interfaces to facilitate composing simple patterns into more complex ones, e.g. LEDPattern.solid(Color.kBlue).breathe(Seconds.of(0.75)). Pattern composition relies on changing out the write behavior; for example, offsetBy increments the indexes to write to; while blink will switch between playing a base pattern and turning off all the LEDs.

Add a view class for splitting a single large buffer into smaller distinct sections, which is useful for dealing with long chained LED strips mounted on different parts of a robot. Views cannot be written directly to an LED strip (in fact, trying to do so won't even compile).

Adds some utility methods to the Color class for interpolating between two colors, and support color representations with 32-bit integers to avoid object allocations.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-06-05 19:41:10 -07:00
Wispy
5f8c842223 [wpilib] Compressor: Add more Sendable data (#6687) 2024-06-03 07:47:17 -07:00
scarmain
c62396ce4e [wpilib] Fix PowerDistribution.GetAllCurrents() (#6025) 2024-05-24 16:31:19 -07:00
Nicholas Armstrong
f42bc45ee8 [wpilib] FlywheelSim cleanup (#6629)
This is a cleanup of the FlywheelSim class with a few added features.

- One FlywheelSim constructor that takes a plant, DCMotor, and a optional number of measurementStdDevs. The documentation now states how to construct the plant either through LinearSystemId.createFlywheelSystem or identifyVelocitySystem.

- The gearbox, gearing and moment of Inertia (J) are now private final fields. The gearing is determined from the plant in the constructor as well as the moment of inertia. There are getter methods that allow the flywheelSim to return the gearbox, gearing, and moment of inertia.

- The getCurrentDrawAmps function now uses m_x instead of getAngularVelocityRadPerSec in accordance with more accuracy and matches the patter in other sims.

- Added getter methods for the InputVoltage, angularAcceleration and torque

- (Java only) A third getter method for returning the AngularVelocity of the flywheel using a MutableMeasure as a backing field that is set when getAngularVelocity is called. This summarily returns the angularVelocity as just a Measure object. This allows the user of this class to handle unit conversions with less numerical manipulation. Alterations in C++ for this feature were not needed.
2024-05-24 16:05:14 -07:00
Dustin Spicuzza
dc0e9712e6 [wpilib] Add support for Sharp IR sensors (#6023) 2024-05-24 12:55:30 -07:00
Thad House
d05c7c125b [wpilib] Rewrite DutyCycleEncoder and AnalogEncoder (#6398) 2024-05-24 11:53:56 -07:00
Nicholas Armstrong
ab315e24c8 [wpimath] LinearSystemSim Constructor and method cleanup (#6502)
Modified Java constructors to take a variable number of measurement std devs argument with checks in place to make sure the right amount (or none) are passed into the constructor. All changes passed down to classes utilizing LinearSystemSim.

Removed excess constructors

Removed Java and C++ CurrentDrawAmps method as it doesn't belong in a generic (non electrical) linear system. Kept a non override version in all derived electrical classes.

Also LinearSystemSim has now been made agnostic to electrical systems. Inputs don't have to be voltage. BatteryVoltage clamp function has been pushed down to electrical subclasses.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-05-15 11:40:30 -06:00
Nicholas Armstrong
7fc17811fa [wpimath] Add full state support to LinearSystemId functions (#6554)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-05-15 07:23:22 -06:00
Thad House
4ce8f3f935 Change C APIs to a unified string implementation (#6299)
Currently in the entire C API of WPILib we have ~8 different ways of handling strings. The C API actually isn't built for pure C callers (We don't actually have any of those). Instead, they're built for interop between languages like LabVIEW and C# which can talk to C API's directly.

For output parameters, the choice was fairly obvious. An output struct containing a const string pointer and a length makes the most sense. Its easy to use these from most other languages, and doesn't require special null termination handling. Freeing these is also easy, as if you ever receive one of these string structures, theres just a single function call to free it.

Input parameters are a bit more complex. To be used from pure C, and from LabVIEW, a null terminated string is the best in most cases. However, null terminated strings in general have a lot of downsides. Additionally, from LabVIEW there are other considerations around encoding that having a wrapper struct helps make a bit easier. From a language like C#, a wrapper struct is by far the easiest, as custom marshalling can make it trivial to marshal both UTF8 and UTF16 strings down.

The final consideration is its nice to have an identical concept for both input and output. It makes the rules fairly easy to understand.

WPILib will not have any APIs that manipulate a string allocated externally. This means WPI_String can be const, as across the boundary it is always const.
If a WPILib API takes a const WPI_String*, WPILib will not manipulate or attempt to free that string, and that string is treated as an input. It is up to the caller to handle that memory, WPILib will never hold onto that memory longer than the call.
If a WPILib API takes a WPI_String*, that string is an output. WPILib will allocate that API with WPI_AllocateString(), fill in the string, and return to the caller. When the caller is done with the string, they must free it with WPI_FreeString().
If an output struct contains a WPI_String member, that member is considered read only, and should not be explicitly freed. The caller should call the free function for that struct.
If an array of WPI_Strings are returned, each individual string is considered read only, and should not be explicitly freed. The free function for that array should be called by the caller.
If an input struct containing a WPI_String, or an input array of WPI_Strings is passed to WPILib, the individual strings will not be manipulated or freed by WPILib, and the caller owns and should free that memory.
Callbacks also follow these rules. The most common is a callback either getting passed a const WPI_String* or a struct containing a WPI_String. In both of these cases, the callback target should consider these strings read only, and not attempt to free them or manipulate them.
2024-05-13 05:35:14 -07:00
Peter Johnson
178fe99f12 [wpiutil] Split DataLog background writer into different class (#6590)
DataLog is now a base class, with DataLogBackgroundWriter being the
background thread version and DataLogWriter being a non-threaded version.

Also split the C header into a separate file to make it more wpiformat friendly.
2024-05-12 14:09:43 -07:00
Tyler Veness
d88c71ffdc [wpiutil] Upgrade to fmt 10.2.1, add wpi::print (#6161)
We now use a wrapper (wpi::print) to catch exceptions since we can't patch
std::print() to not throw when we ultimately migrate to it.

fmtlib and std format/print throw the same exceptions and always have. We previously patched fmt::print() to not throw a write failure exception, but we can't do that for std::print(); wpi::print() is the migration plan.
2024-05-12 06:25:42 -07:00
Isaac Turner
d3060d8eba [wpilib] IterativeRobotBase: Provide function to print watchdog epochs (#6581) 2024-05-04 10:19:36 -07:00
Isaac Turner
9c7120e6bf [wpilibc] Remove deprecated Joystick angle functions (#6569) 2024-05-03 12:38:58 -07:00
Isaac Turner
9cae707065 [wpilib] Remove deprecated SetHandler function (#6556) 2024-04-29 21:03:45 -07:00
Juan Jose Chong
abfe2488ff [wpilib] Add flash update capability to ADI IMUs (#6450) 2024-04-21 20:39:53 -07:00