Compare commits

...

245 Commits

Author SHA1 Message Date
Tyler Veness
35eb90c135 Fix "'dimensionless' ambiguous symbol" error (#2382)
A typedef for units::dimensionless::dimensionless is defined, which
conflicted with the namespace when we added "using namespace
dimensionless". This patch reverts the "using namespace" directive.
"using" directives were added to pull three of the four relevant
typedefs but avoid the "dimensionless" type conflict.

This issue was first introduced in #2301.
2020-02-21 00:41:50 -08:00
Dustin Spicuzza
761f79385a Add SimulationInit and SimulationPeriodic functions (#2377)
Fixes #2375
2020-02-18 23:05:16 -08:00
Thad House
554bda3332 HAL: Expose NetComm SendConsoleLine (#2337)
This can be use to synchronize writes between threads, assuming writes all go through this and not stdout.
2020-02-18 20:44:40 -08:00
Thad House
2a968df779 Add method for releasing a waiting interrupt (#2347)
Useful for a new high level interrupt implementation.
2020-02-18 20:41:42 -08:00
sciencewhiz
30ccd13b69 Add methods for getting color of an LED (#2366)
Also fix rounding in Color.
2020-02-18 20:40:03 -08:00
Thad House
60c09ea51f Fix notifier race happening with very fast notifiers (#2370)
What would happen is the Stop() call would happen between the notifier loop being triggered and calling UpdateAlarm(). This would cause the Update to overwrite the stop.
2020-02-18 20:38:05 -08:00
Oblarg
65eab93527 Fix DifferentialDriveVoltageConstraint for tight turns w/ zero velocity (#2341) 2020-02-15 12:36:16 -08:00
sciencewhiz
a226ad8509 Set a default option for Sendable Chooser in examples (#2361) 2020-02-15 09:54:12 -08:00
Peter Johnson
31f4fd70ce Sim GUI: Fix crash when field/robot image load is canceled (#2362) 2020-02-15 09:53:21 -08:00
Dustin Spicuzza
7275ab9837 Add headerpad_max_install_names to Mac builds (#2333)
This allows dylib paths to be rewritten to a larger size by downstream tools.
2020-02-10 21:52:58 -08:00
Dustin Spicuzza
5b3facc63b TrapezoidProfile: Make units public (#2342) 2020-02-10 21:44:21 -08:00
CircuitCraft42
0f313fb9ab cmake: Improved portability of OpenCV Java binding search (#2348)
The CMake option OPENCV_JAVA_INSTALL_DIR can be set to the location
to search for the jar file. Note that the file name cannot be
changed, as, after checking several Linux package repositories,
that seems to be constant across all of them.

Fixes #2346.
2020-02-10 17:30:54 -08:00
Oblarg
05b7593e66 C++ circular_buffer: support types not implicitly convertible from int (#2350)
Also fixes two cases of returning a reference to a constant.
2020-02-08 13:35:21 -08:00
sciencewhiz
1b85066d26 Fix C++ ParallelRaceGroup multiple calls behavior (#2339)
The Java version was correct, but the C++ version would only run once.
2020-02-08 10:26:06 -08:00
sciencewhiz
e93b64f58d Add note that only a single instance of ADXRS450 is supported (#2349) 2020-02-08 10:24:18 -08:00
Oblarg
f0a18f31e7 Timer: add hasElapsed, advanceIfElapsed (#2322)
The current hasPeriodPassed() function is confusing.  In preparation for deprecating it,
add new advanceIfElapsed() function with same functionality and hasElapsed() function
which only checks that the time period has elapsed and does not advance the timer.

Also fix a couple of incorrect usages of hasPeriodPassed().
2020-02-08 10:23:29 -08:00
Vasista Vovveti
29c82527a5 Fix typo in ADXL sim double creation (#2332)
Sets m_simY to the virtual Y acceleration.
2020-02-04 20:15:25 -08:00
Peter Johnson
c165dc5e50 Simulation GUI: Add 2D field view (#2261)
The field image and robot image can be loaded or just a wireframe used.
The robot can be moved and rotated with a mouse click + drag.
The robot position is settable in robot code via the Field2d class.
2020-02-01 21:30:23 -08:00
sciencewhiz
42da07396c Add missing references to f in PIDSubsystem javadoc (#2318) 2020-01-31 19:18:17 -08:00
Jonathan Noyola
20e6c04059 Fix cmake install of hal generated files (#2320) 2020-01-31 19:18:00 -08:00
Declan Freeman-Gleason
ff5d3e5b36 RamseteController: Add setEnabled method (#2313) 2020-01-27 21:53:00 -08:00
sciencewhiz
6cc68ab503 Update MavenArtifacts.md (#2289) 2020-01-27 19:45:53 -08:00
Thad House
068465146b Fix null check order in SendableRegistry (#2314) 2020-01-27 19:43:31 -08:00
Thad House
3bcf8057d4 Add more detail to RuntimeLoader failure message (#2309)
Now specifies the C++ runtime is needed, along with more detail to make it easier to troubleshoot and not lose exception information.
2020-01-27 14:10:46 -08:00
David Vo
8039a6c525 Add missing include to ShuffleboardEventImportance (#2310) 2020-01-26 21:03:15 -08:00
Prateek Machiraju
558c020cca Fix duplicated state when using quintic splines (#2307)
Generating a trajectory using quintic splines caused a duplicated state at all knot points.
2020-01-24 23:10:28 -08:00
Prateek Machiraju
7797da78f5 Add missing methods to Timed and TimedSkeleton templates (#2306) 2020-01-24 20:01:23 -08:00
Oblarg
0ab81d768f Add feed-forward and slew rate limiting to advanced drive examples (#2301) 2020-01-23 18:07:38 -08:00
Oblarg
1cee5ccb93 Feed RobotDrive watchdog in RamseteCommand example (#2298) 2020-01-23 17:41:45 -08:00
Dan Katzuv
3ce01b5ac2 Fix DriveSubsystem.getHeading Java documentation (#2282) 2020-01-23 16:46:53 -08:00
sciencewhiz
e6aa8f3ff4 Update toolchain link in readme (#2304) 2020-01-23 16:43:06 -08:00
Peter Johnson
9d7b087972 Simulation GUI: Add support for custom names (#2292)
This allows users to right click on just about any name in the GUI (e.g. "PWM[0]") and rename it (e.g. "Left Motor [0]"). The index portion is not editable. The name is saved into imgui.ini so it's persistent.
2020-01-20 22:47:36 -08:00
Peter Johnson
bb184ed481 Simulation GUI: Refactor ini saving (#2291) 2020-01-20 21:49:03 -08:00
Peter Johnson
b9b31069cc Fix C++ POVButton (#2294)
Also add unit test.
2020-01-20 21:35:19 -08:00
Peter Johnson
d0cf4e8882 Change sim Filesystem.getDeployDirectory() to src/main/deploy (#2293) 2020-01-19 16:34:45 -08:00
sciencewhiz
02fb850761 Add new speed controllers to shuffleboard docs (#2288)
Also fix java links in C++ docs and a few typos.
2020-01-19 14:26:44 -08:00
sciencewhiz
ac8177e10d Fix GearsBot log methods not being called periodically (#2280)
Add logging for C++ Wrist and Claw
2020-01-17 20:18:15 -08:00
Tyler Veness
2eb5c54476 TrapezoidProfile: Fix aliasing of m_initial to result in calculate() (#2284)
Fixes #2283.
2020-01-17 20:17:21 -08:00
Peter Johnson
0e206e69cf Remove Set Camera Server Shared message (#2285) 2020-01-17 20:16:24 -08:00
Peter Johnson
b1357cace7 Fix LiveWindow SetEnabled C++ std::bad_function_call (#2281)
It was missing a null check.
2020-01-16 00:34:51 -08:00
Thad House
37202b6f28 Add missing SensorUtil::kAnalogOutputs (#2276) 2020-01-15 21:34:28 -08:00
Thad House
2ac0d52960 Remove AnalogTrigger::SetDutyCycle (#2275) 2020-01-15 21:33:58 -08:00
Thad House
dbe1e6f466 Fix missing SetDutyCycleSimDevice on Rio (#2274) 2020-01-15 21:33:35 -08:00
Chris Russell
a61fcbd68d Make Button class concrete (#2244) 2020-01-15 18:59:51 -08:00
Thad House
fe597eeba1 Fix SPI DIO count for sim (#2272)
Only 26 DIO were detectable, not 31.
2020-01-15 18:58:14 -08:00
Jonathan Leitschuh
e213a47efd Official Gradle Wrapper Validation GitHub Action (#2273)
See: https://github.com/gradle/wrapper-validation-action
2020-01-15 14:21:50 -08:00
Peter Johnson
dcb96cb50c TrajectoryGenerator: Allow replacement of error reporting function (C++) (#2267)
C++ version of #2234.
2020-01-13 20:36:16 -08:00
Austin Shalit
60d48fec57 Fix Java static colors having zero values (#2269)
Also add test for this.
2020-01-13 12:21:44 -08:00
Austin Shalit
ee8475d21f Run wpiformat (#2270) 2020-01-13 12:19:08 -08:00
Peter Johnson
f47e318131 C++ units: Interoperate with Windows headers min/max (#2268) 2020-01-12 22:52:36 -08:00
Thad House
cb66bcca3c Add callback handlers for LiveWindow (#2053)
Fixes #2223
2020-01-12 22:37:24 -08:00
Simon Abrelat
73302f6162 Fix color name typos (#2265) 2020-01-12 22:15:19 -08:00
Oblarg
cba21a768f Fix C++ JoystickButton and POVButton (#2259)
C++ JoystickButton and POVButton were both nonfunctional due to slicing when trigger passes itself by value to the button scheduler it creates.

Fix is to remove the virtual Get() method entirely and use only the m_isActive functor; since the subclass now passes the button condition back as a functor to the base class, in which it's stored as a member, it will now still work after being sliced.
2020-01-12 14:57:28 -08:00
Peter Johnson
822e75ec45 Simulator GUI: Handle save file having window size=0 (#2260)
This should never happen, but if it does, it's not recoverable without
either deleting imgui.ini or editing it manually.
2020-01-12 01:37:53 -08:00
Peter Johnson
108ddfa1b4 Fix Pi Camera auto exposure property name (#2258) 2020-01-11 15:04:29 -08:00
Prateek Machiraju
d4c8ee5915 Add Axis enum in XboxController (#2253) 2020-01-10 23:43:19 -08:00
Peter Johnson
ab9647ff5b CommandScheduler: Don't store NetworkTableEntry 2020-01-10 23:42:18 -08:00
Peter Johnson
6666d3be42 SendableBuilder: Allow multiple updateTable functions
This fixes cases like CommandScheduler not working when added to both
LiveWindow and SmartDashboard.
2020-01-10 23:42:18 -08:00
Peter Johnson
795086b4cf Fix Demangle when used standalone (#2256) 2020-01-10 23:41:40 -08:00
Peter Johnson
56765cf49a C++ CommandBase: Don't add to LiveWindow (#2255) 2020-01-10 20:37:49 -08:00
Peter Johnson
bf7012fa2d Fix new CommandScheduler.cancelAll() (#2251)
When called outside the run loop, it would result in a CME in Java.
2020-01-10 16:10:16 -08:00
Peter Johnson
10e8fdb724 Make C++ IterativeRobotBase and RobotBase constructor and destructor public (#2242) 2020-01-08 23:17:12 -08:00
Peter Johnson
790dc552ca Add quirks support for Pi camera (#2241)
- Valid video modes (native modes plus some low-res modes)
- Exposure setting
2020-01-07 20:21:28 -08:00
Peter Johnson
0ec8ed6c05 Make C++ controller using declarations public (#2240) 2020-01-06 23:30:47 -08:00
Tyler Veness
832693617f Add missing definition for PIDController::SetPID() (#2239)
Fixes #2238.
2020-01-06 21:17:16 -08:00
sciencewhiz
772ef8f961 Update Maven location to artifactory (#2235) 2020-01-06 20:13:42 -08:00
Peter Johnson
95b6cd2dd9 TrajectoryGenerator: Allow replacement of error reporting function (#2234)
This is needed to avoid use of DriverStation if used from desktop applications
such as PathWeaver.
2020-01-05 16:01:31 -08:00
sciencewhiz
ce1ac17dfb Remove experimental from new command example descriptions (#2226) 2020-01-04 19:57:31 -08:00
Thad House
b2f7a6b651 Add clarification to LED about length and # of drivers (#2231) 2020-01-04 19:57:10 -08:00
Peter Johnson
bedbef7999 Revert "Remove -no-module-directories flag from javadoc build (#2201)" (#2229)
This reverts commit f9a11cce5e.
2020-01-04 19:52:43 -08:00
Thad House
bc159a92a7 Default sim voltage to 12v, make user rails active (#2224) 2020-01-04 15:07:47 -08:00
Austin Shalit
f50d710a5e Make color ctor public (#2222) 2020-01-04 08:28:18 -08:00
Peter Johnson
bc8f68bec7 Add sim HAL_WaitForCachedControlData (#2221) 2020-01-03 22:38:45 -08:00
Peter Johnson
32c62449be Add ArrayRef overloads to new command classes (#2216)
Also default requirements to {} in all cases for consistency.
2020-01-01 20:09:17 -08:00
Tyler Veness
6190fcb237 Run wpiformat (#2218) 2020-01-01 20:04:56 -08:00
Declan Freeman-Gleason
012d93b2bd Use an explicit stack instead of recursion when parameterizing splines (#2197)
This PR changes the spline parameterizer to use an explicit stack instead of recursion. This is motivated by the fact that splines with adjacent waypoints with approximately opposite headings will never parameterize. In this case the parameterizer subdivides these malformed splines fine for a while, and then gets stuck parameterizing infinitely on some interval. In the recursive approach, this would lead to a stack overflow. We could implement a recursion depth counter (this is what my team did on our similar trajectory code last season), but it's hard to choose a good number for max depth because the initial amount of stack used varies based on how the user calls Parameterize.

A good solution for this is converting the recursion to an "explicit stack," which basically simulates recursion, but allows us to have a much larger maximum stack size. Because we avoid the stack overflow, we can instead throws a more informative MalformedSplineException. If the user is using the TrajectoryGenerator instead of the SplineParameterizer directly then the TrajectoryGenerator will go ahead and catch the exception, return a harmless empty trajectory, and report and error to the driver station.
2020-01-01 18:23:08 -08:00
Matt
222669dc2c Fix trapezoidal profile PID controller setpoint bug (#2210)
Co-Authored-By: Austin Shalit <austinshalit@gmail.com>
2020-01-01 15:23:25 -08:00
Peter Johnson
abe25b795b TrajectoryUtil.toPathweaverJson: Create parent directories (#2214) 2020-01-01 13:35:04 -08:00
sciencewhiz
354185189c Update ProjectYear to 2020 (#2212) 2020-01-01 11:14:31 -08:00
sciencewhiz
f14fe434a1 Add (Old) qualifier to old subsystem (#2211) 2019-12-31 23:00:35 -06:00
Prateek Machiraju
e874ba9313 Add Color classes for use with AddressableLED (#2127)
Both floating point and 8-bit integer classes are included, as well as a wide selection of color constants.

Co-authored-by: Austin Shalit <austinshalit@gmail.com>
2019-12-30 00:01:20 -06:00
Peter Johnson
96348e835a Fix C++ SendableRegistry::AddChild() (#2207)
Add a Sendable* overload so pointers to sendable objects work appropriately.
Otherwise an AddLW(this) in a child (which is a Sendable*) could be a
different pointer than a void* to the same object.

For example:
  AnalogInput constructor calls AddLW(this)
  AnalogPotentiometer constructor calls AddChild(analog input pointer)

Also add handling for the child object moving (if it's Sendable).
2019-12-29 23:37:14 -06:00
Oblarg
d91796f8d2 fix clang-format version number (#2206) 2019-12-29 21:31:26 -06:00
Peter Johnson
9abce8eb06 Fix subsystem LiveWindow usage (#2202) 2019-12-29 21:28:38 -06:00
Peter Johnson
8b4508ad53 Use default path for networktables.ini in simulation (#2205) 2019-12-29 18:55:02 -06:00
Oblarg
5b7dd186d2 Add templates for new commands for vscode plugin (#2016) 2019-12-29 15:02:49 -06:00
Peter Johnson
6ea13ea8f3 ntcore: Add support for local-only operation (#2204)
StartLocal() causes future calls to StartServer() or StartClient() to have
no effect. StopLocal() re-enables these calls.
2019-12-29 14:56:41 -06:00
Oblarg
44bcf7fb4d Java examples: use non-static imports for constants (#2191) 2019-12-29 14:55:49 -06:00
Oblarg
c7a1dfc0bc Add SlewRateLimiter class (#2192)
This is extremely useful for implementing various "ramping" functions
(such as voltage ramps, setpoint ramps, etc). Usage is straightforward;
it behaves like all of our other filter classes. C++ version is unit-safe.
2019-12-29 13:36:28 -06:00
Peter Johnson
a12bb447e4 Fail cmake build if python3 generate_numbers.py fails (#2203) 2019-12-29 13:12:00 -06:00
Declan Freeman-Gleason
c4bd54ef44 Add JNI binding to suppress driver station error/warning messages (#2200)
This is to allow suppressing an ugly stack trace/error message in a unit test in #2197. It doesn't support the full HALSIM_SetSendError callback stuff (i.e. you can only suppress, not intercept, stack traces with this).
2019-12-27 21:11:26 -06:00
Austin Shalit
f9a11cce5e Remove -no-module-directories flag from javadoc build (#2201) 2019-12-27 10:19:49 -06:00
Peter Johnson
6008671c30 Report WPILib version as part of usage reporting (#2199) 2019-12-26 22:34:10 -06:00
Peter Johnson
7b952d599d Add usage reporting for many new things (#2184)
- new CommandScheduler
- kinematics and odometry classes
- new PIDController
- ProfiledPIDController
- TrapezoidProfile (reported in Constraints class)

Also update instances.txt to match latest NI version.

One side effect is that a couple of classes are no longer constexpr.
2019-12-25 00:42:14 -06:00
Peter Johnson
93cdf68694 Add Constants.cpp for MecanumControllerCommand example (#2196) 2019-12-24 16:19:02 -06:00
Peter Johnson
0c6f24562f Fix bug in ULEB128 decoding (#2195) 2019-12-24 14:12:42 -06:00
Thad House
bdc1cab013 Add support for configuring SPI Auto Stall Config (#2193) 2019-12-24 12:52:58 -06:00
Prateek Machiraju
3259cffc63 Add transform methods to Trajectory (#2187) 2019-12-23 13:16:30 -06:00
Oblarg
67b59f2b31 Minor improvements/fixes to new command framework (#2186) 2019-12-23 01:09:25 -06:00
sciencewhiz
1ce24a7a2f Add 2020 speed controllers (#2188)
Add CTRE TalonFX (PWMTalonFX)
Add Playing with Fusion Venom (PWMVenom)
2019-12-22 13:51:43 -06:00
Prateek Machiraju
635882a9f7 Add getter for initial pose in Trajectory (#2180) 2019-12-21 06:57:39 -08:00
Thad House
71a22861eb Use ManagedStatic for CameraServer (#2174) 2019-12-20 14:20:38 -08:00
Thad House
9cb69c5b46 Add a way to pass in a preconstructed value to ManagedStatic (#2175)
A lot of our cases don't need the lazy construction, but do need manual destruction.
2019-12-20 14:06:22 -08:00
Thad House
5e08bb28f8 Add docs and lifecycle tasks for faster dev builds (#2182) 2019-12-20 13:48:26 -08:00
Oblarg
ea4d1a39e1 Update characterization values to match real robot (#2183)
This is in preparation for an end-to-end trajectory tutorial example.

Co-Authored-By: Dalton Smith <gamefollower26@gmail.com>
2019-12-20 13:46:13 -08:00
Prateek Machiraju
31b588d961 Fix ArmFeedforward Javadocs (#2176) 2019-12-15 14:34:18 -08:00
Thad House
0b80d566ad Use ChipObject HMB function for LED (#2173)
It's fixed in v9 and up.
2019-12-14 21:15:32 -08:00
Peter Johnson
f8294e689b Sim GUI: Add a bit of spacing to the analog inputs (#2170)
This helps make it clear they are separate controls.
2019-12-14 10:49:01 -08:00
Peter Johnson
b78f115fcf Work around VS2019 16.4.0 bugs (#2171)
Work around frontend bug in scoped_lock and code generation bug in reverse_iterator in gtest.

See https://github.com/google/googletest/pull/2635
2019-12-14 10:48:19 -08:00
sciencewhiz
b468c51251 Change AddressableLED example to use consistent PWM port (#2168) 2019-12-11 15:39:36 -08:00
Prateek Machiraju
023c088290 Add toString() to relevant kinematics classes (#2160) 2019-12-09 21:35:43 -08:00
Thad House
8a11d13a39 Fix C++ DutyCycleEncoder int constructor (#2166) 2019-12-09 21:35:00 -08:00
Claudius Tewari
daa81c64a7 Minor javadoc fix in SwerveDriveKinematicsConstraint (#2167) 2019-12-09 21:34:32 -08:00
Peter Johnson
e20d96ea4e Use __has_include for WPILib.h (#2164)
Now that commands and cameraserver libraries are no longer direct dependencies,
it's necessary to check for their presence.
2019-12-07 21:39:58 -08:00
Thad House
a76d006a07 Update native-utils to 2020.7.2 (#2161)
Fixes a bug where source directories were being added to the header search path
2019-12-07 17:18:50 -08:00
Thad House
24c031d692 Increase SPI auto byte count to allow 32 bytes to be sent (#2163)
The FPGA now supports 32 bytes.
2019-12-07 17:18:25 -08:00
Thad House
6b4eecf5fe Add hidden functions to get the SPI system and SPI DMA (#2162)
With the addition of stall configuration, its not very clear how it works, and seems like it would be different
per use. So adding ways to manually get them, so the functionality can be figured out how to be used.
2019-12-07 17:16:14 -08:00
Oblarg
ccdd0fbdb2 Add TrapezoidProfile external PID examples (#2131) 2019-12-07 13:37:54 -08:00
Tyler Veness
5c6b8a0f45 Replace std::is_pod_v with std::is_standard_layout_v (#2159)
The former is deprecated in C++20.
2019-12-07 13:34:52 -08:00
Thad House
67d2fed685 Add DutyCycleEncoder channel constructor (#2158)
Avoids extra boilerplate at user level.
2019-12-06 20:58:04 -08:00
Thad House
d8f11eb149 Hardcode channels for LSB weight (#2153)
Avoids a mutex and a lookup.
2019-12-06 20:56:40 -08:00
Thad House
b2ae75acd8 Add way to disable "no extensions found" message (#2134)
We want it enabled by default, but there have been requests for a way to disable it.
2019-12-06 20:55:36 -08:00
Austin Shalit
4f951789fe Build testbench tests online inorder to improve speed (#2144)
* Attempt to build testbench tests online inorder to improve speed

* Fix contianer reference

* Start to remove jenkins shell script

* Change job names

* Remove sshpass

* Remove teststand code

* Copy test results back

* Fix build by using athena container

* Fail if any command fails

* Remove jenkins test script

* Remove name argument

* Fix param count

* Add build display name

* Fix scp to copy into dir

* Update display names

* Update stage name

* Fix test results scp

* Create local test report dir

* Remove commented out old code

* Remove force pseudo-terminal allocation

* Remove extra variables

* Update readme

* Remove old test runs

* Update license header
2019-12-06 17:46:29 -05:00
Austin Shalit
005c4c5beb Try catch around task dependencies to fix loading in editor (#2156) 2019-12-06 11:46:21 -08:00
Tyler Veness
34f6b3f4c0 Fix C++ RamseteCommand param doxygen (#2157) 2019-12-05 23:54:32 -08:00
Oblarg
f7a93713fa Fix up templated TrapezoidProfile classes (#2151)
* Fix two-phase name lookup bug

* Fix param in ProfiledPIDCommand constructor overload

* Fix ProfiledPIDCommand/Controller
2019-12-04 20:40:37 -08:00
Tyler Veness
8c2ff94d70 Rename MathUtils to MathUtil for consistency with other util classes (#2155) 2019-12-04 20:39:12 -08:00
Thad House
d003ec2dc9 Update to 2020v9 image (#2154)
- Fix VISA include and FPGA header
- Fix missing VISA lib from executables
2019-12-04 20:38:43 -08:00
Peter Johnson
8e7cc3fe78 Add user-friendly SimDeviceSim wrappers (#2150)
This makes unit testing with SimDevice devices much easier.
2019-12-02 23:27:33 -08:00
Matt
6c8f6cf479 Fix bug in cubic and quintic hermetic spline generation (#2139)
Add documentation for spline derivatives and explicitly zero matrices.
2019-12-01 21:29:52 -08:00
Peter Johnson
e37ecd33ae Sim GUI: Add support for LED displays (#2138)
LED displays connect the LEDs in various ways (column major vs row major,
different starting locations, serpentine connection order), so add
configuration parameters for these options.
2019-12-01 21:28:02 -08:00
Prateek Machiraju
57c5523d67 Fix documentation in RamseteCommand (#2149) 2019-12-01 21:27:02 -08:00
Matt
7b9c6ebc2f Fix wpiutilJNIShared linkage typo in wpilibj (#2143) 2019-12-01 13:25:46 -08:00
Oblarg
9a515c80f8 Template C++ LinearFilter to work with unit types (#2142) 2019-11-30 23:12:02 -08:00
Prateek Machiraju
5b73c17f25 Remove encoder velocities methods in DifferentialDriveOdometry (#2147)
It doesn't make sense to continue to provide a less accurate method of performing odometry
when a more accurate method using distances exists.

This also removes the need to pass DifferentialDriveKinematics to the constructor.
2019-11-30 23:10:29 -08:00
Banks T
b8c1024261 Fix PS3Eye VID and PID (#2146) 2019-11-30 12:35:47 -08:00
Prateek Machiraju
2622c6c291 Add default values for b and zeta in RamseteController (#2145)
Values b=2.0 and zeta=0.7 have been well-tested to produce desirable results.
2019-11-29 21:16:01 -08:00
Austin Shalit
f66ae59992 Add HSV helpers to AddressableLED (#2135)
Also change the setLED() method to setRGB() for consistency and clarity.

Add rainbow example to demonstrate HSV usage.
2019-11-29 15:16:57 -08:00
Oblarg
5e97c81d80 Add MedianFilter class for moving-window median (#2136)
This kind of filter is extremely useful for signals that are susceptible to sudden
outliers - ultrasonics, 1-D LIDAR, and results from vision processing are all
good use-cases.

This also modifies the existing ultrasonic examples accordingly.
2019-11-29 15:13:40 -08:00
Tyler Veness
f79b7a058a Remove unnecessary constructor arg for LinearFilter's circular buffers (#2140)
They are initialized in LinearFilter's constructor, so the default is
never used.
2019-11-28 23:27:20 -08:00
Austin Shalit
e49494830f Replace Jenkins with Azure agent (#1914) 2019-11-25 22:00:35 -08:00
sciencewhiz
b67d049ac2 Check status of PDP CAN reads (#2126)
Fixes #2124
2019-11-25 21:47:35 -08:00
Peter Johnson
70102a60b7 SendableRegistry.foreachLiveWindow: Prevent concurrent modification (#2129)
Copy the internal map values into an array before iterating.

In C++, change to recursive mutex as well.
2019-11-25 21:47:06 -08:00
Oblarg
6dcd2b0e2c Improve various subsystem APIs (#2130)
Improves the APIs for various prebuilt subsystems (PIDSubsystem, TrapezoidProfileSubsystem, ProfiledPIDSubsystem). Addresses #2128, and also changes the rather cumbersome getSetpoint API to a more intuitive setSetpoint one. Updates examples to match.
2019-11-25 21:46:47 -08:00
Thad House
ce3973435e HAL_CAN_ReceiveMessage: return MessageNotFound if no callbacks registered (#2133) 2019-11-25 21:45:44 -08:00
Thad House
3fcfc8ea72 Fix double disable segfaulting interrupts (#2132)
Also fixes DigitalOutput not closing correctly.
2019-11-25 21:43:58 -08:00
sciencewhiz
6ceafe3cd0 Fix class reference for logger (#2123) 2019-11-23 07:47:02 -08:00
Peter Johnson
b058dcf64e Catch exceptions generated by OpenCV in cscore JNI (#2118) 2019-11-22 08:12:17 -08:00
Tyler Veness
0b9307fdf3 Remove unused parts of .styleguide files (#2119) 2019-11-22 06:34:58 -08:00
Peter Johnson
39be812b2e Fix C++ ArmFeedforward (#2120) 2019-11-22 06:31:32 -08:00
Oblarg
21e957ee42 Add DifferentialDrive voltage constraint (#2075) 2019-11-21 21:43:02 -08:00
Oblarg
e0bc97f66b Add ProfiledPIDSubsystem example (#2076) 2019-11-21 20:55:16 -08:00
Modelmat
3df44c874d Remove Rotation2d.h wpi/math include (#2117) 2019-11-21 19:54:29 -08:00
CTT
a58dbec8aa Add holonomic follower examples (#2052) 2019-11-21 19:52:56 -08:00
Tyler Veness
9a8067465c Fix incomplete .styleguide (#2113)
Also clean up other .styleguides.

Fixes #2111.
2019-11-20 22:44:18 -08:00
Tyler Veness
ffa4b907c0 Fix C++ floating point literal formatting (#2114)
Found formatting errors with this regex
"([^a-z0-9\.]\.[0-9]|[^a-z0-9\.][0-9]\.[^a-z0-9\.])" and ignored false
positives.

Fixes #2112.
2019-11-20 21:48:15 -08:00
Oblarg
3d1ca856b2 Fix missing typename and return type (#2115) 2019-11-20 21:46:33 -08:00
Austin Shalit
5f85457a97 Add usage reporting for AddressableLED (#2108) 2019-11-20 20:13:39 -08:00
Austin Shalit
4ebae17123 Enforce leading/trailing zeros in Java numeric constants (#2105)
Enforce that integer literals must not have leading zeros and that floating point literals must have leading or trailing zeros in Java.
2019-11-20 20:13:15 -08:00
Oblarg
fa85fbfc1c Template C++ TrapezoidProfile and ProfiledPIDController on units (#2109) 2019-11-20 20:11:46 -08:00
Thad House
f62e23f1af Add Doxygen for new HAL interfaces (#2110) 2019-11-20 16:21:07 -08:00
Thad House
5443fdabc1 Directly construct PWM port from HAL, avoid wpilib PWM object (#2106) 2019-11-20 14:48:14 -08:00
Austin Shalit
c0e36df9d8 Standardize on PWMVictorSPX in examples (#2104) 2019-11-19 21:48:22 -08:00
Oblarg
8c4d9f5415 Add TrapezoidProfileSubsystem (#2077)
Adds a subsystem that continually runs a TrapezoidProfile, for composition with offboard PID controllers.
2019-11-19 12:38:42 -08:00
Prateek Machiraju
45201d15fc Add encoder distance overload to DifferentialDriveOdometry (#2096)
Also force encoders to be reset to zero on pose reset.
2019-11-19 09:56:34 -08:00
Tyler Veness
845aba33fe Make feedforward classes constexpr (#2103)
ArmFeedforward::Calculate() can't be made constexpr because std::cos()
and thus units::math::cos() is not constexpr.

Fixes #2101.
2019-11-19 06:47:59 -08:00
Thad House
500c43fb84 Add examples for DMA, DutyCycle, DutyCycleEncoder and AddressableLED (#2100) 2019-11-18 22:12:17 -08:00
Prateek Machiraju
5891628112 Use DifferentialDriveWheelSpeeds in RamseteCommand ctor (#2091) 2019-11-18 22:11:05 -08:00
Thad House
b37b68daaf Add JRE deployment to MyRobot Deploy (#2099) 2019-11-18 19:52:56 -08:00
Oblarg
0e83c65d27 Fix small logic error in ParallelDeadlineGroup (#2095) 2019-11-18 15:33:45 -08:00
Thad House
6f6c6da9f5 Updates to addressable LED (#2098)
Only PWM Headers are supported, so enforce that.

Also fixes some init checks and init order checks.
2019-11-18 15:25:04 -08:00
Thad House
1894219ef6 Fix devmain package in commands (#2097) 2019-11-18 15:24:04 -08:00
Peter Johnson
77a9949bbf Add AddressableLED simulation GUI support 2019-11-18 00:51:59 -08:00
Peter Johnson
a4c9e4ec28 Add AddressableLED simulation support 2019-11-18 00:51:59 -08:00
Thad House
8ed2059074 Add AddressableLED (#2092) 2019-11-17 16:39:38 -08:00
Thad House
59507b12dc Bump to 2020 v7 image (#2086) 2019-11-15 21:51:31 -08:00
Peter Johnson
5d39bf8065 Make halsimgui::DrawLEDs() values parameter const (#2088) 2019-11-15 20:29:51 -08:00
Prateek Machiraju
841ef91c0f Use gyro angle instead of robot angle for odometry (#2081)
The odometry classes previously took in the robot angle as an argument, meaning that users had to take care of offsetting the gyro themselves to accurately report the robot angle. This change will make it so that users will not have to worry about resetting gyros and adding offsets themselves, as this will be handled by the odometry classes.
2019-11-15 17:34:10 -08:00
Tyler Veness
1b66ead49d Use standard constant for pi instead of 3.14 (#2084) 2019-11-15 17:33:18 -08:00
Thad House
db2c3dddd7 Use DMA Global Number for DMA Index (#2085) 2019-11-15 17:32:29 -08:00
Thad House
82b2170feb Add DMA support to HAL and WPILibC (#2080) 2019-11-14 22:52:34 -08:00
Thad House
8280b7e3af Add DutyCycleEncoder and AnalogEncoder (#2040) 2019-11-14 22:51:33 -08:00
Thad House
5510960068 Use kNumSystems for DutyCycle count in Ports (#2083) 2019-11-14 12:15:47 -08:00
Thad House
df10652183 Remove release configs of deploy in MyRobot (#2082)
Bug in lower level library causes having both be broken. So for now just removed release.

Issue created in low level library to fix
2019-11-14 12:15:36 -08:00
Thad House
bf5388393e Add deploy options to myRobot (#2079)
Will only deploy to USB by default, and will not deploy the JRE, but will deploy a Java app.
2019-11-13 22:45:19 -08:00
Thad House
b7bc1ea745 Update to 2020v6 image (#2078) 2019-11-13 21:35:52 -08:00
Thad House
708009cd20 Update to gradle 6.0 (#2074) 2019-11-12 17:14:04 -08:00
Thad House
3cce61b89f Add SmartDashboard::GetEntry function in C++ (#2064)
Existed in Java already.
2019-11-12 17:11:32 -08:00
CTT
565e1f3e79 Fix spelling in MecanumDriveOdometry docs (#2072) 2019-11-11 23:25:09 -08:00
Peter Johnson
1853f7b6b7 Add timing window to simulation GUI
This shows the FPGA time and notifier timing, and has buttons to
start/pause/step the simulation.

The GUI also pauses DS new data notifications when paused.  This could be
done globally instead by blocking NotifyNewData at the HAL level?
2019-11-11 22:03:29 -08:00
Peter Johnson
c5a0497124 Add simulation pause/resume/step support
Calling HALSIM_PauseTiming pauses the FPGA clock and notifiers.
Calling HALSIM_ResumeTiming resumes the FPGA clock and notifiers.
Calling HALSIM_StepTiming steps the FPGA clock and runs applicable notifiers.

This will effectively pause TimedRobot and any other notifier-based events,
but of course will not pause user threads that do not use the notifier (e.g.
image processing).
2019-11-11 22:03:29 -08:00
Peter Johnson
f5446c7409 Add Notifier HALSIM access 2019-11-11 22:03:29 -08:00
Peter Johnson
3e049e02f0 Add name to HAL Notifier 2019-11-11 22:03:29 -08:00
David Vo
2da64d15f6 Make usage reporting enums type match (#2069)
This changes the C++ HALUsageReporting enums to have an
explicit type which matches the HAL_Report parameter
types.  In practice this shouldn't change much except
for tooling that might be parsing this header.
2019-11-11 21:38:49 -08:00
David Vo
f04d95e50f Make FRCUsageReporting.h C-compatible (#2070)
Now that HAL_Report has been moved into FRCUsageReporting.h,
this should also be C-compatible.

This also removes the C++ ifdef guard in HAL.h.
2019-11-11 21:38:24 -08:00
sciencewhiz
d748c67a54 Generate docs for command libraries and fix doclint enable (#2071) 2019-11-11 21:38:04 -08:00
Prateek Machiraju
55a7f2b4ad Add template for old command-based style (#2031) 2019-11-10 23:20:33 -08:00
CTT
486fa9c696 Add XboxController examples for arcade and tank drive (#2058) 2019-11-10 22:53:17 -08:00
Oblarg
e3dd1c5d77 Fix small bug in SplineHelper (#2061)
Also add comments for clamped cubic solution.
2019-11-10 22:52:24 -08:00
Oblarg
7dc7c71b58 Add feedforward components (#2045)
Add helper classes for computing feedforwards with parameters supplied by the characterization tool.
2019-11-09 20:16:42 -08:00
Oblarg
5f33d6af12 Fix ProfiledPIDSubsystem parameter name (#2017)
Change from goal to setpoint (these are two different things).
2019-11-09 09:16:50 -08:00
sciencewhiz
94843adb8f Standardize documentation of Speed Controllers bounds (#2043)
Some were in constructor docs, some in init function docs, and some
inline in code. Move them all to class docs.
2019-11-09 09:14:53 -08:00
Thad House
9bcff37b93 Add HAL specific version of wpi_setError (#2055)
Cleans up error writing, and allows fewer headers to be included in many of the wpilibc cpp files.

This removes all usages of the hal/HAL.h header.
2019-11-08 22:53:20 -08:00
Thad House
326aecc9a0 Add error message for CAN Write Overrun (#2062) 2019-11-08 22:51:11 -08:00
Oblarg
00228678d4 Add requirements param to more Command APIs (#2059)
Assorted improvements to the ergonomics of declaring requirements in the new
command framework. C++ requirements list parameters have been defaulted
to an empty list, some missing C++ requirements list parameters have been
added, and both C++ and Java have been given requirements list params in
various InstantCommand wrapper methods (#2049), whose value is
forwarded to the command.
2019-11-08 18:30:30 -08:00
Thad House
ff39a96cee Make DigitalOutput a DigitalSource (#2054)
It's perfectly safe to use as a DigitalSource, and can enable some cool tricks.
2019-11-07 20:03:43 -08:00
Thad House
5ccad2e8a4 Fix frc2::Timer returning incorrect timestamp values (#2057) 2019-11-07 20:02:27 -08:00
Thad House
629e95776a Add VendorDeps JSON files for command libraries (#2048)
Add commandversion flag to the examples and templates json files.
2019-11-07 17:38:07 -08:00
Thad House
6858a57f72 Make notifier command tests a lot more lenient (#2056)
They don't need to be testing timing, just that the command starts and stops.
2019-11-07 17:26:29 -08:00
Thad House
0ebe32823a Fix MyRobotStatic accidentally linking to shared command libs (#2046) 2019-11-06 14:06:04 -08:00
Thad House
384d00f9e6 Fix various duty cycle bugs (#2047) 2019-11-06 14:05:25 -08:00
Thad House
1f6850adf2 Add CAN Manufacturer for Studica (#2050) 2019-11-06 14:04:27 -08:00
Peter Johnson
7508aada93 Add ability to end startCompetition() main loop (#2032)
This is useful for both cleanly exiting from simulation and for unit testing
at a framework level.

This change required removing move constructor/assignment from IterativeRobot.
2019-11-05 21:33:09 -08:00
Peter Johnson
f5b4be16db Old C++ Command: Make GetName et al public (#2042)
These used to be effectively public due to SendableBase, and are public
in the Java version.
2019-11-05 20:53:40 -08:00
Peter Johnson
e6f5c93ab1 Clean up new C++ commands (#2027)
- Remove use of std::set. The only place std::set was actually used was in ParallelRaceGroup,
but this was of minimal utility as ParallelRaceGroup checked for duplicate subsystem
requirements, so it would be very unusual to end up with duplicate commands
in any case; replaced it with a vector.
- Remove use of std::unordered_map except for SelectCommand. Replaced with vector.
- Use pImpl idiom for CommandScheduler
- Minimize include files (remove unnecessary ones)
- Reformat include file order for consistency
2019-11-05 20:52:49 -08:00
Thad House
39f46ceab6 Don't allow rising and falling values to be read from AnalogTrigger (#2039)
They can't be caught from user code
2019-11-05 20:42:01 -08:00
Thad House
d93aa2b6b2 Add missing lock in FRCDriverStation (#2034)
Switch newDataCounter to atomic
2019-11-05 20:41:16 -08:00
Austin Shalit
114ddaf81f Fix duplicate encoders in examples (#2033) 2019-11-03 09:08:05 -08:00
Peter Johnson
f22d0961e3 Sim GUI: Add duty cycle support 2019-11-02 21:43:57 -07:00
Peter Johnson
3262c2badb Sim GUI: Use new multi-channel PDP getter function 2019-11-02 21:43:57 -07:00
Peter Johnson
96d40192ae Revert accidental change to MyRobot.cpp (#2029) 2019-11-02 21:06:22 -07:00
carbotaniuman
ed30d5d40e Add JSON support for Trajectories (#2025) 2019-11-02 11:35:03 -07:00
Peter Johnson
2b6811eddb Fix null pointer dereference in C++ CommandScheduler (#2023)
Java has a null check that was missing in C++ when adding default commands.
2019-11-01 23:42:01 -07:00
Thad House
1d695a1660 Add FPGA Duty Cycle support (#1987) 2019-11-01 23:41:30 -07:00
Thad House
509819d83f Split the two command implementations into separate libraries (#2012)
This will allow us at the user code side to determine to include old commands, new commands or both.
2019-11-01 21:58:54 -07:00
Thad House
2ad15cae19 Add multi PDP getter and sim PCM/PDP multi arg functions (#2014) 2019-11-01 21:55:35 -07:00
Thad House
931b8ceefd Add new usage reporting types from 2020v5 (#2026) 2019-11-01 21:54:17 -07:00
Tyler Veness
0b3821eba3 Change files with CRLF line endings to LF (#2022) 2019-11-01 20:26:05 -07:00
Thad House
6f159d1426 Add way to atomically check for new data, and wait otherwise (#2015) 2019-11-01 17:09:28 -07:00
Austin Shalit
a769f1f227 Fix bug in RamseteCommand (using degrees instead of radians) (#2020) 2019-11-01 13:21:02 -07:00
Oblarg
c5186d8159 Clean up PIDCommand (#2010)
PIDCommand uses a function based (callback) model, so functions designed for use in derived classes are of limited utility.
2019-11-01 13:11:55 -07:00
Oblarg
9ebd23d61e Add setVoltage method to SpeedController (#1997)
Add a voltage-compensated setVoltage method to SpeedController, which is sorely needed to help teams use feedforward-based controls effectively. Also uses correct units on the cpp side.

Also update relevant examples.
2019-11-01 09:32:40 -07:00
Prateek Machiraju
f6e311ef86 Fix SplineHelper bug (#2018)
Add unit test to check interior waypoints
2019-11-01 09:28:11 -07:00
Oblarg
f33bd9f050 Fix NPE in RamseteCommand (#2019) 2019-11-01 09:26:48 -07:00
Thad House
1c1e0c9a6a Add HAL_SetAllSolenoids to sim (#2004) 2019-10-30 21:29:35 -07:00
Thad House
ea9bb651a3 Remove accidental OpenCV link from wpilibc shared library (#2013) 2019-10-30 21:28:45 -07:00
Oblarg
cc07425182 Change command decorators to return implementation (#2007)
Changes Command decorators to return actual implementation classes rather than Commands. Previously, decorated commands were not Sendable, which was a problem. Also, there's no real reason not to expose the implementation details here, as we're extremely unlikely to change the implementations in the future.
2019-10-30 21:28:08 -07:00
Thad House
16b34cce20 Remove IterativeRobot templates (#2011)
With the class being deprecated, new projects shouldn't be created with it
2019-10-30 21:26:30 -07:00
Thad House
669127e49c Update intellisense to work with Beta 2020 code (#2008)
Needed to fix case when both rio and raspbian compilers installed, along with C++17 intellisense.
2019-10-29 21:36:13 -07:00
Thad House
9dc30797e4 Fix usage reporting indices (#2009)
According to NI, 0 is unspecified, and all the indices need to be
index + 1, so the first index becomes 1.
2019-10-29 21:34:10 -07:00
Thad House
f6b844ea30 Move HAL Interrupt struct to anonymous namespace (#2003) 2019-10-28 22:32:28 -07:00
Thad House
a72f809911 Add extern C to DigitalGlitchFilterJNI (#2002) 2019-10-28 22:30:04 -07:00
Thad House
916596cb01 Fix invalid examples json, add validator (#2001) 2019-10-28 20:10:05 -07:00
Peter Johnson
5509a8e968 Use constexpr for all example constants
Also make DifferentialDriveKinematics constructor constexpr.
2019-10-28 09:19:41 -07:00
Peter Johnson
0be6b64756 Use constexpr for DifferentialDriveKinematics 2019-10-28 09:19:41 -07:00
1133 changed files with 34985 additions and 5180 deletions

View File

@@ -0,0 +1,10 @@
name: "Validate Gradle Wrapper"
on: [push]
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gradle/wrapper-validation-action@v1

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
dependency-reduced-pom.xml
doxygen.log
build*/
!buildSrc/
# Created by the jenkins test script
test-reports

View File

@@ -9,16 +9,9 @@ cppSrcFileInclude {
}
generatedFileExclude {
gtest/
ni-libraries/include/
ni-libraries/lib/
FRCNetComm\.java$
simulation/frc_gazebo_plugins/frcgazebo/
simulation/gz_msgs/src/include/simulation/gz_msgs/msgs\.h$
}
modifiableFileExclude {
\.so$
simulation/halsim_gui/src/main/native/include/portable-file-dialogs\.h$
}
repoRootNameOverride {

View File

@@ -1,6 +1,6 @@
{
"enableCppIntellisense": true,
"currentLanguage": "cpp",
"projectYear": "2019",
"projectYear": "2020",
"teamNumber": 0
}

View File

@@ -55,6 +55,7 @@ option(USE_VCPKG_LIBUV "Use vcpkg libuv" OFF)
option(USE_VCPKG_EIGEN "Use vcpkg eigen" OFF)
option(FLAT_INSTALL_WPILIB "Use a flat install directory" OFF)
option(WITH_SIMULATION_MODULES "build simulation modules" OFF)
set(OPENCV_JAVA_INSTALL_DIR "" CACHE PATH "Location to search for the OpenCV jar file")
if (NOT WITHOUT_JAVA AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "
@@ -64,6 +65,15 @@ FATAL: Cannot build static libs with Java enabled.
")
endif()
if (WITHOUT_JAVA OR WITHOUT_CSCORE)
if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
message(WARNING "
WARNING: OpenCV Java dir set but java is not enabled!
It will be ignored.
")
endif()
endif()
set( wpilib_dest wpilib)
set( include_dest wpilib/include )
set( main_lib_dest wpilib/lib )

View File

@@ -37,7 +37,7 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont
## Coding Guidelines
WPILib uses modified Google style guides for both C++ and Java, which can be found in the [styleguide repository](https://github.com/wpilibsuite/styleguide). Autoformatters are available for many popular editors at https://github.com/google/styleguide. Running wpiformat is required for all contributions and is enforced by our continuous integration system. We currently use clang-format 5.0 with wpiformat.
WPILib uses modified Google style guides for both C++ and Java, which can be found in the [styleguide repository](https://github.com/wpilibsuite/styleguide). Autoformatters are available for many popular editors at https://github.com/google/styleguide. Running wpiformat is required for all contributions and is enforced by our continuous integration system. We currently use clang-format 6.0 with wpiformat.
While the library should be fully formatted according to the styles, additional elements of the style guide were not followed when the library was initially created. All new code should follow the guidelines. If you are looking for some easy ramp-up tasks, finding areas that don't follow the style guide and fixing them is very welcome.

15
FasterBuilds.md Normal file
View File

@@ -0,0 +1,15 @@
# Faster Builds for Developers
When you run `./gradlew build`, it builds EVERYTHING. This means debug and release builds for desktop and all installed cross compilers. For many developers, this is way too much, and causes much developer pain.
To help with some of these things, common tasks have shortcuts to only build necessary things for common development and testing tasks.
## Development (Desktop)
For projects `wpiutil`, `ntcore`, `cscore`, `hal` `wpilibOldCommands`, `wpilibNewCommands` and `cameraserver`, a `testDesktopJava` and a `testDesktopCpp` task exists. These can be ran with `./gradlew :projectName:task`, and will only build the minimum things required to run those tests.
For `wpilibc`, a `testDesktopCpp` task exists. For `wpilibj`, a `testDesktopJava` task exists.
For `wpilibcExamples`, a `buildDesktopCpp` task exists (These can't be ran, but they can compile).
For `wpilibjExamples`, a `buildDesktopJava` task exists.

View File

@@ -5,8 +5,8 @@ WPILib publishes its built artifacts to our Maven server for use by downstream p
## Repositories
We provide two repositories. These repositories are:
* (Release) https://first.wpi.edu/FRC/roborio/maven/release/
* (Development) https://first.wpi.edu/FRC/roborio/maven/development/
* (Release) https://frcmaven.wpi.edu/artifactory/release/
* (Development) https://frcmaven.wpi.edu/artifactory/development/
The release repository is where official WPILib releases are pushed.
The development repository is where development releases of every commit to [master](https://github.com/wpilibsuite/allwpilib/tree/master) is pushed.
@@ -72,6 +72,10 @@ All artifacts are based at `edu.wpi.first.artifactname` in the repository.
* hal
* wpiutil
* halsim
* imgui
* wpiutil
* ntcore
* wpiutil
@@ -85,7 +89,6 @@ All artifacts are based at `edu.wpi.first.artifactname` in the repository.
* opencv
* wpiutil
* wpilibj
* hal
* cameraserver
@@ -93,10 +96,35 @@ All artifacts are based at `edu.wpi.first.artifactname` in the repository.
* cscore
* wpiutil
* wpilibc
* hal
* cameraserver
* ntcore
* cscore
* wpiutil
* wpilibNewCommands
* wpilibc
* hal
* cameraserver
* ntcore
* cscore
* wpiutil
* wpilibNewCommands
* wpilibc
* hal
* cameraserver
* ntcore
* cscore
* wpiutil
### Third Party Artifacts
This repository provides the builds of the following third party software.
All artifacts are based at `edu.wpi.first.thirdparty.frcYEAR` in the repository.
* googletest
* imgui
* opencv

View File

@@ -34,6 +34,8 @@ The following build options are available:
* TODO
* EXTERNAL_HAL_FILE
* TODO
* OPENCV_JAVA_INSTALL_DIR
* Set this option to the location of the archive of the OpenCV Java bindings (it should be called opencv-xxx.jar, with the x'es being version numbers). NOTE: set it to the LOCATION of the file, not the file itself!
## Build Setup

View File

@@ -27,7 +27,7 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
- On Linux, GCC works fine
- On Windows, you need Visual Studio 2019 (the free community edition works fine).
Make sure to select the C++ Programming Language for installation
- [ARM Compiler Toolchain](https://github.com/wpilibsuite/toolchain-builder/releases)
- [ARM Compiler Toolchain](https://github.com/wpilibsuite/roborio-toolchain/releases)
* Note that for 2020 and beyond, you should use version 7 or greater of GCC
- Doxygen (Only required if you want to build the C++ documentation)

View File

@@ -44,6 +44,7 @@ Team 254 Library wpilibj/src/main/java/edu/wpi/first/wpilibj/spline/SplineP
wpilibc/src/main/native/include/spline/SplineParameterizer.h
wpilibc/src/main/native/include/trajectory/TrajectoryParameterizer.h
wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp
Portable File Dialogs simulation/halsim_gui/src/main/native/include/portable-file-dialogs.h
==============================================================================

View File

@@ -1,19 +1,91 @@
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo Hello, world!
displayName: 'Run a one-line script'
- script: |
echo Add other tasks to build, test, and deploy your project.
echo See https://aka.ms/yaml
displayName: 'Run a multi-line script'
# Testing steps for real hardware
trigger:
batch: true
branches:
include:
- master
stages:
- stage: Build
jobs:
- job: IntegrationTests
displayName: Integration Tests
pool:
vmImage: 'Ubuntu 16.04'
container:
image: wpilib/roborio-cross-ubuntu:2020-18.04
timeoutInMinutes: 0
steps:
- task: Gradle@2
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')))
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
testResultsFiles: '**/TEST-*.xml'
tasks: 'copyWpilibJIntegrationTestJarToOutput copyWpilibCTestLibrariesToOutput'
options: '-Ponlylinuxathena -PbuildServer'
- task: PublishPipelineArtifact@0
inputs:
artifactName: 'Integration Tests'
targetPath: 'build/integrationTestFiles'
- stage: TestBench
displayName: Test Bench
jobs:
- job: Cpp
displayName: C++
pool: RoboRioConnections
timeoutInMinutes: 30
workspace:
clean: all
steps:
- task: DownloadPipelineArtifact@0
inputs:
artifactName: 'Integration Tests'
targetPath: 'build/integrationTestFiles'
- task: ShellScript@2
displayName: Run C++ Tests
inputs:
scriptPath: test-scripts/deploy-and-run-test-on-robot.sh
args: 'cpp -A "--gtest_output=xml:/home/admin/testResults/cppreport.xml"'
- task: PublishTestResults@2
displayName: Publish C++ Test Results
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '*.xml'
testRunTitle: 'C++ Test Report'
searchFolder: '$(System.DefaultWorkingDirectory)/test-reports'
- job: Java
pool: RoboRioConnections
timeoutInMinutes: 30
workspace:
clean: all
steps:
- task: DownloadPipelineArtifact@0
inputs:
artifactName: 'Integration Tests'
targetPath: 'build/integrationTestFiles'
- task: ShellScript@2
displayName: Run Java Tests
inputs:
scriptPath: test-scripts/deploy-and-run-test-on-robot.sh
args: 'java'
- task: PublishTestResults@2
displayName: Publish Java Test Results
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '*.xml'
testRunTitle: 'Java Test Report'
searchFolder: '$(System.DefaultWorkingDirectory)/test-reports'

View File

@@ -3,15 +3,14 @@ import edu.wpi.first.toolchain.*
plugins {
id 'base'
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '4.0.1'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.1'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
id 'edu.wpi.first.NativeUtils' apply false
id 'edu.wpi.first.GradleJni' version '0.9.1'
id 'edu.wpi.first.GradleVsCode' version '0.9.4'
id 'edu.wpi.first.GradleJni' version '0.10.1'
id 'edu.wpi.first.GradleVsCode' version '0.11.0'
id 'idea'
id 'visual-studio'
id 'com.gradle.build-scan' version '2.3'
id 'net.ltgt.errorprone' version '0.6' apply false
id 'com.github.johnrengelman.shadow' version '4.0.3' apply false
id 'net.ltgt.errorprone' version '1.1.1' apply false
id 'com.github.johnrengelman.shadow' version '5.2.0' apply false
}
if (project.hasProperty('buildServer')) {
@@ -99,7 +98,9 @@ subprojects {
// Disables doclint in java 8.
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
if (project.name != "docs") {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
}
@@ -109,5 +110,5 @@ ext.getCurrentArch = {
}
wrapper {
gradleVersion = '5.4.1'
gradleVersion = '6.0'
}

View File

@@ -5,5 +5,5 @@ repositories {
}
}
dependencies {
compile "edu.wpi.first:native-utils:2020.1.4"
implementation "edu.wpi.first:native-utils:2020.7.2"
}

View File

@@ -0,0 +1,48 @@
import groovy.transform.CompileStatic
import javax.inject.Inject
import jaci.gradle.deploy.artifact.MavenArtifact
import jaci.gradle.deploy.context.DeployContext
import org.gradle.api.Project
import jaci.gradle.ActionWrapper
import java.util.function.Function
@CompileStatic
class JREArtifact extends MavenArtifact {
Function<DeployContext, Boolean> buildRequiresJre = (Function<DeployContext, Boolean>){ true }
void setJreDependency(String dep) {
dependency = project.dependencies.add(configuration(), dep)
}
@Inject
JREArtifact(String name, Project project) {
super(name, project)
configuration = project.configurations.create(configuration())
onlyIf = { DeployContext ctx ->
(buildRequiresJre.apply(ctx) && jreMissing(ctx)) || project.hasProperty("force-redeploy-jre")
}
predeploy << new ActionWrapper({ DeployContext ctx ->
ctx.logger.log('Deploying RoboRIO JRE (this will take a while)...')
})
directory = '/tmp'
filename = 'frcjre.ipk'
postdeploy << new ActionWrapper({ DeployContext ctx ->
ctx.logger.log('Installing JRE...')
ctx.execute('opkg remove frc2020-openjdk*; opkg install /tmp/frcjre.ipk; rm /tmp/frcjre.ipk')
ctx.logger.log('JRE Deployed!')
})
}
String configuration() {
return name + 'frcjre'
}
boolean jreMissing(DeployContext ctx) {
return ctx.execute('if [[ -f "/usr/local/frc/JRE/bin/java" ]]; then echo OK; else echo MISSING; fi').result.contains("MISSING")
}
}

View File

@@ -7,16 +7,12 @@ cppSrcFileInclude {
\.cpp$
}
modifiableFileExclude {
\.so$
}
repoRootNameOverride {
cameraserver
}
includeOtherLibs {
^HAL/
^hal/
^networktables/
^opencv2/
^support/

View File

@@ -10,12 +10,12 @@ evaluationDependsOn(':hal')
apply from: "${rootDir}/shared/javacpp/setupBuild.gradle"
dependencies {
compile project(':wpiutil')
compile project(':ntcore')
compile project(':cscore')
devCompile project(':wpiutil')
devCompile project(':ntcore')
devCompile project(':cscore')
implementation project(':wpiutil')
implementation project(':ntcore')
implementation project(':cscore')
devImplementation project(':wpiutil')
devImplementation project(':ntcore')
devImplementation project(':cscore')
}
ext {

View File

@@ -27,12 +27,12 @@ repositories {
}
dependencies {
compile 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.code.gson:gson:2.8.5'
compile project(':wpiutil')
compile project(':ntcore')
compile project(':cscore')
compile project(':cameraserver')
implementation project(':wpiutil')
implementation project(':ntcore')
implementation project(':cscore')
implementation project(':cameraserver')
}
model {

View File

@@ -13,6 +13,7 @@
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/DenseMap.h>
#include <wpi/ManagedStatic.h>
#include <wpi/SmallString.h>
#include <wpi/StringMap.h>
#include <wpi/mutex.h>
@@ -47,8 +48,14 @@ struct CameraServer::Impl {
};
CameraServer* CameraServer::GetInstance() {
static CameraServer instance;
return &instance;
struct Creator {
static void* call() { return new CameraServer{}; }
};
struct Deleter {
static void call(void* ptr) { delete static_cast<CameraServer*>(ptr); }
};
static wpi::ManagedStatic<CameraServer, Creator, Deleter> instance;
return &(*instance);
}
static wpi::StringRef MakeSourceValue(CS_Source source,

View File

@@ -69,7 +69,9 @@ if (NOT WITHOUT_JAVA)
#find java files, copy them locally
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/OpenCV/java/)
if("${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/OpenCV/java/)
endif()
find_file(OPENCV_JAR_FILE NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin NO_DEFAULT_PATH)
find_file(OPENCV_JNI_FILE NAMES libopencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.so

View File

@@ -19,7 +19,8 @@ ext {
sharedCvConfigs = [cscore : [],
cscoreBase: [],
cscoreDev : [],
cscoreTest: []]
cscoreTest: [],
cscoreJNIShared: []]
staticCvConfigs = [cscoreJNI: []]
useJava = true
useCpp = true

View File

@@ -412,7 +412,11 @@ std::unique_ptr<PropertyImpl> HttpCameraImpl::CreateEmptyProperty(
}
bool HttpCameraImpl::CacheProperties(CS_Status* status) const {
#ifdef _MSC_VER // work around VS2019 16.4.0 bug
std::scoped_lock<wpi::mutex> lock(m_mutex);
#else
std::scoped_lock lock(m_mutex);
#endif
// Pretty typical set of video modes
m_videoModes.clear();

View File

@@ -78,7 +78,11 @@ template <typename THandle, typename TStruct, int typeValue, typename TMutex>
template <typename... Args>
THandle UnlimitedHandleResource<THandle, TStruct, typeValue, TMutex>::Allocate(
Args&&... args) {
#ifdef _MSC_VER // work around VS2019 16.4.0 bug
std::scoped_lock<TMutex> lock(m_handleMutex);
#else
std::scoped_lock sync(m_handleMutex);
#endif
size_t i;
for (i = 0; i < m_structures.size(); i++) {
if (m_structures[i] == nullptr) {

View File

@@ -5,6 +5,9 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <exception>
#include <opencv2/core/core.hpp>
#include <wpi/SmallString.h>
#include <wpi/jni_util.h>
#include <wpi/raw_ostream.h>
@@ -33,6 +36,7 @@ static JClass rawFrameCls;
static JException videoEx;
static JException nullPointerEx;
static JException unsupportedEx;
static JException exceptionEx;
// Thread-attached environment for listener callbacks.
static JNIEnv* listenerEnv = nullptr;
@@ -45,7 +49,8 @@ static const JClassInit classes[] = {
static const JExceptionInit exceptions[] = {
{"edu/wpi/cscore/VideoException", &videoEx},
{"java/lang/NullPointerException", &nullPointerEx},
{"java/lang/UnsupportedOperationException", &unsupportedEx}};
{"java/lang/UnsupportedOperationException", &unsupportedEx},
{"java/lang/Exception", &exceptionEx}};
static void ListenerOnStart() {
if (!jvm) return;
@@ -67,6 +72,30 @@ static void ListenerOnExit() {
jvm->DetachCurrentThread();
}
/// throw java exception
static void ThrowJavaException(JNIEnv* env, const std::exception* e) {
wpi::SmallString<128> what;
jclass je = 0;
if (e) {
const char* exception_type = "std::exception";
if (dynamic_cast<const cv::Exception*>(e)) {
exception_type = "cv::Exception";
je = env->FindClass("org/opencv/core/CvException");
}
what = exception_type;
what += ": ";
what += e->what();
} else {
what = "unknown exception";
}
if (!je) je = exceptionEx;
env->ThrowNew(je, what.c_str());
}
extern "C" {
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) {
@@ -1096,10 +1125,16 @@ JNIEXPORT void JNICALL
Java_edu_wpi_cscore_CameraServerCvJNI_putSourceFrame
(JNIEnv* env, jclass, jint source, jlong imageNativeObj)
{
cv::Mat& image = *((cv::Mat*)imageNativeObj);
CS_Status status = 0;
cs::PutSourceFrame(source, image, &status);
CheckStatus(env, status);
try {
cv::Mat& image = *((cv::Mat*)imageNativeObj);
CS_Status status = 0;
cs::PutSourceFrame(source, image, &status);
CheckStatus(env, status);
} catch (const std::exception& e) {
ThrowJavaException(env, &e);
} catch (...) {
ThrowJavaException(env, 0);
}
}
// int width, int height, int pixelFormat, int totalData
@@ -1555,11 +1590,19 @@ JNIEXPORT jlong JNICALL
Java_edu_wpi_cscore_CameraServerCvJNI_grabSinkFrame
(JNIEnv* env, jclass, jint sink, jlong imageNativeObj)
{
cv::Mat& image = *((cv::Mat*)imageNativeObj);
CS_Status status = 0;
auto rv = cs::GrabSinkFrame(sink, image, &status);
CheckStatus(env, status);
return rv;
try {
cv::Mat& image = *((cv::Mat*)imageNativeObj);
CS_Status status = 0;
auto rv = cs::GrabSinkFrame(sink, image, &status);
CheckStatus(env, status);
return rv;
} catch (const std::exception& e) {
ThrowJavaException(env, &e);
return 0;
} catch (...) {
ThrowJavaException(env, 0);
return 0;
}
}
/*
@@ -1571,11 +1614,19 @@ JNIEXPORT jlong JNICALL
Java_edu_wpi_cscore_CameraServerCvJNI_grabSinkFrameTimeout
(JNIEnv* env, jclass, jint sink, jlong imageNativeObj, jdouble timeout)
{
cv::Mat& image = *((cv::Mat*)imageNativeObj);
CS_Status status = 0;
auto rv = cs::GrabSinkFrameTimeout(sink, image, timeout, &status);
CheckStatus(env, status);
return rv;
try {
cv::Mat& image = *((cv::Mat*)imageNativeObj);
CS_Status status = 0;
auto rv = cs::GrabSinkFrameTimeout(sink, image, timeout, &status);
CheckStatus(env, status);
return rv;
} catch (const std::exception& e) {
ThrowJavaException(env, &e);
return 0;
} catch (...) {
ThrowJavaException(env, 0);
return 0;
}
}
static void SetRawFrameData(JNIEnv* env, jobject rawFrameObj,

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -102,7 +102,7 @@ static bool IsPercentageProperty(wpi::StringRef name) {
if (name.startswith("raw_")) name = name.substr(4);
return name == "brightness" || name == "contrast" || name == "saturation" ||
name == "hue" || name == "sharpness" || name == "gain" ||
name == "exposure_absolute";
name == "exposure_absolute" || name == "exposure_time_absolute";
}
static constexpr const int quirkLifeCamHd3000[] = {
@@ -112,6 +112,11 @@ static constexpr char const* quirkPS3EyePropExAuto = "auto_exposure";
static constexpr char const* quirkPS3EyePropExValue = "exposure";
static constexpr const int quirkPS3EyePropExAutoOn = 0;
static constexpr const int quirkPS3EyePropExAutoOff = 1;
static constexpr char const* quirkPiCameraPropExAuto = "auto_exposure";
static constexpr char const* quirkPiCameraPropExValue =
"exposure_time_absolute";
static constexpr const int quirkPiCameraPropExAutoOn = 0;
static constexpr const int quirkPiCameraPropExAutoOff = 1;
int UsbCameraImpl::RawToPercentage(const UsbCameraProperty& rawProp,
int rawValue) {
@@ -1112,6 +1117,25 @@ void UsbCameraImpl::DeviceCacheVideoModes() {
}
}
// The Pi camera reports mode ranges, which we don't currently handle, so only
// provide a set of discrete modes; list based on
// https://picamera.readthedocs.io/en/release-1.10/fov.html
if (modes.empty() && m_picamera) {
for (VideoMode::PixelFormat pixelFormat :
{VideoMode::kYUYV, VideoMode::kMJPEG, VideoMode::kBGR}) {
modes.emplace_back(pixelFormat, 1920, 1080, 30);
modes.emplace_back(pixelFormat, 2592, 1944, 15);
modes.emplace_back(pixelFormat, 1296, 972, 42);
modes.emplace_back(pixelFormat, 1296, 730, 49);
modes.emplace_back(pixelFormat, 640, 480, 90);
modes.emplace_back(pixelFormat, 320, 240, 90);
modes.emplace_back(pixelFormat, 160, 120, 90);
modes.emplace_back(pixelFormat, 640, 480, 60);
modes.emplace_back(pixelFormat, 320, 240, 60);
modes.emplace_back(pixelFormat, 160, 120, 60);
}
}
{
std::scoped_lock lock(m_mutex);
m_videoModes.swap(modes);
@@ -1192,12 +1216,13 @@ void UsbCameraImpl::SetQuirks() {
wpi::StringRef desc = GetDescription(descbuf);
m_lifecam_exposure =
desc.endswith("LifeCam HD-3000") || desc.endswith("LifeCam Cinema (TM)");
m_picamera = desc.startswith("mmal service");
int deviceNum = GetDeviceNum(m_path.c_str());
if (deviceNum >= 0) {
int vendorId, productId;
if (GetVendorProduct(deviceNum, &vendorId, &productId)) {
m_ps3eyecam_exposure = vendorId == 0x2000 && productId == 0x0145;
m_ps3eyecam_exposure = vendorId == 0x1415 && productId == 0x2000;
}
}
}
@@ -1248,7 +1273,9 @@ void UsbCameraImpl::SetExposureAuto(CS_Status* status) {
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExAuto),
quirkPS3EyePropExAutoOn, status);
} else if (m_picamera) {
SetProperty(GetPropertyIndex(quirkPiCameraPropExAuto),
quirkPiCameraPropExAutoOn, status);
} else {
SetProperty(GetPropertyIndex(kPropExAuto), 3, status);
}
@@ -1258,6 +1285,9 @@ void UsbCameraImpl::SetExposureHoldCurrent(CS_Status* status) {
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExAuto),
quirkPS3EyePropExAutoOff, status); // manual
} else if (m_picamera) {
SetProperty(GetPropertyIndex(quirkPiCameraPropExAuto),
quirkPiCameraPropExAutoOff, status); // manual
} else {
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
}
@@ -1267,6 +1297,9 @@ void UsbCameraImpl::SetExposureManual(int value, CS_Status* status) {
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExAuto),
quirkPS3EyePropExAutoOff, status); // manual
} else if (m_picamera) {
SetProperty(GetPropertyIndex(quirkPiCameraPropExAuto),
quirkPiCameraPropExAutoOff, status); // manual
} else {
SetProperty(GetPropertyIndex(kPropExAuto), 1, status); // manual
}
@@ -1277,6 +1310,8 @@ void UsbCameraImpl::SetExposureManual(int value, CS_Status* status) {
}
if (m_ps3eyecam_exposure) {
SetProperty(GetPropertyIndex(quirkPS3EyePropExValue), value, status);
} else if (m_picamera) {
SetProperty(GetPropertyIndex(quirkPiCameraPropExValue), value, status);
} else {
SetProperty(GetPropertyIndex(kPropExValue), value, status);
}

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -166,6 +166,7 @@ class UsbCameraImpl : public SourceImpl {
// Quirks
bool m_lifecam_exposure{false}; // Microsoft LifeCam exposure
bool m_ps3eyecam_exposure{false}; // PS3 Eyecam exposure
bool m_picamera{false}; // Raspberry Pi camera
//
// Variables protected by m_mutex

View File

@@ -10,6 +10,8 @@ evaluationDependsOn(':hal')
evaluationDependsOn(':cameraserver')
evaluationDependsOn(':wpilibc')
evaluationDependsOn(':wpilibj')
evaluationDependsOn(':wpilibOldCommands')
evaluationDependsOn(':wpilibNewCommands')
def baseArtifactIdCpp = 'documentation'
def artifactGroupIdCpp = 'edu.wpi.first.wpilibc'
@@ -29,6 +31,8 @@ cppProjectZips.add(project(':ntcore').cppHeadersZip)
cppProjectZips.add(project(':cscore').cppHeadersZip)
cppProjectZips.add(project(':cameraserver').cppHeadersZip)
cppProjectZips.add(project(':wpilibc').cppHeadersZip)
cppProjectZips.add(project(':wpilibOldCommands').cppHeadersZip)
cppProjectZips.add(project(':wpilibNewCommands').cppHeadersZip)
doxygen {
executables {
@@ -71,8 +75,8 @@ doxygen {
}
tasks.register("zipCppDocs", Zip) {
baseName = zipBaseNameCpp
destinationDir = outputsFolder
archiveBaseName = zipBaseNameCpp
destinationDirectory = outputsFolder
dependsOn doxygen
from ("$buildDir/docs/doxygen/html")
into '/'
@@ -100,7 +104,7 @@ task generateJavaDocs(type: Javadoc) {
classpath += project(":wpiutil").sourceSets.main.compileClasspath
options.links("https://docs.oracle.com/en/java/javase/11/docs/api/")
options.addStringOption "tag", "pre:a:Pre-Condition"
options.addStringOption('Xdoclint:accessibility,html,missing,reference,syntax')
options.addBooleanOption "Xdoclint:html,missing,reference,syntax", true
options.addBooleanOption('html5', true)
dependsOn project(':wpilibj').generateJavaVersion
dependsOn project(':hal').generateUsageReporting
@@ -110,6 +114,8 @@ task generateJavaDocs(type: Javadoc) {
source project(':ntcore').sourceSets.main.java
source project(':wpilibj').sourceSets.main.java
source project(':cameraserver').sourceSets.main.java
source project(':wpilibOldCommands').sourceSets.main.java
source project(':wpilibNewCommands').sourceSets.main.java
source configurations.javaSource.collect { zipTree(it) }
include '**/*.java'
failOnError = true
@@ -130,8 +136,8 @@ task generateJavaDocs(type: Javadoc) {
}
tasks.register("zipJavaDocs", Zip) {
baseName = zipBaseNameJava
destinationDir = outputsFolder
archiveBaseName = zipBaseNameJava
destinationDirectory = outputsFolder
dependsOn generateJavaDocs
from ("$buildDir/docs/javadoc")
into '/'

Binary file not shown.

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

35
gradlew vendored
View File

@@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -154,19 +154,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
@@ -175,14 +175,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

2
gradlew.bat vendored
View File

@@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,

View File

@@ -57,7 +57,7 @@ set_property(TARGET hal PROPERTY FOLDER "libraries")
install(TARGETS hal EXPORT hal DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen DESTINATION "${include_dest}/hal")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen/ DESTINATION "${include_dest}/hal")
if (MSVC OR FLAT_INSTALL_WPILIB)
set (hal_config_dir ${wpilib_dest})

View File

@@ -185,3 +185,14 @@ nativeUtils.exportsConfigs {
}
}
}
model {
binaries {
all {
if (!(it instanceof NativeBinarySpec)) return
if (it.component.name != 'hal' && it.component.name != 'halBase') return
if (it.targetPlatform.name != nativeUtils.wpi.platforms.roborio) return
nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared')
}
}
}

View File

@@ -1,14 +1,54 @@
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// ifdef's definition is to allow for default parameters in C++.
#ifdef __cplusplus
/**
* Reports a hardware usage to the HAL.
*
* @param resource the used resource
* @param instanceNumber the instance of the resource
* @param context a user specified context index
* @param feature a user specified feature string
* @return the index of the added value in NetComm
*/
int64_t HAL_Report(int32_t resource, int32_t instanceNumber,
int32_t context = 0, const char* feature = nullptr);
#else
/**
* Reports a hardware usage to the HAL.
*
* @param resource the used resource
* @param instanceNumber the instance of the resource
* @param context a user specified context index
* @param feature a user specified feature string
* @return the index of the added value in NetComm
*/
int64_t HAL_Report(int32_t resource, int32_t instanceNumber, int32_t context,
const char* feature);
#endif
#ifdef __cplusplus
}
#endif
/*
* Autogenerated file! Do not manually edit this file.
*/
#ifdef __cplusplus
namespace HALUsageReporting {
typedef enum {
enum tResourceType : int32_t {
${usage_reporting_types_cpp}
} tResourceType;
typedef enum {
};
enum tInstances : int32_t {
${usage_reporting_instances_cpp}
} tInstances;
};
}
#endif

View File

@@ -3,6 +3,7 @@ kLanguage_CPlusPlus = 2
kLanguage_Java = 3
kLanguage_Python = 4
kLanguage_DotNet = 5
kLanguage_Kotlin = 6
kCANPlugin_BlackJagBridge = 1
kCANPlugin_2CAN = 2
kFramework_Iterative = 1
@@ -41,4 +42,11 @@ kDriverStationEIO_TouchSlider = 11
kADXL345_SPI = 1
kADXL345_I2C = 2
kCommand_Scheduler = 1
kCommand2_Scheduler = 2
kSmartDashboard_Instance = 1
kKinematics_DifferentialDrive = 1
kKinematics_MecanumDrive = 2
kKinematics_SwerveDrive = 3
kOdometry_DifferentialDrive = 1
kOdometry_MecanumDrive = 2
kOdometry_SwerveDrive = 3

View File

@@ -62,7 +62,7 @@ kResourceType_PCM = 60
kResourceType_PigeonIMU = 61
kResourceType_NidecBrushless = 62
kResourceType_CANifier = 63
kResourceType_CTRE_future0 = 64
kResourceType_TalonFX = 64
kResourceType_CTRE_future1 = 65
kResourceType_CTRE_future2 = 66
kResourceType_CTRE_future3 = 67
@@ -83,3 +83,12 @@ kResourceType_PWMVictorSPX = 81
kResourceType_RevSparkMaxPWM = 82
kResourceType_RevSparkMaxCAN = 83
kResourceType_ADIS16470 = 84
kResourceType_PIDController2 = 85
kResourceType_ProfiledPIDController = 86
kResourceType_Kinematics = 87
kResourceType_Odometry = 88
kResourceType_Units = 89
kResourceType_TrapezoidProfile = 90
kResourceType_DutyCycle = 91
kResourceType_AddressableLEDs = 92
kResourceType_FusionVenom = 93

View File

@@ -0,0 +1,23 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class AddressableLEDJNI extends JNIWrapper {
public static native int initialize(int pwmHandle);
public static native void free(int handle);
public static native void setLength(int handle, int length);
public static native void setData(int handle, byte[] data);
public static native void setBitTiming(int handle, int lowTime0, int highTime0, int lowTime1, int highTime1);
public static native void setSyncTime(int handle, int syncTime);
public static native void start(int handle);
public static native void stop(int handle);
}

View File

@@ -7,8 +7,6 @@
package edu.wpi.first.hal;
import java.nio.IntBuffer;
public class AnalogJNI extends JNIWrapper {
/**
* <i>native declaration : AthenaJava\target\native\include\HAL\Analog.h:58</i><br> enum values
@@ -94,13 +92,18 @@ public class AnalogJNI extends JNIWrapper {
public static native void getAccumulatorOutput(int analogPortHandle, AccumulatorResult result);
public static native int initializeAnalogTrigger(int analogInputHandle, IntBuffer index);
public static native int initializeAnalogTrigger(int analogInputHandle);
public static native int initializeAnalogTriggerDutyCycle(int dutyCycleHandle);
public static native void cleanAnalogTrigger(int analogTriggerHandle);
public static native void setAnalogTriggerLimitsRaw(int analogTriggerHandle, int lower,
int upper);
public static native void setAnalogTriggerLimitsDutyCycle(int analogTriggerHandle, double lower,
double higher);
public static native void setAnalogTriggerLimitsVoltage(int analogTriggerHandle,
double lower, double upper);
@@ -115,4 +118,7 @@ public class AnalogJNI extends JNIWrapper {
public static native boolean getAnalogTriggerTriggerState(int analogTriggerHandle);
public static native boolean getAnalogTriggerOutput(int analogTriggerHandle, int type);
@SuppressWarnings("AbbreviationAsWordInName")
public static native int getAnalogTriggerFPGAIndex(int analogTriggerHandle);
}

View File

@@ -0,0 +1,21 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal;
public class DutyCycleJNI extends JNIWrapper {
public static native int initialize(int digitalSourceHandle, int analogTriggerType);
public static native void free(int handle);
public static native int getFrequency(int handle);
public static native double getOutput(int handle);
public static native int getOutputRaw(int handle);
public static native int getOutputScaleFactor(int handle);
@SuppressWarnings("AbbreviationAsWordInName")
public static native int getFPGAIndex(int handle);
}

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -130,6 +130,8 @@ public final class HAL extends JNIWrapper {
String details, String location, String callStack,
boolean printMsg);
public static native int sendConsoleLine(String line);
public static native int getPortWithModule(byte module, byte channel);
public static native int getPort(byte channel);

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -38,4 +38,6 @@ public class InterruptJNI extends JNIWrapper {
public static native void setInterruptUpSourceEdge(int interruptHandle, boolean risingEdge,
boolean fallingEdge);
public static native void releaseWaitingInterrupt(int interruptHandle);
}

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -19,6 +19,11 @@ public class NotifierJNI extends JNIWrapper {
*/
public static native int initializeNotifier();
/**
* Sets the name of the notifier.
*/
public static native void setNotifierName(int notifierHandle, String name);
/**
* Wakes up the waiter with time=0. Note: after this function is called, all
* calls to waitForNotifierAlarm() will immediately start returning 0.

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -21,6 +21,8 @@ public class PDPJNI extends JNIWrapper {
public static native double getPDPChannelCurrent(byte channel, int handle);
public static native void getPDPAllCurrents(int handle, double[] currents);
public static native double getPDPTotalCurrent(int handle);
public static native double getPDPTotalPower(int handle);

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -61,4 +61,6 @@ public class SPIJNI extends JNIWrapper {
double timeout);
public static native int spiGetAutoDroppedCount(int port);
public static native void spiConfigureAutoStall(int port, int csToSclkTicks, int stallTicks, int pow2BytesPerRead);
}

View File

@@ -0,0 +1,77 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim;
import edu.wpi.first.hal.sim.mockdata.AddressableLEDDataJNI;
public class AddressableLEDSim {
private final int m_index;
public AddressableLEDSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return AddressableLEDDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
AddressableLEDDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerOutputPortCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerOutputPortCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelOutputPortCallback);
}
public int getOutputPort() {
return AddressableLEDDataJNI.getOutputPort(m_index);
}
public void setOutputPort(int outputPort) {
AddressableLEDDataJNI.setOutputPort(m_index, outputPort);
}
public CallbackStore registerLengthCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerLengthCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelLengthCallback);
}
public int getLength() {
return AddressableLEDDataJNI.getLength(m_index);
}
public void setLength(int length) {
AddressableLEDDataJNI.setLength(m_index, length);
}
public CallbackStore registerRunningCallback(NotifyCallback callback, boolean initialNotify) {
int uid = AddressableLEDDataJNI.registerRunningCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelRunningCallback);
}
public boolean getRunning() {
return AddressableLEDDataJNI.getRunning(m_index);
}
public void setRunning(boolean running) {
AddressableLEDDataJNI.setRunning(m_index, running);
}
public CallbackStore registerDataCallback(ConstBufferCallback callback) {
int uid = AddressableLEDDataJNI.registerDataCallback(m_index, callback);
return new CallbackStore(m_index, uid, AddressableLEDDataJNI::cancelDataCallback);
}
public byte[] getData() {
return AddressableLEDDataJNI.getData(m_index);
}
public void setData(byte[] data) {
AddressableLEDDataJNI.setData(m_index, data);
}
public void resetData() {
AddressableLEDDataJNI.resetData(m_index);
}
}

View File

@@ -79,6 +79,15 @@ public class DriverStationSim {
DriverStationDataJNI.notifyNewData();
}
/**
* Toggles suppression of DriverStation.reportError and reportWarning messages.
*
* @param shouldSend If false then messages will will be suppressed.
*/
public void setSendError(boolean shouldSend) {
DriverStationDataJNI.setSendError(shouldSend);
}
public void resetData() {
DriverStationDataJNI.resetData();
}

View File

@@ -0,0 +1,51 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim;
import edu.wpi.first.hal.sim.mockdata.DutyCycleDataJNI;
public class DutyCycleSim {
private final int m_index;
public DutyCycleSim(int index) {
m_index = index;
}
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DutyCycleDataJNI.registerInitializedCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DutyCycleDataJNI::cancelInitializedCallback);
}
public boolean getInitialized() {
return DutyCycleDataJNI.getInitialized(m_index);
}
public void setInitialized(boolean initialized) {
DutyCycleDataJNI.setInitialized(m_index, initialized);
}
public CallbackStore registerFrequencyCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DutyCycleDataJNI.registerFrequencyCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DutyCycleDataJNI::cancelFrequencyCallback);
}
public int getFrequency() {
return DutyCycleDataJNI.getFrequency(m_index);
}
public void setFrequency(int frequency) {
DutyCycleDataJNI.setFrequency(m_index, frequency);
}
public CallbackStore registerOutputCallback(NotifyCallback callback, boolean initialNotify) {
int uid = DutyCycleDataJNI.registerOutputCallback(m_index, callback, initialNotify);
return new CallbackStore(m_index, uid, DutyCycleDataJNI::cancelOutputCallback);
}
public double getOutput() {
return DutyCycleDataJNI.getOutput(m_index);
}
public void setOutput(double output) {
DutyCycleDataJNI.setOutput(m_index, output);
}
}

View File

@@ -0,0 +1,23 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim;
import edu.wpi.first.hal.sim.mockdata.NotifierDataJNI;
public final class NotifierSim {
private NotifierSim() {
}
public static long getNextTimeout() {
return NotifierDataJNI.getNextTimeout();
}
public static int getNumNotifiers() {
return NotifierDataJNI.getNumNotifiers();
}
}

View File

@@ -0,0 +1,94 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim;
import edu.wpi.first.hal.SimBoolean;
import edu.wpi.first.hal.SimDouble;
import edu.wpi.first.hal.SimEnum;
import edu.wpi.first.hal.SimValue;
import edu.wpi.first.hal.sim.mockdata.SimDeviceDataJNI;
public class SimDeviceSim {
private final int m_handle;
public SimDeviceSim(String name) {
m_handle = SimDeviceDataJNI.getSimDeviceHandle(name);
}
public SimValue getValue(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimValue(handle);
}
public SimDouble getDouble(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimDouble(handle);
}
public SimEnum getEnum(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimEnum(handle);
}
public SimBoolean getBoolean(String name) {
int handle = SimDeviceDataJNI.getSimValueHandle(m_handle, name);
if (handle <= 0) {
return null;
}
return new SimBoolean(handle);
}
public static String[] getEnumOptions(SimEnum val) {
return SimDeviceDataJNI.getSimValueEnumOptions(val.getNativeHandle());
}
public SimDeviceDataJNI.SimValueInfo[] enumerateValues() {
return SimDeviceDataJNI.enumerateSimValues(m_handle);
}
public int getNativeHandle() {
return m_handle;
}
public CallbackStore registerValueCreatedCallback(SimValueCallback callback, boolean initialNotify) {
int uid = SimDeviceDataJNI.registerSimValueCreatedCallback(m_handle, callback, initialNotify);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimValueCreatedCallback);
}
public CallbackStore registerValueChangedCallback(SimValueCallback callback, boolean initialNotify) {
int uid = SimDeviceDataJNI.registerSimValueChangedCallback(m_handle, callback, initialNotify);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimValueChangedCallback);
}
public static SimDeviceDataJNI.SimDeviceInfo[] enumerateDevices(String prefix) {
return SimDeviceDataJNI.enumerateSimDevices(prefix);
}
public CallbackStore registerDeviceCreatedCallback(String prefix, SimDeviceCallback callback, boolean initialNotify) {
int uid = SimDeviceDataJNI.registerSimDeviceCreatedCallback(prefix, callback, initialNotify);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimDeviceCreatedCallback);
}
public CallbackStore registerDeviceFreedCallback(String prefix, SimDeviceCallback callback) {
int uid = SimDeviceDataJNI.registerSimDeviceFreedCallback(prefix, callback);
return new CallbackStore(uid, SimDeviceDataJNI::cancelSimDeviceFreedCallback);
}
public static void resetData() {
SimDeviceDataJNI.resetSimDeviceData();
}
}

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -24,4 +24,20 @@ public final class SimHooks {
public static void restartTiming() {
SimulatorJNI.restartTiming();
}
public static void pauseTiming() {
SimulatorJNI.pauseTiming();
}
public static void resumeTiming() {
SimulatorJNI.resumeTiming();
}
public static boolean isTimingPaused() {
return SimulatorJNI.isTimingPaused();
}
public static void stepTiming(long delta) {
SimulatorJNI.stepTiming(delta);
}
}

View File

@@ -0,0 +1,41 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.hal.sim.ConstBufferCallback;
import edu.wpi.first.hal.sim.NotifyCallback;
import edu.wpi.first.hal.JNIWrapper;
public class AddressableLEDDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerOutputPortCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelOutputPortCallback(int index, int uid);
public static native int getOutputPort(int index);
public static native void setOutputPort(int index, int outputPort);
public static native int registerLengthCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelLengthCallback(int index, int uid);
public static native int getLength(int index);
public static native void setLength(int index, int length);
public static native int registerRunningCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelRunningCallback(int index, int uid);
public static native boolean getRunning(int index);
public static native void setRunning(int index, boolean running);
public static native int registerDataCallback(int index, ConstBufferCallback callback);
public static native void cancelDataCallback(int index, int uid);
public static native byte[] getData(int index);
public static native void setData(int index, byte[] data);
public static native void resetData(int index);
}

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -49,5 +49,8 @@ public class DriverStationDataJNI extends JNIWrapper {
public static native void registerAllCallbacks(NotifyCallback callback, boolean initialNotify);
public static native void notifyNewData();
public static native void setSendError(boolean shouldSend);
public static native void setSendConsoleLine(boolean shouldSend);
public static native void resetData();
}

View File

@@ -0,0 +1,30 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.hal.sim.NotifyCallback;
import edu.wpi.first.hal.JNIWrapper;
public class DutyCycleDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerFrequencyCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelFrequencyCallback(int index, int uid);
public static native int getFrequency(int index);
public static native void setFrequency(int index, int frequency);
public static native int registerOutputCallback(int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelOutputCallback(int index, int uid);
public static native double getOutput(int index);
public static native void setOutput(int index, double output);
public static native void resetData(int index);
}

View File

@@ -0,0 +1,15 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.hal.sim.mockdata;
import edu.wpi.first.hal.JNIWrapper;
public class NotifierDataJNI extends JNIWrapper {
public static native long getNextTimeout();
public static native int getNumNotifiers();
}

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -13,5 +13,9 @@ public class SimulatorJNI extends JNIWrapper {
public static native void waitForProgramStart();
public static native void setProgramStarted();
public static native void restartTiming();
public static native void pauseTiming();
public static native void resumeTiming();
public static native boolean isTimingPaused();
public static native void stepTiming(long delta);
public static native void resetHandles();
}

View File

@@ -0,0 +1,243 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "hal/AddressableLED.h"
#include <cstring>
#include <FRC_FPGA_ChipObject/fpgainterfacecapi/NiFpga_HMB.h>
#include "ConstantsInternal.h"
#include "DigitalInternal.h"
#include "HALInitializer.h"
#include "PortsInternal.h"
#include "hal/ChipObject.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/LimitedHandleResource.h"
using namespace hal;
namespace {
struct AddressableLED {
std::unique_ptr<tLED> led;
void* ledBuffer;
size_t ledBufferSize;
int32_t stringLength = 1;
};
} // namespace
static LimitedHandleResource<
HAL_AddressableLEDHandle, AddressableLED, kNumAddressableLEDs,
HAL_HandleEnum::AddressableLED>* addressableLEDHandles;
namespace hal {
namespace init {
void InitializeAddressableLED() {
static LimitedHandleResource<HAL_AddressableLEDHandle, AddressableLED,
kNumAddressableLEDs,
HAL_HandleEnum::AddressableLED>
alH;
addressableLEDHandles = &alH;
}
} // namespace init
} // namespace hal
extern "C" {
HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
HAL_DigitalHandle outputPort, int32_t* status) {
hal::init::CheckInit();
auto digitalPort =
hal::digitalChannelHandles->Get(outputPort, hal::HAL_HandleEnum::PWM);
if (!digitalPort) {
// If DIO was passed, channel error, else generic error
if (getHandleType(outputPort) == hal::HAL_HandleEnum::DIO) {
*status = HAL_LED_CHANNEL_ERROR;
} else {
*status = HAL_HANDLE_ERROR;
}
return HAL_kInvalidHandle;
}
if (digitalPort->channel >= kNumPWMHeaders) {
*status = HAL_LED_CHANNEL_ERROR;
return HAL_kInvalidHandle;
}
auto handle = addressableLEDHandles->Allocate();
if (handle == HAL_kInvalidHandle) {
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
}
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
led->led.reset(tLED::create(status));
if (*status != 0) {
addressableLEDHandles->Free(handle);
return HAL_kInvalidHandle;
}
led->led->writeOutputSelect(digitalPort->channel, status);
if (*status != 0) {
addressableLEDHandles->Free(handle);
return HAL_kInvalidHandle;
}
led->ledBuffer = nullptr;
led->ledBufferSize = 0;
uint32_t session = led->led->getSystemInterface()->getHandle();
*status = NiFpga_OpenHostMemoryBuffer(session, "HMB_0_LED", &led->ledBuffer,
&led->ledBufferSize);
if (*status != 0) {
addressableLEDHandles->Free(handle);
return HAL_kInvalidHandle;
}
return handle;
}
void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {
addressableLEDHandles->Free(handle);
}
void HAL_SetAddressableLEDOutputPort(HAL_AddressableLEDHandle handle,
HAL_DigitalHandle outputPort,
int32_t* status) {
auto digitalPort =
hal::digitalChannelHandles->Get(outputPort, hal::HAL_HandleEnum::PWM);
if (!digitalPort) {
*status = HAL_HANDLE_ERROR;
return;
}
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}
led->led->writeOutputSelect(digitalPort->channel, status);
}
void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
int32_t length, int32_t* status) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}
if (length > HAL_kAddressableLEDMaxLength) {
*status = PARAMETER_OUT_OF_RANGE;
return;
}
led->led->strobeReset(status);
while (led->led->readPixelWriteIndex(status) != 0) {
}
if (*status != 0) {
return;
}
led->led->writeStringLength(length, status);
led->stringLength = length;
}
static_assert(sizeof(HAL_AddressableLEDData) == sizeof(uint32_t),
"LED Data must be 32 bit");
void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
const struct HAL_AddressableLEDData* data,
int32_t length, int32_t* status) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}
if (length > led->stringLength) {
*status = PARAMETER_OUT_OF_RANGE;
return;
}
std::memcpy(led->ledBuffer, data, length * sizeof(HAL_AddressableLEDData));
asm("dmb");
led->led->strobeLoad(status);
}
void HAL_SetAddressableLEDBitTiming(HAL_AddressableLEDHandle handle,
int32_t lowTime0NanoSeconds,
int32_t highTime0NanoSeconds,
int32_t lowTime1NanoSeconds,
int32_t highTime1NanoSeconds,
int32_t* status) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}
led->led->writeLowBitTickTiming(1, highTime0NanoSeconds / 25, status);
led->led->writeLowBitTickTiming(0, lowTime0NanoSeconds / 25, status);
led->led->writeHighBitTickTiming(1, highTime1NanoSeconds / 25, status);
led->led->writeHighBitTickTiming(0, lowTime1NanoSeconds / 25, status);
}
void HAL_SetAddressableLEDSyncTime(HAL_AddressableLEDHandle handle,
int32_t syncTimeMicroSeconds,
int32_t* status) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}
led->led->writeSyncTiming(syncTimeMicroSeconds, status);
}
void HAL_StartAddressableLEDOutput(HAL_AddressableLEDHandle handle,
int32_t* status) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}
led->led->strobeStart(status);
}
void HAL_StopAddressableLEDOutput(HAL_AddressableLEDHandle handle,
int32_t* status) {
auto led = addressableLEDHandles->Get(handle);
if (!led) {
*status = HAL_HANDLE_ERROR;
return;
}
led->led->strobeAbort(status);
}
} // extern "C"

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -181,7 +181,7 @@ void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
if (*status != 0) return;
gyro->center = static_cast<int32_t>(
static_cast<double>(value) / static_cast<double>(count) + .5);
static_cast<double>(value) / static_cast<double>(count) + 0.5);
gyro->offset = static_cast<double>(value) / static_cast<double>(count) -
static_cast<double>(gyro->center);

View File

@@ -201,6 +201,14 @@ double HAL_GetAnalogVoltage(HAL_AnalogInputHandle analogPortHandle,
return voltage;
}
double HAL_GetAnalogValueToVolts(HAL_AnalogInputHandle analogPortHandle,
int32_t rawValue, int32_t* status) {
int32_t LSBWeight = HAL_GetAnalogLSBWeight(analogPortHandle, status);
int32_t offset = HAL_GetAnalogOffset(analogPortHandle, status);
double voltage = LSBWeight * 1.0e-9 * rawValue - offset * 1.0e-9;
return voltage;
}
double HAL_GetAnalogAverageVoltage(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
int32_t value = HAL_GetAnalogAverageValue(analogPortHandle, status);
@@ -216,26 +224,38 @@ double HAL_GetAnalogAverageVoltage(HAL_AnalogInputHandle analogPortHandle,
int32_t HAL_GetAnalogLSBWeight(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
int32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(
0, port->channel, status); // XXX: aiSystemIndex == 0?
return lsbWeight;
// On the roboRIO, LSB is the same for all channels. So the channel lookup can
// be avoided
return FRC_NetworkCommunication_nAICalibration_getLSBWeight(0, 0, status);
// Keep the old code for future hardware
// auto port = analogInputHandles->Get(analogPortHandle);
// if (port == nullptr) {
// *status = HAL_HANDLE_ERROR;
// return 0;
// }
// int32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(
// 0, port->channel, status); // XXX: aiSystemIndex == 0?
// return lsbWeight;
}
int32_t HAL_GetAnalogOffset(HAL_AnalogInputHandle analogPortHandle,
int32_t* status) {
auto port = analogInputHandles->Get(analogPortHandle);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
int32_t offset = FRC_NetworkCommunication_nAICalibration_getOffset(
0, port->channel, status); // XXX: aiSystemIndex == 0?
return offset;
// On the roboRIO, offset is the same for all channels. So the channel lookup
// can be avoided
return FRC_NetworkCommunication_nAICalibration_getOffset(0, 0, status);
// Keep the old code for future hardware
// auto port = analogInputHandles->Get(analogPortHandle);
// if (port == nullptr) {
// *status = HAL_HANDLE_ERROR;
// return 0;
// }
// int32_t offset = FRC_NetworkCommunication_nAICalibration_getOffset(
// 0, port->channel, status); // XXX: aiSystemIndex == 0?
// return offset;
}
} // extern "C"

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -8,9 +8,11 @@
#include "hal/AnalogTrigger.h"
#include "AnalogInternal.h"
#include "DutyCycleInternal.h"
#include "HALInitializer.h"
#include "PortsInternal.h"
#include "hal/AnalogInput.h"
#include "hal/DutyCycle.h"
#include "hal/Errors.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/LimitedHandleResource.h"
@@ -21,7 +23,7 @@ namespace {
struct AnalogTrigger {
std::unique_ptr<tAnalogTrigger> trigger;
HAL_AnalogInputHandle analogHandle;
HAL_Handle handle;
uint8_t index;
};
@@ -46,7 +48,7 @@ void InitializeAnalogTrigger() {
extern "C" {
HAL_AnalogTriggerHandle HAL_InitializeAnalogTrigger(
HAL_AnalogInputHandle portHandle, int32_t* index, int32_t* status) {
HAL_AnalogInputHandle portHandle, int32_t* status) {
hal::init::CheckInit();
// ensure we are given a valid and active AnalogInput handle
auto analog_port = analogInputHandles->Get(portHandle);
@@ -64,19 +66,46 @@ HAL_AnalogTriggerHandle HAL_InitializeAnalogTrigger(
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
trigger->analogHandle = portHandle;
trigger->handle = portHandle;
trigger->index = static_cast<uint8_t>(getHandleIndex(handle));
*index = trigger->index;
trigger->trigger.reset(tAnalogTrigger::create(trigger->index, status));
trigger->trigger->writeSourceSelect_Channel(analog_port->channel, status);
return handle;
}
HAL_AnalogTriggerHandle HAL_InitializeAnalogTriggerDutyCycle(
HAL_DutyCycleHandle dutyCycleHandle, int32_t* status) {
hal::init::CheckInit();
// ensure we are given a valid and active DutyCycle handle
auto dutyCycle = dutyCycleHandles->Get(dutyCycleHandle);
if (dutyCycle == nullptr) {
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
HAL_AnalogTriggerHandle handle = analogTriggerHandles->Allocate();
if (handle == HAL_kInvalidHandle) {
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
}
auto trigger = analogTriggerHandles->Get(handle);
if (trigger == nullptr) { // would only occur on thread issue
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
trigger->handle = dutyCycleHandle;
trigger->index = static_cast<uint8_t>(getHandleIndex(handle));
trigger->trigger.reset(tAnalogTrigger::create(trigger->index, status));
trigger->trigger->writeSourceSelect_Channel(dutyCycle->index, status);
trigger->trigger->writeSourceSelect_DutyCycle(true, status);
return handle;
}
void HAL_CleanAnalogTrigger(HAL_AnalogTriggerHandle analogTriggerHandle,
int32_t* status) {
analogTriggerHandles->Free(analogTriggerHandle);
// caller owns the analog input handle.
// caller owns the input handle.
}
void HAL_SetAnalogTriggerLimitsRaw(HAL_AnalogTriggerHandle analogTriggerHandle,
@@ -89,11 +118,46 @@ void HAL_SetAnalogTriggerLimitsRaw(HAL_AnalogTriggerHandle analogTriggerHandle,
}
if (lower > upper) {
*status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR;
return;
}
trigger->trigger->writeLowerLimit(lower, status);
trigger->trigger->writeUpperLimit(upper, status);
}
void HAL_SetAnalogTriggerLimitsDutyCycle(
HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
int32_t* status) {
auto trigger = analogTriggerHandles->Get(analogTriggerHandle);
if (trigger == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
if (getHandleType(trigger->handle) != HAL_HandleEnum::DutyCycle) {
*status = HAL_HANDLE_ERROR;
return;
}
if (lower > upper) {
*status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR;
return;
}
if (lower < 0.0 || upper > 1.0) {
*status = PARAMETER_OUT_OF_RANGE;
return;
}
int32_t scaleFactor =
HAL_GetDutyCycleOutputScaleFactor(trigger->handle, status);
if (*status != 0) {
return;
}
trigger->trigger->writeLowerLimit(static_cast<int32_t>(scaleFactor * lower),
status);
trigger->trigger->writeUpperLimit(static_cast<int32_t>(scaleFactor * upper),
status);
}
void HAL_SetAnalogTriggerLimitsVoltage(
HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
int32_t* status) {
@@ -102,16 +166,22 @@ void HAL_SetAnalogTriggerLimitsVoltage(
*status = HAL_HANDLE_ERROR;
return;
}
if (getHandleType(trigger->handle) != HAL_HandleEnum::AnalogInput) {
*status = HAL_HANDLE_ERROR;
return;
}
if (lower > upper) {
*status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR;
return;
}
// TODO: This depends on the averaged setting. Only raw values will work as
// is.
trigger->trigger->writeLowerLimit(
HAL_GetAnalogVoltsToValue(trigger->analogHandle, lower, status), status);
HAL_GetAnalogVoltsToValue(trigger->handle, lower, status), status);
trigger->trigger->writeUpperLimit(
HAL_GetAnalogVoltsToValue(trigger->analogHandle, upper, status), status);
HAL_GetAnalogVoltsToValue(trigger->handle, upper, status), status);
}
void HAL_SetAnalogTriggerAveraged(HAL_AnalogTriggerHandle analogTriggerHandle,
@@ -121,7 +191,8 @@ void HAL_SetAnalogTriggerAveraged(HAL_AnalogTriggerHandle analogTriggerHandle,
*status = HAL_HANDLE_ERROR;
return;
}
if (trigger->trigger->readSourceSelect_Filter(status) != 0) {
if (trigger->trigger->readSourceSelect_Filter(status) != 0 ||
trigger->trigger->readSourceSelect_DutyCycle(status) != 0) {
*status = INCOMPATIBLE_STATE;
// TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not
// support average and filtering at the same time.");
@@ -136,7 +207,8 @@ void HAL_SetAnalogTriggerFiltered(HAL_AnalogTriggerHandle analogTriggerHandle,
*status = HAL_HANDLE_ERROR;
return;
}
if (trigger->trigger->readSourceSelect_Averaged(status) != 0) {
if (trigger->trigger->readSourceSelect_Averaged(status) != 0 ||
trigger->trigger->readSourceSelect_DutyCycle(status) != 0) {
*status = INCOMPATIBLE_STATE;
// TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not "
// "support average and filtering at the same time.");
@@ -177,16 +249,27 @@ HAL_Bool HAL_GetAnalogTriggerOutput(HAL_AnalogTriggerHandle analogTriggerHandle,
case HAL_Trigger_kInWindow:
result =
trigger->trigger->readOutput_InHysteresis(trigger->index, status);
break; // XXX: Backport
break;
case HAL_Trigger_kState:
result = trigger->trigger->readOutput_OverLimit(trigger->index, status);
break; // XXX: Backport
break;
case HAL_Trigger_kRisingPulse:
case HAL_Trigger_kFallingPulse:
*status = ANALOG_TRIGGER_PULSE_OUTPUT_ERROR;
return false;
break;
}
return result;
}
int32_t HAL_GetAnalogTriggerFPGAIndex(
HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status) {
auto trigger = analogTriggerHandles->Get(analogTriggerHandle);
if (trigger == nullptr) {
*status = HAL_HANDLE_ERROR;
return -1;
}
return trigger->index;
}
} // extern "C"

File diff suppressed because it is too large Load Diff

View File

@@ -103,9 +103,9 @@ void initializeDigital(int32_t* status) {
(kSystemClockTicksPerMicrosecond * 1e3);
pwmSystem->writeConfig_Period(
static_cast<uint16_t>(kDefaultPwmPeriod / loopTime + .5), status);
static_cast<uint16_t>(kDefaultPwmPeriod / loopTime + 0.5), status);
uint16_t minHigh = static_cast<uint16_t>(
(kDefaultPwmCenter - kDefaultPwmStepsDown * loopTime) / loopTime + .5);
(kDefaultPwmCenter - kDefaultPwmStepsDown * loopTime) / loopTime + 0.5);
pwmSystem->writeConfig_MinHigh(minHigh, status);
// Ensure that PWM output values are set to OFF
for (uint8_t pwmIndex = 0; pwmIndex < kNumPWMChannels; pwmIndex++) {

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -96,6 +96,20 @@ bool remapDigitalSource(HAL_Handle digitalSourceHandle,
HAL_AnalogTriggerType analogTriggerType,
uint8_t& channel, uint8_t& module, bool& analogTrigger);
/**
* Remap the Digital Channel to map to the bitfield channel of the FPGA
*/
constexpr int32_t remapDigitalChannelToBitfieldChannel(int32_t channel) {
// First 10 are headers
if (channel < kNumDigitalHeaders) return channel;
// 2nd group of 16 are mxp. So if mxp port, add 6, since they start at 10
else if (channel < kNumDigitalMXPChannels)
return channel + 6;
// Assume SPI, so remove MXP channels
else
return channel - kNumDigitalMXPChannels;
}
/**
* Map DIO channel numbers from their physical number (10 to 26) to their
* position in the bit field.

View File

@@ -0,0 +1,127 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include "hal/DutyCycle.h"
#include <memory>
#include "DigitalInternal.h"
#include "DutyCycleInternal.h"
#include "HALInitializer.h"
#include "PortsInternal.h"
#include "hal/ChipObject.h"
#include "hal/Errors.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/LimitedHandleResource.h"
using namespace hal;
namespace hal {
LimitedHandleResource<HAL_DutyCycleHandle, DutyCycle, kNumDutyCycles,
HAL_HandleEnum::DutyCycle>* dutyCycleHandles;
namespace init {
void InitializeDutyCycle() {
static LimitedHandleResource<HAL_DutyCycleHandle, DutyCycle, kNumDutyCycles,
HAL_HandleEnum::DutyCycle>
dcH;
dutyCycleHandles = &dcH;
}
} // namespace init
} // namespace hal
static constexpr int32_t kScaleFactor = 4e7 - 1;
extern "C" {
HAL_DutyCycleHandle HAL_InitializeDutyCycle(HAL_Handle digitalSourceHandle,
HAL_AnalogTriggerType triggerType,
int32_t* status) {
hal::init::CheckInit();
bool routingAnalogTrigger = false;
uint8_t routingChannel = 0;
uint8_t routingModule = 0;
bool success =
remapDigitalSource(digitalSourceHandle, triggerType, routingChannel,
routingModule, routingAnalogTrigger);
if (!success) {
*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}
HAL_DutyCycleHandle handle = dutyCycleHandles->Allocate();
if (handle == HAL_kInvalidHandle) {
*status = NO_AVAILABLE_RESOURCES;
return HAL_kInvalidHandle;
}
auto dutyCycle = dutyCycleHandles->Get(handle);
uint32_t index = static_cast<uint32_t>(getHandleIndex(handle));
dutyCycle->dutyCycle.reset(tDutyCycle::create(index, status));
dutyCycle->dutyCycle->writeSource_AnalogTrigger(routingAnalogTrigger, status);
dutyCycle->dutyCycle->writeSource_Channel(routingChannel, status);
dutyCycle->dutyCycle->writeSource_Module(routingModule, status);
dutyCycle->index = index;
return handle;
}
void HAL_FreeDutyCycle(HAL_DutyCycleHandle dutyCycleHandle) {
// Just free it, the unique ptr will take care of everything else
dutyCycleHandles->Free(dutyCycleHandle);
}
void HAL_SetDutyCycleSimDevice(HAL_EncoderHandle handle,
HAL_SimDeviceHandle device) {}
int32_t HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status) {
auto dutyCycle = dutyCycleHandles->Get(dutyCycleHandle);
if (!dutyCycle) {
*status = HAL_HANDLE_ERROR;
return 0;
}
// TODO Handle Overflow
unsigned char overflow = 0;
return dutyCycle->dutyCycle->readFrequency(&overflow, status);
}
double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status) {
return HAL_GetDutyCycleOutputRaw(dutyCycleHandle, status) /
static_cast<double>(kScaleFactor);
}
int32_t HAL_GetDutyCycleOutputRaw(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status) {
auto dutyCycle = dutyCycleHandles->Get(dutyCycleHandle);
if (!dutyCycle) {
*status = HAL_HANDLE_ERROR;
return 0;
}
// TODO Handle Overflow
unsigned char overflow = 0;
return dutyCycle->dutyCycle->readOutput(&overflow, status);
}
int32_t HAL_GetDutyCycleOutputScaleFactor(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status) {
return kScaleFactor;
}
int32_t HAL_GetDutyCycleFPGAIndex(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status) {
auto dutyCycle = dutyCycleHandles->Get(dutyCycleHandle);
if (!dutyCycle) {
*status = HAL_HANDLE_ERROR;
return -1;
}
return dutyCycle->index;
}
} // extern "C"

View File

@@ -0,0 +1,24 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <memory>
#include "hal/ChipObject.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/LimitedHandleResource.h"
namespace hal {
struct DutyCycle {
std::unique_ptr<tDutyCycle> dutyCycle;
int index;
};
extern LimitedHandleResource<HAL_DutyCycleHandle, DutyCycle, kNumDutyCycles,
HAL_HandleEnum::DutyCycle>* dutyCycleHandles;
} // namespace hal

View File

@@ -35,7 +35,7 @@ Encoder::Encoder(HAL_Handle digitalSourceHandleA,
return;
}
m_counter = HAL_kInvalidHandle;
SetMaxPeriod(.5, status);
SetMaxPeriod(0.5, status);
break;
}
case HAL_Encoder_k1X:
@@ -238,6 +238,19 @@ void InitializeEncoder() {
} // namespace init
} // namespace hal
namespace hal {
bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
HAL_FPGAEncoderHandle* fpgaHandle,
HAL_CounterHandle* counterHandle) {
auto encoder = encoderHandles->Get(handle);
if (!handle) return false;
*fpgaHandle = encoder->m_encoder;
*counterHandle = encoder->m_counter;
return true;
}
} // namespace hal
extern "C" {
HAL_EncoderHandle HAL_InitializeEncoder(
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -13,8 +13,16 @@
namespace hal {
bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
HAL_FPGAEncoderHandle* fpgaEncoderHandle,
HAL_CounterHandle* counterHandle);
class Encoder {
public:
friend bool GetEncoderBaseHandle(HAL_EncoderHandle handle,
HAL_FPGAEncoderHandle* fpgaEncoderHandle,
HAL_CounterHandle* counterHandle);
Encoder(HAL_Handle digitalSourceHandleA,
HAL_AnalogTriggerType analogTriggerTypeA,
HAL_Handle digitalSourceHandleB,

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -124,7 +124,7 @@ static int32_t HAL_GetMatchInfoInternal(HAL_MatchInfo* info) {
static wpi::mutex* newDSDataAvailableMutex;
static wpi::condition_variable* newDSDataAvailableCond;
static int newDSDataAvailableCounter{0};
static std::atomic_int newDSDataAvailableCounter{0};
namespace hal {
namespace init {
@@ -176,27 +176,27 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
if (baseLength + detailsRef.size() + locationRef.size() +
callStackRef.size() <=
65536) {
65535) {
// Pass through
retval = FRC_NetworkCommunication_sendError(isError, errorCode, isLVCode,
details, location, callStack);
} else if (baseLength + detailsRef.size() > 65536) {
} else if (baseLength + detailsRef.size() > 65535) {
// Details too long, cut both location and stack
auto newLen = 65536 - baseLength;
auto newLen = 65535 - baseLength;
std::string newDetails{details, newLen};
char empty = '\0';
retval = FRC_NetworkCommunication_sendError(
isError, errorCode, isLVCode, newDetails.c_str(), &empty, &empty);
} else if (baseLength + detailsRef.size() + locationRef.size() > 65536) {
} else if (baseLength + detailsRef.size() + locationRef.size() > 65535) {
// Location too long, cut stack
auto newLen = 65536 - baseLength - detailsRef.size();
auto newLen = 65535 - baseLength - detailsRef.size();
std::string newLocation{location, newLen};
char empty = '\0';
retval = FRC_NetworkCommunication_sendError(
isError, errorCode, isLVCode, details, newLocation.c_str(), &empty);
} else {
// Stack too long
auto newLen = 65536 - baseLength - detailsRef.size() - locationRef.size();
auto newLen = 65535 - baseLength - detailsRef.size() - locationRef.size();
std::string newCallStack{callStack, newLen};
retval = FRC_NetworkCommunication_sendError(isError, errorCode, isLVCode,
details, location,
@@ -229,6 +229,18 @@ int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
return retval;
}
int32_t HAL_SendConsoleLine(const char* line) {
wpi::StringRef lineRef{line};
if (lineRef.size() <= 65535) {
// Send directly
return FRC_NetworkCommunication_sendConsoleLine(line);
} else {
// Need to truncate
std::string newLine{line, 65535};
return FRC_NetworkCommunication_sendConsoleLine(newLine.c_str());
}
}
int32_t HAL_GetControlWord(HAL_ControlWord* controlWord) {
return HAL_GetControlWordInternal(controlWord);
}
@@ -338,14 +350,46 @@ void HAL_ObserveUserProgramTest(void) {
FRC_NetworkCommunication_observeUserProgramTest();
}
HAL_Bool HAL_IsNewControlData(void) {
static int& GetThreadLocalLastCount() {
// There is a rollover error condition here. At Packet# = n * (uintmax), this
// will return false when instead it should return true. However, this at a
// 20ms rate occurs once every 2.7 years of DS connected runtime, so not
// worth the cycles to check.
thread_local int lastCount{-1};
std::lock_guard lock{*newDSDataAvailableMutex};
int currentCount = newDSDataAvailableCounter;
return lastCount;
}
void HAL_WaitForCachedControlData(void) {
HAL_WaitForCachedControlDataTimeout(0);
}
HAL_Bool HAL_WaitForCachedControlDataTimeout(double timeout) {
int& lastCount = GetThreadLocalLastCount();
int currentCount = newDSDataAvailableCounter.load();
if (lastCount != currentCount) {
lastCount = currentCount;
return true;
}
auto timeoutTime =
std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
std::unique_lock lock{*newDSDataAvailableMutex};
while (newDSDataAvailableCounter.load() == currentCount) {
if (timeout > 0) {
auto timedOut = newDSDataAvailableCond->wait_until(lock, timeoutTime);
if (timedOut == std::cv_status::timeout) {
return false;
}
} else {
newDSDataAvailableCond->wait(lock);
}
}
return true;
}
HAL_Bool HAL_IsNewControlData(void) {
int& lastCount = GetThreadLocalLastCount();
int currentCount = newDSDataAvailableCounter.load();
if (lastCount == currentCount) return false;
lastCount = currentCount;
return true;
@@ -365,9 +409,9 @@ HAL_Bool HAL_WaitForDSDataTimeout(double timeout) {
auto timeoutTime =
std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
int currentCount = newDSDataAvailableCounter.load();
std::unique_lock lock{*newDSDataAvailableMutex};
int currentCount = newDSDataAvailableCounter;
while (newDSDataAvailableCounter == currentCount) {
while (newDSDataAvailableCounter.load() == currentCount) {
if (timeout > 0) {
auto timedOut = newDSDataAvailableCond->wait_until(lock, timeoutTime);
if (timedOut == std::cv_status::timeout) {
@@ -388,7 +432,7 @@ static void newDataOccur(uint32_t refNum) {
// to signal our threads
if (refNum != refNumber) return;
// Notify all threads
newDSDataAvailableCounter++;
newDSDataAvailableCounter.fetch_add(1);
newDSDataAvailableCond->notify_all();
}

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -24,6 +24,7 @@
#include <wpi/timestamp.h>
#include "HALInitializer.h"
#include "HALInternal.h"
#include "ctre/ctre.h"
#include "hal/ChipObject.h"
#include "hal/DriverStation.h"
@@ -42,6 +43,7 @@ using namespace hal;
namespace hal {
namespace init {
void InitializeHAL() {
InitializeAddressableLED();
InitializeAccelerometer();
InitializeAnalogAccumulator();
InitializeAnalogGyro();
@@ -56,6 +58,8 @@ void InitializeHAL() {
InitializeCounter();
InitializeDigitalInternal();
InitializeDIO();
InitializeDMA();
InitializeDutyCycle();
InitializeEncoder();
InitializeFPGAEncoder();
InitializeFRCDriverStation();
@@ -75,6 +79,15 @@ void InitializeHAL() {
InitializeThreads();
}
} // namespace init
void ReleaseFPGAInterrupt(int32_t interruptNumber) {
if (!global) {
return;
}
int32_t status = 0;
global->writeInterruptForceNumber(static_cast<unsigned char>(interruptNumber),
&status);
}
} // namespace hal
extern "C" {
@@ -212,6 +225,10 @@ const char* HAL_GetErrorMessage(int32_t code) {
return ERR_FRCSystem_NetCommNotResponding_MESSAGE;
case ERR_FRCSystem_NoDSConnection:
return ERR_FRCSystem_NoDSConnection_MESSAGE;
case HAL_CAN_BUFFER_OVERRUN:
return HAL_CAN_BUFFER_OVERRUN_MESSAGE;
case HAL_LED_CHANNEL_ERROR:
return HAL_LED_CHANNEL_ERROR_MESSAGE;
default:
return "Unknown error status";
}
@@ -253,6 +270,28 @@ uint64_t HAL_GetFPGATime(int32_t* status) {
return (upper2 << 32) + lower;
}
uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, int32_t* status) {
// Capture the current FPGA time. This will give us the upper half of the
// clock.
uint64_t fpga_time = HAL_GetFPGATime(status);
if (*status != 0) return 0;
// Now, we need to detect the case where the lower bits rolled over after we
// sampled. In that case, the upper bits will be 1 bigger than they should
// be.
// Break it into lower and upper portions.
uint32_t lower = fpga_time & 0xffffffffull;
uint64_t upper = (fpga_time >> 32) & 0xffffffff;
// The time was sampled *before* the current time, so roll it back.
if (lower < unexpanded_lower) {
--upper;
}
return (upper << 32) + static_cast<uint64_t>(unexpanded_lower);
}
HAL_Bool HAL_GetFPGAButton(int32_t* status) {
if (!global) {
*status = NiFpga_Status_ResourceNotInitialized;

View File

@@ -19,6 +19,7 @@ static inline void CheckInit() {
}
extern void InitializeAccelerometer();
extern void InitializeAddressableLED();
extern void InitializeAnalogAccumulator();
extern void InitializeAnalogGyro();
extern void InitializeAnalogInput();
@@ -32,6 +33,8 @@ extern void InitializeConstants();
extern void InitializeCounter();
extern void InitializeDigitalInternal();
extern void InitializeDIO();
extern void InitializeDMA();
extern void InitializeDutyCycle();
extern void InitializeEncoder();
extern void InitializeFPGAEncoder();
extern void InitializeFRCDriverStation();

View File

@@ -0,0 +1,15 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <stdint.h>
namespace hal {
void ReleaseFPGAInterrupt(int32_t interruptNumber);
} // namespace hal

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -13,9 +13,11 @@
#include "DigitalInternal.h"
#include "HALInitializer.h"
#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/ChipObject.h"
#include "hal/Errors.h"
#include "hal/HALBase.h"
#include "hal/handles/HandlesInternal.h"
#include "hal/handles/LimitedHandleResource.h"
@@ -64,12 +66,6 @@ class InterruptThreadOwner : public wpi::SafeThreadOwner<InterruptThread> {
}
};
} // namespace
static void threadedInterruptHandler(uint32_t mask, void* param) {
static_cast<InterruptThreadOwner*>(param)->Notify(mask);
}
struct Interrupt {
std::unique_ptr<tInterrupt> anInterrupt;
std::unique_ptr<tInterruptManager> manager;
@@ -77,6 +73,12 @@ struct Interrupt {
void* param = nullptr;
};
} // namespace
static void threadedInterruptHandler(uint32_t mask, void* param) {
static_cast<InterruptThreadOwner*>(param)->Notify(mask);
}
static LimitedHandleResource<HAL_InterruptHandle, Interrupt, kNumInterrupts,
HAL_HandleEnum::Interrupt>* interruptHandles;
@@ -118,7 +120,11 @@ void* HAL_CleanInterrupts(HAL_InterruptHandle interruptHandle,
if (anInterrupt == nullptr) {
return nullptr;
}
anInterrupt->manager->disable(status);
if (anInterrupt->manager->isEnabled(status)) {
anInterrupt->manager->disable(status);
}
void* param = anInterrupt->param;
return param;
}
@@ -152,7 +158,10 @@ void HAL_EnableInterrupts(HAL_InterruptHandle interruptHandle,
*status = HAL_HANDLE_ERROR;
return;
}
anInterrupt->manager->enable(status);
if (!anInterrupt->manager->isEnabled(status)) {
anInterrupt->manager->enable(status);
}
}
void HAL_DisableInterrupts(HAL_InterruptHandle interruptHandle,
@@ -162,7 +171,9 @@ void HAL_DisableInterrupts(HAL_InterruptHandle interruptHandle,
*status = HAL_HANDLE_ERROR;
return;
}
anInterrupt->manager->disable(status);
if (anInterrupt->manager->isEnabled(status)) {
anInterrupt->manager->disable(status);
}
}
int64_t HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
@@ -259,4 +270,19 @@ void HAL_SetInterruptUpSourceEdge(HAL_InterruptHandle interruptHandle,
anInterrupt->anInterrupt->writeConfig_FallingEdge(fallingEdge, status);
}
void HAL_ReleaseWaitingInterrupt(HAL_InterruptHandle interruptHandle,
int32_t* status) {
auto anInterrupt = interruptHandles->Get(interruptHandle);
if (anInterrupt == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
uint32_t interruptIndex =
static_cast<uint32_t>(getHandleIndex(interruptHandle));
hal::ReleaseFPGAInterrupt(interruptIndex);
hal::ReleaseFPGAInterrupt(interruptIndex + 8);
}
} // extern "C"

View File

@@ -139,6 +139,9 @@ HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status) {
return handle;
}
void HAL_SetNotifierName(HAL_NotifierHandle notifierHandle, const char* name,
int32_t* status) {}
void HAL_StopNotifier(HAL_NotifierHandle notifierHandle, int32_t* status) {
auto notifier = notifierHandles->Get(notifierHandle);
if (!notifier) return;

View File

@@ -175,7 +175,11 @@ double HAL_GetPDPTemperature(HAL_PDPHandle handle, int32_t* status) {
HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
return pdpStatus.bits.temp * 1.03250836957542 - 67.8564500484966;
if (*status != 0) {
return 0;
} else {
return pdpStatus.bits.temp * 1.03250836957542 - 67.8564500484966;
}
}
double HAL_GetPDPVoltage(HAL_PDPHandle handle, int32_t* status) {
@@ -186,7 +190,11 @@ double HAL_GetPDPVoltage(HAL_PDPHandle handle, int32_t* status) {
HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
return pdpStatus.bits.busVoltage * 0.05 + 4.0; /* 50mV per unit plus 4V. */
if (*status != 0) {
return 0;
} else {
return pdpStatus.bits.busVoltage * 0.05 + 4.0; /* 50mV per unit plus 4V. */
}
}
double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
@@ -205,6 +213,9 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
PdpStatus1 pdpStatus;
HAL_ReadCANPacketTimeout(handle, Status1, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) {
return 0;
}
switch (channel) {
case 0:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan1_h8) << 2) |
@@ -235,6 +246,9 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
PdpStatus2 pdpStatus;
HAL_ReadCANPacketTimeout(handle, Status2, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) {
return 0;
}
switch (channel) {
case 6:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan7_h8) << 2) |
@@ -265,6 +279,9 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
PdpStatus3 pdpStatus;
HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) {
return 0;
}
switch (channel) {
case 12:
raw = (static_cast<uint32_t>(pdpStatus.bits.chan13_h8) << 2) |
@@ -289,6 +306,75 @@ double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
return raw * 0.125; /* 7.3 fixed pt value in Amps */
}
void HAL_GetPDPAllChannelCurrents(HAL_PDPHandle handle, double* currents,
int32_t* status) {
int32_t length = 0;
uint64_t receivedTimestamp = 0;
PdpStatus1 pdpStatus;
HAL_ReadCANPacketTimeout(handle, Status1, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) return;
PdpStatus2 pdpStatus2;
HAL_ReadCANPacketTimeout(handle, Status2, pdpStatus2.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) return;
PdpStatus3 pdpStatus3;
HAL_ReadCANPacketTimeout(handle, Status3, pdpStatus3.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) return;
currents[0] = ((static_cast<uint32_t>(pdpStatus.bits.chan1_h8) << 2) |
pdpStatus.bits.chan1_l2) *
0.125;
currents[1] = ((static_cast<uint32_t>(pdpStatus.bits.chan2_h6) << 4) |
pdpStatus.bits.chan2_l4) *
0.125;
currents[2] = ((static_cast<uint32_t>(pdpStatus.bits.chan3_h4) << 6) |
pdpStatus.bits.chan3_l6) *
0.125;
currents[3] = ((static_cast<uint32_t>(pdpStatus.bits.chan4_h2) << 8) |
pdpStatus.bits.chan4_l8) *
0.125;
currents[4] = ((static_cast<uint32_t>(pdpStatus.bits.chan5_h8) << 2) |
pdpStatus.bits.chan5_l2) *
0.125;
currents[5] = ((static_cast<uint32_t>(pdpStatus.bits.chan6_h6) << 4) |
pdpStatus.bits.chan6_l4) *
0.125;
currents[6] = ((static_cast<uint32_t>(pdpStatus2.bits.chan7_h8) << 2) |
pdpStatus2.bits.chan7_l2) *
0.125;
currents[7] = ((static_cast<uint32_t>(pdpStatus2.bits.chan8_h6) << 4) |
pdpStatus2.bits.chan8_l4) *
0.125;
currents[8] = ((static_cast<uint32_t>(pdpStatus2.bits.chan9_h4) << 6) |
pdpStatus2.bits.chan9_l6) *
0.125;
currents[9] = ((static_cast<uint32_t>(pdpStatus2.bits.chan10_h2) << 8) |
pdpStatus2.bits.chan10_l8) *
0.125;
currents[10] = ((static_cast<uint32_t>(pdpStatus2.bits.chan11_h8) << 2) |
pdpStatus2.bits.chan11_l2) *
0.125;
currents[11] = ((static_cast<uint32_t>(pdpStatus2.bits.chan12_h6) << 4) |
pdpStatus2.bits.chan12_l4) *
0.125;
currents[12] = ((static_cast<uint32_t>(pdpStatus3.bits.chan13_h8) << 2) |
pdpStatus3.bits.chan13_l2) *
0.125;
currents[13] = ((static_cast<uint32_t>(pdpStatus3.bits.chan14_h6) << 4) |
pdpStatus3.bits.chan14_l4) *
0.125;
currents[14] = ((static_cast<uint32_t>(pdpStatus3.bits.chan15_h4) << 6) |
pdpStatus3.bits.chan15_l6) *
0.125;
currents[15] = ((static_cast<uint32_t>(pdpStatus3.bits.chan16_h2) << 8) |
pdpStatus3.bits.chan16_l8) *
0.125;
}
double HAL_GetPDPTotalCurrent(HAL_PDPHandle handle, int32_t* status) {
PdpStatusEnergy pdpStatus;
int32_t length = 0;
@@ -296,6 +382,9 @@ double HAL_GetPDPTotalCurrent(HAL_PDPHandle handle, int32_t* status) {
HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) {
return 0;
}
uint32_t raw;
raw = pdpStatus.bits.TotalCurrent_125mAperunit_h8;
@@ -311,6 +400,9 @@ double HAL_GetPDPTotalPower(HAL_PDPHandle handle, int32_t* status) {
HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) {
return 0;
}
uint32_t raw;
raw = pdpStatus.bits.Power_125mWperunit_h4;
@@ -328,6 +420,9 @@ double HAL_GetPDPTotalEnergy(HAL_PDPHandle handle, int32_t* status) {
HAL_ReadCANPacketTimeout(handle, StatusEnergy, pdpStatus.data, &length,
&receivedTimestamp, TimeoutMs, status);
if (*status != 0) {
return 0;
}
uint32_t raw;
raw = pdpStatus.bits.Energy_125mWPerUnitXTmeas_h4;

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -37,5 +37,7 @@ int32_t HAL_GetNumPCMModules(void) { return kNumPCMModules; }
int32_t HAL_GetNumSolenoidChannels(void) { return kNumSolenoidChannels; }
int32_t HAL_GetNumPDPModules(void) { return kNumPDPModules; }
int32_t HAL_GetNumPDPChannels(void) { return kNumPDPChannels; }
int32_t HAL_GetNumDutyCycles(void) { return kNumDutyCycles; }
int32_t HAL_GetNumAddressableLEDs(void) { return kNumAddressableLEDs; }
} // extern "C"

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -35,5 +35,7 @@ constexpr int32_t kNumPCMModules = 63;
constexpr int32_t kNumSolenoidChannels = 8;
constexpr int32_t kNumPDPModules = 63;
constexpr int32_t kNumPDPChannels = 16;
constexpr int32_t kNumDutyCycles = tDutyCycle::kNumSystems;
constexpr int32_t kNumAddressableLEDs = tLED::kNumSystems;
} // namespace hal

View File

@@ -565,7 +565,7 @@ void HAL_StopSPIAuto(HAL_SPIPort port, int32_t* status) {
void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend,
int32_t dataSize, int32_t zeroSize,
int32_t* status) {
if (dataSize < 0 || dataSize > 16) {
if (dataSize < 0 || dataSize > 32) {
*status = PARAMETER_OUT_OF_RANGE;
return;
}
@@ -589,7 +589,7 @@ void HAL_SetSPIAutoTransmitData(HAL_SPIPort port, const uint8_t* dataToSend,
// set byte counts
tSPI::tAutoByteCount config;
config.ZeroByteCount = static_cast<unsigned>(zeroSize) & 0x7f;
config.TxByteCount = static_cast<unsigned>(dataSize) & 0xf;
config.TxByteCount = static_cast<unsigned>(dataSize) & 0x1f;
spiSystem->writeAutoByteCount(config, status);
}
@@ -631,4 +631,21 @@ int32_t HAL_GetSPIAutoDroppedCount(HAL_SPIPort port, int32_t* status) {
return spiSystem->readTransferSkippedFullCount(status);
}
void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
int32_t stallTicks, int32_t pow2BytesPerRead,
int32_t* status) {
std::scoped_lock lock(spiAutoMutex);
// FPGA only has one auto SPI engine
if (port != spiAutoPort) {
*status = INCOMPATIBLE_STATE;
return;
}
tSPI::tStallConfig stallConfig;
stallConfig.CsToSclkTicks = static_cast<uint8_t>(csToSclkTicks);
stallConfig.StallTicks = static_cast<uint16_t>(stallTicks);
stallConfig.Pow2BytesPerRead = static_cast<uint8_t>(pow2BytesPerRead);
spiSystem->writeStallConfig(stallConfig, status);
}
} // extern "C"

View File

@@ -0,0 +1,145 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include <wpi/jni_util.h>
#include "HALUtil.h"
#include "edu_wpi_first_hal_AddressableLEDJNI.h"
#include "hal/AddressableLED.h"
using namespace frc;
using namespace wpi::java;
static_assert(sizeof(jbyte) * 4 == sizeof(HAL_AddressableLEDData));
extern "C" {
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: initialize
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_initialize
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto ret = HAL_InitializeAddressableLED(
static_cast<HAL_DigitalHandle>(handle), &status);
CheckStatus(env, status);
return ret;
}
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: free
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_free
(JNIEnv* env, jclass, jint handle)
{
HAL_FreeAddressableLED(static_cast<HAL_AddressableLEDHandle>(handle));
}
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: setLength
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_setLength
(JNIEnv* env, jclass, jint handle, jint length)
{
int32_t status = 0;
HAL_SetAddressableLEDLength(static_cast<HAL_AddressableLEDHandle>(handle),
length, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: setData
* Signature: (I[B)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_setData
(JNIEnv* env, jclass, jint handle, jbyteArray arr)
{
int32_t status = 0;
JByteArrayRef jArrRef{env, arr};
auto arrRef = jArrRef.array();
HAL_WriteAddressableLEDData(
static_cast<HAL_AddressableLEDHandle>(handle),
reinterpret_cast<const HAL_AddressableLEDData*>(arrRef.data()),
arrRef.size() / 4, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: setBitTiming
* Signature: (IIIII)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_setBitTiming
(JNIEnv* env, jclass, jint handle, jint lowTime0, jint highTime0,
jint lowTime1, jint highTime1)
{
int32_t status = 0;
HAL_SetAddressableLEDBitTiming(static_cast<HAL_AddressableLEDHandle>(handle),
lowTime0, highTime0, lowTime1, highTime1,
&status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: setSyncTime
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_setSyncTime
(JNIEnv* env, jclass, jint handle, jint syncTime)
{
int32_t status = 0;
HAL_SetAddressableLEDSyncTime(static_cast<HAL_AddressableLEDHandle>(handle),
syncTime, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: start
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_start
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
HAL_StartAddressableLEDOutput(static_cast<HAL_AddressableLEDHandle>(handle),
&status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AddressableLEDJNI
* Method: stop
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AddressableLEDJNI_stop
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
HAL_StopAddressableLEDOutput(static_cast<HAL_AddressableLEDHandle>(handle),
&status);
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -486,18 +486,31 @@ Java_edu_wpi_first_hal_AnalogJNI_getAccumulatorOutput
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: initializeAnalogTrigger
* Signature: (ILjava/lang/Object;)I
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_AnalogJNI_initializeAnalogTrigger
(JNIEnv* env, jclass, jint id, jobject index)
(JNIEnv* env, jclass, jint id)
{
jint* indexHandle =
reinterpret_cast<jint*>(env->GetDirectBufferAddress(index));
int32_t status = 0;
HAL_AnalogTriggerHandle analogTrigger = HAL_InitializeAnalogTrigger(
(HAL_AnalogInputHandle)id, reinterpret_cast<int32_t*>(indexHandle),
&status);
HAL_AnalogTriggerHandle analogTrigger =
HAL_InitializeAnalogTrigger((HAL_AnalogInputHandle)id, &status);
CheckStatus(env, status);
return (jint)analogTrigger;
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: initializeAnalogTriggerDutyCycle
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_AnalogJNI_initializeAnalogTriggerDutyCycle
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
HAL_AnalogTriggerHandle analogTrigger =
HAL_InitializeAnalogTriggerDutyCycle((HAL_DutyCycleHandle)id, &status);
CheckStatus(env, status);
return (jint)analogTrigger;
}
@@ -531,6 +544,21 @@ Java_edu_wpi_first_hal_AnalogJNI_setAnalogTriggerLimitsRaw
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: setAnalogTriggerLimitsDutyCycle
* Signature: (IDD)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_AnalogJNI_setAnalogTriggerLimitsDutyCycle
(JNIEnv* env, jclass, jint id, jdouble lower, jdouble upper)
{
int32_t status = 0;
HAL_SetAnalogTriggerLimitsDutyCycle((HAL_AnalogTriggerHandle)id, lower, upper,
&status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: setAnalogTriggerLimitsVoltage
@@ -622,4 +650,20 @@ Java_edu_wpi_first_hal_AnalogJNI_getAnalogTriggerOutput
return val;
}
/*
* Class: edu_wpi_first_hal_AnalogJNI
* Method: getAnalogTriggerFPGAIndex
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_AnalogJNI_getAnalogTriggerFPGAIndex
(JNIEnv* env, jclass, jint id)
{
int32_t status = 0;
auto val =
HAL_GetAnalogTriggerFPGAIndex((HAL_AnalogTriggerHandle)id, &status);
CheckStatus(env, status);
return val;
}
} // extern "C"

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -13,6 +13,8 @@
using namespace frc;
extern "C" {
/*
* Class: edu_wpi_first_hal_DigitalGlitchFilterJNI
* Method: setFilterSelect
@@ -76,3 +78,5 @@ Java_edu_wpi_first_hal_DigitalGlitchFilterJNI_getFilterPeriod
CheckStatus(env, status);
return result;
}
} // extern "C"

View File

@@ -0,0 +1,126 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#include <jni.h>
#include "HALUtil.h"
#include "edu_wpi_first_hal_DutyCycleJNI.h"
#include "hal/DutyCycle.h"
using namespace frc;
extern "C" {
/*
* Class: edu_wpi_first_hal_DutyCycleJNI
* Method: initialize
* Signature: (II)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_DutyCycleJNI_initialize
(JNIEnv* env, jclass, jint digitalSourceHandle, jint analogTriggerType)
{
int32_t status = 0;
auto handle = HAL_InitializeDutyCycle(
static_cast<HAL_Handle>(digitalSourceHandle),
static_cast<HAL_AnalogTriggerType>(analogTriggerType), &status);
CheckStatus(env, status);
return handle;
}
/*
* Class: edu_wpi_first_hal_DutyCycleJNI
* Method: free
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_DutyCycleJNI_free
(JNIEnv*, jclass, jint handle)
{
HAL_FreeDutyCycle(static_cast<HAL_DutyCycleHandle>(handle));
}
/*
* Class: edu_wpi_first_hal_DutyCycleJNI
* Method: getFrequency
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_DutyCycleJNI_getFrequency
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto retVal = HAL_GetDutyCycleFrequency(
static_cast<HAL_DutyCycleHandle>(handle), &status);
CheckStatus(env, status);
return retVal;
}
/*
* Class: edu_wpi_first_hal_DutyCycleJNI
* Method: getOutput
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_DutyCycleJNI_getOutput
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto retVal =
HAL_GetDutyCycleOutput(static_cast<HAL_DutyCycleHandle>(handle), &status);
CheckStatus(env, status);
return retVal;
}
/*
* Class: edu_wpi_first_hal_DutyCycleJNI
* Method: getOutputRaw
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_DutyCycleJNI_getOutputRaw
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto retVal = HAL_GetDutyCycleOutputRaw(
static_cast<HAL_DutyCycleHandle>(handle), &status);
CheckStatus(env, status);
return retVal;
}
/*
* Class: edu_wpi_first_hal_DutyCycleJNI
* Method: getOutputScaleFactor
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_DutyCycleJNI_getOutputScaleFactor
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto retVal = HAL_GetDutyCycleOutputScaleFactor(
static_cast<HAL_DutyCycleHandle>(handle), &status);
CheckStatus(env, status);
return retVal;
}
/*
* Class: edu_wpi_first_hal_DutyCycleJNI
* Method: getFPGAIndex
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_DutyCycleJNI_getFPGAIndex
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto retVal = HAL_GetDutyCycleFPGAIndex(
static_cast<HAL_DutyCycleHandle>(handle), &status);
CheckStatus(env, status);
return retVal;
}
} // extern "C"

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -448,6 +448,21 @@ Java_edu_wpi_first_hal_HAL_sendError
return returnValue;
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: sendConsoleLine
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_HAL_sendConsoleLine
(JNIEnv* env, jclass, jstring line)
{
JStringRef lineStr{env, line};
jint returnValue = HAL_SendConsoleLine(lineStr.c_str());
return returnValue;
}
/*
* Class: edu_wpi_first_hal_HAL
* Method: getPortWithModule

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -294,4 +294,19 @@ Java_edu_wpi_first_hal_InterruptJNI_setInterruptUpSourceEdge
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_InterruptJNI
* Method: releaseWaitingInterrupt
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_InterruptJNI_releaseWaitingInterrupt
(JNIEnv* env, jclass, jint interruptHandle)
{
int32_t status = 0;
HAL_ReleaseWaitingInterrupt((HAL_InterruptHandle)interruptHandle, &status);
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -10,6 +10,8 @@
#include <cassert>
#include <cstdio>
#include <wpi/jni_util.h>
#include "HALUtil.h"
#include "edu_wpi_first_hal_NotifierJNI.h"
#include "hal/Notifier.h"
@@ -37,6 +39,21 @@ Java_edu_wpi_first_hal_NotifierJNI_initializeNotifier
return (jint)notifierHandle;
}
/*
* Class: edu_wpi_first_hal_NotifierJNI
* Method: setNotifierName
* Signature: (ILjava/lang/String;)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_NotifierJNI_setNotifierName
(JNIEnv* env, jclass cls, jint notifierHandle, jstring name)
{
int32_t status = 0;
HAL_SetNotifierName((HAL_NotifierHandle)notifierHandle,
wpi::java::JStringRef{env, name}.c_str(), &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_NotifierJNI
* Method: stopNotifier

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -98,6 +98,25 @@ Java_edu_wpi_first_hal_PDPJNI_getPDPChannelCurrent
return current;
}
/*
* Class: edu_wpi_first_hal_PDPJNI
* Method: getPDPAllCurrents
* Signature: (I[D)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_PDPJNI_getPDPAllCurrents
(JNIEnv* env, jclass, jint handle, jdoubleArray jarr)
{
double storage[16];
int32_t status = 0;
HAL_GetPDPAllChannelCurrents(handle, storage, &status);
if (!CheckStatus(env, status, false)) {
return;
}
env->SetDoubleArrayRegion(jarr, 0, 16, storage);
}
/*
* Class: edu_wpi_first_hal_PDPJNI
* Method: getPDPTotalCurrent

View File

@@ -394,4 +394,20 @@ Java_edu_wpi_first_hal_SPIJNI_spiGetAutoDroppedCount
return retval;
}
/*
* Class: edu_wpi_first_hal_SPIJNI
* Method: spiConfigureAutoStall
* Signature: (IIII)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_SPIJNI_spiConfigureAutoStall
(JNIEnv* env, jclass, jint port, jint csToSclkTicks, jint stallTicks,
jint pow2BytesPerRead)
{
int32_t status = 0;
HAL_ConfigureSPIAutoStall(static_cast<HAL_SPIPort>(port), csToSclkTicks,
stallTicks, pow2BytesPerRead, &status);
CheckStatus(env, status);
}
} // extern "C"

View File

@@ -0,0 +1,61 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <stdint.h>
#include "hal/AddressableLEDTypes.h"
#include "hal/Types.h"
/**
* @defgroup hal_addressable Addressable LED Functions
* @ingroup hal_capi
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
HAL_DigitalHandle outputPort, int32_t* status);
void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle);
void HAL_SetAddressableLEDOutputPort(HAL_AddressableLEDHandle handle,
HAL_DigitalHandle outputPort,
int32_t* status);
void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
int32_t length, int32_t* status);
void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
const struct HAL_AddressableLEDData* data,
int32_t length, int32_t* status);
void HAL_SetAddressableLEDBitTiming(HAL_AddressableLEDHandle handle,
int32_t lowTime0NanoSeconds,
int32_t highTime0NanoSeconds,
int32_t lowTime1NanoSeconds,
int32_t highTime1NanoSeconds,
int32_t* status);
void HAL_SetAddressableLEDSyncTime(HAL_AddressableLEDHandle handle,
int32_t syncTimeMicroSeconds,
int32_t* status);
void HAL_StartAddressableLEDOutput(HAL_AddressableLEDHandle handle,
int32_t* status);
void HAL_StopAddressableLEDOutput(HAL_AddressableLEDHandle handle,
int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif
/** @} */

View File

@@ -0,0 +1,19 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <stdint.h>
#define HAL_kAddressableLEDMaxLength 5460
struct HAL_AddressableLEDData {
uint8_t b;
uint8_t g;
uint8_t r;
uint8_t padding;
};

View File

@@ -233,6 +233,16 @@ int32_t HAL_GetAnalogLSBWeight(HAL_AnalogInputHandle analogPortHandle,
*/
int32_t HAL_GetAnalogOffset(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
/**
* Get the analog voltage from a raw value.
*
* @param analogPortHandle Handle to the analog port the values were read from.
* @param rawValue The raw analog value
* @return The voltage relating to the value
*/
double HAL_GetAnalogValueToVolts(HAL_AnalogInputHandle analogPortHandle,
int32_t rawValue, int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -37,11 +37,17 @@ extern "C" {
* Initializes an analog trigger.
*
* @param portHandle the analog input to use for triggering
* @param index the trigger index value (output)
* @return the created analog trigger handle
*/
HAL_AnalogTriggerHandle HAL_InitializeAnalogTrigger(
HAL_AnalogInputHandle portHandle, int32_t* index, int32_t* status);
HAL_AnalogInputHandle portHandle, int32_t* status);
/**
* Initializes an analog trigger with a Duty Cycle input
*
*/
HAL_AnalogTriggerHandle HAL_InitializeAnalogTriggerDutyCycle(
HAL_DutyCycleHandle dutyCycleHandle, int32_t* status);
/**
* Frees an analog trigger.
@@ -54,7 +60,8 @@ void HAL_CleanAnalogTrigger(HAL_AnalogTriggerHandle analogTriggerHandle,
/**
* Sets the raw ADC upper and lower limits of the analog trigger.
*
* HAL_SetAnalogTriggerLimitsVoltage is likely better in most cases.
* HAL_SetAnalogTriggerLimitsVoltage or HAL_SetAnalogTriggerLimitsDutyCycle
* is likely better in most cases.
*
* @param analogTriggerHandle the trigger handle
* @param lower the lower ADC value
@@ -77,12 +84,19 @@ void HAL_SetAnalogTriggerLimitsVoltage(
HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
int32_t* status);
void HAL_SetAnalogTriggerLimitsDutyCycle(
HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
int32_t* status);
/**
* Configures the analog trigger to use the averaged vs. raw values.
*
* If the value is true, then the averaged value is selected for the analog
* trigger, otherwise the immediate value is used.
*
* This is not allowed to be used if filtered mode is set.
* This is not allowed to be used with Duty Cycle based inputs.
*
* @param analogTriggerHandle the trigger handle
* @param useAveragedValue true to use averaged values, false for raw
*/
@@ -96,6 +110,8 @@ void HAL_SetAnalogTriggerAveraged(HAL_AnalogTriggerHandle analogTriggerHandle,
* is designed to help with 360 degree pot applications for the period where the
* pot crosses through zero.
*
* This is not allowed to be used if averaged mode is set.
*
* @param analogTriggerHandle the trigger handle
* @param useFilteredValue true to use filtered values, false for average or
* raw
@@ -137,6 +153,15 @@ HAL_Bool HAL_GetAnalogTriggerTriggerState(
HAL_Bool HAL_GetAnalogTriggerOutput(HAL_AnalogTriggerHandle analogTriggerHandle,
HAL_AnalogTriggerType type,
int32_t* status);
/**
* Get the FPGA index for the AnlogTrigger.
*
* @param analogTriggerHandle the trigger handle
* @return the FPGA index
*/
int32_t HAL_GetAnalogTriggerFPGAIndex(
HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -55,7 +55,8 @@ HAL_ENUM(HAL_CANManufacturer) {
HAL_CAN_Man_kTeamUse = 8,
HAL_CAN_Man_kKauaiLabs = 9,
HAL_CAN_Man_kCopperforge = 10,
HAL_CAN_Man_kPWF = 11
HAL_CAN_Man_kPWF = 11,
HAL_CAN_Man_kStudica = 12
};
// clang-format on
/** @} */

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -24,9 +24,12 @@
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tCounter.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDIO.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDMA.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tDutyCycle.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tEncoder.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tGlobal.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tHMB.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tInterrupt.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tLED.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPWM.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tPower.h>
#include <FRC_FPGA_ChipObject/nRoboRIO_FPGANamespace/tRelay.h>

View File

@@ -0,0 +1,129 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include <stdint.h>
#include "hal/AnalogTrigger.h"
#include "hal/Types.h"
// clang-format off
/**
* The DMA Read Status.
*/
HAL_ENUM(HAL_DMAReadStatus ) {
HAL_DMA_OK = 1,
HAL_DMA_TIMEOUT = 2,
HAL_DMA_ERROR = 3,
};
// clang-format on
struct HAL_DMASample {
uint32_t readBuffer[74];
int32_t channelOffsets[22];
uint64_t timeStamp;
uint32_t captureSize;
uint8_t triggerChannels;
};
#ifdef __cplusplus
extern "C" {
#endif
HAL_DMAHandle HAL_InitializeDMA(int32_t* status);
void HAL_FreeDMA(HAL_DMAHandle handle);
void HAL_SetDMAPause(HAL_DMAHandle handle, HAL_Bool pause, int32_t* status);
void HAL_SetDMARate(HAL_DMAHandle handle, int32_t cycles, int32_t* status);
void HAL_AddDMAEncoder(HAL_DMAHandle handle, HAL_EncoderHandle encoderHandle,
int32_t* status);
void HAL_AddDMAEncoderPeriod(HAL_DMAHandle handle,
HAL_EncoderHandle encoderHandle, int32_t* status);
void HAL_AddDMACounter(HAL_DMAHandle handle, HAL_CounterHandle counterHandle,
int32_t* status);
void HAL_AddDMACounterPeriod(HAL_DMAHandle handle,
HAL_CounterHandle counterHandle, int32_t* status);
void HAL_AddDMADigitalSource(HAL_DMAHandle handle,
HAL_Handle digitalSourceHandle, int32_t* status);
void HAL_AddDMAAnalogInput(HAL_DMAHandle handle,
HAL_AnalogInputHandle aInHandle, int32_t* status);
void HAL_AddDMAAveragedAnalogInput(HAL_DMAHandle handle,
HAL_AnalogInputHandle aInHandle,
int32_t* status);
void HAL_AddDMAAnalogAccumulator(HAL_DMAHandle handle,
HAL_AnalogInputHandle aInHandle,
int32_t* status);
void HAL_AddDMADutyCycle(HAL_DMAHandle handle,
HAL_DutyCycleHandle dutyCycleHandle, int32_t* status);
void HAL_SetDMAExternalTrigger(HAL_DMAHandle handle,
HAL_Handle digitalSourceHandle,
HAL_AnalogTriggerType analogTriggerType,
HAL_Bool rising, HAL_Bool falling,
int32_t* status);
void HAL_StartDMA(HAL_DMAHandle handle, int32_t queueDepth, int32_t* status);
void HAL_StopDMA(HAL_DMAHandle handle, int32_t* status);
void* HAL_GetDMADirectPointer(HAL_DMAHandle handle);
enum HAL_DMAReadStatus HAL_ReadDMADirect(void* dmaPointer,
HAL_DMASample* dmaSample,
int32_t timeoutMs,
int32_t* remainingOut,
int32_t* status);
enum HAL_DMAReadStatus HAL_ReadDMA(HAL_DMAHandle handle,
HAL_DMASample* dmaSample, int32_t timeoutMs,
int32_t* remainingOut, int32_t* status);
// Sampling Code
uint64_t HAL_GetDMASampleTime(const HAL_DMASample* dmaSample, int32_t* status);
int32_t HAL_GetDMASampleEncoderRaw(const HAL_DMASample* dmaSample,
HAL_EncoderHandle encoderHandle,
int32_t* status);
int32_t HAL_GetDMASampleCounter(const HAL_DMASample* dmaSample,
HAL_CounterHandle counterHandle,
int32_t* status);
int32_t HAL_GetDMASampleEncoderPeriodRaw(const HAL_DMASample* dmaSample,
HAL_EncoderHandle encoderHandle,
int32_t* status);
int32_t HAL_GetDMASampleCounterPeriod(const HAL_DMASample* dmaSample,
HAL_CounterHandle counterHandle,
int32_t* status);
HAL_Bool HAL_GetDMASampleDigitalSource(const HAL_DMASample* dmaSample,
HAL_Handle dSourceHandle,
int32_t* status);
int32_t HAL_GetDMASampleAnalogInputRaw(const HAL_DMASample* dmaSample,
HAL_AnalogInputHandle aInHandle,
int32_t* status);
int32_t HAL_GetDMASampleAveragedAnalogInputRaw(const HAL_DMASample* dmaSample,
HAL_AnalogInputHandle aInHandle,
int32_t* status);
void HAL_GetDMASampleAnalogAccumulator(const HAL_DMASample* dmaSample,
HAL_AnalogInputHandle aInHandle,
int64_t* count, int64_t* value,
int32_t* status);
int32_t HAL_GetDMASampleDutyCycleOutputRaw(const HAL_DMASample* dmaSample,
HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2013-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2013-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -37,6 +37,12 @@ extern "C" {
int32_t HAL_SendError(HAL_Bool isError, int32_t errorCode, HAL_Bool isLVCode,
const char* details, const char* location,
const char* callStack, HAL_Bool printMsg);
/**
* Sends a line to the driver station console.
*
* @param line the line to send (null terminated)
*/
int32_t HAL_SendConsoleLine(const char* line);
/**
* Gets the current control word of the driver station.
@@ -193,6 +199,24 @@ int32_t HAL_GetMatchInfo(HAL_MatchInfo* info);
*/
void HAL_ReleaseDSMutex(void);
/**
* Checks if new control data has arrived since the last
* HAL_WaitForCachedControlData or HAL_IsNewControlData call. If new data has
* not arrived, waits for new data to arrive. Otherwise, returns immediately.
*/
void HAL_WaitForCachedControlData(void);
/**
* Checks if new control data has arrived since the last
* HAL_WaitForCachedControlData or HAL_IsNewControlData call. If new data has
* not arrived, waits for new data to arrive, or a timeout. Otherwise, returns
* immediately.
*
* @param timeout timeout in seconds
* @return true for new data, false for timeout
*/
HAL_Bool HAL_WaitForCachedControlDataTimeout(double timeout);
/**
* Has a new control packet from the driver station arrived since the last
* time this function was called?

View File

@@ -0,0 +1,109 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "hal/AnalogTrigger.h"
#include "hal/Types.h"
/**
* @defgroup hal_dutycycle DutyCycle Functions
* @ingroup hal_capi
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* Initialize a DutyCycle input.
*
* @param digitalSourceHandle the digital source to use (either a
* HAL_DigitalHandle or a HAL_AnalogTriggerHandle)
* @param triggerType the analog trigger type of the source if it is
* an analog trigger
* @return thre created duty cycle handle
*/
HAL_DutyCycleHandle HAL_InitializeDutyCycle(HAL_Handle digitalSourceHandle,
HAL_AnalogTriggerType triggerType,
int32_t* status);
/**
* Free a DutyCycle.
*
* @param dutyCycleHandle the duty cycle handle
*/
void HAL_FreeDutyCycle(HAL_DutyCycleHandle dutyCycleHandle);
/**
* Indicates the duty cycle is used by a simulated device.
*
* @param handle the duty cycle handle
* @param device simulated device handle
*/
void HAL_SetDutyCycleSimDevice(HAL_DutyCycleHandle handle,
HAL_SimDeviceHandle device);
/**
* Get the frequency of the duty cycle signal.
*
* @param dutyCycleHandle the duty cycle handle
* @return frequency in Hertz
*/
int32_t HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status);
/**
* Get the output ratio of the duty cycle signal.
*
* <p> 0 means always low, 1 means always high.
*
* @param dutyCycleHandle the duty cycle handle
* @return output ratio between 0 and 1
*/
double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status);
/**
* Get the raw output ratio of the duty cycle signal.
*
* <p> 0 means always low, an output equal to
* GetOutputScaleFactor() means always high.
*
* @param dutyCycleHandle the duty cycle handle
* @return output ratio in raw units
*/
int32_t HAL_GetDutyCycleOutputRaw(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status);
/**
* Get the scale factor of the output.
*
* <p> An output equal to this value is always high, and then linearly scales
* down to 0. Divide the result of getOutputRaw by this in order to get the
* percentage between 0 and 1.
*
* @param dutyCycleHandle the duty cycle handle
* @return the output scale factor
*/
int32_t HAL_GetDutyCycleOutputScaleFactor(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status);
/**
* Get the FPGA index for the DutyCycle.
*
* @param dutyCycleHandle the duty cycle handle
* @return the FPGA index
*/
int32_t HAL_GetDutyCycleFPGAIndex(HAL_DutyCycleHandle dutyCycleHandle,
int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif
/** @} */

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -94,6 +94,14 @@
#define HAL_HANDLE_ERROR_MESSAGE \
"HAL: A handle parameter was passed incorrectly"
#define HAL_LED_CHANNEL_ERROR -1099
#define HAL_LED_CHANNEL_ERROR_MESSAGE \
"HAL: Addressable LEDs only supported on PWM Headers, not MXP or DIO"
#define HAL_INVALID_DMA_ADDITION -1102
#define HAL_INVALID_DMA_ADDITION_MESSAGE \
"HAL_AddDMA() only works before HAL_StartDMA()"
#define HAL_SERIAL_PORT_NOT_FOUND -1123
#define HAL_SERIAL_PORT_NOT_FOUND_MESSAGE \
"HAL: The specified serial port device was not found"
@@ -117,6 +125,13 @@
#define HAL_CAN_TIMEOUT -1154
#define HAL_CAN_TIMEOUT_MESSAGE "HAL: CAN Receive has Timed Out"
#define HAL_SIM_NOT_SUPPORTED -1155
#define HAL_SIM_NOT_SUPPORTED_MESSAGE "HAL: Method not supported in sim"
#define HAL_CAN_BUFFER_OVERRUN -35007
#define HAL_CAN_BUFFER_OVERRUN_MESSAGE \
"HAL: CAN Output Buffer Full. Ensure a device is attached"
#define VI_ERROR_SYSTEM_ERROR_MESSAGE "HAL - VISA: System Error";
#define VI_ERROR_INV_OBJECT_MESSAGE "HAL - VISA: Invalid Object"
#define VI_ERROR_RSRC_LOCKED_MESSAGE "HAL - VISA: Resource Locked"

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -7,6 +7,8 @@
#pragma once
#include "hal/Types.h"
/**
* @defgroup hal_extensions Simulator Extensions
* @ingroup hal_capi
@@ -41,5 +43,19 @@ int HAL_LoadOneExtension(const char* library);
* @return the succes state of the initialization
*/
int HAL_LoadExtensions(void);
/**
* Enables or disables the message saying no HAL extensions were found.
*
* Some apps don't care, and the message create clutter. For general team code,
* we want it.
*
* This must be called before HAL_Initialize is called.
*
* This defaults to true.
*
* @param showMessage true to show message, false to not.
*/
void HAL_SetShowExtensionsNotFoundMessages(HAL_Bool showMessage);
} // extern "C"
/** @} */

View File

@@ -24,6 +24,7 @@
#include "hal/DriverStation.h"
#include "hal/Encoder.h"
#include "hal/Errors.h"
#include "hal/FRCUsageReporting.h"
#include "hal/HALBase.h"
#include "hal/I2C.h"
#include "hal/Interrupts.h"
@@ -41,7 +42,3 @@
#include "hal/Threads.h"
#include "hal/Types.h"
#include "hal/Value.h"
#ifdef __cplusplus
#include "hal/FRCUsageReporting.h"
#endif

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2008-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -109,6 +109,20 @@ HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t channel);
*/
uint64_t HAL_GetFPGATime(int32_t* status);
/**
* Given an 32 bit FPGA time, expand it to the nearest likely 64 bit FPGA time.
*
* Note: This is making the assumption that the timestamp being converted is
* always in the past. If you call this with a future timestamp, it probably
* will make it in the past. If you wait over 70 minutes between capturing the
* bottom 32 bits of the timestamp and expanding it, you will be off by
* multiples of 1<<32 microseconds.
*
* @return The current time in microseconds according to the FPGA (since FPGA
* reset) as a 64 bit number.
*/
uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, int32_t* status);
/**
* Call this to start up HAL. This is required for robot programs.
*
@@ -135,34 +149,6 @@ uint64_t HAL_GetFPGATime(int32_t* status);
*/
HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode);
// ifdef's definition is to allow for default parameters in C++.
#ifdef __cplusplus
/**
* Reports a hardware usage to the HAL.
*
* @param resource the used resource
* @param instanceNumber the instance of the resource
* @param context a user specified context index
* @param feature a user specified feature string
* @return the index of the added value in NetComm
*/
int64_t HAL_Report(int32_t resource, int32_t instanceNumber,
int32_t context = 0, const char* feature = nullptr);
#else
/**
* Reports a hardware usage to the HAL.
*
* @param resource the used resource
* @param instanceNumber the instance of the resource
* @param context a user specified context index
* @param feature a user specified feature string
* @return the index of the added value in NetComm
*/
int64_t HAL_Report(int32_t resource, int32_t instanceNumber, int32_t context,
const char* feature);
#endif
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -153,6 +153,16 @@ void HAL_AttachInterruptHandlerThreaded(HAL_InterruptHandle interruptHandle,
void HAL_SetInterruptUpSourceEdge(HAL_InterruptHandle interruptHandle,
HAL_Bool risingEdge, HAL_Bool fallingEdge,
int32_t* status);
/**
* Releases a waiting interrupt.
*
* This will release both rising and falling waiters.
*
* @param interruptHandle the interrupt handle to release
*/
void HAL_ReleaseWaitingInterrupt(HAL_InterruptHandle interruptHandle,
int32_t* status);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
/* Copyright (c) 2016-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -31,6 +31,15 @@ extern "C" {
*/
HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status);
/**
* Sets the name of a notifier.
*
* @param notifierHandle the notifier handle
* @param name name
*/
void HAL_SetNotifierName(HAL_NotifierHandle notifierHandle, const char* name,
int32_t* status);
/**
* Stops a notifier from running.
*

Some files were not shown because too many files have changed in this diff Show More