Squashed 'third_party/allwpilib/' changes from 00e090877..66b57f032
66b57f032 [wpimath] Copy child constraint in region constraints (#2831)
cfac22b4c [wpilib] Reset odometry in path following examples (#2859)
2ef67f20a [wpilib] Add way to silence joystick connection warnings (#2845)
7a73946ce [build] Update OpenCV to remove WITH_GTK (#2856)
6d22b5a3c [wpigui] Render during resize events (#2857)
50050a0e5 [wpilibc] Update C++ DiffDriveSim example to match Java (#2839)
de1742279 [wpilib] Add IsJoystickConnected method (#2847)
6b5e83ce1 [wpilibj] DrivetrainSim: Initialize m_u to default value (#2854)
17d75d8a3 [wpilibj] SimDeviceSim: Make register device callbacks static (#2835)
616405f7a [wpilib] Fix DiffDriveSim pose reset and example (#2837)
5c2dc043c [wpilib] Update examples to export NewCommands (#2841)
24a3c12f3 [wpilib] Fix names and descriptions of examples (#2846)
3e544282f [hal] Use FPGA time in HAL_SendError (#2849)
3c85a4064 [sim] Use units for voltage and current in RoboRioSim (#2853)
ac3c336b9 [wpimath] Use units for LinearSystemId Kv and Ka (#2852)
f24f28244 [build] Disable Gazebo builds when -PmakeSim is not set (#2810)
0dfee4745 [wpiutil] netconsoleTee: Add option to specify port (#2840)
eb80f7a78 [wpilibc] SendableRegistry: Add range and null checks (#2830)
68fed2a1a [build] Update NativeUtils to 2021.0.4 (#2828)
10d118a8d Fix C++ gradle in OtherVersions.md (#2826)
e021c3319 [wpilib] Set AnalogPotentiometer dashboard type (#2825)
7b7548196 [wpilib] AnalogPotentiometer: provide scaled value to Dashboard (#2824)
e019c735e [build] Update compiler to 2021 (#2823)
c253f2c7e Update Readme to match current practice (NFC) (#2820)
0ce9133b5 [wpimath] Address issues with LinearSystemLoop reset() and matrix initialization (#2819)
6ac9683a3 [build] Fix Gradle flags for CI documentation job (#2817)
1d7739d8d [build] Build with -PreleaseMode on tag push (#2816)
1de2a6d85 [build] Fix release versioning (#2815)
0a723a50d [build] Use fetch-depth: 0 to get all history (#2812)
34b91318f [build] Add Developer ID signing workflow (#2779)
b11a7114a [build] Bump thirdparty-opencv to 3.4.7-4 (#2811)
2ca5e1c8d Update requirements in README to include full VS install and JDK (#2808)
7ae8c7b24 [sim] Use DutyCycleEncoder FPGA index for sim device number (#2803)
1e17e4086 [build] Add a javaFormat Gradle task (#2805)
1069019fd [wpilib] Add DutyCycleEncoderSim (#2798)
4422904a2 [build] Add WITH_GUI cmake option
5d085b78b [build] Fix cmake shared library build
0927c73b1 [build] Update NativeUtils to latest version (#2797)
5fe8f9017 [build] Refactor CMake flags (#2788)
5cdffeaba [sim] StepTiming(): incrementally step Notifiers in sequence (#2794)
6e7c7374f [build] Globally Exclude PMD.TooManyMethods (#2793)
fb7b41793 [wpilib] Add ADXRS450_GyroSim (#2800)
abbf9f01a [wpilib] Fix typos in simulation classes (#2799)
17698af5e [wpimath] Add distance/angle constructor to Translation2d (#2791)
b66fcdb3f [sim] Fix Field2D GUI crash when collapsed (#2786)
7fc48b75d [command] Add PIDSubsystem PIDController as child (#2784)
07ac5370d [wpimath] Fix m_nextR instantiation in LinearSystemLoop ctor (#2783)
7c8f1cf7a [wpilib] Support scheduling functions more often than robot loop (#2766)
57a97e3fb [wpilib] Remove WatchdogTest print statements (#2781)
061432147 [wpilib] Clean up physics simulation class APIs (#2763)
8f3e5794b [wpilib] Add TimedRobot unit tests (#2771)
a112b5e23 [wpilib] Fix ProfiledPIDController continuous input (#2652)
67859aea4 [build] Split documentation into its own job (#2775)
37643ab0b [wpimath] Use std::lower_bound in Trajectory::Sample() calculation (#2774)
b0ee11f7c [build] Update vcpkg actions to latest (#2776)
7647e29b2 Add docs for building robot projects with other WPILib versions (#2756)
a3e672f86 [wpimath] C++: Assign zero in MakeWhiteNoiseVector if std-dev is zero (#2773)
9058fe803 [wpilib] Update docs link to stable (NFC) (#2772)
32f429a81 [wpimath] Move DiscretizeR() in EKF and UKF from Predict() to Correct() (#2753)
bf2665654 [wpimath] Fix quintic spline generation from control vectors (#2762)
96e26247d [wpiutil] Add custom priority queue implementation (#2770)
8e538aa82 [wpilibc] Make IsSimulation() checks constexpr (#2769)
fa809b2c4 [wpilibc] Clean up include files (#2708)
9a63cd36c [wpilibc] Const-qualify Watchdog comparison operator (#2767)
21d949daa [wpilibc] Add LinearSystemLoop C++ ctor to match Java (#2755)
330b90e04 [wpilib] Enable ArmSubsystem in ArmBot example (#2752)
693daafe2 [wpilib] Rename LinearSystemSim's ResetState() to SetState() (#2750)
c3b3fb8b7 [sim] Change StepTiming to wait for notifiers (#2603)
62731bea2 [wpilib] Add set functions to differential drive simulation (#2746)
c55fb583b [wpilibj] Watchdog: Implement equals and hashCode (#2743)
9725aff83 [wpilib] Clean up DifferentialDrivetrainSim API (#2747)
1320691eb [wpilib] Shorten differential drive simulation stability test (#2745)
451f67c63 [hal] SimDevice class: remove HAL_SimDeviceHandle constructor (#2744)
43b1b128b Improve README-CMAKE.md (#2737)
fc991cb59 [wpilib] Clean up simulation physics API (#2739)
17d3d2f75 [wpilibc] Add ScopedTracer class (#2724)
73950b985 [wpilibc] RobotBase::IsReal, IsSimulation: Add doxygen comments (#2735)
61ee331f1 [build] Double gradle build max heap size to 2G (#2689)
651319589 [wpilibc] Fix a use-after-free in DifferentialDrivetrainSim (#2741)
5479948bd Update filepaths in thirdparty notices (#2713)
1ec145ec8 [imgui] Add IMGUI_IMPL_OPENGL_LOADER_GL3W to cmake compile defs (#2728)
8ab47cb07 [wpilib] Add C++ diff-drive sim tests and fix Java test name (#2729)
b7b3dcf3e Reorganize build documentation (#2712)
f7da0b452 Improve list of build requirements in README (#2709)
f9a338018 [build] Add macOS CMake CI (#2711)
b61f08d3f [wpilib] Add physics simulation support with state-space (#2615)
050322592 [build] CMake: Fix Metal linking on macOS (#2725)
d4d0b5501 [wpilib] Use more inclusive terminology (NFC) (#2723)
6c5726c96 Add CODE_OF_CONDUCT (#2716)
56972447b [wpigui] Only build static for both gradle and cmake (#2703)
67e1796ef [wpimath] Fix Eigen rule-of-three violations (#2707)
1ae8da3b3 [wpigui] Move portable-file-dialogs.h to wpigui and upgrade it (#2704)
3ed97f45f [cscore] Properly init variable in usbviewer (#2702)
ae2809cad [wpimath] Update KalmanFilter C++ class docs based on Java (NFC) (#2699)
b0a296477 [wpimath] Use newer link to controls book in comments (NFC) (#2700)
629a4574d [wpimath] Include Eigen headers in cppHeadersZip (#2696)
4be809499 [wpimath] Use more specific Eigen includes in headers (#2693)
b10063da9 [sim] Set Encoder reset to false when count set (#2692)
5e54e1314 [sim] Ignore incoming websocket DS/Joystick when real DS connected
8f87c5631 [sim] Automatically turn off GUI DS when real DS connected
1b18560e9 [sim] ds_socket: Remove iostream
f86a5f9b0 [sim] WebSockets: don't override HAL_Main
f1b1bdb12 [hal] Add HAL_Shutdown and simulation shutdown callbacks
0365557b2 [sim] Make extension registry thread-safe
883d96283 [wpiutil] SimpleBufferPool: Deallocate on destruction
35790a899 [wpimath] Remove rho overload from LinearQuadraticRegulator constructors (#2687)
8edc17dac [wpimath] Add Vector overload for times and div (#2686)
502f5c8b5 [wpimath] Make LinearPlantInversionFeedforward's A and B matrices final (#2688)
bc28fb187 [wpimath] Remove print from LinearSystemIDTest (#2684)
de0277713 [sim] Add API for extensions to discover each other (#2681)
1593eb4d4 [sim] Add plotting to simulation GUI
70ba92f91 [sim] GUI: Show DS info even when GUI DS disabled
47cc71ea0 [hal] Add HALSIM_GetJoystickCounts
9453d6727 [sim] Output more error details on extension load failure (#2680)
f758af826 [wpilib] Use misspell to find more spelling errors (NFC) (#2679)
6a1e5385e [sim] WS: Don't call virtual function from destructor
63487dca7 [sim] Fix WS blank device messages (e.g. DriverStation)
7d6f09f5c [sim] SimDataValue: Fix cancellation
148eed3cd [sim] Make sure NotifyListener members are initialized
05701317b [build] Make loading sim extensions from MyRobot easier (#2671)
7548fdae5 [hal] Fix InitialzeInterrupts naming (#2673)
3e41d92c1 [wpilib] Use misspell to fix spelling errors (NFC) (#2674)
ad6c8b882 [hal] Fix PDP Energy Calculation (#2672)
947ff655c [wpimath] Refactor KalmanFilter to be steady-state only (#2657)
183b7c85a [wpigui] Handle Direct3D framebuffer resize
4cf6947af [cscore] Add wpigui-based USB camera viewer
b83709b26 [wpigui] Add GetDistSquared and MaxFit functions
c699d5517 [wpigui] Build dev executable in cmake build
781afaa85 [wpigui] Refactor texture handling
007b03a2c [hal] Fix wpiformat errors (#2670)
ed1869334 [hal] Add no throw/error version of CAN Write methods (#2063)
7c99224bb Create maintainers.md (#1937)
c2c409090 [build] Fix CMake imgui and wpigui on macOS (#2669)
416288061 [build] Fix Gradle build on macOS 11.0 Big Sur (#2656)
83376bc23 [build] Add sourcelink support for windows pdbs (#2592)
c0de98f9f [sim] Fix GUI scaling of window sizes (#2668)
70db0db22 [build] Don't unconditionally regenerate wpimath numbers (#2665)
526f26685 [wpilib] Add methods to check game and enabled state together (#2661)
5d1220e62 [sim] Use wpigui for simulator GUI
b80fde438 [wpigui] Add wpigui wrappers for GLFW+imgui
148f43b4a [wpilibc] Use LLVM containers in ShuffleboardInstance (#2658)
0d88213de [sim] Add missing new line to extension loader message (#2663)
36b8d74fa [build] Revert "[build] Apply temporary JDK arch fix (#2643)" (#2655)
5021f2815 [wpilibc] Fix InterruptableSensorBase comment (#2659)
ee6a81457 [wpilib] Enable continuous input on theta controller in swerve examples (#2651)
807de9a0a [build] Fix Eigen include path for CMake install (#2649)
9398b6b55 [sim] Add AnalogEncoderSim (#2647)
932bfcf37 [sim] Add WebSocket extension (client/server) (#2589)
e127bac7f [sim] Properly initialize AnalogTrigger (#2646)
bccf13bf6 [build] Run unit tests in CMake build (#2644)
950bbd6dc [wpilibj] Fix joystick button edge synchronisation (#2433)
e680ba85f [build] Apply temporary JDK arch fix (#2643)
b23ede7d5 [wpimath] Remove unnecessary copying in constraints (#2645)
73047d8b3 [wpiutil] Fix WPIUtilJNI.now() implementation (#2640)
ef5e0c2e7 [wpimath] Remove duplicate WPIMathJNI class (#2639)
dc9e560f9 [sim] Add callback for NotifyNewData
ae5b07ba0 [hal] Add stubs for sim joysticks and match info on Rio
3384c23a5 [build] Specify --tags on fetch and add version sanity check (#2638)
c2259d42a [wpilib] Add Toggle() function to solenoid classes (#2635)
370e9d089 [build] Remove Azure Pipelines CI
cab8b18c6 [build] Add GitHub Actions CI Workflow
3b283ab9a [wpimath] Add core State-space classes (#2614)
e5b84e2f8 [wpimath] Use project includes for units, Drake, Eigen (#2634)
f86417d79 [wpimath] Move MathShared.h to wpimath/ directory
8dc3d2383 [wpimath] Move DrakeJNI to edu.wpi.first.math.WPIMathJNI
42993b15c [wpimath] Move math functionality into new wpimath library (#2629)
ad817d4f2 [sim] Map wpi::Now() to simulated FPGA time (#2631)
77954bb3d [wpiutil] Add JNI wrapper for wpi::Now() (#2632)
52f7a62e1 [wpiutil] Allow aarch64 platform on any OS (#2625)
1b8ceb36f [sim] Add callbacks for joysticks and match info (#2628)
ceea1f9d4 [sim] Add Mechanism2D to Simulation GUI (#2607)
2f81f2b78 [wpilib] Fix timestamp slew in SlewRateLimiter (#2627)
aba035eb3 [command] Modify swerve and mecanum commands to use new controller
5ca270208 [wpilib] Add HolonomicDriveController class and tests
af588adce [wpiutil] Add angle normalization method
399684a58 [wpilibc] Make SendableChooser movable (#2621)
5cf4c16f5 [wpilibj] Suppress serialVersionUID warnings (#2618)
0fe2319df [wpilibj] Use try with resources for Java tests (#2612)
e759dad01 [wpiutil] Add Drake and Drake JNI (#2613)
0c18abed3 [build] Double gradle build max heap size to 1G (#2616)
89dad2fd8 [build] Use artifactory doxygen mirror (#2600)
a6a71f8c7 [hal] Fix RoboRIO notifier never starting (#2611)
1fee190fd [wpiutil] Add MIME type utility (#2608)
23ba3ca19 [wpilib] Change Watchdog to use HAL notifier (#2602)
33d836329 [sim] Fix HAL notifier race condition (#2606)
49dcf7cf5 [command] Speed up MecanumControllerCommand and SwerveControllerCommand tests (#2604)
9778445a7 [sim] Change stepTiming to take seconds (#2599)
c2cc90b27 [sim] Move WPILib C++ sim implementations out of line (#2598)
b9feb8122 [sim] Add joystick simulation support (#2595)
b06ddcdd8 [wpilib] Improve and sync AnalogPotentiometer docs (NFC) (#2580)
16ef372b5 [hal] Merge WaitForCachedData into WaitForDSData (#2587)
f0a34ea64 [wpilib] Remove Analog Gyro specific docs from Gyro interface (#2596)
33f7dec5c [wpilibj] Fix Gyro.getRotation2d() units bug (#2594)
300580359 [build] Update to latest native utils (#2591)
eeaaf5d25 [build] Add Azure build using cmake on Windows (#2588)
15819cc98 [command] Add SimulationPeriodic to templates (#2582)
fe6bfb1ba [cscore] Provide USB Camera VID and PID in Windows (#2585)
5c8d7b242 [build] Remove install prefix from CMakeLists.txt for Windows (#2584)
ff0801d78 [build] Revert change to DeriveLineEnding made in #1961 (#2581)
ac4b0a311 [wpilib] AnalogPotentiometer: Use average voltage (#2583)
227084e92 [hal] Implement stub mockdata on RoboRIO (#2575)
a175f6e86 [command] Add simulationPeriodic method to Subsystem (#2577)
4043c461d [wpiutil] HttpServerConnection: Make more functions virtual (#2576)
b3b2aa635 [wpilib] Fix SplineHelper cubic spline bug (#2572)
5bd2dca46 [sim] Move HAL_LoadExtensions to end of HAL_Initialize (#2571)
21740fd2c [build] Add PDBs to jnicvstatic archives (#2573)
c11ef442f [wpiutil] Add HttpWebSocketServerConnection (#2505)
b5a38001d [cscore] Add support for changing the USB camera path (#2547)
5b6f68cf7 [wpilib] Add parentheses to MSVC #pragma message (#2569)
3050e935a [sim] Add WPILib-class-taking constructors (#2538)
80a1fa9ec [sim] Add support for disabling SimDevices (#2568)
1851ba143 [sim] Remove index from RoboRIO simulation interface (#2567)
c4b8a2505 [sim] Add Java wrapper for getProgramStarted (#2566)
a1d2d40ad [wpilib] Add RamseteController examples (#2553)
a3881bb45 [wpilibc] Add implicit conversion from degree_t to Rotation2d (#2564)
6e4ee8da2 [cscore] Limit jnicvstatic exports to only C and JNI symbols (#2565)
2a0f79b90 [wpilib] Add X and Y component getters to Pose2d and Transform2d (#2563)
5ccc98bc1 [wpiutil] Add angular acceleration units (#2562)
b1353e4d6 [cscore] Fix jnicvstatic classifier (#2561)
9f4de9155 [cscore] Add new jnicvstatic artifact type (#2560)
d30d1088d [wpiutil] Split units.h into separate headers for each unit (#2551)
c6e634664 [sim] Support StepTiming() even when timing is not paused (#2558)
e08c8a1fc [wpiutil] Add circular buffer class with static size (#2542)
e50dbe0c4 [wpilib] Add Gyro::GetRotation2d() (#2555)
d9c7bbd04 [wpiutil] Restore existing dll directory when setting dll directory (#2559)
dac0e5b13 [sim] Set Windows timer precision to 1ms (#2557)
ce3bc9194 [sim] Move Sim classes from HAL to wpilibc/j (#2549)
22c0e2813 [build] Upgrade CI to clang-format 10.0 (#1961)
9796987d5 [wpiutil] Add new combined native class loader (#2554)
4d275e476 [cscore] Fix USB camera test failure (#2556)
492d6c282 [sim] Update thirdparty-imgui (#2552)
765f00935 [wpiutil] Add HttpQueryMap and HttpPath/HttpPathRef (#2544)
629e8b41f [sim] Provide method to set the runtime type (#2539)
71c187a1e [hal] Add GetIndex() to handles classes (#2548)
00e991e2a [wpiutil] Add dual-IPv4/IPv6 uv::AddrToName() (#2545)
8a80f97c0 [hal] Move JNI helpers and sim namespace to hal namespace (#2543)
3cbec411c [build] Add package declaration check to checkstyle (#2446)
3bcb89fb8 Set rpath on all unix platforms to $ORIGIN (#2299)
62b8a36ce [sim] Wrap timing functions in C++ SimHooks (#2540)
27566abb0 [command] PIDSubsystem: Add GetSetpoint (#2534)
dfb130270 [wpilib] Use inclusive language where practical (#2533)
1ba616f84 [build] Fix 32-bit Windows builds (#2537)
11fb0a4cb [cscore] EnumerateUsbCameras(): Only list capture devices (#2532)
1557a4c3b [sim] Make SimDeviceInfo/SimValueInfo data members public (#2531)
ab28a7d65 [build] Run Gradle Wrapper validation on PRs (#2527)
d58a5e124 [sim] Name DSCommJoystickPacket structure (#2525)
762347f00 [wpilibj] Throw separate exception for constraint misbehavior (#2510)
4b76adf15 [wpilibc] Remove incorrect timer rollover (#2523)
6be1b9524 [wpilibj] Trajectory: Add zero-arg constructor (#2513)
38ad79061 CONTRIBUTING.md: Change Travis to Azure (#2520)
86acb27e2 [wpilibc] Fix doxygen comments (#2519)
1b395fa21 [wpilib] Implement Trajectory.equals() (#2517)
92380485c [command] Make cancel safe to call from initialize (#2440)
27f9a21a2 [wpilib] Moved Watchdog output to reportWarning() (#2413)
cf7088a46 [wpilibj] RamseteController: Fix units typo in javadocs (#2515)
67554ef3b [build] Add .inl files to styleguide (NFC) (#2506)
cf20b068c [sim] Map HAL_GetSystemActive to HALSIM_GetDriverStationEnabled (#2501)
0b9316d94 [build] Revert workaround for azure windows library loading issue (#2481) (#2499)
3011ebe54 [wpilibc] Fix uninitialized variable in Trajectory class (#2495)
4b77b0773 [wpilibj] SensorUtil: change exception type (#2490)
e5935a473 [wpilibc] Fix const-qualification in kinematics and constraints (#2478)
a3a8472b8 [wpilib] Trajectory: Add MaxVelocity and Region constraints (#2466)
212182d99 [wpilibj] Remove getSimObject (#2479)
c82b8546b [build] Work around azure windows library loading issue (#2481)
fac4e3fcf [wpilibc] Add real-time priority constructor to Notifier (#2303)
5b0122fed [sim] Add NetworkTables view to Simulation GUI (#2327)
b46b5df16 [wpilibc] Output Tracer to DriverStation by default (#2469)
cb5102933 [wpilib] Add Color.fromHSV() static helper (#2461)
e504b3ecb [command] Add NetworkButton (#2373)
0ad0ec098 [wpilibj] Move button tests to button package (#2472)
d1d32ada0 [build] Fix artifact publishing (#2471)
8058daa98 [sim] Add encoder rate and distance to Simulation GUI (#2470)
f4c5c0f5b [command] Add withName inline decorator to Java (#2420)
2ecb8dab7 Add issue templates (#2189)
576d427f0 [wpilib] SpeedControllerGroup: Add vector-taking constructor (#2194)
21aafea09 [hal] Use std::thread for Notifier thread on Rio (#2152)
3ed290856 [sim] Add HALSIM accessors for encoder rate and distance (#2467)
2b188b54d [ntcore] Always show StartLocal instances as connected (#2462)
306720e63 [build] Split build logic into separate files (#2457)
a308dd447 [wpilib] Fix SplineHelper quintic spline generation bug (#2429)
8f33d21bc [wpilib] Add init methods to Preferences (#2443)
b9ee3ae03 [wpilibc] Refactor Tracer functionality out of Watchdog class (#2456)
c14b87b22 [wpilibj] Refactor Tracer functionality out of Watchdog class (#2452)
8a279aaf2 [build] Check SHA-256 of downloaded Gradle distribution (#2169)
3a5e541b2 [wpilibc] Add doxygen deprecated tag to deprecated methods (#2336)
43574128b Add a CODEOWNERS file (#2431)
e4a990384 [build] Fix generateJavadoc dependencies (#2458)
0d30108dc [wpiutil] Endian.h: minor cleanup and improvements (#2454)
b7a79c70c C++: Add Watchdog to CommandScheduler (#2437)
6e6f28d1a Add watchdog and epoch reporting to CommandScheduler (#2319)
d14978e54 New commands: add docs to end() (#2450)
1c28b729a Move curvature_t to units namespace (#2444)
303194b08 Add missing CAN definition for IO Breakout (#2394)
2ee3bfaa2 Make SlewRateLimiter unit declarations public (#2445)
029a94dd3 Remove old simulation bits (ds_nt, lowfi, print) (#2432)
f6df9217b Remove static import usage in SelectCommand example (#2442)
184fae4ba DutyCycleEncoder: Set ownsDutyCycle for channel constructor (#2436)
35b236651 Timer.start(): Match C++ behavior in Java (#2434)
c92677055 DutyCycleEncoder: Close created DigitalInput (#2435)
272eaf184 DutyCycleEncoder: Fix simulation support (#2387)
56fbb1fc3 Make Ultrasonic.setAuto() static (#2419)
33f6bf947 DriverStation (Java): Make getStickButton functions public (#2424)
07326edb6 Sim GUI: Add user rename support to SimDevice list (#2426)
144610151 Bump NativeUtils to enable bigobj (#2430)
4228d3609 Fix Watchdog epoch prints being off by three orders of magnitude (#2414)
510936a2a Improve Button API documentation in GenericHID (#2421)
5854e284e Convert license file to Markdown (#2190)
a732606e5 Geometry classes: remove explicit serializers/deserializers (#2312)
84e300739 Fix ProfiledPIDController profile direction for continuous input (#2279)
8edf9282c Timer: synchronize on lock object (#2352)
5a1acaaef Update copyright dates for #2121 (#2415)
4fd7c210d Shuffleboard: Fixed mix up of title and type parameters (#2121)
a26a7d217 Remove references to percent tolerance (#2380)
7b7f44d93 Use netcomm function to get target class rather then hardcoded (#2391)
6cf89aa0f Fix interrupt cancellation (#2406)
3be83784c Add Transform2d::Inverse() (#2407)
b6c163acd Const-qualify frc2::Timer::HasElapsed() (#2397)
05a26b727 Fix missing Field2d package (#2386)
35eb90c13 Fix "'dimensionless' ambiguous symbol" error (#2382)
761f79385 Add SimulationInit and SimulationPeriodic functions (#2377)
554bda333 HAL: Expose NetComm SendConsoleLine (#2337)
2a968df77 Add method for releasing a waiting interrupt (#2347)
30ccd13b6 Add methods for getting color of an LED (#2366)
60c09ea51 Fix notifier race happening with very fast notifiers (#2370)
65eab9352 Fix DifferentialDriveVoltageConstraint for tight turns w/ zero velocity (#2341)
a226ad850 Set a default option for Sendable Chooser in examples (#2361)
31f4fd70c Sim GUI: Fix crash when field/robot image load is canceled (#2362)
7275ab983 Add headerpad_max_install_names to Mac builds (#2333)
5b3facc63 TrapezoidProfile: Make units public (#2342)
0f313fb9a cmake: Improved portability of OpenCV Java binding search (#2348)
05b7593e6 C++ circular_buffer: support types not implicitly convertible from int (#2350)
1b85066d2 Fix C++ ParallelRaceGroup multiple calls behavior (#2339)
e93b64f58 Add note that only a single instance of ADXRS450 is supported (#2349)
f0a18f31e Timer: add hasElapsed, advanceIfElapsed (#2322)
29c82527a Fix typo in ADXL sim double creation (#2332)
c165dc5e5 Simulation GUI: Add 2D field view (#2261)
42da07396 Add missing references to f in PIDSubsystem javadoc (#2318)
20e6c0405 Fix cmake install of hal generated files (#2320)
ff5d3e5b3 RamseteController: Add setEnabled method (#2313)
6cc68ab50 Update MavenArtifacts.md (#2289)
068465146 Fix null check order in SendableRegistry (#2314)
3bcf8057d Add more detail to RuntimeLoader failure message (#2309)
8039a6c52 Add missing include to ShuffleboardEventImportance (#2310)
558c020cc Fix duplicated state when using quintic splines (#2307)
7797da78f Add missing methods to Timed and TimedSkeleton templates (#2306)
0ab81d768 Add feed-forward and slew rate limiting to advanced drive examples (#2301)
1cee5ccb9 Feed RobotDrive watchdog in RamseteCommand example (#2298)
3ce01b5ac Fix DriveSubsystem.getHeading Java documentation (#2282)
e6aa8f3ff Update toolchain link in readme (#2304)
9d7b08797 Simulation GUI: Add support for custom names (#2292)
bb184ed48 Simulation GUI: Refactor ini saving (#2291)
b9b31069c Fix C++ POVButton (#2294)
d0cf4e888 Change sim Filesystem.getDeployDirectory() to src/main/deploy (#2293)
02fb85076 Add new speed controllers to shuffleboard docs (#2288)
ac8177e10 Fix GearsBot log methods not being called periodically (#2280)
2eb5c5447 TrapezoidProfile: Fix aliasing of m_initial to result in calculate() (#2284)
0e206e69c Remove Set Camera Server Shared message (#2285)
b1357cace Fix LiveWindow SetEnabled C++ std::bad_function_call (#2281)
37202b6f2 Add missing SensorUtil::kAnalogOutputs (#2276)
2ac0d5296 Remove AnalogTrigger::SetDutyCycle (#2275)
dbe1e6f46 Fix missing SetDutyCycleSimDevice on Rio (#2274)
a61fcbd68 Make Button class concrete (#2244)
fe597eeba Fix SPI DIO count for sim (#2272)
e213a47ef Official Gradle Wrapper Validation GitHub Action (#2273)
dcb96cb50 TrajectoryGenerator: Allow replacement of error reporting function (C++) (#2267)
60d48fec5 Fix Java static colors having zero values (#2269)
ee8475d21 Run wpiformat (#2270)
f47e31813 C++ units: Interoperate with Windows headers min/max (#2268)
cb66bcca3 Add callback handlers for LiveWindow (#2053)
73302f616 Fix color name typos (#2265)
cba21a768 Fix C++ JoystickButton and POVButton (#2259)
822e75ec4 Simulator GUI: Handle save file having window size=0 (#2260)
108ddfa1b Fix Pi Camera auto exposure property name (#2258)
d4c8ee591 Add Axis enum in XboxController (#2253)
ab9647ff5 CommandScheduler: Don't store NetworkTableEntry
6666d3be4 SendableBuilder: Allow multiple updateTable functions
795086b4c Fix Demangle when used standalone (#2256)
56765cf49 C++ CommandBase: Don't add to LiveWindow (#2255)
bf7012fa2 Fix new CommandScheduler.cancelAll() (#2251)
10e8fdb72 Make C++ IterativeRobotBase and RobotBase constructor and destructor public (#2242)
790dc552c Add quirks support for Pi camera (#2241)
0ec8ed6c0 Make C++ controller using declarations public (#2240)
832693617 Add missing definition for PIDController::SetPID() (#2239)
772ef8f96 Update Maven location to artifactory (#2235)
95b6cd2dd TrajectoryGenerator: Allow replacement of error reporting function (#2234)
ce1ac17df Remove experimental from new command example descriptions (#2226)
b2f7a6b65 Add clarification to LED about length and # of drivers (#2231)
bedbef799 Revert "Remove -no-module-directories flag from javadoc build (#2201)" (#2229)
bc159a92a Default sim voltage to 12v, make user rails active (#2224)
f50d710a5 Make color ctor public (#2222)
bc8f68bec Add sim HAL_WaitForCachedControlData (#2221)
32c62449b Add ArrayRef overloads to new command classes (#2216)
6190fcb23 Run wpiformat (#2218)
012d93b2b Use an explicit stack instead of recursion when parameterizing splines (#2197)
222669dc2 Fix trapezoidal profile PID controller setpoint bug (#2210)
abe25b795 TrajectoryUtil.toPathweaverJson: Create parent directories (#2214)
354185189 Update ProjectYear to 2020 (#2212)
f14fe434a Add (Old) qualifier to old subsystem (#2211)
e874ba931 Add Color classes for use with AddressableLED (#2127)
96348e835 Fix C++ SendableRegistry::AddChild() (#2207)
d91796f8d fix clang-format version number (#2206)
9abce8eb0 Fix subsystem LiveWindow usage (#2202)
8b4508ad5 Use default path for networktables.ini in simulation (#2205)
5b7dd186d Add templates for new commands for vscode plugin (#2016)
6ea13ea8f ntcore: Add support for local-only operation (#2204)
44bcf7fb4 Java examples: use non-static imports for constants (#2191)
c7a1dfc0b Add SlewRateLimiter class (#2192)
a12bb447e Fail cmake build if python3 generate_numbers.py fails (#2203)
c4bd54ef4 Add JNI binding to suppress driver station error/warning messages (#2200)
f9a11cce5 Remove -no-module-directories flag from javadoc build (#2201)
6008671c3 Report WPILib version as part of usage reporting (#2199)
7b952d599 Add usage reporting for many new things (#2184)
93cdf6869 Add Constants.cpp for MecanumControllerCommand example (#2196)
0c6f24562 Fix bug in ULEB128 decoding (#2195)
bdc1cab01 Add support for configuring SPI Auto Stall Config (#2193)
3259cffc6 Add transform methods to Trajectory (#2187)
67b59f2b3 Minor improvements/fixes to new command framework (#2186)
1ce24a7a2 Add 2020 speed controllers (#2188)
635882a9f Add getter for initial pose in Trajectory (#2180)
71a22861e Use ManagedStatic for CameraServer (#2174)
9cb69c5b4 Add a way to pass in a preconstructed value to ManagedStatic (#2175)
5e08bb28f Add docs and lifecycle tasks for faster dev builds (#2182)
ea4d1a39e Update characterization values to match real robot (#2183)
31b588d96 Fix ArmFeedforward Javadocs (#2176)
0b80d566a Use ChipObject HMB function for LED (#2173)
f8294e689 Sim GUI: Add a bit of spacing to the analog inputs (#2170)
b78f115fc Work around VS2019 16.4.0 bugs (#2171)
b468c5125 Change AddressableLED example to use consistent PWM port (#2168)
023c08829 Add toString() to relevant kinematics classes (#2160)
8a11d13a3 Fix C++ DutyCycleEncoder int constructor (#2166)
daa81c64a Minor javadoc fix in SwerveDriveKinematicsConstraint (#2167)
e20d96ea4 Use __has_include for WPILib.h (#2164)
a76d006a0 Update native-utils to 2020.7.2 (#2161)
24c031d69 Increase SPI auto byte count to allow 32 bytes to be sent (#2163)
6b4eecf5f Add hidden functions to get the SPI system and SPI DMA (#2162)
ccdd0fbdb Add TrapezoidProfile external PID examples (#2131)
5c6b8a0f4 Replace std::is_pod_v with std::is_standard_layout_v (#2159)
67d2fed68 Add DutyCycleEncoder channel constructor (#2158)
d8f11eb14 Hardcode channels for LSB weight (#2153)
b2ae75acd Add way to disable "no extensions found" message (#2134)
4f951789f Build testbench tests online inorder to improve speed (#2144)
005c4c5be Try catch around task dependencies to fix loading in editor (#2156)
34f6b3f4c Fix C++ RamseteCommand param doxygen (#2157)
f7a93713f Fix up templated TrapezoidProfile classes (#2151)
8c2ff94d7 Rename MathUtils to MathUtil for consistency with other util classes (#2155)
d003ec2dc Update to 2020v9 image (#2154)
8e7cc3fe7 Add user-friendly SimDeviceSim wrappers (#2150)
6c8f6cf47 Fix bug in cubic and quintic hermetic spline generation (#2139)
e37ecd33a Sim GUI: Add support for LED displays (#2138)
57c5523d6 Fix documentation in RamseteCommand (#2149)
7b9c6ebc2 Fix wpiutilJNIShared linkage typo in wpilibj (#2143)
9a515c80f Template C++ LinearFilter to work with unit types (#2142)
5b73c17f2 Remove encoder velocities methods in DifferentialDriveOdometry (#2147)
b8c102426 Fix PS3Eye VID and PID (#2146)
2622c6c29 Add default values for b and zeta in RamseteController (#2145)
f66ae5999 Add HSV helpers to AddressableLED (#2135)
5e97c81d8 Add MedianFilter class for moving-window median (#2136)
f79b7a058 Remove unnecessary constructor arg for LinearFilter's circular buffers (#2140)
e49494830 Replace Jenkins with Azure agent (#1914)
b67d049ac Check status of PDP CAN reads (#2126)
70102a60b SendableRegistry.foreachLiveWindow: Prevent concurrent modification (#2129)
6dcd2b0e2 Improve various subsystem APIs (#2130)
ce3973435 HAL_CAN_ReceiveMessage: return MessageNotFound if no callbacks registered (#2133)
3fcfc8ea7 Fix double disable segfaulting interrupts (#2132)
6ceafe3cd Fix class reference for logger (#2123)
b058dcf64 Catch exceptions generated by OpenCV in cscore JNI (#2118)
0b9307fdf Remove unused parts of .styleguide files (#2119)
39be812b2 Fix C++ ArmFeedforward (#2120)
21e957ee4 Add DifferentialDrive voltage constraint (#2075)
e0bc97f66 Add ProfiledPIDSubsystem example (#2076)
3df44c874 Remove Rotation2d.h wpi/math include (#2117)
a58dbec8a Add holonomic follower examples (#2052)
9a8067465 Fix incomplete .styleguide (#2113)
ffa4b907c Fix C++ floating point literal formatting (#2114)
3d1ca856b Fix missing typename and return type (#2115)
5f85457a9 Add usage reporting for AddressableLED (#2108)
4ebae1712 Enforce leading/trailing zeros in Java numeric constants (#2105)
fa85fbfc1 Template C++ TrapezoidProfile and ProfiledPIDController on units (#2109)
f62e23f1a Add Doxygen for new HAL interfaces (#2110)
5443fdabc Directly construct PWM port from HAL, avoid wpilib PWM object (#2106)
c0e36df9d Standardize on PWMVictorSPX in examples (#2104)
8c4d9f541 Add TrapezoidProfileSubsystem (#2077)
45201d15f Add encoder distance overload to DifferentialDriveOdometry (#2096)
845aba33f Make feedforward classes constexpr (#2103)
500c43fb8 Add examples for DMA, DutyCycle, DutyCycleEncoder and AddressableLED (#2100)
589162811 Use DifferentialDriveWheelSpeeds in RamseteCommand ctor (#2091)
b37b68daa Add JRE deployment to MyRobot Deploy (#2099)
0e83c65d2 Fix small logic error in ParallelDeadlineGroup (#2095)
6f6c6da9f Updates to addressable LED (#2098)
1894219ef Fix devmain package in commands (#2097)
77a9949bb Add AddressableLED simulation GUI support
a4c9e4ec2 Add AddressableLED simulation support
8ed205907 Add AddressableLED (#2092)
59507b12d Bump to 2020 v7 image (#2086)
5d39bf806 Make halsimgui::DrawLEDs() values parameter const (#2088)
841ef91c0 Use gyro angle instead of robot angle for odometry (#2081)
1b66ead49 Use standard constant for pi instead of 3.14 (#2084)
db2c3dddd Use DMA Global Number for DMA Index (#2085)
82b2170fe Add DMA support to HAL and WPILibC (#2080)
8280b7e3a Add DutyCycleEncoder and AnalogEncoder (#2040)
551096006 Use kNumSystems for DutyCycle count in Ports (#2083)
df1065218 Remove release configs of deploy in MyRobot (#2082)
bf5388393 Add deploy options to myRobot (#2079)
b7bc1ea74 Update to 2020v6 image (#2078)
708009cd2 Update to gradle 6.0 (#2074)
3cce61b89 Add SmartDashboard::GetEntry function in C++ (#2064)
565e1f3e7 Fix spelling in MecanumDriveOdometry docs (#2072)
1853f7b6b Add timing window to simulation GUI
c5a049712 Add simulation pause/resume/step support
f5446c740 Add Notifier HALSIM access
3e049e02f Add name to HAL Notifier
2da64d15f Make usage reporting enums type match (#2069)
f04d95e50 Make FRCUsageReporting.h C-compatible (#2070)
d748c67a5 Generate docs for command libraries and fix doclint enable (#2071)
55a7f2b4a Add template for old command-based style (#2031)
486fa9c69 Add XboxController examples for arcade and tank drive (#2058)
e3dd1c5d7 Fix small bug in SplineHelper (#2061)
7dc7c71b5 Add feedforward components (#2045)
5f33d6af1 Fix ProfiledPIDSubsystem parameter name (#2017)
94843adb8 Standardize documentation of Speed Controllers bounds (#2043)
9bcff37b9 Add HAL specific version of wpi_setError (#2055)
326aecc9a Add error message for CAN Write Overrun (#2062)
00228678d Add requirements param to more Command APIs (#2059)
ff39a96ce Make DigitalOutput a DigitalSource (#2054)
5ccad2e8a Fix frc2::Timer returning incorrect timestamp values (#2057)
629e95776 Add VendorDeps JSON files for command libraries (#2048)
6858a57f7 Make notifier command tests a lot more lenient (#2056)
0ebe32823 Fix MyRobotStatic accidentally linking to shared command libs (#2046)
384d00f9e Fix various duty cycle bugs (#2047)
1f6850adf Add CAN Manufacturer for Studica (#2050)
7508aada9 Add ability to end startCompetition() main loop (#2032)
f5b4be16d Old C++ Command: Make GetName et al public (#2042)
e6f5c93ab Clean up new C++ commands (#2027)
39f46ceab Don't allow rising and falling values to be read from AnalogTrigger (#2039)
d93aa2b6b Add missing lock in FRCDriverStation (#2034)
114ddaf81 Fix duplicate encoders in examples (#2033)
f22d0961e Sim GUI: Add duty cycle support
3262c2bad Sim GUI: Use new multi-channel PDP getter function
96d40192a Revert accidental change to MyRobot.cpp (#2029)
ed30d5d40 Add JSON support for Trajectories (#2025)
2b6811edd Fix null pointer dereference in C++ CommandScheduler (#2023)
1d695a166 Add FPGA Duty Cycle support (#1987)
509819d83 Split the two command implementations into separate libraries (#2012)
2ad15cae1 Add multi PDP getter and sim PCM/PDP multi arg functions (#2014)
931b8ceef Add new usage reporting types from 2020v5 (#2026)
0b3821eba Change files with CRLF line endings to LF (#2022)
6f159d142 Add way to atomically check for new data, and wait otherwise (#2015)
a769f1f22 Fix bug in RamseteCommand (using degrees instead of radians) (#2020)
c5186d815 Clean up PIDCommand (#2010)
9ebd23d61 Add setVoltage method to SpeedController (#1997)
f6e311ef8 Fix SplineHelper bug (#2018)
f33bd9f05 Fix NPE in RamseteCommand (#2019)
1c1e0c9a6 Add HAL_SetAllSolenoids to sim (#2004)
ea9bb651a Remove accidental OpenCV link from wpilibc shared library (#2013)
cc0742518 Change command decorators to return implementation (#2007)
16b34cce2 Remove IterativeRobot templates (#2011)
669127e49 Update intellisense to work with Beta 2020 code (#2008)
9dc30797e Fix usage reporting indices (#2009)
f6b844ea3 Move HAL Interrupt struct to anonymous namespace (#2003)
a72f80991 Add extern C to DigitalGlitchFilterJNI (#2002)
916596cb0 Fix invalid examples json, add validator (#2001)
5509a8e96 Use constexpr for all example constants
0be6b6475 Use constexpr for DifferentialDriveKinematics
936627bd9 wpilibc: Remove direct CameraServer dependency (#1989)
8e333c0aa Use FPGA Time instead of wall clock time for odometry (#1996)
d4430b765 Gearsbot example: Use standard argument order (#1995)
75438ab2c Add RamseteCommand (#1951)
989df1b46 Bump Native Utils and OpenCV dependencies (#1993)
dbc33b61e Fix Timer usage in TrapezoidProfileCommand (#1992)
79f8c5644 Add TrapezoidProfileCommand (#1962)
9440edf2b Refactor TrajectoryGenerator (#1972)
73a30182c Add frc2::Timer (#1968)
36ea865ed Add toString for geometry and trajectory classes (#1991)
cbe05e7e8 Update ProfiledPIDController API (#1967)
d04eb3546 Deprecate old PID classes (#1964)
02264db69 Add JNI dependencies to myRobotCpp (#1980)
2a76c996e Use VID/PID detection for PS3Eye (#1977)
a3820bbdf Remove HAL_BaseInitialize (#1981)
a83fb4793 Update to 2020v5 image (#1983)
4b0ed910e Make SwerveDriveKinematics.toChassisSpeeds() public (#1976)
103c1b121 Remove DS caching from the HAL level (#1971)
6635ea75e Fix NPE in SendableRegistry.foreachLiveWindow() (#1974)
cfe23c5cd Fix grammar error in comment for configureButtonBindings (#1969)
4bde2654e Fix mac azure build (#1973)
4f034e6c1 generateTrajectory: default reversed param to false (#1953)
acf960f72 Sim GUI: Add option to disable outputs on DS disable
2d3dac99f Sim GUI: Handle low resolutions and scale default window positions
07c86e0cd Sim GUI: Support High DPI monitors
46ad95512 SimDeviceData: Add missing null check
5bce489b9 Add ProggyDotted font to imgui (both cmake and gradle)
55af553ac Simulation GUI: Map gamepad the same way as DS
c59f9cea5 CameraServer: Add VID/PID support for Linux USB devices (#1960)
3fc89c84d Make splinePointsFromSplines public (#1963)
2c5093797 Fix implicitly deleted move constructors (#1954)
f3ad927f4 Update Java SmartDashboard and LiveWindow to match C++
05c25deb7 Fix move handling of C++ Sendable in SmartDashboard and LiveWindow
d726591ce Fix Gazebo sim plugin build (#1959)
2ff694fa4 Unbreak gradle build when other compilers installed (#1958)
53816155b Improve command decorator names (#1945)
a38f183a9 Fix GenResources.cmake so it's usable in a submodule (#1956)
b3398dca3 Set gradlebase correctly for all examples (#1950)
2c311013d Add Aarch64Bionic platform detection (#1922)
c10f2003c Add generateTrajectory overload (#1944)
63cfa64fb Add getters for pose in odometry classes (#1943)
2402c2bad Fix C++ command group recursive constructor bug (#1941)
f4eedf597 Fix ConcurrentModificationException in CommandScheduler (#1938)
bb0b207d2 Fix array out of bounds exception caused by parallel race group (#1935)
7bd69e591 Fix typo in temperature (#1940)
ec9738245 Bump to 2020 v4 image (#1931)
46303a822 Add messaging to extension loading in the HAL (#1926)
d169d6be9 Set extract_static for Doxygen config so that static members show up (#1930)
4e183eb10 Bump to 2020 v3 image (#1929)
84c185803 LiveWindow: catch errors in callback/builder functions (#1921)
0e3b0f3da Remove deprecated free() calls (#1925)
7f839b87c Remove timeouts from azure builds (#1924)
45b766a5d Fix main thread ID being potentially incorrect for simulation (#1923)
56d782b16 Add secondary camera name for PS3Eye (#1920)
2b4894038 Add simulation GUI plugin
f97d16073 Add imgui build to cmake
55a844a3e HAL sim: Add encoder channel B access
10deba854 Remove sendables from SendableRegistry when close() is called (#1917)
a9f0e4668 Implement sim devices for ADXL345, ADXL362, ADXRS450, Ultrasonic
aa9064586 Add ability to associate other devices with a SimDevice
81c2c8a7d Add simulation generic device/value support
e8d6f8a2c Move mockdata/HAL_Value.h to hal/Value.h
1b266717a Add simulation module support to cmake build (#1906)
fb8f3bd06 Add testbench yaml file (#1915)
846d8def0 Update to 2020 v2 image (#1913)
d6ac6e512 Fix PortForwarder package declaration (#1912)
227157086 Fix PS3Eye exposure setting (#1911)
885744d7e Add myRobot C++ version to cmake build (#1907)
366091fa8 Document that ConditionalCommand requires all subsystems (#1909)
c58b072c8 Fix Drive usage reporting order (#1908)
762c88adb Update compiler versions in readme (#1905)
af8ce568d Add Ramsete unicycle controller (#1790)
b2c2934d0 Fix javadoc warnings about invalid usage of ">" (#1904)
cce26ec78 Replace CRLF line endings with LF (#1902)
cb54602d4 Add support for writing RTR CAN Frames to the CAN API (#1900)
9f740e590 Use OS for serial port instead of NI VISA (#1875)
b23baf611 Add ability to run robot main loop in a separate thread (#1895)
457f94ba2 Add trajectory generation using hermite splines (#1843)
fd612052f Update native utils to use new frchome directory (#1884)
8858ec55c Remove periodic can read call (#1868)
41efb8015 Update CANAPITypes.h (#1860)
c93be1b2d Remove LabVIEW HAL support (#1901)
680f8919e Remove eigen, units and libuv from doxygen generation (#1898)
c5812524f Bump GradleJNI plugin version (#1899)
971303da8 Add PortForwarder class (#1890)
50db77bf2 Fix wpiutil cmake eigen install source directory (#1891)
85d42c199 C++ PIDCommand: Add GetMeasurement() and UseOutput() (#1892)
2dfbb855d wpilibj: Fix SwerveDriveKinematics ctor parameter name (#1889)
471f375a3 Simplify Sendable interface (#1864)
1d8c4d016 Replace ::value and ::type with _v and _t suffixes (#1885)
a5650b943 Add Units Utility class for Java (#1829)
904479ad4 Deprecate GearTooth class for removal (#1878)
86b666bba Add equality comparator to geometry classes (#1882)
62f07c182 Make one-arg Rotation2d constructor implicit (#1883)
f405582f8 Add kinematics suite (#1787)
561cbbd14 Deprecate Filter class for removal (#1876)
84e2973aa Remove unused include from Filesystem.h (#1877)
f49859ebf Remove NI VISA headers, as they are now included in NI Libraries (#1879)
bc59db5e6 Rename DEBUG macro to DEBUG0 (#1871)
dd928b4cb Remove JNI logging (#1872)
3e0f7d099 Use units for new NotifierCommand (#1869)
5ffe15d5f Remove ability to build all combined artifacts (#1867)
516cbef2c Remove RoboRIO ifdef from simulation headers (#1859)
9b6ffc201 Replace SetOutputRange() with SetIntegratorRange()
ff8b8f0a8 Remove percent tolerance from PID controller
0ca8d667d Clean up AutoCloseable and other Java warnings (#1866)
7112add67 Watchdog: use units::second_t instead of double (#1863)
761bc3ef8 Change C++ WaitCommand to use units (#1865)
1fb301123 Add MathUtils.clamp() for Java (#1861)
eb3e0c9c9 Fix cmake Eigen include directory (#1862)
2250b7fbe Rename GearsBotNew example to GearsBot
c9f9feff1 Replace deprecated API usage in C++ examples
d6b9c7e14 CONTRIBUTING.md: Point to frc-docs instead of screensteps (#1858)
d10a1a797 Fix eigen build in vcpkg (#1856)
2bdb44325 Add frc2 includes to list of "other lib" regexes (#1855)
4b2b21d24 Replace outdated Java collections (#508)
8993ce5bf Move Eigen headers out of main include folder (#1854)
0f532a117 Add PWMSparkMax (#1751)
f7ad363d8 Add jni cross compile options for aarch64 (#1853)
9afea3340 Add support for aarch64 jetson bionic builds (#1844)
d787b5d60 Add more items to .gitignore (#1850)
5dd0d1b7d Use units in SPI
07ac711b3 Fix units deprecated warning in IterativeRobot
decfd858b Correctly report -1 for POV on disconnected joystick (#1852)
076ed7770 Add new C++ Command framework (#1785)
a0be07c37 Refactor HAL handle move construction/assignment (#1845)
558c38308 Add new Java Command framework (#1682)
1379735af Delete RobotState and SensorUtil constructors (#1847)
e3d86fee4 Move circular buffer class from wpilib to wpiutil (#1840)
4cd8a5667 TimedRobot.cpp: Fix deprecation warning (#1846)
b2861f894 Use 2020 artifacts and artifactory server (#1838)
98cc32703 Update to use artifactory to publish artifacts (#1833)
fa0640300 Move drive integration tests into wpilibj/src/test (#1836)
e716c36b8 Fix Nat.java generation to be incremental (#1831)
9fd2b5e3f Fix MSVC builds on cmake windows in vcpkg (#1835)
7e95010a2 Add compile-time EJML matrix wrapper to wpiutil (#1804)
3ebc5a6d3 Add ProfiledPIDController
fc98a79db Clean up PIDController interface in preparation for ProfiledPIDController
fdc098267 Fix compilation error in elevator trapezoid profile example (#1826)
a3dd84e85 Make XBoxController Button enum public (#1823)
a216b9e9e Add TrapezoidProfile example (#1814)
8f386f6bb wpilibc: Add unit-safety to C++ geometry classes (#1811)
c07ac2353 wpilibc: Add overloads for units (#1815)
f1d71da8a Move GetStackTrace and Demangle to wpiutil, add Windows support (#1819)
ef037457e Make LinearFilter copyable and moveable (#1789)
76930250c Remove objective-cpp support (#1816)
1c246418f Move TrapezoidProfileTest to trajectory folder (#1812)
95a54a0f2 Add java arcade drive example (#1810)
a4530243e HAL sim: Fix incorrectly setting dio port to initialized on cleanup (#1813)
09d00a622 Update Java examples to use new PIDController (#1809)
ba9b51742 Add missing Java examples (#841)
6411bd79c InterruptableSensorBase: Fix callback function deletion (#1807)
810e58ea8 I2C: Add tip about writeBulk() to transaction() (#1806)
607d6c148 Fix wpilibj integration tests jar name (#1808)
c9873e81b Remove PIDControllerRunner and mutex from new PIDController (#1795)
98d0706de Fix cscore build with OpenCV 4 (#1803)
fbe67c90c Make Sendable setters synchronous (#1799)
c67a488a0 Format SendableBuilderImpl javadocs (#1802)
8e93ce892 Fix PIDControllerRunner member destruction order (#1801)
c98ca7310 Add EJML dependency to wpiutil (#1769)
3b12276bc SendableBase: remove unnecessary synchronization (#1797)
e6d348f38 Fix missing default name in Java PIDController (#1792)
df12fc2a8 Java cleanups (#1776)
39561751f Update GradleVSCode version (#1786)
37d316aa0 Add C++20 std::math constants shim (#1788)
dd4310959 Deprecate frc/WPILib.h (#1779)
823174f30 Update native utils to 2020.0.4 (#1783)
37c695266 Squelch -Wdeprecated-copy for Eigen with GCC >= 9
04c9b000f Revert "Fix build of Eigen 3.3.7 with GCC 9"
ca3e71e21 wpiutil: Fix Process::Spawn() (#1778)
d946d5a2b Fix Eigen compilation errors and add tests (#1777)
8b1b9ac75 Fix build of Eigen 3.3.7 with GCC 9
2f680ba99 Add Eigen linear algebra library
a885db7d4 Make MotorEncoderTest use LinearFilter (#1775)
ee2410169 Add geometry classes (#1766)
48fe54271 Add HALSIM_SetSendError implementation (#1773)
dff58c87f Fix unused warning in release build (#1771)
dde61aad3 Remove TimerEventHandler typedef from Notifier class (#1767)
0f6ef80ab Add RobotState#IsEStopped and DriverStation#IsEStopped (#952)
e48886187 Move unit tests from integration test suite (#1170)
dffa1a5cb Make null checks more descriptive (#1688)
fe59d854d Notifier: add null check (#1684)
10731f3d6 Update uv Udp wrapper for latest features
89f7b72b6 Update libuv to 1.30.1 release
85f2f8740 wpiutil: Add unique_function (#1761)
73ec94078 Remove SampleRobot (#1658)
62be0392b Replace std::lock_guard and std::lock with std::scoped_lock (#1758)
24d31df55 Make sure move constructor is generated for TrapezoidProfile (#1757)
841ef5d73 Remove template types from lock RAII wrapper usages (#1756)
e582518ba Fix some move constructors (#1754)
8757bc471 Remove pre-C++17 shims (#1752)
ea9512977 Add replacement PIDController class (#1300)
9b798d228 Add TrapezoidProfile class (#1673)
804926fb5 Unconditionally skip athena builds for sim (#1748)
118e9d29d Add C++14 units library (#1749)
c705953d7 Add usage reporting to LinearFilter (#1750)
852d1b9ca Don't cross-build gazebo for raspbian (#1747)
eedb3a1ad Fix GCC 9 warnings (#1730)
60dce66a4 Remove wpi::ArrayRef std::initializer_list constructor (#1745)
9e19b29c3 Use base azure image for primary wpilib build (#1744)
299425071 Update jni library, fix cross builds of the jni symbol check (#1742)
a6b0e9b85 Only disable execution of cross compile google tests (#1741)
3c2093119 Use docker container to run wpiformat (#1740)
5fe2eebce Revert "Don't build halsim_gazebo on raspbian (#1737)" (#1743)
4b1b92bb7 Replace wpi::optional with C++17 std::optional (#1732)
0fbb0d989 Update to 2020 compilers (#1733)
2dc94e605 Disable google tests on cross compilers (#1738)
d9cb57a42 Don't build halsim_gazebo on raspbian (#1737)
f7cfdd7ce Replace crlf line endings with lf (#1731)
b6d5d90d9 Add JaCoCo Support (#1734)
c7ab2baa6 Add way to disable the jni check tasks from a property (#1736)
0c45c5b7e Fix skip athena and skip raspbian flags (#1735)
3dfb01d45 Update to new Native Utils (#1696)
30e936837 Clean up LinearDigitalFilter class (#782)
311e2de4c Remove deprecated Joystick constants (#1715)
c08fd6682 Update CAN manufacturer list (#1706)
258bba0c2 ErrorBase and WPIError improvements (#1727)
372ca4f45 cmake: Enable googletest unit tests (#1720)
223d47af0 HALSIM: support mocking of HAL_SendError() (#1728)
55cb683db Change compiler flags to C++17 (#1723)
ee8a33c56 wpiutil: SafeThread: Add thread id, support getting shared_ptr (#1722)
61426d08d wpiutil: Signal: make operator() const (#1721)
b630b63ef Remove functions in LiveWindow deprecated since 2018 (#1716)
1d0c05d4f Styleguide fixes for #1718 (#1719)
f07569df1 Fix newer GCC/clang compiler warnings (#1718)
0120f3124 C++ SPI: Fix SetClockRate to take int (#1717)
c2829ed98 Configure gradle to ignore unresolved headers (#1711)
221e66f46 Allow disabling static init of JNI libraries (#1672)
738852e11 cmake: Add cross toolchain files for Rio and Pi (#1710)
27b697b08 Remove frc directory include shims (#1714)
9e45373a7 Remove functions and classes deprecated for 2018 season (#1059)
eeb1025ac SPI: Report port as instance for usage reporting (#1704)
bc6f1e246 Windows compiler options improvements (#1709)
bb48ae391 cmake: Move example programs into folders (#1654)
221011494 Update for C++17 and fix MSVC warnings (#1694)
fb1239a2a Add raw sources and sinks to cscore (#1670)
7de947734 Add lambda overloads for interrupts (#1636)
90957aeea Move libuv to its own subfolder in build (#1661)
47aae502a Styleguide fixes (#1702)
0bff98b5e Correct DifferentialDrive::ArcadeDrive param docs (#1698)
b52e40b80 Allow widgets to be added by passing value suppliers (#1690)
4a00cd77b Add usage reporting for the Shuffleboard API (#1685)
e25e515f2 Publish artifacts on azure (#1678)
322ef9b96 Force Java 11, fix javadoc generation (#1695)
d42ef5df0 Fix Watchdog print formatting (#1693)
f432f65be Update copyright year in license to 2019 (#1524)
1726b77ac wpiutil: uv: Remove copy from SimpleBufferPool (#1680)
620bec9ca wpiutil: uv: Add LoopClosing status to Handle (#1647)
7cd6e2e7f UsbCamera: Solve race in windows initialization (#1638)
7732836bd Completely disable watchdog tests on mac (#1679)
698edfda9 Remove framework load, disable mac timeout test (#1676)
1c454b000 Add Shuffleboard calls to IterativeRobotBase in C++ (#1607)
f42905b32 Include missing headers in HAL.h (#1660)
bdc822fad Only generate passthrough URLs for RoboRIO (#1624)
d3affb16b Make failure of HAL_GetFPGATime() more descriptive (#1633)
2de3bf7f5 Update LLVM from stable upstream (#1653)
3cf4f38f5 Fix build on macos10.14.4 (#1648)
4e0c10f48 Fix CAN Clean using wrong ID (#1668)
3b0631324 Fix Gray to BGR conversion in CameraServer (#1665)
6cd1c73ef Fix GUID comparison creating weird symbol (#1659)
063bbab6f MavenArtifacts.md: update links to HTTPS (#1674)
aab4c494d Fix type in build.gradle (#1604)
bf46af260 Disable extraneous data warnings in libjpeg (#1630)
655763a9a Limit length of message sent to DS SendError call (#1618)
a095ec2d8 Fix linker errors with free functions in Threads.h (#1625)
12ab035aa Fix receive side of LabVIEW USB streams (#1621)
99e4f7dd2 Fix SPI CS1 not working correctly (#1614)
60c2f5905 C++ CameraServer: initialize default Usb camera device number (#1601)
d55ca191b CameraServer: Add switched camera support (#1600)
e8b24717c C++ Shuffleboard fixes (#1595)
182758c05 Fix Ultrasonic sensor runner thread (#1598)
74f7ba04b Java PIDBase: Make setPIDSourceType and getPIDSourceType public (#1599)
997d4fdf4 Update HAL GetStackTrace to properly report user errors (#1594)
76d9e2663 uv: Add reuse to pipe (#1577)
a230c814c Add support for WPILib vscode extension for allwpilib C++ intellisense (#1590)
12cb77cd7 Fix DS Comm button tests (#1591)
8a9822a96 Allow multiple instances of the same PDP (#1582)
a9371a758 Fix missing exposure property on windows USB cameras (#1571)
6992f5421 cscore: Avoid crash if invalid (null) source set in MjpegServer (#1585)
43696956d Fix Watchdog incorrectly resetting expiration flag upon disable (#1580)
ae3fd5ada Fix docs search having unspecified module directory (#1568)
404666b29 Fix Halsim DS Button Format (#1583)
1eb4c99d1 Update README for 2019 changes (#1569)
910b9f3af Add support for camera descriptions on windows (#1572)
09d90b02f Remove prints and unecessary items from windows GetNetworkInterfaces (#1573)
0e1f9c2ed ntcore: Read ini escaped quotes correctly (#1579)
f156a0011 wpiutil uv: Pass IPC value of listening pipe to accepted pipe (#1576)
4a6087ed5 Disable watchdog test on mac (#1578)
88a09dd13 cscore: Handle USB camera integer menus (#1561)
7d1959636 Changed terminology from "Overload" to "Override" (#1563)
bd05dfa1c Fix ds_socket matchinfo (#1555)
05d6660a6 cscore: Add config json to VideoSink (#1543)
1349dd4bd Make MjpegServer functions public (#1545)
fdf298b17 CameraServer: Return MjpegServer from StartAutomaticCapture(VideoSource) (#1544)
453a9047e Fix cmake hal sim build (#1539)
e97e7a761 Add DriverStationSim.notifyNewData (#1537)
308bdbe29 cscore: Windows UsbCamera: Use custom windows message for initial connection (#1534)
f889b45d5 cscore: MjpegServer: Fix FPS limiting (#1536)
444b899a9 Java: Fix Timer.get() handling of accumulated time (#1531)
f121ccff0 Avoid Watchdog thread clobbering m_isExpired flag after callback (#1527)
bc2c932f9 Fix MotorSafety deadlock (#1526)
6bdd7ce50 Update docs for disabled init to match all the other modes (#1523)
c12d7729e Update examples to use VictorSPX's rather then Sparks (#1521)
363511604 cscore: set charset of displayed pages (#1520)
6105873cb Provide alternate device paths info for USB cameras (#1519)
80f87ff8a Allow video sources to be added to Shuffleboard (#1453)
a2368a619 Watchdog: add timeout message suppression feature
ae3cb6c83 Watchdog.java: add comment fixes from reverted #1442
f0f196e5b Revert "MotorSafety: Use Watchdog instead of DS class polling (#1442)"
7c35355d2 Revert "Suppress Watchdog's generic timeout message in MotorSafety (#1486)"
75cc09a9e Revert "Suppress timeout message in C++ MotorSafety class (#1512)"
0e2e18063 PowerDistributionPanelTest.cpp: Include thread
01d132206 Add constants for built-in Shuffleboard widgets and layouts (#1468)
ceed1d74d ntcore: Strip whitespace from IP addresses (#1516)
e1bf62399 cscore: handle HTTP stream hangs (#1513)
d46ce13ff Fix CAN API timing out incorrectly (#1497)
300eeb330 Suppress timeout message in C++ MotorSafety class (#1512)
d81700125 Only write version information on real robot (#1510)
8ac4b113a Fix build on macOS 10.14.2 (#1509)
f3864e9ab Move deprecated message in C++ from class level to constructor (#1505)
799c3ea8a Disable gyro sim test on mac (#1506)
8d95c38e3 Watchdog: Fix potential IllegalFormatException (#1508)
a7f4e29b7 Update versioning and vscode plugin (#1498)
b88369f5e Move deprecation warning for SampleRobot to constructor (#1503)
ce6f1d058 Change deperecation year for serial port direct constructor (#1504)
f163216a4 Add support for raspbian extraction (#1494)
c449ef106 Unconditionally await in awaitUntil (#1499)
6593f4346 Default to DS attached to true in sim (#1500)
ce1367a11 Make JNI library not found message clearer (#1495)
0d7d88026 Renable full Java 8 Compatibility (#1493)
ca2acec88 Update to NI Libraries 2019v12 (#1492)
3721463eb Don't use symbolic path searching for USB detection (#1491)
6e8f8be37 Make C++ examples able to run GradleRIO unit tests (#1490)
d84240d8e Bump opencv version to 3.4.4-4 (#1489)
1823cb2b6 Fix periodic can packets not being received properly (#1488)
41596608c Suppress Watchdog's generic timeout message in MotorSafety (#1486)
0c3b488e1 Make ntcore instances not smart pointers (#1485)
7d7af287f Add empty classes to command/classes creation (#1479)
411962299 Fix characters in license file (#1480)
d528a7796 wpiutil: Fix resources build (#1476)
dab7e1b7a Add multiCameraServer to cmake build (#1477)
ab4934546 Add missing param javadoc comment and fix argument order inconsistency (#1475)
608d82423 wpiutil: Use scoped connections to ensure cleanup (#1474)
e0e15eafe wpiutil: Add shared resources for http servers
0fb24538a wpiutil: HttpServerConnection: add SendStaticResponse
d65547ea7 Bump OpenCV version (#1471)
bfe15245a Add multiCameraServer executable (#1422)
ff58c5156 Change SmartDashboard type of PIDBase.cpp to match PIDBase.java (#1470)
6d4326a56 Rate-limit Watchdog timeout prints to 1Hz (#1459)
97ba195b8 Fix LiveWindow attempting to start listeners on uninitialized sendables (#1463)
3d546428a Add missing SubTableListener methods to C++ NetworkTable (#1465)
b64dfacff DriverStation: fix error checking for GetXXXAxis and GetXXXPov (#1469)
dcbf02a1e Update auto SPI for timestamp changes (#1457)
7e1ec2883 NI image 2019v9 (#1467)
ef16317f8 Update NativeUtils and Doxygen (#1462)
26e8e587f MotorSafety: Use Watchdog instead of DS class polling (#1442)
0d0492bfc HAL: Add additional error messages to HAL_GetErrorMessage (#965)
3b33abfc7 Make Watchdog use single thread dispatch (#1347)
99033481e Add netconsoleTee
b4901985b Add netconsoleServer
97edb6c68 wpiutil: uv::Buffer: Add Dup() function
73de3364b AxisCamera constructor: add StringRef overload (#1458)
5551981b3 Upgrade to Gradle 5.0 (#1444)
90572a3cc Add wpilibc and wpilibj skeleton templates (#1441)
c40518805 Fix directory iterators not working correctly (#1454)
bea0565ac Update to OpenCV 3.4.4 (#1452)
0b0345436 wpiutil: Replace LLVM Optional with C++17-compatible optional
489701cac wpiutil: Rename Optional.h to LLVMOptional.h
a769d56ec Create C++ ShuffleBoard example (#1438)
6f0c185a0 Add methods to change the selected tab in the Shuffleboard app (#1448)
a60f312d1 Add eager null checks in drive base classes (#1447)
acb786a79 Remove MotorSafetyHelper, create MotorSafety base class instead (#562)
df347e3d8 wpiutil: uv::Process: Revamp args/options approach (#1434)
e4aa45f34 wpiutil: WebSocket: Fix Sec-Websocket-Accept computation
75cc3cda2 wpiutil: SHA1: Add method to get raw bytes instead of hex
45f4472d4 Add mechanism to control Shuffleboard recordings and add event markers (#1414)
69cb53b51 Add support for USB Webcams on Windows (#1390)
70a66fc94 Make Gradle show stdout for wpilibj tests (#1431)
9207d788a Convert ReadInterrupt* to return int64_t time (#1417)
ef3a31aa2 Add an example of using the HAL directly (#1374)
63775362f Remove SynchronousPID class (#1429)
55493b0c1 Fix polymorphic exception types being caught by value (#1426)
1696557c4 Fix deprecation warning in wpilibj shuffleboard example (#1427)
ecd376be4 Export C functions from JNI statically linked library (#1425)
f54c0f70f Update opencv to 3.4.3-19 (#1424)
9bc998f4b cscore: Add JSON for source settings (#1423)
43d188a42 RobotBase: Call cscore Shutdown() from destructor
563d5334c Update OpenCV to 3.4.3-17
193b0a222 cscore: Add Shutdown() function
76f5d153f wpiutil: Add Stop() to EventLoopRunner
19caeca99 cscore: Use more standard naming for Instance public variables
0abae1765 cscore: Refactor sink and source creation
81d10bc65 cscore: Build examples on Windows (#1421)
b51b86525 Stop webserver on test run (#1420)
ace37c517 CameraServer: enable usb cameras on non-Linux platforms (#1411)
ac751d322 Fix unused variable warnings in ntcore (#1416)
7c9a3c4d7 Update NI Library to 2019.7.1 and OpenCV to 3.4.3-16 (#1418)
8be693f55 Fix list layout in shuffleboard example (#1413)
622ae29df CameraServer: Change opencv sources to publish "cv:" type (#1412)
e7c98feca libuv: Use WPI (FPGA) clock on roboRio (#1409)
28087424e Add deploy directory detection (#1400)
b6830638d NetworkListener: use Pimpl idiom (#1405)
fb557f49e Add missing driver station documentation (#1388)
746f950a0 Remove ifdefs from linux NetworkListener (#1404)
9a38a3e18 Don't use static for raw_ostream outs/errs (#1401)
2e3e3a47b Use a kill -9 after attemting a safe kill (#1397)
e27d6d7bb cscore: Change impl to only one singleton (#1398)
1dec0393a Fix static deletion race condition in DS thread (#1396)
d03b02032 wpiutil: Add WorkerThread (#1302)
71e29b1d9 Remove unused import from rumble example (#1395)
f0b0965f9 Remove large HAL headers from wpilibc headers (#1386)
f774e47c8 Add an example showing how to use a hid rumbler (#1394)
761933a16 Refactor Java Ultrasonic to use a List container (#1389)
99e0f08a6 Move applicable integration tests to native build as unit tests (#1364)
e89d5eb69 Fix stringop truncation warning from GCC 8.2 (#1393)
2501e1188 Enable HTML5 javadocs (#1267)
9174f23f3 Remove some usages of windows.h (#1370)
9f6544fa8 Allow binding commands to POV (#1378)
9a1af132b Unify GetHostname() and use libuv implementation (#1391)
a8aacd365 Update build setup for raspbian and debug binaries (#1384)
8ff81f5a2 cscore: Separate platform-specific sources (#1387)
349e273ec AnalogGyro: add "calibrating for n seconds" message (#1380)
0a2ab4f0d Revert change in behavior in HeldButtonScheduler (#1381)
7c1a7332e uv::Async, uv::AsyncFunction: allow calling from within loop
172e438cd wpiutil: uv::Async: Keep weak reference to loop
1a7a0db1f wpiutil: Change uv::AsyncFunction to use promise/future.
11e5faf46 Use Array Constructor rather then new array to toArray (#1368)
c7118f8ad wpiutil: Signal: Don't use std::forward when calling (#1371)
7933d2cbe wpiutil: uv: Don't close uninitialized handles (#1372)
ce8c71b1f Fix link for license (#1367)
da9a57552 Rename squaredInputs to squareInputs in DifferentialDrive (#1361)
7068551a3 Bump OpenCV and GTest to 2019 dependencies (#1366)
bd9484a2f Make MyRobot compilation test use TimedRobot (#1363)
b9fa3a439 Update to 2019 RoboRIO and 2019 v4 image (#1352)
88b93c220 Update NativeUtils to not copy NI libraries to jenkins RoboRIO (#1359)
0a937bb5b wpiutil: SafeThread: Ensure thread is released in destructor (#1358)
613d5eda0 wpiutil: SafeThread: join on thread exit (#1357)
18c8cce6a SafeThread: Avoid use-after-free risk in thread shutdown (#1355)
36000ddb3 wpiutil: uv::Loop: Store the thread ID of the loop
de6d6c9a5 wpiutil: EventLoopRunner: Allow getting the loop shared_ptr.
6d99c0ac6 wpiutil: EventLoopRunner: Remove extraneous wpi namespace qualifier
164e9a2c7 wpiutil: uv::Work: Don't connect work and afterWork if they're null
f3fb95af7 wpiutil: uv::Tcp: Simplify reuse function
40a9fc44f wpiutil: uv::Poll: add reuse functionality
f0ac04864 Remove pmd and checkstyle publishing from azure (#1353)
81498e6af Deprecate IterativeRobot in favor of TimedRobot (#1341)
f1056efa0 Updates version plugin to 2.2 (#1349)
54fbec27d Fix typo (#1348)
fd8215345 Fix shuffleboard C++ tests, and run them on desktop (#1351)
7b471d8c6 Fix windows image on azure pipelines (#1350)
175c6c1f0 Add fluent builders for more flexibly adding data to Shuffleboard (#1022)
ac7dfa504 Switch to using containers for Linux builds on Azure (#1335)
a73285486 Clean up edge detection logic in ButtonScheduler subclasses (#1340)
617185602 Document Watchdog epochs better (#1345)
d5d744a39 Fix publishing of templates on jenkins (#1343)
8b1274d74 Replace typedefs in C++ with using declarations (#1339)
26c33a9a5 Remove priority_condition_variable (#1337)
5fad2b105 Remove travis and appveyor configuration files (#1338)
32ec07ee0 Throw correct exception in HAL_getJoystickAxes/POVs JNI (#1336)
15c5a820b Publish tests to azure ci (#1334)
e15fabd2e Add cmake azure build (#1332)
1aa844672 Add move constructors and assignment operators to wpilibc (#1314)
b1965f74a Add styleguide check to azure pipelines build (#1331)
0c58a0a70 Repackage CameraServer classes (#1321)
467c9fd68 Add kInvalid value to HAL_I2CPort and HAL_SPIPort (#1329)
b505bbefd Rename variable in SPI class not compliant with style guide (#1330)
5c6b78ea2 Set up CI with Azure Pipelines (#1306)
f89274fb1 Fix hal header zip task dependencies (#1327)
1137582a7 Revert "Move deprecated ntcore classes to wpilibj jar (#1322)" (#1326)
e26e3b6aa Fix HAL Headers Zip (#1325)
456d3e16a Update NI Libraries to layout without C++ (#1324)
e21007304 Move HAL classes to their own base package (#1317)
0068b6aea Remove wpilibj tests from wpilibjIntegrationTests (#1323)
12c92a822 Move deprecated ntcore classes to wpilibj jar (#1322)
d2a5aaafd Use external dependencies for NI and NetComm libraries (#1304)
bedef476f Replace IterativeRobot in examples with TimedRobot (#1310)
59386635e Add CAN API constructor that takes explicit manufacturer and device type (#1311)
a846ed062 Add virtual destructor to CameraServerShared (#1313)
8b5dc53cc Add Lambda support to InstantCommand (#1262)
59700882f PIDController: Mention unit for 'period' (#1305)
025af2452 Make NetworkTableEntry.callRpc and createRpc public (#1303)
c0ff6198b Change hal sim to use spinlocks (#1291)
67b1c8531 Notifier: properly reset HAL alarm in non-periodic case (#1296)
0b113ad9c Fix some PIDCommand constructors not forwarding subsystems (#1299)
c8482cd6d wpiutil: Add WebSocket implementation (#1186)
d6d532182 wpiutil UidVector: Implement clear() and forward iterator (#1293)
8d91343bf wpiutil spinlock.h: Include STL mutex for convenience (#1292)
488ba7937 Add more checkstyle checks to simulator code (#1289)
de212a9dd Add names to simulator components (#1268)
8d8f120cc EventLoopRunner: Use AsyncFunction
57490e000 Add uv::AsyncFunction to do a roundtrip function call to a uv::Async
1de1900db Change uv::Async to accept data parameters
4a3e43d4a Add HttpMultipartScanner (#1197)
9e37ee13d Add wpi::HttpServerConnection and an example of its use (#1281)
7b95c5341 ntcore: Change params in Java RpcAnswer from String to byte[] (#1280)
5283726cc ntcore: Describe RPC version 0 in spec (#1279)
0b8f4b5e6 Add libdl to wpiutil cmake build (#1288)
a5f7342fc Run cmake build in travis (#1287)
6df742544 cmake: Compile cscore and wpiutil examples (#1286)
d7b68f3f9 Unbreak cmake build (#1285)
e28295fc7 Add dependency injection of Subsystem to Command (#1275)
6df500e72 Add missing library dependencies in simulation dev executables (#1284)
83cfb8b19 UrlParser: fix Has() functions (#1283)
82b25d0ec spinlock_bench.cpp: Fix wpiformat warning (#1282)
b44f27ddf SendableChooser: Rename addDefault and addObject for clarity (#1239)
fa78f30e3 ntcore: Make protocol revision more visible in docs (#1278)
46ae19d08 wpiutil: Add a mutex-compatible spinlock implementation (#1272)
77124a229 Twine: disable part of isValid() that causes spurious warnings (#1271)
1462a5bd4 Fix spacing and const correctness in sim (#1269)
44099d9a2 Update errorprone config for Java 10 (#1265)
c2ceebfb9 Add gyro and accelerometer simulator wrappers (#1183)
0a0d9245e cscore: Add connection strategy to sources (#1252)
7bd3f9f0b Change ButtonScheduler scope start method to public (#1254)
4801ae249 Replace ellipsis characters munged by wpiformat with three periods (#1256)
0e9172f9a Fix many errorprone warnings (#1247)
6db5f8043 docs: Set use_mathjax to true (#1251)
898076f69 docs/build.gradle: Use unix EOL (#1250)
195e10181 cscore: Use Twine instead of StringRef in API (#1244)
97a8f8f47 HAL: Add Doxygen module documentation (#1246)
9408fd517 Add Doxygen comments for namespaces (#1245)
00c2cd7da Improve JNI loading efficiency (#1224)
cbb62fb98 Fix errorprone so it is version locked and reports warnings (#1242)
a11fcb605 Add UseConcurrentHashMap exception to PMD and clean NOPMDs (#1243)
139b1720b Fix JavaDoc generation (#1241)
011f0ff53 UsbCamera: Make setConnectVerbose public and add test (#1240)
75a67202e Add documentation building to repo (#1238)
186e1dc54 ntcore: Documentation cleanups (#1237)
f2393feee cscore: Documentation cleanups (#1236)
66e35128c Use Pimpl idiom for CameraServer
6933fefe5 Use Pimpl idiom for Scheduler
fedf82812 Command: Use SmallPtrSet for requirements instead of std::set
eb64ea9fc MotorSafetyHelper: Use SmallPtrSet instead of std::set
826ed7fe3 SmallPtrSet: Fix makeIterator
a2d314b0d ConditionalCommand.cpp: Remove iostream include
6b37ca9f9 UsbCamera: Allow silencing of Connecting message (#1231)
0614913f1 Add a way to indicate a Sendable is an actuator (#1226)
5fafaf627 Add confirmation to SendableChooser (#1217)
397a296e2 Add a .controllable key as a standard part of Sendable (#1225)
1d9ed8f45 Fix SensorUtil issues (#1194)
bbb622aaa Revert "Use ASAN when on Clang (#1187)" (#1234)
8cbe7a625 cscore: Move CvSourceImpl placeholders into SourceImpl (#1230)
932308b49 MjpegServer: Add ability to set compression, etc in code (#1229)
939827825 cscore: Add properties support to VideoSink (#1228)
c9a75a119 cscore: Support multiple levels of JPEG compression (#1223)
04ee8dbe7 UsbCamera: In JPEG mode, get size from image instead of mode (#1222)
7fd7192b1 Disable UvGetAddrInfo Concurrent test on Windows (#1227)
63c1f80d6 halsim_ds_socket: Update tag parsing, and add rumble support (#1214)
d54c2665d Update UsageReporting enums and their uses for 2019 (#1218)
8aac46542 Add a SimpleBufferPool for uv::Buffer (#1215)
c78e1499d Remove appveyor artifacts, and only build 64 bit (#1212)
a34df5589 Switch DS Sim Sockets to use UV loops (#1211)
eb2c6e19f Add sim hooks to set match data (#1191)
c25d48fd0 HttpParser: Add Reset() function (#1210)
794403dce Add shim headers for headers moved to cameraserver and frc folders
d89b7dd41 Move CameraServer and WPILib headers into their own folder
31ced30c1 HttpParser: Change Execute() to return StringRef (#1209)
74a306d47 Add halsim_ds_socket to allow a simulated robot to talk to the real DS (#1180)
5bf582113 Cleanup docs in uv::Stream and uv::Tcp (#1207)
eed28a585 Add sockaddr_in overloads for uv::Tcp and uv::Udp (#1206)
435e026c0 uv::Loop: Add user-defined data (#1205)
739267d36 Add Reuse function to uv::Tcp (#1208)
85118a023 Minor fixes required to enable the simulated robots to run (#1181)
ae72c0b29 Clean up style issues in wpilibj_frcnetcomm.py (#1199)
b72885b4f Remove wildcard dep version from gazebo msg (#1203)
70b0d7cb0 UDPClient: Add receive functionality (#1204)
053ca47d4 Update gradle dependencies (#1202)
74efe5aaf Get halsim_gazebo building again (#1201)
fe5d7dd6b Move DS caching from user level to the HAL (#1143)
0b5df467e Update Native Utils to fix static allocations (#1196)
80134164a Move Java main function from library to user code (#1148)
76b26c2df HAL_InitializePWMPort: Check for MXP port (#1195)
f8635e8ab Update to gradle 4.9 (#1193)
4029b5d84 Update gazebo plugins to Gazebo 9 (#1189)
4c527b9b0 Add vscode intellisense settings (#1173)
caa03d23a Make JxArrayRef less error-prone for jxArray (#1190)
297863b17 Add HttpParser and UrlParser C++ wrappers for http_parser.
1992b67ee Import nodejs/http-parser.
e2314f352 wpiutil: Add C++ libuv wrappers (#1166)
340b26bad Use ASAN when on Clang (#1187)
7f000fecc Force a DS mutex release on shutdown on desktop (#1188)
76c901ce7 Add simple motor simulation classes (#1117)
57fc61407 Compile C headers in C mode, and fix cscore C (#1179)
89d15f061 Fix main function initialization (#1176)
f5b1028b5 Fix race conditions in command tests by increasing the delay time (#1178)
ad3e2d7d3 Make HAL headers C-compatible (#1177)
3818a8b3b Update to gradle 4.8.1 (#1174)
59e8b6026 Add HAL Documentation (#1132)
de5d7d3c1 Only use priority_mutex on RoboRIO by default. (#1172)
ebd41fe0b Bring back the gazebo plugins (#1063)
70960b025 Signal: rename Signal to Signal_mt and Signal_st to Signal.
c8afe9bc2 Signal: Optimize to use plain std::function.
1ecaaafa6 Discuss and include licenses for third party software. (#1101)
33a01b314 Add maven documentation (#1140)
1d8456e2b Move FRCNetComm.java into generated directory (#1168)
b5bacc09a libuv: Silence cast-function-type warning on GCC 8. (#1169)
876c65047 wpiutil: Add a signal-slot implementation. (#1163)
3eae079db Add PDP usage reporting (#1167)
122fdf48b libuv: Hook up to build.
d94f49b3b libuv: Silence clang compiler warning in uv-common.c
39670fc9c libuv: Add pragmas for win32 libraries.
6f0d50b9c libuv: Avoid conditional-true compiler warning.
873b2ed13 libuv: Add missing casts.
321c144d2 libuv: Remove extern "C" from uv.h.
13e1af259 libuv: Remove MSVC 2008 stdint from uv.h and uv-win.h.
9d7792ead libuv: Remove aix, os390, and sunos from uv-unix.h.
6d93d3c25 libuv: Rename source files from .c to .cpp.
156822dbc Import libuv 1.21.0.
208f82d6f Revert "Add libuv dependency (#1109)"
a818c7fd4 Add loop timing to IterativeRobot and TimedRobot (#781)
50b13d2f3 Convert UnitTestUtility to a JUnit 5 MockHardwareExtension (#1153)
b7807bf9d Clean up Command container iteration code (#73)
ea7d11b1d Twine: Make isNull() public. (#1162)
212f378d0 Replace globalError in ErrorBase with a global set of all errors (#615)
2faba39b5 Change wpilibc artifact name to match standard (#1158)
064989f2e Fix projects having different version numbers (#1113)
6b1b4796c Remove Link Script (#1159)
1ebb83e0f Remove explicit close() from Gyro interface (#1152)
9108a9359 Switch non-integration tests to JUnit 5 (#1120)
c7e97f45f Add RobotPeriodic functions to default templates. (#1149)
5af85dd1b Explicitly states the gyro direction contract for the Gyro interface (#1151)
b20158015 Update java robot class docs (#1150)
b1bb63f9a Add ADX Simulator tests (#1142)
056e68f2a Use new CAN API for PDP (#1081)
f6e4df6a1 Remove OS Serial Port (#1141)
0cde67143 Upgrade to gradle 4.8 (#1136)
1f9645afe Fix CAN API reads (#1139)
86285b427 Removes MSVC 2013 Shims (#1130)
e548a5f70 Update and enable PMD 6.3.0 (#1107)
8eafe7f32 Solve some safety issues with RPCs (#1127)
6aebba545 Import MapVector from LLVM. (#1128)
664a3c246 ntcore: Fix C API polling array returns. (#1126)
321dfaf0a Remove non-existent directory from .styleguide (#1124)
8373e0361 Made Controller interface public (#1123)
8c680a26f Moved C++ comments from source files to headers (#1111)
d9971a705 Throw UncleanStatusException rather then RuntimeException (#1114)
85fe722f4 Fixes JNI files not getting cleaned on rebuild (#1121)
c04f463b7 Makes FRCNetComm interfaces static final classes. (#1118)
307da3ad2 Simplify allocation of JNI global classes and exceptions (#1110)
39f80730d Disable broken ntcore tests using JUnit 5 (#1116)
35cfe0d92 Add comment to FRCNetComm.java noting that it is autogenerated (#1115)
8d218dbca Add support for unit testing from GradleRIO for C++ projects (#1094)
938f83514 Update things deprecated in gradle 4.8; remove unused function (#1093)
1dc55c03d Add Windows PDBs to release zips, and skip strip on mac (#1092)
859b457c3 Add libuv dependency (#1109)
8958c4eab Fixed wpilibj_frcnetcomm.py and added invocation to Travis (#1106)
7c9517ce5 Fix gain encapsulation in LinearDigitalFilter (#1105)
5bf9720cc Use externally built Google Test (#1108)
d1587ed2c LICENSE.txt: Update copyright date to 2018. (#1100)
5fcb67aaf Fix Checkstyle (#1095)
2e5fece59 Add utility class tests (#871)
863cfde39 Adds tests to ensure all examples have matching item in json file (#1079)
c4728d291 Makes CAN API initializer setup HAL (#1084)
fb45a5b31 Allows passing in the main robot class from the command line (#1091)
86c1f8ae5 Fixes initialization when not using the provided main (#1085)
381c25c57 Fixes interrupts not getting closed properly. (#1088)
62d5301b1 Changes notifier to be closable. (#1090)
40cc743cc Enable checkstyle on cscore, ntcore, wpiutil (#1032)
ecfe95383 Made SensorBase a utility class and renamed it to SensorUtil (#813)
ba93f79d8 Fix mac builds (#1087)
dcc276484 Default to requiring frc namespace for wpilibc. (#972)
cbaff5285 Implements AutoCloseable for types, replacing free() (#1048)
a2ecb1027 Update LLVM to latest upstream. (#1080)
680aabbe7 Add new CAN API (#1036)
55b0fe008 Fixes JNI symbol check on VS 2015 (#1078)
8b8c3d546 Updates NativeUtils dependency (#1077)
38a7786f2 Remove spotless (#1074)
df182f382 PIDController now supports composition (#976)
5cc757357 Updates JNI to support embedded jni libraries for easier setup (#1075)
17401e10f Add setting to invert the right side of the drive (#1045)
73439d821 DriverStation: Fix getStickButtonPressed/Released (#856)
72a79aac5 Fixed the names of the arguments to some C++ drive classes (#1070)
c89678971 Replaced the START_ROBOT_CLASS() macro with a template function (#1050)
64b03704f Rename Joystick default channel constants (#904)
630fc55bd Implemented synchronous PID controller (#993)
f90e429bf Add removeAll to preferences (#987)
2e0709f05 Add spotless to check line endings (#1055)
11d46713d Fixes pessimistic std::move (#1069)
ef442d775 Refactored DriverStation.java unplugged message handling to match C++ (#808)
3e6c3c3e9 Replaces Timer in PIDController.java with Notifier (#878)
8d57b73b4 Fixed naming convention of static variable in TimedRobot.java (#876)
d8c8643b5 Format HTML and XML files (#944)
adb609835 Removed extra newlines after open curly braces (#935)
938d5379e Adds command examples to built examples (#1062)
7cd15aa04 Re-enable JsonIteratorObjectTest.KeyValue.
f8ed48af9 Update json from upstream version 3.1.2.
c274d1790 StringRef: Add comparison operators against const char*.
6699f8636 Make most StringRef functions noexcept.
c2b1ed3ed ArrayRef: Add value_type typedef like std containers.
2c27ad073 raw_istream enhancements.
31bb55c31 Add std::vector and unsigned variants of raw_ostream.
dd4230d74 StringMap: Add decrement operations to iterator.
cff475c1f Moves C++ templates and examples to match gradle setup (#1065)
d564e19ef Only prints the debug binary message once per build (#1066)
1d6eb629a Adds Objective C++ Build capabilities to cscore mac (#1029)
406e18663 Switches NotifyListenerVector to SmallVector (#1004)
ab70220ec Makes SPI edge changes more obvious (#1056)
560123ab7 Fixes command folder name in templates.json (#1061)
4e1964156 Removes 32 bit configs for linux and mac. (#1060)
5ff3d837b Fix compilation with GCC 8 (#1051)
74d7107ac Add AppVeyor Build Support (#1013)
e21a246a4 Make the HAL self initialize when ever any initialization function is called (#1012)
59a8e9da5 Fixes gradle wpilibj classpath for editors (#1047)
795c60da0 Adds a testCpp task to all projects (#1014)
f3db32911 Enables MyRobot project (#1028)
f07799c67 Disables unstable and failing unit tests (#1057)
eec4f53a6 Forces CRLF files to LF (#1054)
01d8d0c79 Moved C++ header includes out of extern "C" and added missing C header includes (#1053)
6729a7d6b Run wpiformat on merged repo (#1021)
0babbf317 Adds CMake Readme (#1042)
337e89cf6 Adds JNI Simulator interface and updated Sim API (#1002)
104637134 Fixes some JNI issues with method calling and class storage (#1043)
665a6e356 Allow users to feed the watchdog contained in drive objects (#1044)
b7ea481bf Notifier: reset updatedAlarm before waiting (#946)
7a34f5d17 Check for nullptr return from malloc, calloc, and realloc. (#1023)
e8d5759d9 Actually have the cscore examples build, and makes them build only on linux (#1030)
eeae84c71 Adds cscore examples to builds (#1027)
dab6f40b4 Moves examples.xml to json, and adds template json (#1026)
5c2c5ccd0 Remove atomic static shim. (#1020)
8cbfe35bd ntcore: Remove MSVC 2013 shim. (#1018)
954f8c40f Adds CMake Builds (#1015)
6a49173ce Update cscore examples for llvm to wpi rename. (#1016)
1043aef7f ntcore: Make header actually a C header (#1007)
f7bcf5305 HAL: wait for all objects to release handle before freeing (#1011)
6a159c5bd Miscellaneous cleanups (#1008)
a098814ea Removes the make_unique shim for c++11 (#1010)
a28832e52 Add backwards compatibility shims for old wpiutil headers.
f84018af5 Move entirety of llvm namespace to wpi namespace.
93859eb84 TimedRobot now uses the Notifier HAL API (#942)
e7cf6bf7c Fixed wpilibj GenericHID.getType() (#969)
a8fd88840 Revert "Uses ComputeDigitalMask function across HAL DIO (#837)" (#1005)
c84bd744c Uses ComputeDigitalMask function across HAL DIO (#837)
11b99a016 Removes old version files from git ignore (#1003)
dfa46cbdd Fix typos, keep formatting consistent. (#974)
91151e33b Add out to gitignore (#988)
2ed9ae165 Removed unused ROBOT_TASK_PRIORITY constant from RobotBase.java (#991)
fdfea3516 Fix JavaDoc tag (#995)
47783842e Fix JavaDoc tag in Differential Drive (#996)
7f88cf768 New 2018 and later build setup (#1001)
cb2c9eb6d Remove gmock and builds from utility libraries (#999)
4a1e52075 Merge cscore into allwpilib.
b3aa659f9 Merge ntcore into allwpilib.
4870d83ad Merge wpiutil into allwpilib.
7210a8fd2 Prepare ntcore for merge into allwpilib.
0f947613a Prepare wpiutil for merge into allwpilib.
ea73c10cd Prepare cscore for merge into allwpilib.
6d3d52f92 Fix GetJpegSize() and JpegNeedsDHT() to handle SOF as first tag. (#127)
dbd1f1781 Ran wpiformat (#126)
96e9a6989 Improved Command-based examples (#906)
14228d82f Adds Direct port name Serial API (#956)
040731447 Add FPS and byte count telemetry measurement for sources. (#125)
5175829ba PWM: Use getRaw and setRaw for Sendable "Value" property. (#963)
9d7293734 SendableChooser: Do not automatically add to LiveWindow. (#964)
1e5ec362f CameraServer: catch VideoExceptions in video listener. (#949)
7bb3e4efc Made documentation for RobotDriveBase::SetDeadband() clearer (#953)
67de595c8 ADXRS450_Gyro: Add null check around reset (#948)
82152e90f Adds defaults to PWM config (#961)
1e7d43989 HAL Notifier: Don't disable the notifier manager when the last handle is cleaned up (#960)
71d06a1a2 HttpRequest: Don't reorder parameters. (#73)
698feff2f MjpegServer: Support limiting FPS. (#123)
3ef9ffaf3 HttpCamera: Force reconnect when SetUrls() is called. (#122)
3025a182c Fix two bugs in client synchronization. (#270)
febc41c85 Fix Travis CI wpiformat install (#72)
627ca6db7 Fix Travis CI wpiformat install (#121)
c80b0de2c Fix Travis CI wpiformat install (#269)
979984fa6 Fix Travis CI wpiformat install (#947)
57e9fb33d Fixes C++ SendableChooser using invalid temp variable (#945)
f5a292dad Adds TriState JNI entry point (#938)
4e9e7ec8f ParseHttpHeaders: Make case-insensitive per HTTP spec.
77d6c1174 Invert right side motors in MecanumDrive sendable (#933)
c69b8f00d ReadJpeg: Don't read past the end of the image. (#119)
0542b50f7 Work around fallthrough warnings on GCC 7+.
1077ef9fb Adds compile task (#118)
67f9c9a5b Fixed TimedRobot.java hanging if an exception was thrown (#926)
f720cbb12 Switches CtreCanNode to use locking and std::chrono for time (#909)
64a7e57fe Added output normalization to DifferentialDrive::CurvatureDrive() (#924)
5ca00dddb Added TimedRobot::GetPeriod() (#915)
120ceb342 Fix channel reassignments for C++ Joystick twist and throttle axes (#903)
5cbafc138 Updates to image 17 (#913)
39d1650d5 Fixes double to int to double cast in encoderJNI (#918)
02336fc47 Makes FMS data never be a null string. (#900)
c00848c06 Fixes indexed classed handle resource (#899)
738a1c015 PIDController: setContinuous should only check input range if continuous is true (#896)
48ae6c954 Publishes match specific data and other FMS info to NT (#874)
07f70cf78 Fixes control data packet delay (#875)
e4e1eab41 Fix cancel of inner commands in ConditionalCommands (#858)
0e8ff4663 SpeedControllerGroup: Call set() from pidWrite()
54a0a7654 Link to replacements for RobotDrive in JavaDocs (#879)
59f938b58 Invert when getting motor speed in SpeedControllerGroup (#886)
551388845 Fix PIDController with Continous and no Input Range set. (#883)
02b661504 RobotController: Make getBatteryVoltage() static. (#869)
1f4822f33 Replaced Talon motor controller in DifferentialDrive class docs with Spark (#868)
bb38ef564 DifferentialDrive: Invert right motor in LiveWindow. (#867)
ca36d1dce Adding callbacks for notifying when the distance per pulse changes (#861)
ee33296e1 SmartDashboard override .name entry in putData(String, Sendable) (#866)
4376c94dc Updated copyright year
19f7a5f10 Set up wpiformat
4514ff807 Removed extra newlines from beginning of Java classes (#264)
b66d72f5c Updated copyright year
c6f6b352f Set up wpiformat
0ef980336 Update copyright year to 2018 (#864)
eedb8910c Removed extra newlines from beginning of Java classes (#859)
882399c65 Update copyright year to 2018 (#116)
8346caed9 Move subsystem command metadata to metadata key format (#863)
55b6764d5 Fix bugs in simulation libraries (#853)
2c4faee66 Fixes -Og compile and strip binaries (#838)
228728106 Fixes linux and mac builds to -Og, and strips binaries (#261)
cd4b7b6cc Switches to -Og instead of -O2, and strip binaries on linux and mac (#63)
da5458a2d Updates to newest build setup, fixing -Og and strip binaries (#115)
8d1dee16b Add DriverStation NetworkTables HAL Extension (#829)
76b182600 Add Low Fidelity NetworkTables simulation extension (#823)
c647a801a Add Encoder Index as a child (#857)
02131639b Add Digilent DMC 60 Speed Controller (#855)
566e28369 Make setDefaultCommand public (#854)
40eb6dfc9 Fix SmartDashboard PutData to hook setters. (#851)
a3e5378d1 SPI: Check for null (#850)
691741cfc Fixes non public static methods in RobotController. (#852)
166d9e01b Add PWMVictorSPX (#842)
7eab4371f Adds TriState DIO functionality to the HAL (#835)
de134a5c6 Add deprecated shims for LiveWindowSendable and NamedSendable. (#834)
7f074563d Add support for automatic SPI transfer engine. (#836)
d3dd58636 Revert "Fixes SPI bad chip select (#818)" (#822)
9c8510559 Update to image 2018v16 (#833)
86ac70a12 Fix wpilibcIntegrationTests RobotController warnings. (#832)
3c3a448d4 Deprecate SampleRobot (#472)
8744511f1 Fixes some methods in RobotController not being static. (#831)
7729dd972 Fixes JNI symbol check (#830)
8b7aa6109 Adds RobotController class (#828)
88a6b4ac3 PIDController::InitSendable(): Use double, not bool for double values. (#827)
217b1a225 VisionRunner: Add stop() function to stop a runForever() loop. (#826)
d2e7a90f4 Removes statics from hal sim (#825)
8bd48d6c3 Switches HAL to manual instead of static initialization (#824)
1fa0adb09 Removes MSVC and GCC old version workarounds (#821)
f615e68a4 Require GCC 5 for wpilib build (#820)
aa4f0ef4f Start using the new FRC compiler define (#797)
b42285fdd Fixes SPI bad chip select (#818)
8106fbdbe Removes custom CONFIG_ATHENA compiler directive (#796)
942ba5176 Reclassified NetworkTables headers as "other library" (#775)
33a08d5b3 Add halsim unit tests (#783)
4e3af0756 Removes workarounds for issues in image 10 (#816)
5078f6c92 Update to image 2018v13 (#815)
899892c11 Change Utility to use Twine.
54326311a Use Twine in error checks.
fe53dd2f2 Use Twine for error message inputs.
ab137abab Use llvm::Twine across C++ Command structure.
001dedf3b SmartDashboard: Use magic static for static initialization. (#812)
f9bece2ff Update LiveWindow to provide continuous telemetry. (#771)
3befc7015 Make MotorEncoderTest use LinearDigitalFilter's reference overload (#811)
de63e1c8a Fixed race condition between PIDController enable/disable and PIDWrite() call
a76b1aa80 Reduced scope of PIDController's critical sections
350b741ad Cleaned up SampleRobot template and added warning about disabling motor safety (#766)
64bfdc1a6 Bail out of the integration tests if enable fails (#792)
65cc85f68 Add reference constructors/factory methods to LinearDigitalFilter (#810)
6a00dc797 Re-Add PacGoat java example (#802)
e9e407a87 Replace C identifier lists with (void) (#809)
59c4984ed Deprecated internal filter of PID controller (#746)
b428d1e4b Remove CANSpeedController interface. (#806)
099436459 Fixes cross module base class statics (#779)
0b8d3f026 Update SampleRobot template to match comments (#768)
52eba45c5 Add missing documentation for squaredInputs for RobotDrive (#805)
9090a82ef Fixes halsim sources and headers zips (#804)
4e0ed7986 Fix no return warning in jni_util.h (#62)
2a69a4c7d Revert #780 (don't kill FRC_NetCommDaemon). (#795)
9d2393f97 Waits 10 seconds between running the C++ and Java test (#798)
dae619b00 Add error reporting to AbstractComsSetup test initialization. (#800)
9c06d2878 Update to latest native plugin (#799)
e3a2abdf9 HAL_SetDigitalPWMRate(): Use same logic as LabView. (#794)
7867e906e NidecBrushless: Have disable() call PWM.setDisabled(). (#763)
65a044f63 Fix HAL_CleanNotifier race. (#793)
cbd08a1e1 Add tests for equivilance of RobotDrive and DifferentialDrive/MecanumDrive (#732)
e308dd28f Fix javadoc link in Solenoid.java (#789)
fa0b4428e Runs DS enabled loop in process (#785)
6767afd40 Adds a UDPClient (#60)
26a36779a Performed cleanup of Timer's free functions (#776)
dfc0656e5 Fix wpilibj FilterOutputTest null pointer exception (#778)
0f3f5218a Kill FRC_NetCommDaemon as well as robot programs. (#780)
34c44b7ae Improved Drive docs and fix implementation bugs (#774)
7a250a1b9 Implement PCM One Shot feature. Fixes artf4731 (#539)
a338ee8be Add PIDController Wrapping (#601)
c9d440f33 Fix Java Compressor test. Make limits same as C++. (#772)
aa2de65ba Use Twine instead of StringRef where appropriate. (#259)
a00b2449d Removed unused includes and replaced Ultrasonic's std::set with std::vector (#767)
5c659fdcd Deprecated PIDController::SetTolerance() (#764)
d36d72bd4 Fixes MotorSafetyHelper locking and race conditions (#762)
614093c0c Fix documentation for getMatchTime in Timer class to match DriverStation (#761)
877c7f51c raw_istream: Don't forward declare Twine et al. (#59)
912b74151 Use llvm::Twine instead of llvm::StringRef in several places. (#58)
f73db4a49 Twine::isSingleStringRef(): Support CharKind. (#57)
12c4418bd Added callbacks for CAN (#757)
0431cf97f Cleanup PIDController (#597)
ba879f466 Cleaned up variable names for std::lock_guard and their associated mutexes (#759)
96de0b5b1 Variable name fixes (#758)
85157a56c CircularBuffer now uses an idiomatic interface in C++ and Java (#421)
029246ed2 Replaced extra constructors in LinearDigitalFilter with llvm::ArrayRef<> (#755)
6377ab774 Allow deprecated warnings for tests (#756)
05e581f40 Fixed crash in wpilibj SampleRobot (#753)
c73dd807e ErrorBase: Remove last use of sstream and iostream. (#750)
7a0dd9baa Add return-to-zero test for LinearDigitalFilter moving average (#751)
11f37683c Added constructor to PIDController that takes references instead of pointers (#745)
5af0c9c10 Replaced const variables with constexpr (#731)
259461aee Added PIDController::GetAvgError() back in (#749)
d214b3678 Change HAL notifier to polling. (#627)
4a07f0380 PIDController class now uses LinearDigitalFilter for filtering velocity instead of internal queue (#38)
cf828ca85 Upgraded clang-format to 5.0 (#103)
7847c6923 Update for wpi::Now() change to microseconds. (#113)
7f46b50b2 Unify WPI_Now and HAL_GetFPGATime. (#743)
0e4a1c5da NetworkTable: Add key utility functions. (#256)
551504e77 Update documentation for Now() for 1 us steps. (#258)
85e83f1bb WPI_Now(): return microseconds, and make backend replaceable. (#56)
7eac3fcbd Java NetworkTableEntry.setValue() and kin: Handle common Java types. (#257)
303c259b8 Simulate ADX* family of accelerometers and gyros (#688)
cd1dbb1e3 Adds a const buffer listener (#742)
a20474bfc Update sensors to not use direct byte buffers.
479d0beb5 SerialPort: Use byte[] instead of ByteBuffer in JNI.
b93aa176d AnalogInput: Remove byte buffer usage.
9021b37fd I2C: Provide byte[] JNI interfaces.
6307d4100 SPI: Provide byte[] JNI interfaces.
e9b0b9d8f MjpegServer: Use sink name in title. (#112)
cad1b9413 Add exposure quirk for LifeCam Cinema. (#111)
3324bcc5c Use magic statics instead of ATOMIC_STATIC. (#109)
20c8d29ae Fix wpi::mutex usage in SetVideoMode().
110726c5b Adds support to test library for JNI testing (#54)
df7c1389d Remove ni-libraries libi2c and libspi.
6accc31ee HAL: implement I2C and SPI directly instead of using i2clib and spilib.
f56ec10bc Only return lower 32 bits of FPGA time (#741)
e5e6d6a19 Ran formatter based on styleguide#95 (#737)
c663d7cd1 Reflowed comments and removed commented out code (#735)
1e8d18b32 Upgrade Travis CI Python version to 3.5 (#740)
c2d95db3a Fix PreferencesTest. (#739)
7db60f8e7 CvSource: Implement SetVideoMode(). (#104)
b3f1e7431 Ran formatter based on styleguide#95 (#108)
dd7563376 Force load OpenCV and cscore libraries on program initialization (#716)
14fcf3f2f Simplified PIDController integration logic (#645)
020ee227d Move ctre headers to hal/src so they aren't user-visible. (#728)
4d559f385 Use wpi::mutex instead of std::mutex. (#730)
e301adb22 Use wpi::mutex instead of std::mutex. (#105)
3438a1734 Use wpi::mutex instead of std::mutex. (#254)
e4deda5cc Fix SafeThread bad merge. (#53)
80618a2e6 Use wpi mutex and condition_variable. (#52)
e45b6e0f6 Fix typo in priority_condition_variable. (#51)
86d4899a5 Make NetworkTable constructor private/package-private. (#253)
9d8a508cd Add priority_mutex and priority_condition_variable. (#50)
c9ead29f4 SafeThread: Simplify m_lock assignment. (#49)
35d68d2a3 Adds ability to simulate joysticks and event info (#727)
7007725d9 SerialHelper: Check error_code to prevent infinite loop. (#725)
0c83cad70 Upgraded clang-format to 5.0 (#431)
0001047b8 Add NidecBrushless to WPILib.h (#724)
f77fd1eca Set SO_EXCLUSIVEADDRUSE for server sockets on Windows. (#44)
5a5e75392 LLVM path: Don't follow symlinks. (#48)
c88525136 Fixes HALSim_Print build to be the standardized pattern (#721)
42096fac3 Ran formatter (#722)
6be9e69d1 Switch Command Templates to TimedRobot (#719)
7bbd13d91 Adds match specific calls to Java and C++ (#720)
3e4e5261f Remove no warnings on winsock and scl issues (#47)
cf4afb6fe Adds get header task (#46)
55fa1e5e7 Adds header task (#101)
2225c4fee Fixes warnings for casts in sim interrupt functions (#718)
c10165541 Adds warning prints by updating native plugin (#100)
51165ba0a Updates native plugin to add warning prints (#251)
f03b31f43 Adds warning printouts to gradle by updating native plugin (#45)
7efab4c43 Replaced ternary operators with if statements (#346)
c8e44256e Uses NI provided function for SetOccurDataRef rather then importing the symbol ourselves. (#714)
f3cd883c5 Add Nidec Brushless motor. (#705)
f34c736fb Adds warning prints to native library builds (#710)
127648996 Removed uses of deprecated functions (#709)
8b2e656bd Fixed Java velocity PID not calculating result when P = 0 (#717)
6e9d1f55c Updates image to 2018 v10 image (#713)
f4dce9e60 Fixes receive size in Java I2C (#715)
b9aabc71b Fixes publishing basenames for examples to make combiner script work. (#712)
0d5477236 Add IDEA plugin to root project (#707)
faf134a67 C++ examples no longer use deprecated APIs (#703)
c24e75540 Fixes java example publishing and xml file (#706)
bee9f1cb1 Adds header task to print out all headers (#704)
45d48d6b5 Cleaned up C++ examples (#672)
6401aa1fd SerialHelper: Use llvm path functions instead of popen. (#702)
8e797a1a1 Import filesystem directory iterators from llvm. (#43)
6af4940c2 Adds HAL calls for match data from DS (#691)
237b2df82 Add .type metadata to preferences table (#701)
a70687aae Improve error reporting for the new TCP netconsole. (#700)
fbfe85568 Fix preferences test (#699)
595b1df38 Fixed minimum number of joystick axes (#696)
fd32350dc Assign received sequence number on receiving an unknown entry (#250)
b9c8ebeff Ran formatter (#99)
efc7770e9 Fixes NPE in DriverStation initialization (#694)
21585f70a Added functions for detecting button press and release events (#626)
c33fca34e Added TimedRobot template (#673)
de95f08a1 Adding call to notify program started (#692)
90f99dc57 Adds PWM to LoopTiming and CycleStart HAL calls (#693)
f34332643 Uses new FPGA calls to get 64 bit FPGA time and 64 bit PWM cycle start time. (#687)
4ab095e9c Fix formatting in CameraServer.cpp (#689)
541753c81 Updates to 2018 v9 image (#686)
f02bb058b Set the llvm standard output stream to be unbuffered. (#678)
12e96c6f1 Add usage reporting to CameraServer (#682)
b65447b6f Fix spelling typos (#595)
9945a5b3c Ran formatter (#681)
ce4c9edd1 Fixes halsim_print to not try and build when the 'onlyAthena' flag has been set (#685)
a6e6ae41b Add function that can register all the HAL callbacks at once (#646)
f4e2e41aa Remove leading '*' from license and rename to LICENSE.txt (#596)
1e528669f Adds publishing for examples and templates so they can be grabbed from eclipse (#674)
a1ea44840 Adds JNI call to get CANStatus (#677)
9dc1de1d0 Specified angle units for Vector2d rotate() function. (#679)
0521d8504 Moved comment after include line so include order is determined properly (#680)
3c842d823 SPI and I2C simulator (#662)
ec12b0ffe Add wpiformat to Travis CI (#98)
7fd594748 Fix include guards (#97)
be77f9cb2 Pull request for the Extensions interface only (#655)
2fc60680f Remove RedundantModifiers (#578)
0291a95f6 Add cpp examples (#659)
66002d6ca [WIP] Move examples to allwpilib (Java) (#569)
a7e9ac106 Fix capitalization of class names in PIDToleranceTest.cpp (#588)
434d60592 Adds HAL_Initialize to ErrorBase constructor, and makes HAL_Initialize properly reentrant (#668)
ee2074725 Adds WPILib JNI shared debug file publish. (#671)
f4779379c Added brace comments (#670)
877a9eae1 Add SpeedControllerGroup (#362)
b68e1c557 Added brace comments (#96)
ded1beb94 Removes specific raspbian, armv7 and armv8 cross builds (#249)
a6c7789b5 Removes specific raspbian, armv7 and armv8 cross builds (#41)
24752a975 Removes OpenCV dependency from wpilibJNI (#667)
e1dc09951 Updates to the 2018v5 image (#665)
f0cc62324 Change metadata format to dotfile, make certain entries metadata (#666)
ba3a85d0c Changes TalonSRX to PWMTalonSRX in wpilibj and wpilibc. (#656)
79919a5f1 Moves wpilibc link script into shared folder (#660)
94ea5bfb0 Move published wpilibj JNI shared artifact into shared/ subfolder (#658)
24680bbd5 Change link script artifact id (#657)
73f8412b4 Correctly handle negative waitForXQueue timeouts in Java.
529d7f5fe Initialize logger min level from logger_impl.
a6c1e18ae NetworkTable.containsKey(): Always return false on empty key.
8a37b81f4 LoadEntries: Don't emit NOTIFY_FLAGS. (#247)
f81b6fbcd Fix handling of deleted values in several places. (#241)
7fab0e0ef Depend on wpiutil 3.+, ntcore 4.+, cscore 1.+ rather than just +. (#651)
223e61df2 Depend on wpiutil 3.+ rather than just +. (#95)
303df626a Depend on wpiutil 3.+ rather than just +. (#235)
9e8ad778d Update wpilib-version-plugin to 2.0. (#39)
1f18cc541 Add SaveEntries() and LoadEntries(). (#233)
e68a71022 Move immediate connection notification logic into Dispatcher.
e4a8bff70 Move immediate entry notification logic into Storage.
10982e027 Don't actually remove deleted entries from m_entries. (#239)
dd66b2384 Remove priority mutex (#644)
19addb04c Split RobotDrive class into a class for each drive type (#552)
abb66d3e4 Replace FRC_NetworkCommunication CAN in wpilibj with HAL CAN (#650)
db4981f16 Java now asks the HAL if it is a simulation or not (#647)
8edc02b06 Update README for new build system. (#232)
4b2aaee9e Made package local methods in NetworkTableInstance public (#234)
9fdb33b6a Switches native linux arm build to be `nativearm` arch (#38)
6e1be897d Ran formatter (#643)
423d8f686 Add missing usage reporting. (#639)
eb38204d1 Update the README to note the need for gcc 5+ and Visual Studio (#640)
1711291cd Fix Travis build (#641)
3faecdb35 Add SHA1 algorithm implementation. (#32)
57ba58917 PreferencesTest: Use new NetworkTables API. (#636)
2249a8bac Adds a HAL wrapper around the CAN API's (#623)
c572e6a30 Adds the rest of the data needed for a publish on jenkins (#628)
e444b6015 Updated remaining .styleguide files to new config file format (#635)
db96f41ad Log.cpp: Use raw_ostream and llvm path functions. (#93)
38dbed8e0 .styleguide now uses generalized config file format (#621)
10fbf17d4 .styleguide now uses generalized config file format (#94)
34c18ef00 Remove getTable from wpilibj Sendable interface.
0d4fde17e Remove GetTable from wpilibc Sendable interface.
040a8c6bc Update wpilibc to use new NetworkTables package and interfaces.
4e80570c4 Update wpilibj to use new NetworkTables package and interfaces.
91529cc43 Update NetworkTables for new API.
ef8580969 Fix bug in raw_fd_istream::read_impl(). (#30)
95bce5d65 Add more storage incoming unit tests.
cedbafeb2 Add INetworkConnection interface for unit testing.
7c1d2f4bc Improve client connection synchronization behavior.
8099d6dbd Refactor Storage ProcessIncoming().
8e01b68cf Switch Storage save/load to use raw_ostream/raw_istream.
d707a07f8 Refactor Storage load and save functionality.
5ab20bb27 Implement independent instances.
8125a179f Only include .cpp files in testsuite build.
041563f8e Change UidVector to be LRU with a reuse threshold. (#29)
ef3267833 Fix IterativeRobot/TimedRobot RobotInit(). (#633)
a5ef50c9e Add documentation for PeriodMultiplier (#632)
6eee45789 Renable javadoc fail on error (#631)
fb6d7b347 Fixes javadocs (#630)
2d78fdabb Fix recieve typo in JNI names. (#629)
94c31ceeb Gets wpilib compiling with skipAthena and onlyAthena flags (#625)
c3f7c85f8 Adds wpi GetHostname function (#25)
12b2efa48 Log.cpp: Use raw_ostream and llvm path functions. (#223)
67d4da51e Restore travis support. (#608)
6e4f66cc8 Classify other libraries' headers properly and fix committed formatting issues (#620)
5d403a7b4 Makes an empty stringref have a valid Data pointer (#28)
3c88f94b4 HttpUtil has moved to wpiutil; use it. (#92)
06636a0e1 Set up wpiformat (#86)
a4e781a23 Fixed spacing and comment annotations around namespace and extern declarations (#587)
f151892db Contents of copyright line now has more standard ordering (#585)
c45fb73f3 Convert for loops to foreach loops (#592)
848280d1f Improve C++ Compressor documentation based on Java's docs. (#607)
8416b4e42 Add default parameter to StringRef to allow null termination on lengthed strings. (#27)
1a0ed61f7 Force the java dev library to be built during `build` (#24)
68501759f tcpsockets: Don't pull in platform-specific headers in headers. (#26)
f7016b359 HALUtil: Update to new GetJavaStackTrace function.
be58a279a Cross-platform JNI sometimes has jlong != int64.
909e6c485 Error.cpp: Use llvm path function instead of OS basename.
5c0b08f4f Turn off -Wunused-const-variable on Mac.
05d1cfa27 Add "override" qualifier to several headers.
ae675ae4e DriverStation: Work around missing pthread_local on Mac.
d3b636d07 fpga_clock: Don't use constexpr for time_points.
8b460f594 sim DriverStation: Fix missing includes.
bdfa32876 Fixed Gradle test task name (#617)
4a3472ebb Removed unused include in PIDCommand.cpp (#616)
9c804c135 Fixes builds with skipAthena and onlyAthena, and mac builds (#613)
2a9c454ba Cleaned up and updated .styleguide for new build system file locations and ran wpiformat (#612)
1a9a6c367 Fixes HalSimStaticDeps config and publishing (#610)
e1195e8b9 Update to 2018_v4 image and new build system. (#598)
dd85b1e51 Update googletest and googlemock to 1.8.0. (#90)
2d3cf1bdb Updates plugin to 1.2.12 (#91)
baa8021c7 Force dev java to be built during `build` task (#227)
133540f57 Switches to the new build system (#87)
43c103c0a Update googletest and googlemock to 1.8.0. (#23)
162ac787b Update googletest and googlemock to 1.8.0. (#226)
fa7d5bc02 Add UidVector (used in both ntcore and cscore Notifier). (#22)
9d4508812 Fix destruction order issue in SourceImpl. (#89)
7ef56de3f Fix mac builds. (#88)
0d76b3f30 Added gradlew.bat to .gitattributes (#225)
50ed55e8e Force OpenCV to 3.1.0 (#602)
92c4c49b0 Removes the custom platform include flag (#224)
855df5d67 raw_mem_istream: Add StringRef constructor.
c8d9cc7e5 Add filename constructor to raw_fd_istream.
1c1fbf14c Import LLVM openFileForRead and openFileForWrite.
9e4dc235d Connect to server in parallel rather than doing round-robin. (#205)
4bd8cf6f5 Native tests depend on native sources, so include in exportedHeaders. (#222)
d9c754c30 Add a java version of the dev app. (#218)
ea028a382 Add a cpp dev run task. (#219)
7d9e6b7e2 Move ReadLine into raw_istream class as getline. (#20)
17b5cace5 Base64: Add raw_ostream and SmallString interfaces. (#19)
2fa41b23b Add a java version of the dev app. (#16)
9f5f6111d Add a cpp dev run task. (#17)
078216412 Gradle 4.1 (#220)
5439fe7b1 Gradle 4.1 (#18)
55111ac35 Fix CORS issue with all requests (#85)
f0cc5d9ca Adds an all artifact to the published libraries (#15)
ccfeab5ac Adds an all artifact to the published libraries (#217)
d682295cc Miscellaneous cleanups for HAL, wpilibc, and wpilibj JNI (#589)
5e19c1881 Use diamond operator
617ff52f1 Use generics
7e011bda6 Add HTTP utilities. (#7)
8418c3912 Add Path and Twine components from LLVM. (#10)
5d3af62c0 Remove use of std::chrono_literals (C++14 feature). (#574)
4b8ef57a9 Remove networktables2.type Java custom container types. (#214)
d910b0b2a Remove deprecated throwing get functions. (#213)
80c8de7d6 Add dependency to jni task to fix 32 bit builds (#216)
7f776deae Fix ntcoreExe build model. (#215)
8209ba8a0 Move NetworkTable into nt namespace, with a shim. (#211)
25c8e873d TCPConnector: Add method to connect to server in parallel. (#6)
e24db75f0 Build updates to newest version of plugins and gradle, along with config file (#13)
5df746366 Remove wpiutil and update to the new build system (#210)
eb7331f2a Actually makes the right classifier
03bd0820c Adds a java classifier whenever jenkins is building (#12)
63768166e Updates to plugin 1.2 (#9)
bd899a7a7 Fixes mac RuntimeDetector (#11)
ddd5aeba1 Checkstyle 8.1 (#584)
301442ee4 Add json support to wpiutil.
de9dd1180 Include src/main/native/cpp when building test.
436ed4d1e Implement comparison operators for llvm::StringMap.
88aa273e5 license.txt: Add LLVM license.
d11d8409a license.txt: Remove leading asterisks
9385d1b6d GetJavaStackTrace: Provide llvm::StringRef excludeFuncPrefix. (#3)
b90653f3e Logger: Add def_func and min_level constructors. (#2)
1243cf04e Adds new build system to repo (#1)
3cfcbe9a9 Remove Scheduler.java from the sim path. (#564)
4f5b5b137 Adds gmock files
6bc793505 Suppress MultipleTopLevelClasses warning (#581)
3b44160cf Rearrange some method calls so methods fail faster (#583)
d9586c8d3 Fixes JNI aliasing issues involving ControlWord and AllianceStation (#575)
74df3fac4 Require non null (#580)
06321b8e8 Fix encoder sourceA null check (#579)
f3efb948f Switches CANJNI to use byte[] rather then ByteBuffer, and throws exceptions for invalid platforms (#571)
432c03bf6 Updated Gradle to 4.0.1 (#573)
bfd224278 Fix Java MyRobot linting (#572)
822ea6abc Made SpeedController class organization consistent between languages (#568)
97437ee58 Miscellaneous formatting and style fixes for integration tests (#570)
aa7fe0db2 Fixes unused buffer warning on platforms other then athena (#566)
237685d4a Fixes static initialization of HAL handles (#565)
abbe63027 Gets WPILib building on windows and C++11 vs C++1y (#561)
89d3b08e7 Added TimedRobot (#520)
f826216a2 Gets JNI compiling on all platforms (#563)
aa0a874ad Add periodic method to subsystems (#528)
2da26c057 Make HAL_Initialize timeout configurable, makes result a bool, and makes Java an exception rather than assert. (#557)
d34c84490 Fixed function ordering in robot base classes (#553)
68b63632c Removed functions that have been deprecated for at least one year (#551)
d2de94778 Remove memory leak in ConditionalCommand (#537)
4fd4a50d4 Update Preferences to not use deprecated APIs (#555)
9d9382071 Replaced STL streams with LLVM's raw_ostream (#344)
c57a7f0a4 Switches all notifiers created with the external API to be threaded (#546)
1d15fcd07 Prints error when HAL_GetFPGATime call fails in fpga_clock. (#558)
e824b1129 Adds way to reset and version all HAL handles (#545)
0cd03c66e Remove deprecated Task class (#550)
462b231da Adds function to HAL to free malloc'd joystick name (#543)
e4a918850 Fixed return value of SendableChooser<T>::GetSelected() for non-pointer T's (#512)
d472af351 Removes CAN.h from the HAL (#556)
98a587a34 Removed unused includes and added missing stdint.h includes (#549)
5fd996876 Fixed a typo (#547)
f43675e2b Add functionality for getting the current network mode (#202)
417cf33f9 Expose ITable paths (#200)
b433d98c0 Replace std::stringstream with llvm::raw_svector_ostream (#345)
7006672b0 Fixes hal shim from alias to using item (#538)
efec0c5cc Moves the HAL priority_ custom types to the hal namespace (#532)
16e71eac4 Fixes assertions to not crash StringRef (#534)
067b1f3ee Adds a way to get the native handle from SafeThread (#198)
3d2f41d08 Adds a way to get the native handle from SafeThread (#198)
68b62abb5 Adds chrono wrapper around fpga time (#527)
b2f347969 Switches SPI and I2C to use enums in the HAL for ports (#531)
67d62ba16 Travis now passes the current year to wpiformat (#438)
e1fc60b8d SolenoidBase functions are now static (#530)
f32e696fe Fix exception when getting a relay in kReverse Direction. Fixes #458 (#525)
fc81298fa Switches DS to use Occur callback rather than internal netcomm semaphore (#510)
5987cfeaa Fix SPIs to not set CS DIO pins into DIO mode (#504)
cd0ece451 Removes the semaphore class (#529)
dc9f85ebb Fix comment refering to old _val enum values (#524)
35a2055cd Improve documentation for WaitCommand and TimedCommand. (#494)
a1066776a Make SmartDashboard methods static (#523)
4dae74734 Refactor RobotDrive squaring (#390)
d348a5b94 Fixes WaitForInterrupt to return values matching enum (#503)
f0c413f40 Relay stores nt value in enum (#460)
846eee2f6 HashMap -> LinkedHashMap (#492)
0b9ff68da StartLiveWindowMode ITables use lambdas (#461)
7187e005d Add Checkstyle WhitespaceAfter check (#466)
a5cd24e7e Reduce scope of for loop variables to for loop initializer (#517)
dbe821bae Change the wrapper to use the all distribution with the sources (#498)
04486c647 CameraServer: Always update addresses when updating stream values. (#496)
2ee8ba936 SafePWM: Rename Feed to feed (#463)
b07782cd8 Removes StatusIsFatal checks from PDP (#493)
305450b6e Remove 'value' from PIDSourceType (#464)
fdd0b853e Fixes Base.h to work properly with MSVC 2015 and above (#513)
49de28d3d Add overloads for property types except enum (#73)
c34cf1176 MjpegServer: style fixes for root page (#72)
42facbb07 Make Java "struct" constructors public for testing/simulating (#195)
9f97cd61b Correct platform path for 32-bit Linux (#179)
1d025204e Fixed Spelling Mistakes in SmartDashboard.java (#506)
59133a7d9 Use Javadoc formatting for Java comments. (#66)
b484cbba7 Adds SinkFrameTimeoutCpp to def file (#61)
61e34621c Add GetNextFrame timeout to CvSink and MjpegServer.
5e9575de6 Add missing CS_SetDefaultLogger in cscore-jni.def.
12f759860 Corrects assumptions about return values from i2c-lib (#484)
c02d34dbf Allow resetting the logger back to default (#55)
8f97637b7 Fix handling of HTTP cameras that do not provide a Content-Length. (#59)
878d3a6f4 Publish video modes to webserver. (#58)
ef25bbde7 Fix SetExposureAuto. (#57)
1bdbb5ddc Remove usages of isEnable() (#483)
b573fb655 Fix param order in RobotDrive docs (#481)
b50a7bdbe Fixes memory leak for SPI reads (#474)
5a5f10dfc Fixes I2C read change size of pointer (#479)
8c3efa592 Increment reference count when creating VideoSource object (#53)
e6656326a Adds field IP to round robin list (#187)
e375b4a9f CameraServer: auto-increment startAutomaticCapture(). (#468)
ff141ab1f Fixes exception on camera creation without plugged in camera (#470)
cf8cab850 Fixes missing VideoProperty constructor. (#49)
b8537be21 CameraServer: Remove NT-driven settings. (#467)
db5dfa174 Adds sliders for all settable properties to the default webpage (#48)
13457d1bf Update setUpdateRate() documentation to match implementation.
8f1b034b2 Fix typo in JavaDoc (#462)
71d0a07e0 Fixes solenoid allocation error message (#455)
d32234249 Remove comments about Blue DS (#450)
8f8c4d3d9 HttpUtil: Allow "http" scheme to be mixed case.
d47bd1ecb Fixes embedded library name used for extraction in Java (#45)
e9fcb5381 Fixes Java artifact clasifiers when using custom suffix (#44)
3e2631f49 Fixes Java artifact clasifiers when using custom suffix (#183)
bc7ab1769 CameraServer updates (#446)
3c3236c5d Fix video mode notifications.
7a049c29b Added a conditional command that chooses 1 of 2 commands (#435)
23462ec7d Adds way to force publishing version from command line (#43)
ac56b0a33 Adds way to force publishing version from command line (#182)
1fc375b31 Updates the gradle wrapper to version 3.3 (#445)
eee7f3991 Allow VisionRunner to stop (#442)
b55c604c0 Updates Gradle to 3.3, and removes the Visual Studio 2015 workaround (#41)
a72f8f3bc Add new ARM Toolchain, add toolchainpath to README (#42)
2e3503517 Add OS level serial port (#426)
27c0405fc Reruns gradle wrapper to fully generate 3.3 files (#181)
b9e80ecfd Updates to gradle 3.3, and removes Visual Studio 2015 workaround (#180)
a3adb38be Adds support for specifying output suffix of arm packages. (#34)
593ba37c4 Java VideoEvent: Make propertyHandle public.
4ed78a84e Java VideoMode: Provide PixelFormat-taking constructor.
e893662c0 Adds new functions to def file (#40)
15e58acc7 Java SendableChooser no longer sets a default on addObject (#441)
5df78c520 Adds support for building separate armhf artifacts (#177)
f13f88688 Fixes arm example builds on windows (#39)
5dd8e4dc7 Adds defs for the C windows functions, and shims the 5 missing ones (#38)
5aa5e3e09 SendableChooser generic value (#433)
883fd5b06 For property events, provide property name rather than source name.
7ddbf2010 Create VideoCamera base class and move camera settings functions to it.
23135d7a5 Allow Sink.SetSource() to be given an empty source.
b91ab0b44 Gets builds working on Windows (VS 2015) (#37)
9a2ec13ba Fixes SetIntArrayRegion template for windows builds (#178)
78995f5cc Fixes SetIntArrayRegion template for windows builds (#178)
f225c4773 Fixes gradle publish with no flags. (#35)
25ae7b2c2 Upgraded Doxygen gradle plugin to 0.3 (#440)
4b6dc9583 Corrected order of access specifiers in MockCommand class (#436)
64eab1f7b Fixes missing Extern "C" from HAL Threads (#437)
bac4b3d5c Fixed gradle publish with no flags. (#176)
182f57216 Adds project and classpath ignores (#425)
65b091a39 Call SmartDashboard::init() in RobotBase constructor. (#428)
ed1a94531 Update license headers to 2017 (#434)
e3f99a4a2 JStringRef: ensure string is null terminated so c_str() works correctly.
df7d3261c JStringRef: ensure string is null terminated so c_str() works correctly.
95ad4783f Revert "Fixes TCPAcceptor able to use an empty string (#172)"
b5b089922 Revert "Fixes TCPAcceptor able to use an empty string (#172)"
9a0a1baa6 Fixes TCPAcceptor able to use an empty string (#172)
6ad9f45d9 Fixes TCPAcceptor able to use an empty string (#172)
4e12ffb0a Update the wpilib version plugin (#423)
7ec223d44 Update WPILib Version Plugin (#33)
ed9e83722 Updates the wpilib version plugin (#171)
b9a08e826 Fixed entry comment (#169)
58931e1d3 Be even more permissive on valid JPEG formats.
976ca8005 Use InetNtop on Win32 rather than WSAAddressToString. (#170)
95e529566 Use InetNtop on Win32 rather than WSAAddressToString. (#170)
4800c201e Add Axis camera creation functions and Http camera NT publishing. (#420)
dc9a9e5d9 Fixes typo in SensorBase error message (#422)
4b16999fb Fix tests that are only built on cmake. (#168)
318d23ba1 Add AxisCamera wrapper class.
9c4c7c08b Java HttpCamera: Make accessor functions public.
9016a9e8b Start implementing HttpCamera.
4c8c41fdc CvSink: Support grayscale images.
205d3b1d0 Some cameras don't provide the JFIF header, so don't require it.
1575fff07 MjpegServer: Limit the number of simultaneous clients to 10.
8c7338f2b TCPAcceptor: Include port number in error messages. (#166)
459cc65b3 TCPAcceptor: Include port number in error messages. (#166)
6844f05c3 Adds SetAllSolenoids function to CTRE PCM code (#419)
8f67f2c24 Remove unused code and add pmd check (#395)
cc246bb9a Switches JNI to use new jni_util methods (#404)
3d2827567 UsbCamera: Simplify the message passing implementation.
bf9f0a9e6 Add vision pipeline API to make it easier to run OpenCV pipelines (#388)
6f41b3cde UsbCamera: Implement LifeCam HD-3000 exposure quirk.
9ffc09a11 Fix settings example if there's no "--" in arg list.
ced2608af Move ExtCtrlIoctl to UsbCameraProperty::DeviceQuery.
adbca532c Break up UsbCameraImpl::DeviceProcessCommands().
5e38d8f28 Refactor UsbCameraProperty.
d6ef2c04a Start refactoring source property implementations.
ce6978387 UsbCamera: Scale some properties to make them constently percentages.
c3160bad4 Update SendableChooser to use HashMap (#394)
94b8ac42c Adds CPP version of vision pipeline (#399)
a03e3d7eb Fixes HAL to build without all headers included in HAL.h (#418)
a42ec08d1 Fix RoboRIO Cross-Toolchain GCC Status (#405)
fddb6cd9d Fixes SPI Accumulator averages (#415)
10b13da3d Refactor USB vendor/product to product string to UsbUtil.h.
88afefe46 Avoid crash in SourceImpl constructor.
841f01601 Fixes SerialHelper when used with OS serial ports. (#411)
8e4afc95c Switches C++ strings to StringRef (#336)
80abf6bf2 Support per-stream resolution settings.
94359709a Add new ARM Toolchain, add toolchainpath to README (#165)
8cec94869 Fix typos (#409)
31ae7c942 Fixed signatures of deleted assignment operators (#408)
d0900626d Removed format.py shim (#393)
0ee4cadca CameraServer: Workaround LabVIEW dashboard OpenCV compatibility. (#406)
8501b7c9e CvSourceImpl::CreateProperty(): Use lock_guard instead of unique_lock.
0ce0855a6 Java: check for null and use new jni_util features.
e1dabbc2d cscore_cpp.cpp: Fix include order.
c08a489e2 Improve error message for VIDIOC_STREAMON "no space left on device".
28a2ba4bf Add external logger interface.
2b8b8e740 Improve logging consistency by using source/sink name throughout.
bdaf60b2d Replace tabs with spaces in gradle files.
7c2f994a6 Refactor source IsConnected() and connected notification.
24b5a9c38 Adds UsageReporting include when using the LabVIEW shim (#401)
bb9f5b749 jni_util: Add JException wrapper class.
c091d74de jni_util: Add JException wrapper class.
626220e9f Fix javadoc typo (#403)
19be09c36 Add null checks on all JNI object parameters.
57d053a8f jni_util: Make JStringRef and JArrayRef null-safe.
8c2a148ed jni_util: Make JStringRef and JArrayRef null-safe.
0e43765c5 jni_util: Add GetJavaStackTrace.
6fbaf57b9 jni_util: Add GetJavaStackTrace.
12aee3e02 Make JLocal and JArrayRef movable but non-copyable.
2df00647d Make JLocal and JArrayRef movable but non-copyable.
498a8e2b7 Fix JArrayRef DirectBuffer destructor.
99395273c Fix JArrayRef DirectBuffer destructor.
4568156bd Make JClass more useful and use it in ntcore JNI.
ce7611562 Make JClass more useful and use it in ntcore JNI.
323d68d46 Fixes multiple initialization of HAL_BaseInitialize (#400)
db2091dd9 Adds safe serial port write methods (#396)
8216d85e5 Adds check for PWM overallocation (#392)
a705eb1c6 Add PMD and solve issues (#389)
77f664a6b Fixes simulator HAL builds (#391)
c30057e92 Remove unused imports (#387)
81fd0eefa usbcvstream example: Print error from GrabFrame.
b5fd15e05 CvSink::GrabFrame(): Add delays like MjpegServer to avoid consuming CPU.
ecfc68417 MjpegServer: Increase bad frame wait from 10 to 20 ms.
4600ea135 Frame: Make Data struct public.
3b82ba894 Refactor JPEG functions to JpegUtil.
c32fc57ce Refactor HTTP utilities.
9a8f66e3e SourceImpl: Add no-copy PutFrame.
ef3971321 Revert "Don't output \r\n before boundary. This throws off some clients."
da68fea08 Fixes shared wpiutil switch on athena (#24)
06108b947 Update CameraServer support. (#386)
1f93a4ab4 Change acronym class names to use MixedCase (UsbCamera, MjpegServer). (#22)
7a587390b Fixes OpenCV on windows when we get to it. (#23)
16181523c Put language in version string (#377)
7e0706cf8 Updated Usage Reporting for 2017 v8 Image (#385)
bff67887f Adds capabilities to support certain HAL functionality from LabVIEW (#382)
351ff5eb4 Adds new Threads API for priority setting while using std::thread (#379)
378a145cf Fixes Missed Symbol from Def file (#162)
3625f11e0 Adds C methods that take a cv::Mat* (#21)
051df1404 Updates ni patch task to automatically switch all files to LF (#381)
ee0318f69 Updates NI Libraries to image 8 (#380)
1332ba3ad Adds JNI symbol check to ensure we don't miss any definitions (#19)
558b2ffa4 NetworkStream: Add setBlocking() and getNativeHandle(). (#161)
1315a3967 NetworkStream: Add setBlocking() and getNativeHandle(). (#161)
a6fb1efcb Switches internal joystick errors to take StringRef (#378)
31fecc28a Check for NaN motor speed. Fixes artf5467. (#376)
00b76d42e Fixed unused variable warning from gcc. (#159)
e7c4150c0 Fixed unused variable warning from gcc. (#159)
bc06c843c Adds JNI symbol check to ensure we don't miss any definitions (#160)
30b1efc35 Adds check to ensure all JNI symbols have been defined properly (#373)
7d721eb56 Fixes memory leak in SerialHelper VISA (#366)
b8e9439d3 Message: Fix typo in error message. (#158)
d48aac5be Gradle Update (#372)
14b56db99 Gradle 3.2.1 (#369)
bfe429de5 Switches handles back to std::array (#367)
57ef5cfd0 Splits out SerialHelper to allow using OS or VISA resources (#365)
4bbb7c0bc Fixed javadoc generation to actually download cscore and ntcore and include the source in its output. (#368)
4de70bff5 Adds missing JNI method definitions (#371)
687f0c7dc Use const parameters in std::sort lambda. (#364)
f3d66e92e Searches for USB serial devices to get the correct VISA object (#363)
046d385a7 Actually fix lack of - (#157)
5caf75237 Fixed version generation when no - is present (#156)
9a91ae54d Fixes incorrectly changed Java enums (#360)
69422dc06 Replaced floats with doubles (#355)
7bcd243ec Reorder the HAL handle types (#357)
8f70bea89 Fixes Athena Runtime build not including ntcore (#356)
948c4275a Fixes the wpilibj jar not getting updated during every build (#359)
03a115991 Java CameraServer: Fix type cast exception. (#358)
a19b1b934 Adds data accessor functions to JNI (#18)
1c8fb298b Ran formatter (#354)
b25a7cb37 Command::IsFinished() must be overriden by subclasses again (#353)
140c365e4 Added XboxController class (#140)
8c93ceb72 Add cscore-based CameraServer. (#352)
0b1e876dc Bump wpiutil version to 1.0.2.
ac50d7cf8 Removes NiVision from allwpilib (#305)
ae8c8ec23 Don't output \r\n before boundary. This throws off some clients.
ecb873ff4 Fixes myRobotJava zipping before Java gets built (#351)
ec8c0eb3c Fix FPS setting and crash in reapplying settings.
3d898dd8f MJPEGServer: Fix URI %xx-decoding.
df18e178e MJPEGServer: Provide a bare-bones HTML root page.
71a6e0898 MJPEGServer: Make a couple of tweaks for Axis camera compatibility.
a05636d9a Add data accessors for USBCamera and MJPEGServer.
5eecbfd9b Implement immediate notify on network interfaces event.
78baa04ec Adds OpenCV to myRobotJava (#350)
65514b302 USBCamera: Update description on reconnect.
881d55f85 VideoListener: Add move assignment operator.
b78f580d4 Adds default methods for Commands (#238) (#238)
cc20d9d0f Add no-parameter constructors for specific sources/sinks.
b115c7522 Adds SPI DIO to WPILib (#256)
6bc092f3a Updates SPI device pin (#348)
f99a266ce Adds CsCore dependency to myRobotCpp (#349)
35aa54441 VideoEvent: Make sourceHandle and sinkHandle public.
bad4ca466 Add event for network interfaces change.
5fecc57e8 Add methods to get the hostname and network interfaces.
e1f4e3d2d Fix mapping into Java enums.
5ace9e418 Renumber event kind values.
9945459a4 Notify sink enable and disable events.
22c11fad3 Notify source property events.
c6b527d45 Notify source connect, disconnect, and video mode changes.
8e9911d33 Notify on sink source change.
b24572594 Notify on source and sink create and destroy.
154ae5dcb Notifier: Take Impl rather than handle in notification functions.
bae203708 Handle: Add methods to get Data struct from Impl pointer.
c0bc8d702 Change examples to start at port 8081 rather than 8080.
736b5ff42 Java: throw VideoException on error.
29cd2b11b enum_usb example: output the property type.
dcf773c3e Add USBCamera setting functions similar to the old WPILib nivision ones.
791cabbc2 Rename Type to Kind.
3c7d8063f VideoProperty: rename type() to getType().
3381340eb Add method to get source/sink type.
6446b9ef1 Add sink source changed event.
6c19eb59b VideoSource, VideoSink: Provide equality operation.
797d049f3 Use java.util.function.Consumer for event listener.
0bcafedeb MJPEGServerImpl: Refactor NeedsDHT.
7e0e8286e SourceImpl: Refactor frame allocation into AllocFrame.
5ae116237 Move MJPEG DHT insertion from SourceImpl to MJPEGServerImpl.
c80c4ae55 MJPEGServer: Use worker thread model.
254b88bdb Start adding support for non-MJPEG frame types.
2657d8917 Adds a c_str method to StringRef (#155)
38ec59f03 Adds a c_str method to StringRef (#155)
1f724d58e Made the test scripts executable to fix -dirty on the version numbers. (#347)
259cf1ff3 Mark NetworkTablesJNI callback interfaces as FunctionalInterface. (#154)
de4a246bb Adds OpenCV Loading to wpilib program startup (#338)
b12658afc Make SafeThreadOwner moveable. (#153)
c23880f82 Make SafeThreadOwner moveable. (#153)
41dd9e4f0 Loads OpenCV JNI Library in Java (#15)
412b80da3 Fixes joystick button handling HAL JNI layer (buttons are in an (#341)
47319960a Fixes a missed change to unique_ptr in the HAL (#337)
b22d21823 Removes CANJaguar specific constants from JNI files (#339)
3d1f69075 Adds a size parameter to JStringRef (#152)
dc94a3fac Adds a size parameter to JStringRef (#152)
6eb82bc31 Exclude genlinks.bat from HAL zip (#333)
a06dd25d5 Adds cscore and opencv to wpilib (#332)
468cac543 Fixes JNI
d4b48216e Renames uberzip to athena-uberzip, and doesn't include static library in it
e1bb05bc5 Updates to the 2017 v7 image (#329)
f83ff41e4 Rename from cameraserver to cscore.
891ce0631 Adds opencv headers to uberzip (#11)
0658ba6f7 Adds javadocs and sources to published windows builds (#10)
29d8d1d74 Implement listener interfaces.
8d2efb283 Improve listener interface.
e07a40a16 Adds an UberZip that preincludes the opencv libraries
38a3eda6a Switches CameraServer on Arm to use non-included native library
6d1ab7606 Enables temporary publishing on windows
8694a020a Removed entries from .styleguide that are included in .gitignore (#331)
1efb2e4d3 Deprecates Task and Semaphore, and changes other deprecations to use wpiutil version (#330)
77edf1e10 Add FRC Driver Station connection support.
28c8678ea SafeThread: Use atomic for m_active.
34acd9d47 SafeThread: Use atomic for m_active.
861726cef Adds gradle task to fix NI libraries whenever new ones are added. (#325)
81212d80c Fixes ultrasonic declaration (#328)
2235a809c Fixes a missed change from the ni-libraries location change (#326)
3fe0f49ac Moves NI headers to their own folder in the repo (#324)
03d8f9193 Moves using namespace from ChipObject.h into hal namespace (#323)
05ca76ea9 Runs clang-format on ntcore (#150)
d1065f0bd Moves deprecation definition to wpiutil (#149)
cf0ec7b9a Moves deprecation definition to wpiutil (#149)
5e54969f6 Adds Task back into WPILibC (#320)
46085824a Add DHT data to MJPEG source images if not present.
18ef5eb1b C++ and Java tests for the new build system (#309)
b5e3d92e9 Remove errant "using namespace" in global namespace (#318)
ba8761e39 "using" directives are no longer used in global namespaces (#219)
78f0b1562 Removes Task.h from wpilib.h header (#317)
5c28b3002 Removes NetworkTables from Java executable jar (#303)
59267da72 Namespace all wpilibc functions/classes into "frc" namespace. (#311)
36ad45c07 Delete .gitreview (#316)
ecb2add79 Removes additional references to CANTalon from the library. (#312)
9bbdaf300 Removes the task class from wpilib (#314)
bc492bb40 Removes the REAL definition from wpilib.h (#315)
7067179b2 Ignores the vscode directory. (#6)
81221c487 Moves JNI internal utility methods to frc namespace (#310)
4828a6986 Update versioning plugin.
3fcc808e9 Use zlib built into OpenCV.
15cdd661a Simplify OpenCV dependencies.
137b3d81f Fixes JNI file not being copied to output directory for integration tests (#308)
6741f47ef Update version plugin (#307)
60d9f3de6 Update version plugin (#148)
f87baaa4f Moves dependencies to their own gradle file, and adds capabilities to link to ntcore and wpilib (#4)
fecd8a448 Fix wpiutil version (#147)
fe4ef75cf Updated wpiutil version
87c7a9db5 Add USB and OpenCV processed dual stream example.
fa2ce4008 Add OpenCV library links to example executables.
4eac3fe9a Disable x86 platform for now until we get OpenCV working with it.
d7efd6251 build.gradle: Fix OpenCV library order.
e10b399f5 CvSource: Implement NotifyError.
39a819538 CvSourceImpl: Add stub for CreateProperty(callback).
e75e9092a Fixes athena runtime zip not being built at the correct times (#306)
247cef5ec Removes CANJaguar from wpilib (#300)
43331419f MJPEGServer: Output boundary at start of image instead of end.
c66a55d81 Implement CvSink.
9a44a3814 Fix source and sink refcounting.
5f69cb2a5 SinkImpl: Refactor GetDescription, add GetError, SetEnabled.
a5f63c3ae SourceImpl::GetNextFrame(): Avoid spurious wakeups.
005396218 SourceImpl: add PutError().
c462d0b24 CvSourceImpl.h: Remove unnecessary include.
29f999e2b Adds new handle structure and type for vendors (#297)
778edaeb2 Reverse the JNI load order to look for system library first. (#145)
273a395a2 Client: when reconnecting, default to NT3. (#143)
5e3755493 Linking and maven publish location rewrite (#298)
aa49ebd47 Links wpiutil on roboRIO dynamically (#141)
c45384b91 Removes the native library from the RoboRIO Jar (#139)
70343c0b3 Fixes missing function for Timer::GetMatchTime() (#299)
88fdbc6d3 Readds wpiutilZip dependency to the build. (#144)
7ca6c5ef3 Remove RemoveSourceProperty.
60e199b0b Fixes format.py on windows (#293)
1071686d8 Replaces C++ IsNewControlData semaphore with atomic bool, and Java code with AtomicBool (#187)
511d55154 Implement most CvSource functionality.
fdebdd520 Added format.py to Travis config (#236)
7ea13f7e0 Refactor properties from USBCameraImpl to SourceImpl.
5ca5583fc Removed unnecessary set of parentheses and ran formatter (#290)
75463a249 Implements threaded notifiers and interrupts in the HAL (#281)
7280d241f Fixes DIO not erroring with too high of DIO number (#288)
963391cf3 Cleanup SolenoidBase, Solenoid, and DoubleSolenoid (#271)
4f4c52d6d Switches JNI to use SafeThread from WPIUtil (#282)
499da6d08 Updated the wpilib version plugin to 1.2. Fixes issues with submodules. (#289)
6754703ad Updated the wpilib version plugin to 1.2.
89b8e5435 Updated the wpilib version plugin to 1.2. Fixes issues with submodules. (#138)
b0ab351f7 Don't check for existence in distributing .debug files. (#137)
39e4d11f8 Remove .pullapprove.yml (#287)
9b6f4ecd0 Don't check for existence in distributing .debug files.
df4a2c07f Checks for system initialization in functions that can be called before creating handle based objects (#285)
c46c49037 Adds wpiUtil to HAL and JNI (#280)
9142cbb82 CvSource: Update interface functions.
1f6b38632 Implement frame timestamps and use wpi::Now() for generation.
f2751db5c Adds NI Libraries symbolic link (#286)
aad1266a9 Distribute shared library .debug files.
06a40680a Change debug strip to be part of link task (as doLast).
cc2cbf810 Exclude opencv MANIFEST.MF files to prevent repeat unzips.
cf9aa9032 Don't overwrite platform-dependent opencv zip files.
d51f6c45e JNI: initialize status to 0.
017ec83ce Add support for OpenCV to Java wrappers.
6641612de Update to use wpi version plugin.
218718a06 Add OpenCV dependency and update OpenCV interfaces.
353041535 Distribute shared library .debug files. (#136)
e4234f519 raw_istream: Add std::istream style in_avail(). (#135)
d81840d6c raw_istream: Add std::istream style in_avail(). (#135)
1d336996b Dispatcher: Minimize amount of time m_flush_mutex is held. (#132)
86c43df8d Fix connection notification races. (#130)
5c1b7ecd1 Change debug strip to be part of link task (as doLast). (#134)
011ac1fa2 Java: Allow any Number type (not just Double) to be passed to putValue(). (#129)
2bff276ad Fixes a missed formatting issue (#283)
e5e1a1a4d Moved version generation to the WPILib versioning plugin. (#277)
b8e5258cf Creates the build dir if it doesn't exist, and deletes the version files during clean' (#131)
56179088b Updated the gradle build to get the version from the WPILibVersioning plugin (#123)
780e9580b Ignores KeepAlive messages during initial handshakes (#128)
0613f1d18 Cleanup encoder class (#272)
8b94e0933 Update README (#261)
23ef57561 Cleanup PowerDistributionPanel (#275)
33b95816e Cleanup SensorBase class (#273)
4c1e4fd80 Updates image to v6 (#278)
b775b01e0 Optimizes NetworkTables string concatenation (#125)
0a8e0e974 MJPEGServer: Pass resolution and FPS requests to source.
89805a44c Fix NetworkTable::setFlag typo (#124)
9caa0af4d USBCamera, HTTPCamera: Name functions consistent with classes.
70531762b usbstream: Wait for enter rather than infinite loop/sleep.
30f4ecd17 Rename HTTPSink to MJPEGServer.
d56c3f9ad USBCamera: Default to MJPEG and lowest resolution.
73a97c177 USBCamera: Finish implementing mode support.
3784b665d Updated version for beta 1 (#270)
567ea1d58 Remove CAN TalonSRX from WPILib (moving to external library) (#268)
55346e28d DoubleSolenoid free reverse port handle instead of channel (#274)
8ec2b1d96 README: Fix artifact names.
c858e0391 README: Remove reference to cmake.
63c9af457 Add license.
473a87a76 USBCameraImpl.cpp: Clean up formatting a bit.
4c6f6536b tests.gradle: Link to wpiutil.
cb4d8a655 Add examples.
417545d52 Finish most of USBCameraImpl.
7f88bd15d SinkImpl: Keep enabled count rather than just boolean.
49b8c4ba7 Fixes the gradle dependencies for building (#269)
f1c2b6656 Reverts the 2017 Image for Beta 1 (#264)
27bf94fd0 Remove kDefaultPeriod from IterativeRobot (#232)
4896a77c8 Fixes guarantees for waitForData (#252)
d1d3f049f Solve scp file not found (#263)
7b3f6eeae Add raw_fd_istream. (#121)
f6df7cad9 Add raw_fd_istream. (#121)
15cb50516 TCPStream: Avoid SIGPIPE signals.
cc1b94afd TCPStream: Avoid SIGPIPE signals.
c313dde03 Updated the rpath to point to the correct location for the Java integration tests. (#262)
8d1c51b7e Update image 2017 v5 (#254)
a59e00e90 Adds a test to make sure WaitForData is properly waiting (#258)
7070162b9 Fixed lint errors (#259)
9859c14ca Fixes status parameter in wrong location for initialization range functions (#260)
a7eca7d4b Adds ConnectionInfo to Rpc callback (#116)
64ebe7f5e Updates SmartDashboard with new NetworkTables3 functions (#162)
8b2345a70 Removes an unnecessary function from HAL Power (#237)
e65f9908d Makes IterativeRobot not double check for new control data (#253)
fd52912d7 Fixed return value propagation of format.py (#251)
9e7993905 Remove slack integration (#257)
9047c98e6 Fixes possible indefinite timeout on multiple RPC calls (#120)
a65620722 Forces exceptions to throw on HAL handle creation functions (#209)
53d078966 Storage: Escape equal sign in strings. (#119)
ee24a6f4f Disable support for non-MJPEG formats.
70616c48e Add support for enumerating and changing USB camera video mode.
81e63ea3a Fix simulation build with latest ntcore/wpiutil. (#250)
d4bbd5cc6 Make raw_socket_istream constructor explicit.
1affae956 Make raw_socket_istream constructor explicit.
7463e0208 Logger: Use raw_ostream and SmallString.
d3ed26f7c Logger: Use raw_ostream and SmallString.
f711ced4c Add raw_socket_ostream.
1ec89fc4f Add raw_socket_ostream.
a92b7298f Add 1-character read to raw_istream.
de07b01a7 Add 1-character read to raw_istream.
4c6c096c5 Change API of raw_istream to be more similar to raw_ostream.
c2ae897b0 Change API of raw_istream to be more similar to raw_ostream.
b2e129197 Refactor JNI helpers into wpiutil (support/jni_util.h). (#105)
94c2b6579 Refactor JNI helpers into wpiutil (support/jni_util.h). (#105)
760d6a26d Make SafeThread header-only. (#117)
3a419768c Make SafeThread header-only. (#117)
d8ee44349 Update to latest LLVM code (#88)
ee4244850 Update to latest LLVM code (#88)
d90cf843e Move common utility classes to wpiutil library. (#79)
f6b700ea9 Move common utility classes to wpiutil library. (#79)
5dfae8d6b Fixed include order (#245)
107a4cc1e Add wpiutil dependency. (#190)
35d51d68f Made a comment use more professional language (#249)
049fec470 Fixed compilation with GCC 6 (#248)
659dbef75 Ran format.py after writing unit tests for and fixing bugs in it (#239)
a5fe605aa HTTPSink: Add basic property setting support.
7818c3bda USBCamera: Normalize property names.
d5e5755ff Collapse boolean/double/enum properties into just integer.
8fbc23b1f HTTPSinkImpl fixes.
ac9b6f7b1 Implemented CircularBuffer resizing (#224)
425ed464e Removed leading underscores from variable names (#246)
2c15bb247 Remove delay from periodic methods. (#243)
28e178b1a Update Compressor documentation (#244)
d05f0820b HTTPSinkImpl: Report property step and default.
dad44cc92 Add status parameter to property functions.
2c80587d1 Start implementing USBCamera.
80eb05643 Fix property handles (and allocate more bits to the property index).
80e546b79 Adds a way to externally test C structures (#115)
6eba04ed8 Use copy-and-swap idiom for reference-counted classes.
c606671d2 Consistently name property max/min functions and add step/default.
9bb37d5df Remove support for multiple channels.
5d2a08443 Fix Typos. Fixes artf4853 (#242)
e952236e1 Reverts the last 2 Rpc changes (#114)
9a3100b22 Fully asigns the ConnectionInfo struct (#113)
7e9754acf Passes the ConnectionInfo of the Rpc client on server callback (#112)
087eeec76 C standard library functions and types are now prefixed with std:: (#227)
dbe03afb9 Fixes error in driver station control word cache (#222)
2ecb939b3 Add a method to detect the HAL runtime version (#228)
1416fb8f6 Update Periodic JavaDoc (#231)
aeb6c4889 Added license template file (#225)
c2fc6711d Switches enums to use a fixed size for their base (#230)
f271185cb Adds a RobotPeriodic method to IterativeRobot (#226)
b78592d62 Log.h: Remove unnecessary includes.
052f746c6 Use StringRef and ArrayRef return values when buf passed.
c4ceec145 Enable unit tests.
775386d8b HTTPSinkImpl: Implement GetDescription.
451c08ef7 Add wpiutil library dependency to builds.
52c8743b3 Finish rename of EnumerateSinks to EnumerateSinkHandles.
5c59b9aeb Make HTTPCamera constructor public.
3e00dabd1 Import gmock.
4fc7daedc Fixes incorrect deadband value being passed over PWM (#223)
c5c069743 Switches AppVeyor to use same build for 32 and 64 bit java tests (#107)
ba241cd7f Source: Keep track of how many sinks are connected and enabled.
ddb97bfaf Fix SendStream error handling.
e415ca66b Initial HTTPSink implementation. Untested.
85be299da Start implementation.
9dd5bea7a Create a common CS_Handle. Add initial status values.
e71abedef Add logging implementation.
3888d7726 Adds connection listeners that can be called statically (#111)
6bfc00867 Replaced snake case variable names with mixed case (#221)
2c94d0ba2 Cleaned up integer type usage in the HAL (#192)
0cd05d1a4 Cleaned up integer type usage in wpilibc (#92)
ff93050b3 Remove static_assert for sizeof(uint32_t) <= sizeof(void*) (#220)
05626cfaf Fixed cpplint.py warnings (#215)
59ec54887 Switches notifier to use a typedef for the callback, and prepends HAL_ to InterruptHandlerFunction (#216)
028efff50 Ran format.py (#217)
fc48944b4 Fixes Rpc Cancel. Check was only in timeout case instead of global (#110)
2499771cf Added extensions to .styleguide (#214)
c989ae808 Updated gradle to 3.0 (#208)
2150f5879 Adds AppVeyor support for VS 2013 and 2015 (#106)
85156d15c Fixes the final issue with VS 2013 builds (#109)
6943d14f9 Java: Use wpiutil jni-util.h helpers.
ade4e87d6 Fixes support for MSVC 2013 (#104)
8007a7b15 Correctly handle UTF8 Java translation for StringArray. (#103)
e8643600f Implement all current JNI native functions.
cb7f1f6e3 Initial .def file real content.
af7132be8 Initial CameraServerJNI.cpp commit.
ec080118f Clean up odd special case of GetSourceProperty().
6bcc0e2d8 Correctly prefix CS_EnumerateSourceProperties.
2fd81a7e3 Add copyright notices to Java files.
2f99f81aa Java: Add VideoProperty implementation.
97f1f1c9c CameraServerJNI: Fix case of a few functions.
0fbb2e8a1 Add methods to get property name and enumerate properties.
0158fd35f Continue implementing C wrappers.
80b15b7fe Add a bit of description about how handles work in the C API.
2acca6eeb cameraserver_cpp.h: Move stdint.h above the C++ includes.
151c89fb5 Rename FrameGrab to GrabFrame.
4f22ac410 Move all non-trivial inline functions to cameraserver_oo.inl.
7c1da2dfc Split classes in cameraserver_cpp.h out to cameraserver_oo.h.
b5d32ec84 VideoSource, VideoSink: Move the status flag too.
aec16a934 Revamp API again and start implementing C and Java wrapper shells.
93b486b6b Replaced C-style casts found by GCC in HAL, wpilibc, and JNI (#211)
075155b43 More gradle 3.0 additions (#102)
c25c62e0a Update gradle to 3.0.
2ec6132fc Switches compiler from -O0 to -Og (#197)
8aba2b285 Adds .vscode to styleguide ignore files (#210)
32c95fa0d Moved style guide documents and scripts to wpilibsuite/styleguide (#207)
e653a228f Updates gradle to 3.0. Now that the check bug is fixed, removes the empty check tasks. (#101)
b2831347b Revamp API.
7845caa10 Fixes GetRpcResult not removing calluid from call list on non blocking call (#100)
66d214c8a Finishes blocking call canceling (#99)
277cf2a08 Removes new line from mdns name (#98)
7bf44e951 Fixes server side polled rpcs (#96)
c0ce4270f Adds a way to cancel a blocking rpc call (#94)
d6e8de21e Fixes rpc timeouts and blocking call list error (#95)
1635cba82 Reduced minimum update rate from 100 ms to 10 ms. (#89)
a78647062 Only allows 1 blocking call per Rpc Call Id (#93)
4164e670d Adds Visual Studio Code files to gitignore (#92)
062470ef6 Add llvm::SmallSet. (#90)
0b80bd2b0 Adds timeout capabilities to blocking Rpc Calls (#86)
40365faed Adds a static mutex to notifiers to stop destructor race condition (#204)
e1515299c Initial commit.
776cb915b Revert "PIDController queue now stores inputs instead of errors (#138)" (#205)
5e9fe2f5c Adds an ignore for Visual Studio Code files (#203)
7501ae65a PIDController queue now stores inputs instead of errors (#138)
63469c00c run-tests-on-robot.sh: Save coredump on crash. (#201)
3df257cdb Set duplicate strategy for all jars and zips to prevent duplicates from occurring (#191)
45b8e9ab4 Renamed "pin" to "channel" and variables with underscores now use mixed case (#194)
227fdc1a6 Updated C++ style guide (#196)
d347cebf6 Cleaned up odd formatting from static_cast by using "u" integer literal (#200)
3819cd076 Updated cpplint.py and fixed its regexes for C-style casts (#193)
e8f1fdda4 format.py now emits warnings for modified generated files (#195)
fd4719cb8 Fixed Doxygen comments for LinearDigitalFilter (#198)
bc99d341f Changes remote_name to remote_ip (#87)
6ef4745d8 Added Joystick::GetAxisType() (#98)
0f9f7309e Sets the duplicate strategy to exclude in all zip tasks (#85)
e6244289f Create dummy wpiutil library. (#84)
30fbfe46e Create dummy wpiutil library. (#84)
a73166a66 Make many more utility classes/headers public. (#76)
62a980d3c Fixes Relay Constant Test (#189)
866046edd Some general cleanups in the HAL (#188)
8ac7e44f1 Updates gradle to 2.14.1 (#186)
d66f65e37 Updates gradle to 2.14.1 (#83)
a831978cc Uses the fixed SensorBase functionality in the WPILib (#185)
8da577b56 Moves FRCDriverStation to athena folder (#184)
512ecf649 Makes SensorBase checks use HAL check methods (#182)
0901ae080 Switches the HAL structs to use unique_ptr (#183)
1ca291f20 Fixes a missed HAL_Bool change from int32 (#181)
75eabfee1 Moves DriverStation HAL code to its own header and definition (#179)
f7c3f13a7 Improve CircularBuffer documentation (#180)
57efd13f7 Replaced PIDController::Initialize() with delegating constructors (#178)
7ddc15362 Fixes analog gyro casting to float then returning double (#177)
f9ebd3bde Fixed PIDController::GetError() for continuous inputs (#169)
2c911b0f7 Adds a maximum time based cache to HALControlWord data (#158)
1bf2d58db Reordered DriverStation functions in wpilibc and wpilibj to match wpilibc header (#166)
c93b5bedf Miscellaneous cleanups for wpilibc PID controller (#175)
dffaa0abb Moves HAL cpp headers from root to HAL directory (#174)
20c6525b1 Cleaned up wpilibj enums (#167)
fe7165a8f Removed double-add of shared classpath. Fixes #157. (#164)
d2aa168f6 Implements Better Error Messages from the HAL (#172)
05c00430b Fixes CPP lint errors added to HAL. (#173)
530508716 Fixes a missed float to double change in the HAL. (#176)
b979fc2a6 Adds SetDefault Java definitions to Def file (#82)
58092c519 Adds SetDefault methods to NetworkTables (#54)
6615a34e9 Added contributing and license files (#63)
50a261283 Notifier: maintain freelist to reuse uids. (#81)
6251697f6 Added Lint task and parallelized format.py (#161)
ea1a1e6bc Makes the CANJaguar error status messages more useful (#165)
edf5ecd4a Changes HAL Headers to be C compliant. (#171)
1b1ee7f9f Renamed spiGetSemaphore() to spiGetMutex() (#170)
3fade171f Fixed inconsistencies in documentation (#168)
c99e89dfc Fixed the remaining cpplint.py warnings (#160)
b51e85ae2 Switches HAL to fixed length signed integers, and adds our own HAL_Bool Type (#155)
4a98e6881 Moves the DS new data wait calls down to the HAL. (#156)
0cb288ffb Fixes warnings thrown by cpplint.py (#154)
e44a6e227 Refactored wpilibj HAL JNI to simplify generating it from HAL headers (#109)
aafca4ed7 Reduced duplication between formatting scripts with Task base class (#80)
ea6876e81 Some general HAL cleanups (#153)
aa9c2b2c9 Made Log.h use std::chrono (#136)
43a2eccdc Finishes Prefix Renames (#152)
b637b9ee4 Prepends all HAL functions with HAL_ (#146)
5ad28d58e Switches PWMs to do scaling at the HAL level. (#143)
be2647d44 Switches Java to use HAL Constants (#145)
4a3e3a632 Changes DigitalSource API for HAL ease of use (#144)
7597e3c27 Switches handle resources to dynamic arrays (#142)
0a983eeeb Moves Gyros to the HAL (#131)
b036bf2e3 Add method to get the port number of a Joystick (#137)
73602e6cb Added missing include for robot startup macro (#135)
72455280a Removes unneeded resource includes from WPILibC files (#134)
ea95bb85a Adds Constants from new constants class to encoders (#133)
fb865d3ee Adds a special exception and status message for a handle error (#127)
36ac37db8 Moves Encoders to Handles and Moves WPILib Encoders to HAL (#124)
b45e0917a Adds port constants to the HAL (#130)
0e127679c Removes some unused variables from DigitalInternal (#128)
2f36d508c Gradle 2.14 (#118)
cf29d4560 Moves HAL PCM objects to header and HAL namespace (#129)
8c4ad6242 Switches Solenoids to Handles (#126)
62c217cd0 Switches compressor to handles (#125)
0f105a26f Switches Counters to Handles (#123)
eb4350033 Update Travis OS X build to use newest image. (#75)
47694ef81 Switches DigitalPWM to Handles (#121)
f77a976fb Switches resource errors to AllocationExceptions in JNI (#122)
3593ecb17 Switches PWM and DIO to Handles (#120)
384ad57d2 Updates Gradle to 2.14 (#78)
9b2af0d09 Switches relays to handles (#119)
e8e052712 Switches AnalogInputs and AnalogTriggers to Handles (#117)
77a1af44c Removes freePort from the HAL (#116)
5e2a76147 Moves handle definitions to main handle header (#115)
e1d4845cc Move Analog Outputs to Handles (#112)
95d40ed01 Fixed issue with digital outputs used as pwm on mxp (#14)
aa22d4c33 Clarified that PID controller runs in discrete time (#107)
046e043c4 Moves Interrupts over to Handles instead of pointers (#99)
74fc10999 Fixes preferences formatting (#108)
cee9b2609 Added std:: prefix to more C standard library uses (#106)
daa0260a4 Deduplicated UsageReporting definitions (#104)
d66c61a36 Cleaned up robot startup and cleanup/shutdown code (#77)
ecc210f99 Rename Notifier::m_handlerMutex to Notifier::m_notifyMutex (#105)
3cacc2aba Switches indexed handles to shared_ptr (#101)
085c47b67 Unbreak wpilibc WritePreferencesToFile test. (#103)
4b516de18 Don't delete persistent entries in DeleteAllEntries. (#71)
c7d9ecbab Fix mac build by not defining false and true. (#73)
039515082 Fixes formatting in error.cpp (#102)
c3908660b Switches all HAL Handle errors to be zero (#100)
b2795af2b Added note that multilib GCC is required when building the native version on 64 bit Linux (#66)
6c6c087e3 Fixes .gitignore ignoring needed files (#68)
3c77faaf6 Fix UTF8 conversion in Java. (#70)
fc515f457 Changes HAL Port from a pointer to a handle (#93)
5a82f73d9 Replaced .h C headers with c-prefixed version and added std:: prefix to C standard library usage (#90)
776a991d6 Moves Notifier over to handles (#97)
8527f2c2a Fixes HandleResource classes (#95)
c85b72b95 Fixes a few bugs in the initial handle implementation (#94)
f0d9e19b5 ErrorBase: change to ostringstream. (#66)
c7c011813 Made include ordering/organization more explicit in style guide (#86)
d76f0d402 Adds support for Handles to the HAL (#91)
de7678f2f remove author requirement for now (#84)
2f7eff709 Removed @author from comments (#88)
7a402b417 Replaced "RoboRIO" with "roboRIO" in comments (#87)
10b4814e6 VisionAPI.cpp: Remove non-UTF8 characters. (#85)
613309c0a Replaced wpilibj class Init() methods with delegating constructors (#79)
c622c03ef Places while loop around DS wait condition. (#83)
ed7d2d6aa Splits the HAL Analog Implementation Files (#82)
51ff9e9f6 Classes which use I2C or SPI now do so via composition rather than inheritance (#72)
9f2f301fa Deduplicated FRC network communication headers (#71)
fa8bb3fa9 Remove obsolete timer functions and replace with std::chrono (#64)
4af0bbdde Add Travis Badge to ReadMe (#81)
4aca3c202 Removed extraneous curly braces around std::lock_guards in PIDController class (#78)
753ab85ef Removed commented out includes and imports (#76)
da6b8c7ae Split HAL Digital Implementation files (#59)
305ab08f1 Renamed DriverStation::IsSysBrownedOut() to DriverStation::IsBrownedOut() to match the Java version. This changes the external API. (#67)
e9718fc7b Replaced NULL with nullptr in C++ source files (#70)
8566878af Fixed C++ simulation build with Boost 1.60 (#49)
62812faf6 Clean up include guards and EOF newlines (#65)
d82635bbe Reordered headers according to the style guide (#58)
a598e2d09 format.py: add missing 'sys' import (#69)
b5b2f0c7d Fixed typo in LinearDigitalFilter documentation (#62)
e6f6d2478 Removed empty default constructors and destructors from Gazebo plugins (#63)
21b2aabf1 Removed unused DS_LOG() macro (#61)
74f9da9da artf2612: Added Python script for updating license in source files (#57)
e63830ed2 format.py: Fix running from styleguide directory on Windows. (#55)
eb51de65e format.py: Error out if no files found to format. (#56)
565a125da Reformat for recent commits (#54)
3af8e7e9f ControllerPower.cpp: Use quoted include instead of bracket for HAL. (#53)
e3eae023d Cleanup of gazebo plugins (#46)
6d9b3b0aa Splits HAL Digital and Analog Headers into multiple headers (#52)
9e99df1cf Removed sync group from SpeedController interface (#51)
e842ff7ad Explicitly stop the PIDController Notifier in the destructor (#48)
21b1e39b2 HAL Notifier: Use freelist to avoid use-after-free race. (#50)
8fc55c80a Renames all our .hpp HAL files to .h (#44)
248ca0c4a Added verbose flag to format.py (#47)
0d655d7ce Ran formatter again (#45)
e71f454b9 Renamed folders for consistency, using sim/athena/shared schema (#27)
54092378e Changes HAL to return -1 to 1 for joysticks (#35)
a4f0c4fbe Implements locking in C++ DriverStation, and adds double buffering to DS Thread (#25)
0965d60a7 Fixed a bug where using the two parameter constructor for CANTalon could cause invert-direction to not be initialized. (#26)
f2d601d83 Use interrupt() in our interrupt exceptions (#24)
e14e45da7 Add format script which invokes clang-format on the C++ source code (#41)
68690643d Fix travis configuration to include compiling sim (#28)
00b290210 Converts non hardware dependent tests to unit tests (#10)
975568c77 Adds Error Prone as compile time check to java projects (#13)
a834fff7b Applies Google Styleguide to Java parts of the library (#23)
64ab6e51f Create .pullapprove.yml (#42)
05a208981 Fixed PCM tests by raising tolerance slightly (#15)
6272244a7 Adds error-prone to check java code
a53251805 Adds all relevent tools to gitignore
320db8df1 Add .clang-format.
b827f484b Add Slack Notification from Travis (#11)
000a98f19 Fix apt-get update -q causing build to fail (#20)
bb64dd354 Updated README, and added in CONTRIBUTING. This adds tables of contents, as well as fixing a few other issues.
d1fb8cc20 Merge pull request #60 from wpilibsuite/build/appveyor
7d33059c2 Add appveyor badge to readme
d0c40b5ce Fixes indentation in .travis.yml
6794ff9ce Add Travis Build Configuration
ed0f197d1 Adds appveyor build config
25ad7a623 Merge pull request #59 from wpilibsuite/build/osxTravisBuild
5fb31baea Adds OSX Build to travis
ffb384ebf Add Travis Badge to ReadMe
95098c549 Add required apt packages to travis
386266842 Add Travis config file
083362bd8 Removed {@inheritDoc} from C++ sources and readded .inc files to Doxygen extension mapping
0f228e7b7 Implements a common PWMSpeedController base class
686f5d9fe Fix incorrect comments in the HAL I2C functions and incorrect return values for some I2C class member functions.
ad8763fc8 Removed unused pcre.h header. If regexes are needed in the future, use C++11's regex header.
1011b56b4 Fixes notifier restart error when last notifier is deleted
5904314a7 Improve ADXRS450 error detection.
e85254734 Makes Java Timer timing more accurate
fa8b68419 Make Java AnalogGyro.getAngle() thread-safe.
ec13d00b1 Fixed gradle build issue where files were not getting added to the wpilib java jar correctly.
36447d86d Merge "Clear error buffer total when clearing the buffer contents"
5ac68f74d Support client round robin to multiple server addresses.
b8ad1de33 Make members of ConnectionInfo and EntryInfo public.
1e14403b3 Update POV documentation with examples of POV angles
bee507eda Clear error buffer total when clearing the buffer contents
16343bbe7 Updated release to version 5.
623a5fcf8 Fix C++ CameraServer request handling.
6bd1654b8 Updated release number for the new release
952ebb11a This adds StopMotor() to the SpeedController interface for C++ and Java. For Java, this is as simple as just adding it, as all motors already have an implementation from MotorSafety that is correctly resolved. For C++, I had to override StopMotor in the classes that descend from SafePWM and explicitly call the SafePWM version. RobotDrive now calls StopMotor on each of its SpeedControllers, instead of calling Disable or setting the motor to 0.0 as it was doing previously.
91c5db06d Merge "More updates to the Gyro test fixing potential null pointer exception"
df33a7822 Added Config routine to allow enabling/disabling of limit switch and soft limits. This improves upon the ConfigLimitMode routine, which does not allow certain combinations of enable/disabled limit features. Also keeps parity with LV and Java.
a33076ab9 Merge "Add an additional member variable for "stopped" which indicates the CAN motor controller has been explicitly stopped, but not disabled by the user (main use case is MotorSafety tripping). When Set() is called the next time the controller will be re-enabled automatically."
f80312b86 Merge pull request #52 from robotdotnet/master
836dc7a88 Fixes Connection Listeners
d567bd0bc Add an additional member variable for "stopped" which indicates the CAN motor controller has been explicitly stopped, but not disabled by the user (main use case is MotorSafety tripping). When Set() is called the next time the controller will be re-enabled automatically.
f436b33d7 More updates to the Gyro test fixing potential null pointer exception
728329388 Merge pull request #51 from robotdotnet/RemoteChanges
3c3b2c75c Rate-limit duplicate error messages to avoid flooding console.
710bd586d Adds extended Remote Connection Listener
f17d27aac Merge "artf4818: Fix CAN Talon JNI references with underscores."
94629bcb7 Merge "Updated PDP port of Talon and disabled PDP tests for Victor and Jaguar since the Victor and Jaguar don't draw enough current for the PDP to read above 0. PDP tests for both java and cpp only test the Talon now."
4a6f55b61 Fixed the gyro deviation over time test
fdfedd12f artf4818: Fix CAN Talon JNI references with underscores.
ae1171d1b Merge "Fixed the motor tests by reducing speed to within the limits of the encoders we use. Also fixed java pid tolerances since getAvgError() was broken. It is now fixed and works properly. Added tests for both java and cpp that test if pid tolerances are working using fake input output pairs."
6b356020f Updated PDP port of Talon and disabled PDP tests for Victor and Jaguar since the Victor and Jaguar don't draw enough current for the PDP to read above 0. PDP tests for both java and cpp only test the Talon now.
7041cbc5e Fixed the motor tests by reducing speed to within the limits of the encoders we use. Also fixed java pid tolerances since getAvgError() was broken. It is now fixed and works properly. Added tests for both java and cpp that test if pid tolerances are working using fake input output pairs.
f24c8b1b8 Fixed robot drive for C++ Simulation
d62256156 Merge "Update version number for Release 3 Print distinctive message on robot program startup Change-Id: Ic91b81bd298ee6730503933cf0e733702e4b4405"
61dbd4366 Update version number for Release 3 Print distinctive message on robot program startup Change-Id: Ic91b81bd298ee6730503933cf0e733702e4b4405
f913b5de8 Merge "Removed publishing of java sim jar"
bd3e068f3 PDP Classes should support any PDP address
cb4cc6322 Merge "Added -pthread"
838d8abf6 Added -pthread
94bd629b8 Merge pull request #48 from ThadHouse/master
c6ff69079 Merge "Remove maven local as a possible search location"
5d3ac3ea7 Another improvement to HAL-joy getting to ensure it works in future RIO image updates.
f9e87f0cc Removed publishing of java sim jar
73d6e98bf Loads ntcore from path if extracted load fails
880156832 DriverStation::GetJoystickName(): Make work for stick>0.
75a91e24e Remove maven local as a possible search location
6adf4c48c Merge "Fix HALGetJoystickDescriptor()."
026c427a2 Merge "Fixed Simulation C++ API"
63878d8ab Fixed Simulation C++ API
83f902f2f Fix HALGetJoystickDescriptor().
c90a8c586 getTable(): Don't prepend slash if key already starts with it.
f79ed1ab4 Artf4800: Fixes HALGetJoystick*** Segfault
bf89762e8 Merge "fix sim_ds launch script"
bd1e09162 Merge "Added build dir specification for sim javadoc to not overwrite athena javadoc"
2662a7ab0 Initialized the m_sensors variable to fix artf4798.
713d54fd2 Added build dir specification for sim javadoc to not overwrite athena javadoc
75a07fc3e fix sim_ds launch script
6b740e87b Fix C++ PIDController SetToleranceBuffer and OnTarget locking.
ac27f4b64 Merge "Fix onTarget() so that it returns false until there are any values retrieved"
99b6000a6 Fix onTarget() so that it returns false until there are any values retrieved
628811ed0 Correctly set smart dashboard type for AnalogGyro and ADXRS450_Gyro.
c57e749a9 Merge "Fixed sim_ds script library path"
3350926d2 Merge "PIDController feed forward term can now be calculated by the end user"
4dec393c2 Fixed sim_ds script library path
0e9f07d1c Merge "Fixing install script... again"
5765b1397 Use absolute path for NT persistent storage.
2d4304880 Fixing install script... again
e3ce991f1 PIDController feed forward term can now be calculated by the end user
3cd125397 artf2612: Update license in source files.
008fb2e38 Merge "Removed gz_msgs from wpilibcSim"
887f220fe Ultrasonic: replace linked list with std::set.
dd1977815 Removed gz_msgs from wpilibcSim
7a2be548a Merge "Replaced linked list in Notifier with std::list"
5f9300966 Merge "Renamed Gyro to AnalogGyro to match athena API"
d77f5c801 Replaced linked list in Notifier with std::list
6faa51ff4 Renamed Gyro to AnalogGyro to match athena API
9092b74f4 TCPAcceptor: Check for socket creation failure.
b3d28c7e3 Merge pull request #46 from 333fred/master
ed9238546 Merge pull request #44 from ThadHouse/master
1247976a3 Fixes Android Build issues
880bc7db9 Adds a compilerPrefix argument for using a compiler with a different toolchain. Resolves github #45.
ce2245110 Merge "Adds CANTalon to LiveWindow"
dfba97a54 Merge "Fixing the frcsim installer script"
20f23e0e3 TCPConnector: Don't leak socket descriptors.
99b2b6514 Adds CANTalon to LiveWindow
5976baec0 Merge "Fixes CAN devices in C++ library not showing in the livewindow"
932ec8e30 Merge "HAL: Use extern "C" in implementation files."
1c6fe85a7 Fixes CAN devices in C++ library not showing in the livewindow
d9efcbc7a C++ NetworkTable: Add array and raw getters and setters.
e15ca5a41 Added linear digital filters
5e2a07d58 Fix client connection to 2.0 server.
70bc630f1 Fixing the frcsim installer script
6c89f34e4 Merge "Default bufLength for PIDController in Java should be 1"
d542fe429 Merge "Adds WaitResult to Java waitForInterrupt"
351e8599a HAL: Use extern "C" in implementation files.
620836e1c Update .gitignore.
31a39b4e5 Default bufLength for PIDController in Java should be 1
e2ec34090 Keep track of FPGA time rollovers with 64-bit time.
063925e73 Merge "Change C++ Notifier to allow std::function callback."
de4708cbd Merge "Rewrite C++ Notifier to use HAL multi-notifier support."
8bbc1d43b Merge "Rewrite Java Notifier and update Interrupt JNI."
c01146eb0 Merge "Readded styleguide accidentally removed in the reorg"
3e71573c5 Merge "Artf4179: Allow alternate I2C addresses for ADXL345_I2C"
5bc6e1378 Readded styleguide accidentally removed in the reorg
af2f54720 Java: Don't detach thread when releasing globals.
5cee85f92 Fixed some typos in the comments of MotorEncoderFixture.java, a method name in CANMotorEncoderFixture.java, and the README files
951c81f5b Adds WaitResult to Java waitForInterrupt
75d1891a5 Artf4177: Use read byte count for ReadString
376fc6be6 Artf4179: Allow alternate I2C addresses for ADXL345_I2C
91a451f87 Change C++ Notifier to allow std::function callback.
b0de0b738 Rewrite C++ Notifier to use HAL multi-notifier support.
5dc5ed83b Rewrite Java Notifier and update Interrupt JNI.
fe01096e7 Merge "finishing up FRCSim installer"
236ef199a Merge pull request #41 from 333fred/master
acc7fbbf0 finishing up FRCSim installer
1ea5b21dc Added skipArm flag to disable the arm build entirely
e6054f543 ntcore_c.h: Whitespace fixes.
416a238be Merge "Artf4776 Fixes First DIO PWM usage errors"
2aaaed34f Unbreak build on VS2012.
3d2b54a1c Merge "Artf4774 Fixes HAL getHALErrorMessage missing error"
ae99eb676 Merge "Prevent double free in DigitalGlitchFilter"
e2fb1c6d4 Merge "Set correct error message"
4881795a9 Prevent double free in DigitalGlitchFilter
fef8f933d Add SafeThread to fix thread JNI shutdown races.
17b363f3b working on install process for FRCSim 2016
85c3e6a4f Merge "This commit adds documentation generation, including grabbing ntcore sources, for both Java and C++. This will need changes made in the wpilib promotion tasks to copy the generatd documentation to the correct places."
2c04cf135 Improved READMEs
dbba4a103 Artf4776 Fixes First DIO PWM usage errors
083c90d37 Added libnipalu to make vision programs link properly
729545809 This commit adds documentation generation, including grabbing ntcore sources, for both Java and C++. This will need changes made in the wpilib promotion tasks to copy the generatd documentation to the correct places.
d8de5e4f1 Added ntcore sources zip to the main build
842aba97b Set correct error message
554543c5d Merge "Fixes the sources zip to actually include all sources."
d3f440003 Artf4774 Fixes HAL getHALErrorMessage missing error
20749ed6e Condition java sim build on -PmakeSim flag
44821c3e3 Change how Dispatcher is shut down.
8cc066ecc Fixes the sources zip to actually include all sources.
2540f102b Include sys/select.h on Unix platforms.
684da8d89 Merge "Add SPARK and SD540 motor controllers"
8b3f4aa68 Remove unused member variable.
0537f9d0d Fix mac.gradle.
4b0980fb8 Fixed jar task dependencies. The stripped version of the binary is now added to the jar, not the full debug version of the binary
65e4eeeb7 Fix Windows linkage.
298dc5491 Fix Windows build.
fb486e381 Merge "Added a withoutTests gradle flag for CMAKE feature parity"
32001427d Java: call JNI AttachCurrentThread less frequently.
13496c75b Fixed double free of DriverStation.
2a43813d1 Added a withoutTests gradle flag for CMAKE feature parity
b4c058389 ContainsKey: Compare to nullptr.
88b985be5 Allow building of tests to be disabled in cmake.
d69803804 Repaired simulation build on linux
7528b6b8b Fix NetworkTable::ContainsKey.
0d062fba3 Add Cmake wrappers and unzip desktop ntcore builds
fa903dd9c Add SPARK and SD540 motor controllers
931693345 Merge changes I55ce71c6,I803680c1
31e1041ba Merge "Remove broken and unused HALLibrary.java."
1b03f818a Rewrite CANTalon JNI layer.
cd5765559 Last feature addition for CANTalon java/C++ user-facing API.
4b0407338 Remove broken and unused HALLibrary.java.
0a06fdb52 Clean up FRCNetworkCommunicationsLibrary JNI.
c2ecffe70 Update to latest UsageReporting.h.
ec69c6a86 Fix Solenoid Resource object creation. Fixes artf4758.
bc0c89561 Take 2 on usage reporting.
9e1833058 Report usage for ADXL362 and ADRXS450.
e25d9fc96 Use correct condition variable in DispatchThreadMain().
82d89d3b7 Updated to NI image v18
7ba89306c Merge "Make C++ Analog Potentiometer test work."
c70e710ca Remove raw pointer deprecation warnings.
b1a3ded2f Added desktop classifier publishing for c++ as well
bafe4e56a Notifier: Change back to constructor from ATOMIC_VAR_INIT.
bd2a28f59 Add ADXRS450_Gyro.
6851dee3f Merge "Gyro: Add support for fixed calibration (artf4124)."
de219055f HAL: Add software-based accumulator for SPI devices.
530ce310a Merge "HAL: Add support for multiple Notifiers."
bc6da8eff Add noexcept shim for MSVC.
5d26b1355 NetworkTable: Add override declarations for all functions.
0d7106450 Make TableKeyNotDefinedException::what() const noexcept.
60647a2f8 Turn off Nagle algorithm to decrease latency.
8b0f19a0f Updated Notifier to match changes in gerrit 1171
76ee093e9 Add exception-generating C++ functions, but mark as deprecated.
d0c01ac30 Updates wpilib to use different repos for the different build versions, instead of using classifiers
9e6635ec1 Fixed log compilation on Mac
db91e20ec Updated ntcore build to build both arm and native versions
3cd20d3ff Java: Fix getValue().
6a8fcbc40 Make C++ Analog Potentiometer test work.
5c8214654 comment out halDesktop
f5fe5cfcf JNIWrapper: Fall back to system library if not found in .jar.
10e51f026 Merge "HAL: Increase safety during program termination."
b71cea69c Merge "DigitalInput: Don't crash on Get() of invalid channel."
01b64b5bd Merge "Add support for ADXL362 SPI accelerometer."
e9f98b28c Merge "Reduce overhead of setErrorX() calls."
cd4703065 artf4160 This fixes the java version of the addressOnly() function.
4f535fb77 Merge "Re-enable C++ Pressure Switch Test."
d34ba8866 Re-enable C++ Pressure Switch Test.
b3b03c43c artf4700: Added DigitalGlitchFilter
375a19563 Gyro: Add support for fixed calibration (artf4124).
6d00b77ef Merge "artf4175: Fixes FakeEncoderFixture encoder type error"
93b65aad3 DigitalInput: Don't crash on Get() of invalid channel.
c3c35c604 fix javadoc warnings/errors
03c43a46d HAL: Add support for multiple Notifiers.
07be45af8 HAL: Increase safety during program termination.
c2642f39e Avoid null pointer deref on disconnect.
7182b9a6b Upgrade TCPConnector messages from DEBUG to ERROR / INFO.
ac9e42af3 TCPConnector: Select only IPv4 addresses.
790862db4 Provide default stderr logger for INFO/WARN/ERR levels.
2f8562c23 artf4175: Fixes FakeEncoderFixture encoder type error
bb9988365 Fixed const correctness in casts and unused parameters.
a66eaa434 Reduce overhead of setErrorX() calls.
61760c839 Removed unnecessary ::std::string calls.
055ee0982 Fixed current and potential bugs caught by Coverity
b0fec4089 Merge "Added README, deleted old obsolete building instructions"
906fe65e3 Optimize Solenoid Gets. Fixes artf4730.
84ca2ab0f Merge "Prevent PID tests from hanging."
d998e53f9 Merge "Moved gyro calibration into a separate function so teams can recalibrate at any time after construction"
2f2184e8c Makes HALSetDataSem take a MULTIWAIT_ID rather then a NATIVE_MULTIWAIT_ID
de39877ef artf4153 Adds HAL structure memory management
e3191b0bf Prevent PID tests from hanging.
e162e4d1c Merge "Fix HALGetJoystickAxisType() definition to match header."
5080e5b77 Added README, deleted old obsolete building instructions
f10f8558e Added README for building
9b4dd268b Moved gyro calibration into a separate function so teams can recalibrate at any time after construction
aa95a8c29 Merge "artf4162: Fixes multiple solenoid creations in java"
c935ae2d9 Merge "Adds new CanTalon HAL Functions to C library"
8ad1c07a2 Merge "Remove temporary batch file."
966e4be36 artf4162: Fixes multiple solenoid creations in java
66b28e95a Adds new CanTalon HAL Functions to C library
f36e36424 Fix HALGetJoystickAxisType() definition to match header.
752f5fb4e Merge "Update PCM test to check Solenoid get methods also"
68bb07416 Merge "Arguments to Task are now forwarded to std::thread more correctly"
03ce0a1b9 Remove temporary batch file.
ab90e7aa2 Update PCM test to check Solenoid get methods also
ad64c0b02 Merge "spiSetBitsPerWord doesn't exist; remove from headers."
fec7f3a5e Merge "Make PDP parameters consistent with other HAL functions."
c59e08ee9 Add support for ADXL362 SPI accelerometer.
d59016be3 Arguments to Task are now forwarded to std::thread more correctly
2cd7bc83c Update .gitignore for new tree structure.
964b24361 Make PDP parameters consistent with other HAL functions.
51a35daed spiSetBitsPerWord doesn't exist; remove from headers.
84e793503 std::shared_ptr doesn't need to be initialized with nullptr. The C++ standard already guarantees it will behave as if it is.
26c27756a Updated the definitions file to add overloaded functions, added no-unused-private-field for Mac builds. Gradle also now works with the classifier-based dependency system, rather than having separate repos for every level.
6d854afb0 WPILib Reorganization
c76e60324 Add Java support for raw values.
d98ceb60c Merge pull request #36 from ThadHouse/master
2e050b054 Makes SetTeam use Mdns
c20d34c2b Rename Gyro to AnalogGyro and make Gyro an interface.
e2a455666 Add ByteBuffer interfaces to I2C and SPI.
44ba8823d Merge pull request #34 from JLLeitschuh/feat/functionalTableListener
4c42712b2 Makes ITableListener a lambda function
6a0485a72 Fixed mac lib path
af3facd1c Merge "Notify the Driver Station that code is ready after robotInit is called"
d690974ad Improved error handling in HAL Digital and Solenoid systems.
76756048c Notify the Driver Station that code is ready after robotInit is called
91891081b Merge "Update docs to reflect that PDP can now be at any address."
ff4abd63f Merge "JNI: Don't call HALInitialize() within an assert()."
511c4a4d3 Update docs to reflect that PDP can now be at any address.
967400f18 Merge pull request #32 from ThadHouse/master
a142cc48d Adds StopNotifier and StopRpcServer functions
3469f6733 GetRpcResult: Check m_terminating after wait() returns.
2b6c6f280 Merge pull request #31 from ThadHouse/master
aefeee39a Fixes SetEntryRaw to actually set raw.
27101979f Add extern "C" to ntcore_c implementation.
033520d42 Merge pull request #29 from ThadHouse/master
16e68c348 Fixes parameter type differences for c interface.
94b6073f3 Merge pull request #28 from ThadHouse/master
8fc2eee2b Makes Value::MakeStringArray properly set size
28f55802b Reverted RobotBase debugging changes from Peter.
06372cb14 JNI: Don't call HALInitialize() within an assert().
7023013c4 Simplify JNI interfaces.
927400a43 Added classifiers for networktables to to the pom
2f228380f Updated the ntcore reference and updated the build.gradle file to build with the most recent ntcore commit.
44bd52c44 Update the image version to 15
21124e017 Merge "Revert "Added work around for the missing path on the frc_console_tee command in frcRunRobot""
09962a7c8 Revert "Added work around for the missing path on the frc_console_tee command in frcRunRobot"
969af7b61 Added publishing of an ntcore sources zip
da6611833 Add JNI headers to the exported headers when compiled with JNI
beeefa235 kFramework_Simple was renamed to match the corresponding robot framework's name
26f1bd6a1 Merge "Fixed documentation generation for .inc files"
a34f3f238 Merge "HALUsageReporting::kFramework_Simple was renamed to match the corresponding robot framework's name"
231178c26 HALUsageReporting::kFramework_Simple was renamed to match the corresponding robot framework's name
424efca1b NetworkConnection: bump debug levels a bit.
4d7ea37d5 Fix update message type data.
32a1beb77 WireDecoder: Add commented-out read stream dumping.
d850b2fd7 Gradle build: rebuild on changes to header files in src.
bb52c2441 Merge "Update the library version string for the driver station (artf4708)"
9f5fe63aa Reuse dead connection slots.
03ee425e5 Add additional debug messages.
042e3a323 Update the library version string for the driver station (artf4708)
9200b7c78 Add extern "C" to JNI definitions to catch mismatches.
520d946f6 Fixed documentation generation for .inc files
b793810e4 Fixes for mac builds
9df5f5e27 When running on jenkins, the base name of produced archives becomes the project name. This fixes that to be the correct name.
7fbd0e34d Merge pull request #27 from 333fred/master
77cf3adf6 This commit updates the gradle files to be cleaner. It also builds for the current platform by default, and only builds tests when building for the current platform. Mac builds and VS2015 builds are fixed.
ad3424a69 Fix RobotDrive constructor (4 SpeedControllers).
97a7716a2 Added work around for the missing path on the frc_console_tee command in frcRunRobot
fc0a94af2 Update image version to v14
4da09db20 Revert "Updated the scripts to run as admin and manually start the robot programs. This will be reverted with a new image from NI"
a0cc45a8f Format and style changes. Rebuilt last SRX-related commit with latest checkout.
a3b6535fe Merge "Updated the scripts to run as admin and manually start the robot programs. This will be reverted with a new image from NI"
29299079f Merge "Updated roborio version numbers"
06dea34ff Merge "DO NOT ACCEPT THIS COMMIT UNTIL IMAGE CONTAINS netconsole-host: Don't overwrite system netconsole on deploy"
4972480b2 Updated the scripts to run as admin and manually start the robot programs. This will be reverted with a new image from NI
e73d873df Updated roborio version numbers
4eadd99d2 Merge "Removed simluation eclipse plugin"
1316deaf5 Added LiveWindow support for PID control for CAN speed controllers.
dd0e3e4ab Implement join with timeout (and detach).
d77b3d788 Dispatcher: Remove unused member variable.
64c8f1b48 Reupdated the ntcore version
39c40a9b8 Merge "Revert "Don't overwrite system netconsole on deploy (PENDING NEW IMAGE)""
fbbb8dab7 update the version 12 image number
e44936213 Merge "Revert "Don't overwrite system netconsole on deploy (PENDING NEW IMAGE)""
b4761f8f9 Revert "Don't overwrite system netconsole on deploy (PENDING NEW IMAGE)"
298bc8037 DO NOT ACCEPT THIS COMMIT UNTIL IMAGE CONTAINS netconsole-host: Don't overwrite system netconsole on deploy
bff8eb366 Revert "Don't overwrite system netconsole on deploy (PENDING NEW IMAGE)"
763d81653 Merge "Don't overwrite system netconsole on deploy (PENDING NEW IMAGE)"
4036ddf55 Merge "Fixed miscellaneous typos"
dff6e89b4 Notify local listeners on preferences load.
32af49dbb Fixed miscellaneous typos
c01d057d7 Counter: Explicitly call mode constructor.
490c88a9b Don't overwrite system netconsole on deploy (PENDING NEW IMAGE)
6fc3f1d3d Update netconsole-host binaries (TODO: make part of build)
1309533a4 Updated eclipse plugins to check for the 2016v10 image instead of 2015v23.
57b00d3b3 Fix StorageTest unit test on MSVC 2015.
29e54a989 Adding path back in for OS X toolchains because of Apple lockdown
c384fc97d Fixing up rpath libstdc++ for all versions
9c1ab6987 Merge "Automatically set persistent on new Preferences keys."
d9e9712b0 Merge "Update ntcore to latest version."
e281437c4 Merge "Replaced instances of std::unique_lock with std::lock_guard where possible"
f8c0fb105 Merge "Fix typo in Preferences Test name"
87fc49c66 Automatically set persistent on new Preferences keys.
f93bf82fa Update ntcore to latest version.
c0ecde302 Replaced instances of std::unique_lock with std::lock_guard where possible
c2f5bcc04 Fix typo in Preferences Test name
38e0cd696 Provide compatibility shim for std::make_unique().
898952a2d Merge pull request #26 from Beachbot330/master
202cb8bb1 fix javadoc warnings/errors
f64b05549 Provide DEPRECATED macro as portable version of [[deprecated]].
a480cc65e Removed simluation eclipse plugin
ef3fa53fc Fixed solenoid allocation bug exposed by adding status pointer initialization
049be6870 Always initialize status to 0 when calling HAL from JNI.
c0c91c414 Modified the test scripts to run as admin rather than lvuser until we have the passwd issue resolved
9f859234f Update for latest image, not sure about ctre folder so leaving
89ae8f214 Initialize status in HALInitialize.
4592c90e3 Add protocol specification documentation.
734e9a446 Fix NT_GetEntryInfo implementation signature to match header.
90959defd Provide more extensive listener features.
51064f5e7 Fix client initial flags setting.
3e8afc14b Java NetworkTable: perform string comparion correctly.
3c4b96024 Reverted task dependency changes that do not work
75d9228f3 Fixed networktables build
424bf51a7 Implement local notification.
00f797a32 NetworkTables updates for beta
75358e6c4 This adds a maven publish routine for ntcore to replace the networktables java routine.
e2879b7bf Fix JNI embed location on Windows.
525f88ae1 artf4115: Added MotorSafety to Relays
c21c47f54 artf4000 A fix contributed by James Ward to fix the restriction on the read/write sizes in I2C.
3635299fd Updated Gradle Version
a7feaddd6 Fixed some warnings printed during wpilibC++Sim build
771b5807f Merge "Updated C++ documentation"
c248ce794 Merge "PIDSubsystem.cpp: Use make_shared instead of make_unique."
6db58a2cc PIDSubsystem.cpp: Use make_shared instead of make_unique.
b80d2f665 Merge "Updated gradle version."
4c83259ac C++ NetworkTable: Provide AddSubTableListener().
9c50e9f96 Updated gradle version.
a3effbfb9 Java NetworkTable: Don't use ipAddress when starting server.
90ce262bb C++ NetworkTable: Provide SetPort() method.
23448c827 NetworkTable interface: Provide method to set persistent filename.
d904dfce7 Include the ARM JDK JNI headers.
d9fa086ec Include the ARM JDK JNI headers.
f89c5e150 Use new NetworkTables across WPILib (C++ and Java).
3b91fac19 ntcore.def: Add JNI getEntries function.
f65e69710 Revert changes preventing old user code from compiling.
e42f9b060 Add EntryInfo class (missed in previous commit).
c5d456f3a Add ITable/NetworkTable GetKeys and GetSubTables accessors.
6cbc21942 Add ITable/NetworkTable accessors for new features.
4b06e74a1 Java: Return boolean from put functions.
42f973ebe Java: Don't raise illegal state exceptions unless really necessary.
84e7d5906 Java: Use Global instead of WeakGlobal for callbacks.
51eb96903 Java: Improve robustness against JVM crashes on exit.
6d8e79693 Disable logging on static instance destruction.
f7e603c7d Add DEBUG4 message for messages received during client handshake.
30ad381b6 Notify on entries created/modified during handshake.
5181c4e5b Java: Don't free locals after detaching thread.
a2ec638db Java: Use empty string as default IP rather than null.
ef1e81f93 Merge "Create a WPILib Style guide."
953a2ce80 Implement keep-alives.
e1efb7364 Don't allow update intervals slower than 1 second.
123ba9c67 Use SmallVector instead of malloc buffers for WireEncoder.
d3e63e007 Change cmake to output same jar name (ntcore) as gradle.
21e21d3b8 Fixed the Windows build. Also added ensuring that vs2012 is installed if vs2015 is detecting, and printing an error that actually makes sense if it is not. Finally, added a .gitreview file, so that git-review will be able to autodetect the host and project for ntcore automatically.
702b6de73 Java: Fix crash on JVM exit.
6233b3477 Java: Fix fallback on external library.
07942bf42 Notifier: fix Stop() so it actually notifies the thread.
66f9f73cb Add gradle wrapper.
2dd9eafa4 Enable "make test" on cmake.
b1783cc1d Integrate googletest and googlemock.
c5c615b7d Add sublime text files to .gitignore.
897420a5f Reindent build.gradle.
5d1ab0e82 Merge "Unbreak cmake build."
af01ff300 Updated C++ documentation
550b04cff Merge pull request #21 from ThadHouse/master
46e0ac125 Added documentation to the C interface
22d984a6b Comments the interop functions in the C interface.
8d6f96adb Add NT_FreeCharArray.
1f431754a Simplify C entry point function names.
40093df91 Remove NT_AllocateNTString from ntcore.def.
f3bfee149 Change NT_GetEntry*FromValue to return copies.
9b9b41f40 Reformat to match coding style. No functional changes.
a451fd3f0 Make string/raw getters/setters use char*+len instead of NT_String.
756520724 StartClient(): Make a local copy of server_name.
e516200e0 Java: Add shutdown method to NetworkTable.
5beaf4577 TCPConnector: Add more info to debug messages.
1ca015776 Java: Add backwards compat shims for array types.
dbe4168d8 Java: allow both object arrays and native arrays.
969916851 Need to return nullptr, not false.
b00b4cb18 Avoid warnings by using sprintf_s on MSVC.
2b9e7c6af Silence MSVC warnings regarding bool conversions.
0d9aaa86c Silence unused variable warning.
28b613d60 Silence MSVC winsock deprecated warnings.
b971c741d Fix JNI for Windows and implement JNI getValue functions.
ecadb117d Merge pull request #5 from ThadHouse/master
4b7dfc025 Implements individual getters and setters for the C interface.
a990859db Initial commit of Java wrappers.
9c576b10d NetworkTable: Don't prefix path with / if key is empty.
b28807d79 Client and server tests: Prefix keys for compatibility.
b488cdd6f Support immediate notify of connection listener.
302cc064c ConnectionListener: Use bool instead of int for connected parameter.
6e4d7ca93 NetworkTable: Protect listeners with mutex.
6c8a5935c NetworkTable: Fix table and key listener behavior.
86445b667 Import llvm::SmallPtrSet.
330ba3993 Unbreak Unix build.
0f4eecebe Fix StorageTest on MSVC.
a3dbe9a80 Fix Windows client.
822dc4583 Close persistent file before attempting to rename.
b8a99690b Fix non-unit tests build on Windows.
48b1120c3 Add some basic non-unit tests.
c27a1cec4 Unbreak StorageTest.
9d4a66a40 Merge pull request #17 from 333fred/master
c846dff52 Fixed Gradle build to actually export proper functions
29f73cb5c Don't dispose in ConvertToC for NT_String and NT_Value.
a8836b766 Value: Use variant of enable_if to fix MakeString/MakeRaw in GCC.
96bf5c24b Merge pull request #4 from calcmogul/master
ab9de550d Replaced time.h with std::chrono
4514e4489 refactored HAL library
9cb9c3beb Logger: Move m_min_level init to header.
2d1bc2f4c Uninline constructors to reduce GetInstance() inlined code size.
c6bed1f46 Dispatcher: Move several fixed initial values to header.
c41341c7e Clean up trailing whitespace.
f0e31487f raw_istream and kin: a few cleanups.
a34143ae7 Update TODO.
ca9ce0f3a Implement automatic persistent saves.
a5ccafd92 Merge pull request #3 from 333fred/gradle-changes
43960b9bc changed windows file separator to unix file separator
29d029fa6 merged from frcsim branch
9458da045 Added building for arm, x86, and x64 with Gradle. This only builds ntcore currently, I'm working getting Google Test to work.
738881099 Unbreak cmake build.
4e4669219 Merge "Fixed wpilibJavaSim build"
8056aaa0a Merge "Accelerometer classes no longer use PIMPL pattern"
80247e98e Use relative include paths in tcpsockets.
293d00543 Turn on logging in unit tests.
a395e3577 Notifier: Fix condition variable race.
8d7cdeabb Implement remote procedure calls.
93b0dab7e Accelerometer classes no longer use PIMPL pattern
099056789 Fixed wpilibJavaSim build
f96b61ef1 artf4106: ISO C++ forbids variable-size array
b5695581c artf4170: Make CANTalon disable on destruction.
2bf3b6bed Replaced WPILib.h includes in integration tests with the minimum required subheaders to improve compilation times
e017f93f1 Fixed examples to build/run with new WPILib versions.
4f8c1dff2 Merge changes I8a9cf402,I8c0f8442
92edf35b4 Make deprecated warnings not error for macs.
e199e3571 Revert "Don't error on strict-aliasing warnings."
e9618df1b Avoid pointer aliasing for double/bits conversions.
c34ba968f Message: Remove ArrayRef-taking ExecuteRpc/RpcResponse.
0cbcfbc3f Import llvm::DenseMap.
cd4ebbd8a Tuned test constants for VelocityPID.
d5922bb03 artf4127: Implemented velocity PID controller
492463411 Don't error on strict-aliasing warnings.
cd53feb19 Log DEBUG() macros: avoid spurious warnings in release builds.
00feb6706 Only use enable_if template on Windows.
b3eed3818 Get build working on Windows (MSVC 2013).
f683a5c63 Export C API functions on Win32.
7d409f071 Add win32 tcpsockets implementation.
4146db6fc Visual Studio 2013 compilation fixes.
a86f65db1 Dispatcher: Implement transmit combining.
53a0531de Storage::ProcessIncoming(): Don't override parameter with local.
7db00575c NetworkConnection: Add a bit more debugging.
5b65bfb64 Storage: Fix comparison for client update-on-assign.
3b0eb56cf Update TODO.
e9073a3cc Implement notifiers.
538a19fd4 Implement GetConnections().
84ff80710 Refactor TCP-specific pieces of Dispatcher.
0dcaf56ed Add NetworkAcceptor and NetworkStream interfaces.
6703968f7 Dispatcher: Fix shutdown order race.
8ec65dbfc Use unique_ptr instead of shared_ptr for m_server_acceptor.
4670ef6ec Refactor StorageTest base class.
35e640017 Storage: Add vector include.
67de7af7b Storage: Use unique_ptr instead of shared_ptr for Entry.
3b207ad2c StorageTest: Fix string comparison for Warn().
b5274a495 Dispatcher: Don't call Storage::GetInstance() internally.
11508b77d Ensure initial synchronization is atomic.
0a1077869 NetworkConnection: Kill write thread when read dies and vice-versa.
ecbf76e94 Update tcpsockets classes to use log framework.
6c0103639 Make LOG() usable from other namespaces.
c2eb4a766 Dispatcher: Provide some INFO-level connection messages.
06e8d835d Provide ostream output for StringRef.
3a71acec5 Automatically reconnect client.
a9af4589a Don't send empty message lists from dispatch.
4356e313e Add logging framework.
afcfdb13a Clean up CMakeLists.txt a bit.
3a570add4 Build as a shared rather than static library.
ead125555 Implement client/server handshaking.
98ad6d1b4 Message: Handle receiving Server Hello.
978cdadda Storage::GetEntryType(): Check for null entry.
cde7782c2 Make StorageEntry a struct and move into Storage class.
138ebf5b4 Storage: generate messages rather than intermediate updates.
f0e3bb516 artf4165: D term of PID controller now uses change in input instead of change in error
918cde0c0 artf4155: Move Port.h from hal/lib/Athena to hal/include/HAL
43f16510f moved ctre includes from C++Devices into Hal
959f8775d Merge "Temporarily disable MutexTests until artf4167 is resolved."
0d70a39f6 Merge "Replaced ::std with std for readability/consistency."
ba57c7f24 Make gradle actually build command tests in C++.
a127bca0e Push down null check for m_queue_outgoing.
83be99e78 Immediately process incoming messages.
5b5e3ae6a Dispatcher: Start implementing processing of incoming messages.
f6576b18f Storage: Add more Dispatcher accessors.
9a621e927 Various NetworkConnection improvements.
4b575e3e7 Replaced ::std with std for readability/consistency.
c01f2977a StorageEntry: Make value() const.
683c53bab Message::str(): Return StringRef.
5823e3c78 Storage: Add CreateEntry function for Dispatcher use.
cbc372c71 Temporarily disable MutexTests until artf4167 is resolved.
a0d30ffef Storage: Use StringMap instead of ConcurrentQueue for updates.
fb1b82e23 StorageEntry: Also store copy of name here.
3bc5699ba Storage: Provide accessor for global mutex.
18659257d Storage: Make setters globally atomic.
3c7cb363b NetworkConnection: Prefer emplace to push.
787d39851 Update gradle build to match cmake build.
ae070aca7 Value: Add type check functions.
63dd895e6 Pass CMAKE_TOOLCHAIN_FILE down to external project (gmock).
507b083e7 WireEncoderTest.cpp: Don't test compiler truncation.
13bc05d9e leb128Test: Fix incorrectly sized constants.
3f24b8687 ITable: Add Persist function to make a key persistent.
1368f0ec8 NetworkTable: Use networktables.ini as persistence filename.
196fcf791 ITable: Const'ify getter functions.
6bccf528d ITableListener.h: Forward declare ITable.
1fc03803c ITableListener::ValueChanged: Don't make key const.
f74ca87e2 Merge "NamedSendable::GetName() is now const qualified"
5756be5c2 Merge "Fix std::unique_ptrs using incomplete types"
2da3f7f89 Merge "Replaced all uses of DISALLOW_COPY_AND_ASSIGN macro"
cf965d26a Merge "Make test scripts spawn driverstation as admin."
af3eaae09 Merge "Comment out SetPriority() in Task constructor."
8fa0e6c91 Add shims for old NetworkTable interface.
6f940bcaa Add immediate_notify and is_new to entry listener.
79f732f23 Import llvm::SmallString and dependencies.
593bc2844 Move StringMap.h and StringExtras.h to public includes.
9c204533e Value: Disambiguate std::string&& and StringRef.
4c14f7823 ntcore_cpp.h: Comment cleanup.
4aa2d65bb Storage: Use std::forward and emplace for updates.
bb5848a03 ConcurrentQueue: Add emplace function.
9f728b850 Add MSVC specific compiler flags.
9c2678fdb Make test scripts spawn driverstation as admin.
3bbeccfbb Replaced all uses of DISALLOW_COPY_AND_ASSIGN macro
b4c65dc21 Make global instance init thread-safe.
5df62ac17 Storage: Disable use of update queue by default.
0979c1c9c Storage, NetworkConnection: Don't in-place construct atomics.
8bbe5f9fd ArrayRef: Add portability checks for constexpr.
881dcd08e Fix std::unique_ptrs using incomplete types
3cd3d1691 Message: Use #define instead of constexpr.
6b2fb02be Dispatcher: Don't in-place construct atomics.
8938a1981 Dispatcher: Avoid warning by using for(;;) instead of while(true).
158ae6181 Dispatcher::SetUpdateRate(): Explicitly convert to int.
6bd2534f0 Comment out SetPriority() in Task constructor.
451c4e81c NamedSendable::GetName() is now const qualified
eb7d55fd5 Fixed classes with undefined constructor.
c776324f9 Merge "Make the teststand run as lvuser instead of admin."
98f2d0810 Changed const char* -> string in most of wpilibc.
534ea134a artf4154: Get rid of raw pointers in C++.
fd4c16965 artf4149: Removed references to VxWorks
571256506 Removed dependencies on pthread from frcsim.
3f59f3472 artf4156: Replaced synchronization primitives with C++11 equivalents
98d45777c Remove unnecessary llvm qualifier.
d05902207 Add logging to TODO.
c9260ea78 Change GetEntryTypeFunc to std::function.
c9ca2f902 Add TODO list.
29691e0ac StorageTest: Add LoadPersistent and SavePersistent coverage.
a3fcce891 LoadPersistent: Fix various bugs.
8db016c22 SavePersistent: Sort in name order, fix list commas.
b0802f3e2 StorageTest: Add fixture classes, add GetEntryInfo test.
e4731a4e4 Storage::GetEntryInfo: Actually filter on types.
67ae9e1ba Add initial set of unit tests for Storage.
d6afbc56c Storage: Delete functions now delete from map.
ffb54872c Storage::SetEntryFlags(): Fix deadlock, check for empty name.
ead6b4960 Storage: Use make_shared instead of reset.
21b7acc39 Storage: Make testable, make EntriesMap typedef private.
173111c64 ConcurrentQueue: Make mutex mutable.
cf18355fe Unit tests: Prefer constructor to SetUp() in fixtures.
1cc148848 StartServer: Take persist_filename as a StringRef.
ec5490434 Tighten up C++ API implementation a bit.
0a18d2e57 Storage: Make individual entries thread safe.
c08e2ed8f ConcurrentQueue: Add size() function.
2437f06c7 Implement majority of Storage functionality.
9b7e26576 Continue implementing client.
c4a7f6ec9 SavePersistent: Safely save through temp file.
d05656b71 StorageEntry: Make data public, remove accessors.
04789d9ae SequenceNumber: Add default constructor.
77acf1f35 Implement Flush() API.
412e8034d Start implementing client and server.
a6162ba99 NetworkConnection: Trigger threads as necessary in Stop().
7c5117860 TCPAcceptor: Add shutdown() function.
899c48912 TCPStream: Shutdown on close.
3062e1e74 Message: Add data accessors.
854bfba7c Value: Set last_change field.
1d4de091f Implement nt::Now().
b8f044f8e Make the teststand run as lvuser instead of admin.
440916cf2 Fix string terminator in char** output.
3f4feb2f5 Remove unused variable.
3025a7e51 Finish C wrappers.
fcbd2751b Provide C++ API. Move all classes to "nt" namespace.
56f1481c2 Add Dispatcher.
2ea20b8e8 Value: Use NT_Value for internal storage.
9906116d2 Don't base Value on NT_Value.
555725a05 NetworkConnection: Don't explicitly declare default move constructor.
13cbf4e28 Message: use shared_ptr.
beb92e6cb NetworkConnection: Ignore duplicate Start() calls.
4d3fb3c49 Storage: Use unique_ptr for instance.
dbd0c9830 Message: implement MsgType constructor.
53fb70251 ConcurrentQueue: Add empty() function.
e64070824 Start implementing network connectivity.
8fdaf61ef Use typedef for GetEntryFunc function pointer.
a5713252d Message::Read(): restructure to read directly into Message.
f5ec5e180 Message: don't explicitly convert StringValue.
27e0f22c0 StringValue: Implictly convert/assign from StringRef.
2016bcb37 Replace MessageReader and MessageWriter with Message.
1760d3201 MessageReader: Rename Run() to ReadMessage().
9808c6e62 Remove extra whitespace.
071b278b7 MessageReader: Use rvalue refs and std::move for handlers.
f4673f312 WireDecoder::Read(): Use const char instead of plain char.
8ee4c36e0 MessageReader/MessageWriter: bring in proto_rev().
0f876d198 Use StringRef instead of NT_String in various places.
eecf0deee Add WireDecoder test and finish WireEncoder test.
6aa32e875 WireDecoder: Add overloads for StringValue and Value.
a55b6565b WireDecoder ReadDouble: Use ref cast.
c1c0c8d41 Optimize Write16/32/Double a bit.
163477352 Finish WireEncoder tests and fix a bug.
547e2ad72 leb128 test: naming consistency
ca9064811 Add copyrights and header guards.
958fbaa81 ValueTest / StringValueTest: Make conversion function static.
fa19a54ab Separate ValueTest and StringValueTest into headers.
c9c1b7e5d Rename test files.
4d5e5c82d Start WireEncoder testing.
9bd4a5ecc Add proto_rev accessors to WireEncoder and WireDecoder.
09d6619a5 Add LEB128 test.
e7ba40dcf ReadUleb128: Take const buf.
ae42eee8e More Base64 fixes (correct decode return value).
1e9b9b9a3 Base64: Fix a little differently.
1225d3ef7 Slight whitespace fix.
407ded6b8 Use ASSERT_EQ with correct order of arguments.
c7b5266f9 Add Base64 tests and fix a couple of bugs found.
5a0fccc9c Add unit tests for StringValue and Value.
b66fb68f2 Finish LoadPersistent().
cb30bb5d7 Rename base64 to Base64.
40ebb9a84 C++-ify base64 functions.
b7a87bb6f Make StringValue noncopyable.
e38cce46a Add missing llvm headers.
f6deafee2 Add type-safe wrapper around NT_Value and NT_String.
8d6a0786c Move all C api functions to ntcore.cpp.
9ee307066 Storage: Make entries private, add accessors.
05e084364 Start implementing LoadPersistent.
69e91244f Rename make_StringRef to MakeStringRef.
e37a9d81f Cleanups and commenting.
95d0736bb More coding guidelines name changes, and use "using".
de4ba1aa3 Fix up naming of Base64 and Leb128 functions.
d7ca3343b File renames.
cee77a322 Reformat per new coding guidelines.
f5a82be9e timestamp.cpp: A few cleanups.
2a1ccaff1 Add timestamp function NT_Now().
b195dfbe0 Add ConcurrentQueue implementation.
0aab4c27e Use nullptr.
42ad98567 Use C++11 deleted functions for noncopyable.
c06e62541 Fix code style for pointer and references.
1a48e75d4 Implement SavePersistent.
a896a3ade Import LLVM StringMap et al.
62ef9e1c6 Remove extra Reserve calls.
047cccda8 Refactor WireEncoder.
dbed3fea6 Move remaining read functions.
b88a9295b More refactoring.
c4d4679ed Finish EXECUTE_RPC and RPC_RESPONSE handling.
c2063f3a8 Refactor MessageReader into WireDecoder.
03bae15b9 ntcore: Implement RPC_RESPONSE reading.
842fb957a ntcore: Initial commit.
7f5ee01d3 Merge "DISALLOW_COPY_AND_ASSIGN macro now uses the delete keyword and allows move assignment and construction"
f4d84cdd4 Fixed potentially uninitialized value warnings emitted by clang
974e301a8 Merge changes I3d35139f,I05bb06f6,I4a3db0f1,I452b4794,If281e46a
9dc7bb4ec Merge "Changed 'mvn.bat' to 'mvn.cmd' such that the eclipse plugins can build on Windows with the current version of maven."
1ab3ea670 artf4107: Removed most "Init" functions from classes
e4a8aacc5 artf4107: Replaced throw() with noexcept
faedfa6ed artf4107: GetInstance() calls are now atomic
368ad30d3 artf4107: Uniform initialization syntax introduced
b1befed14 artf4107: clang-modernize was run on WPILib
045a9b32d DISALLOW_COPY_AND_ASSIGN macro now uses the delete keyword and allows move assignment and construction
7a711a21f Make jenkins fail if tests fail catastrophically.
1c3882ec7 Create a WPILib Style guide.
35ccbb9c9 Fixed bad initialization of PDP.
8794f7d63 Changed 'mvn.bat' to 'mvn.cmd' such that the eclipse plugins can build on Windows with the current version of maven.
2c392d181 Fixed comment problem in GyroMecanum cpp and made other small fixes to sample programs.
7dcbe171b Merge "Major formatting changes (breaks diffs). No code changes."
6fefcc779 Merge "Added new sample programs to the eclipse plugins for C++ and Java. Modified examples.xml for the corresponding added programs."
7eb8550bd Major formatting changes (breaks diffs). No code changes.
bd64d9a7e Added and implemented GetInverted method.
0122086d2 Added tests for motor inversions.
ae90e5f6d Added new sample programs to the eclipse plugins for C++ and Java. Modified examples.xml for the corresponding added programs.
2d71c1c1c Merge "[artf4062] Eclipse now throws error on bad build."
0ad0b567e Merge "Artifact artf3896, commented out line that deletes the folders/files in wpilib/tools so teams smartdashboard extensions don't get deleted on plugin update."
401340213 Add PIDInterface for PIDController and CAN devices.
27e450967 Add CANSpeedController interface in Java.
6ce98056d Merge "Added Ultrasonic example program in Java and C++, updated examples XML."
c7944d76a Merge "Add check for CPP Perspective to CPP Launch Shortcuts. Fixes artf2627"
9c0df8c8f Add check for CPP Perspective to CPP Launch Shortcuts. Fixes artf2627
5598445a6 Improve const correctness.
c357d1dca Added Ultrasonic example program in Java and C++, updated examples XML.
c6b790cad Artifact artf3586: Added include for stdint.h in WPIErrors.h file, so the header can stand alone.
ead60eaab artf3622: Each Solenoid creates handles for all other Solenoids as well
39130721d Artifact artf3528, Added support for PDP's having addresses other than zero, and added ability to have multiple PDP's.
8d17270dc Merge "Added functions to get names, HID types and isXbox descriptors from joysticks."
bf4ccf13d Added functions to get names, HID types and isXbox descriptors from joysticks.
ee824680d Re-adjusted some PID values for the tests.
d252ed528 [artf4062] Eclipse now throws error on bad build.
3de0f162b Merge "Added modified Google Style Guide."
13948e819 Merge "[artf3943] Add LiveWindow mode to CANTalon."
ac80114c4 Merge "Fixed BuiltInAccelerometer Tests, changed expected axis of gravity from the z-axis to the y-axis."
7100052c5 Added modified Google Style Guide.
4b45b6a19 Artifact artf3896, commented out line that deletes the folders/files in wpilib/tools so teams smartdashboard extensions don't get deleted on plugin update.
b5ce28135 [artf3943] Add LiveWindow mode to CANTalon.
e48edbebd Fixed BuiltInAccelerometer Tests, changed expected axis of gravity from the z-axis to the y-axis.
0862210f5 Fix bad suffix for staticLibArchiver on macs. Needs to be tested on mac.
1c9dffc30 Commented OS X workaround in build.gradle
32251fe4a Merge "Makes the build work on Mac (needs to be tested on other platforms)"
08487b56a Merge "Changed calculate method to protected and virtual"
40c6fbe24 Makes the build work on Mac (needs to be tested on other platforms)
33f012a60 Merge "CANTalon: Add getter methods for soft limits."
fafc8635c Merge "add some comments etc documenting various not-implemented things"
8674ac20f Merge "Added missing archiver prefix for wpilibc"
2296d6560 Changed calculate method to protected and virtual
bbffc825e Merge "Change wpilibcZip to use "lib" instead of "libs" to match where eclipse plugins expect libraries"
682bc171f Change wpilibcZip to use "lib" instead of "libs" to match where eclipse plugins expect libraries
47088c035 CANTalon: Add getter methods for soft limits.
4cac5a957 add some comments etc documenting various not-implemented things
675fbc032 Test bench fixes and updates. Attempting to make it possible to have a stable build again. Gyro test still seems a bit unreliable.
880eae142 don't use uninitialized variables
d1d28e70e Merge "This commit adds JNI bindings for the C++ Notifier."
269bf9db6 Merge "Removed confusing error on deploy."
671954a66 Merge "Add MSYS Makefile option for cmake to Building.md as well as a note about the warning that's generated. Fixes artf3748"
19526361f Merge "Add DisabledInit to C++ Command Based template. Move and modify comment on Java version. Fixes artf3840"
a9593854d Merge "Fix usage reporting for new motor controllers and Analog output"
9cda6e3ff Merge "Tuned some values in tests to account for hardware imperfections."
0853dc8e5 Merge "Fixed access issues and 'overridableParamatar' misspelling."
0b7bb41b2 This commit adds JNI bindings for the C++ Notifier.
90f05dd31 Removed confusing error on deploy.
9b6e48e14 Add MSYS Makefile option for cmake to Building.md as well as a note about the warning that's generated. Fixes artf3748
5a094879b Add DisabledInit to C++ Command Based template. Move and modify comment on Java version. Fixes artf3840
8b71ddc30 Fix usage reporting for new motor controllers and Analog output
1805968d7 Tuned some values in tests to account for hardware imperfections.
01d73d04f Added missing archiver prefix for wpilibc
1e4e0bacd Gradle Build
569f02de8 Fixed access issues and 'overridableParamatar' misspelling.
0dffbd863 Catch exception when instantiating USB camera if camera isn't present
0e46592ad Don't send DS errors if no DS.
d2edb80da Merge "Use PCM Device ID when getting status. Fixes artf4014."
6159fde98 Set POV values on error to return -1 rather than 0 AND bump the version number (artf4005)
7bdd91a05 Use PCM Device ID when getting status. Fixes artf4014.
605bb45e0 Fix endian order of buffers in AnalogTrigger.java
215002e48 Fix analog trigger bug with MXP mapping (artf4010) Add the interrupt code for MXP mapping and analog triggers Took out the unneeded static definition Change-Id: I9a3483ee8f806b46b4349845e7a189f497c36916
964475c72 Bump the version number to 1.1 for the network table changes
bfa4bbaf7 Final move of Dustins network tables patches
39158754d Partial merge of patch from James Killian Narrows scope of locks in write manager added delay to incomming stream monitor loop
048b02e6c Applied patch from Dustin Spicuzza to fix robot hang
130319b77 Merge "Fixes artf3989: Java SerialPort no longer ignores return value of serialRead"
0b414b1bd Merge "Disable Encoder console spam introduced in e13720b."
8a244cc9d Merge "Make index encoder constructors work."
397162390 Merge "Correct energy to be in Joules rather then millijoules. Fixes artf3940"
bbc216f99 Disable Encoder console spam introduced in e13720b.
72a56e6a8 Make index encoder constructors work.
102c992e5 Fixes artf3989: Java SerialPort no longer ignores return value of serialRead
9f057fddf Correct energy to be in Joules rather then millijoules. Fixes artf3940
e614217d4 New netconsole-host that overwrites the old one on every deploy
9b7042a51 Fix errors in Vision examples.
081d7f736 Merge "Applied updated DIOJNI file from Ron Rossbach. Fixes artf3982."
352c021b1 Merge "Updated the Java CameraServer to use the new USBCamera and prevent large camera data copies. Fixed a small bug in USBCamera to prevent reinitializing a camera if it is already initialized. Also fixed some issues with the getJpegSize function to correct for Java incorrectly casting 0xff to an integer, and the byte buffer limit being set incorrectly."
5f90bf167 Merge "Enable nivision Java wrappers to be generated with Python 3."
445eafefb Merge "More Java nivision wrapper fixes."
a917f63e7 Merge "2015 Color and Retroreflective vision samples for C++ and Java"
2228361f3 Merge "Add SetCANJaguarSyncGroup to RobotDrive"
aaa599fa2 Updated the Java CameraServer to use the new USBCamera and prevent large camera data copies. Fixed a small bug in USBCamera to prevent reinitializing a camera if it is already initialized. Also fixed some issues with the getJpegSize function to correct for Java incorrectly casting 0xff to an integer, and the byte buffer limit being set incorrectly.
5d95bbb33 Enable nivision Java wrappers to be generated with Python 3.
d0258923e More Java nivision wrapper fixes.
91ccc5d10 2015 Color and Retroreflective vision samples for C++ and Java
9fda92005 Merge "Add @file annotation so files are picked up in doxygen"
e9dd72ac7 Merge changes I0ec40c14,I4d099e62
cce1bbc1f Merge "Update to point to Gazebo3.2 header location."
9fc79c41d nivision Java wrappers: implement our own error text function.
1dba91688 Add @file annotation so files are picked up in doxygen
ce7a56284 Fix a few major nivision Java wrapper issues.
34d515deb Make sure Utility file is included in doxygen output.
cff103d15 Merge "Add encoder indexing in Java"
1b5cabc0d Merge "Add encoder indexing support in C++"
9fcfc5b3b Merge "Added the C++ implementation of Peter Johnson's UsbCamera. Rewrote CameraServer to use the new USBCamera implementation and get rid of some unnecessary copying of the entire image."
f181c7013 Merge "Add USBCamera class."
46c40da53 Merge "NIVision: Add dx functions."
1c05a982e Merge "Synchronize CANTalon documentation between languages."
ba7f56833 Add SetCANJaguarSyncGroup to RobotDrive
7600473da Applied updated DIOJNI file from Ron Rossbach. Fixes artf3982.
9f04b7958 Fix Timer.hasPeriodPassed().
2282a11a7 Added the C++ implementation of Peter Johnson's UsbCamera. Rewrote CameraServer to use the new USBCamera implementation and get rid of some unnecessary copying of the entire image.
1a2344bdd Add USBCamera class.
ae9a7d19f Merge "Miscellaneous AnalogTrigger fixes"
e1141b9f2 Merge "Disable C optimize setting so better C++ doc is generated"
ff71aca57 Merge "Update docs to add missing channel numbers"
837671e95 Merge "Document that PDP must be address 0 and add/fix measurement units"
38c0308fc Merge "Correct path of sfx so that it can be launched from eclipse menu"
f21e4a9da Miscellaneous AnalogTrigger fixes
e13720bb9 Add encoder indexing in Java
0cf7d6f45 Update docs to add missing channel numbers
a2dfffedd Add encoder indexing support in C++
87e1df068 Fixed a null pointer exception in the mecanum drive sample program (Fixes artf3974)
f19c290fd NIVision: Add dx functions.
5c342a8e1 Document that PDP must be address 0 and add/fix measurement units
f7117aac4 Correct path of sfx so that it can be launched from eclipse menu
05cd0627b Update to point to Gazebo3.2 header location.
2bc83bd80 Disable C optimize setting so better C++ doc is generated
79fbbbc0d Synchronize CANTalon documentation between languages.
359a15591 Merge "Make 3 axis Accelerometers work in LiveWindow. Fixes artf3902."
fb7f5e9de Add methods to retreive the FPGA index for counters and encoders and return the encoding type as an integer Change-Id: Iaa4062ec124b968b27e7c812cc754032fcb354d2
7db63055f Make 3 axis Accelerometers work in LiveWindow. Fixes artf3902.
b94341a23 Merge "Update nivision JNI generator to correctly gen Priv_ReadJPEGString_C."
afbd70d39 Update nivision JNI generator to correctly gen Priv_ReadJPEGString_C.
ceccd9508 Add PDP to LiveWindow for C++
91b981248 Merge "Add PDP LiveWindow code"
0dbc40e51 Added missing .java file
5ce89b338 Added a Java AxisCamera sample program
8ccf3d9c1 Add AxisCamera Java class
230fa2d16 Add PDP LiveWindow code
d165f57e6 Clean up misc documentation
2d15b6b03 Merge "Update Java install URL to the new URL with the java installer."
5d9baa44e Merge changes Ie40db6c9,I0b5e752e
822416d2f Merge "Write lib version from C++ (fixes artf3788)"
3fe726d85 Merge "Update docs for C++ (fixes artf3761 and artf3953)"
4c0b2c18a Write lib version from Java (fixes artf3788)
b4c5a3af7 Update Javadocs for Java (fixes artf3761 and artf3953)
eddb0b20b Write lib version from C++ (fixes artf3788)
6d8e782f5 Update docs for C++ (fixes artf3761 and artf3953)
036832238 Update Camera templates to make C++ and Java more similar.
19e05ff52 Update Java install URL to the new URL with the java installer.
a6aef54ef Merge "Axis camera C++ example program"
32f3bea46 Axis camera C++ example program
9aacf5eb2 Merge "Artifact artf3925 : PCM : Can't find any user facing java/C++ API for getting/clearing PCM faults"
f3484686c Fix some typos in AxixCamera.cpp
b78b14bf5 Merge "Add AxisCamera C++ class"
c08dc9865 Merge "Add the 2014 C++ vision classes back in"
9fbffd88c Merge "Change the java intermediate vision filename to match c++"
6c15a3600 Change the java intermediate vision filename to match c++
548941dd9 Artifact artf3925 : PCM : Can't find any user facing java/C++ API for getting/clearing PCM faults
9d8418c14 Add AxisCamera C++ class
326bf4fc9 Merge "Updates the InterrupatableSensorBase documentation to reflect the bug described in artf3623."
3c4a1d9a1 NIVision Forward Port
768702826 Updates the InterrupatableSensorBase documentation to reflect the bug described in artf3623.
a55f34646 Encoder/Counter Fixes
53473e21b Add the 2014 C++ vision classes back in
b4097fbd5 Merge "ClearStickyFaults() should not take a param, just clears sticky flags in a one shot manner. GetCompressorFault() => GetCompressorCurrentTooHighFault() There are now three compressor related faults so getters needed to be more verbose. New getters()... GetCompressorCurrentTooHighStickyFault GetCompressorShortedStickyFault GetCompressorShortedFault GetCompressorNotConnectedStickyFault GetCompressorNotConnectedFault"
3b7211455 Merge "Fix imports on vision examples so they compile. Fix Typo."
cc36454b9 Merge "Add C interface for CanTalonSRX::SetModeSelect(modeSelect, demand)."
aae20ddbf Artifact artf3945 : CANTalon : Motor Safety Object never feed
ffd906176 Fix imports on vision examples so they compile. Fix Typo.
9ffdea188 Add C interface for CanTalonSRX::SetModeSelect(modeSelect, demand).
46dc99a11 Adding SFX to tools zip
91d714d2e Merge "Single line bug in CanTalonSRX::GetAnalogInVel(). return value was not being sign-extended."
9a28aaaa7 Merge "Change expected voltage on CAN tests"
96a76ba89 Single line bug in CanTalonSRX::GetAnalogInVel(). return value was not being sign-extended.
d26059a4f Change expected voltage on CAN tests
ee0d83530 Remove an extra constructor from a bad merge
6080a3b18 Duplicate of gerrit 739; changed method from public to private.
3d06a763a CanTalon : Adding config routines for limit switch normally open vs normally closed. They already existed in Labview, so this will keep parity New C++/Java funcs ConfigFwdLimitSwitchNormallyOpen ConfigRevLimitSwitchNormallyOpen
e1480ec79 Noticed that if changeControlMode() is called every teleop loop, it causes motor to stutter as it enters and immediately leaves kDisabled. A simple improvement was to only perform the disable-before-next-set strategy if the caller's request mode is not equal to the current mode.
a5d9ba412 Second pass through all the HAL functions and cpp/java API. Filled in some parity holes between java and cpp.
2434515d4 artf3913 Increased wait delay to 4ms to cover worst case delays for solicted signal getters. Specifically.... -Get firmware vers -Get P,I,D,F gains -Get IZone, Get CloseLoopRampRate -Get IAccum (integral accumulator)
741618250 Merge "C++ CANTalon was missing SetIzone. Added SetIzone to match java, and made the set/get Izone integral."
8b8d7e77c C++ CANTalon was missing SetIzone. Added SetIzone to match java, and made the set/get Izone integral.
c093a553e changed variable type of closeLoopRampRate in setpid to double from int. It's represents V per sec since it calls setCloseLoopRampRate() underneath.
a1375e58c Merge "Don't fail silently if DIO or PWM allocation fails"
15ff7f503 Merge "Added the getButtons method back that reads all the buttons at the same time"
c17ba98f7 Added the getButtons method back that reads all the buttons at the same time
dee755ab1 Merge "renamed param to match function name."
92c54f5f5 Merge "Image v23"
1fde00643 Merge "Fixed post4066 bug: Prestart() inaccessible."
47443b4e1 Fixed post4066 bug: Prestart() inaccessible.
f01e5b557 fixed robotCommand in src
198e2eed1 ClearStickyFaults() should not take a param, just clears sticky flags in a one shot manner. GetCompressorFault() => GetCompressorCurrentTooHighFault() There are now three compressor related faults so getters needed to be more verbose. New getters()... GetCompressorCurrentTooHighStickyFault GetCompressorShortedStickyFault GetCompressorShortedFault GetCompressorNotConnectedStickyFault GetCompressorNotConnectedFault
22c420755 Image v23
bea9eb0ef renamed param to match function name.
b72eb4b81 Merge "added Java vision example programs"
0d8c45472 Don't fail silently if DIO or PWM allocation fails
d61d491a0 added Java vision example programs
786e844a9 Merge "Fix ControllerPower 5v faults and add javadocs. Fixes artf3918."
170b5860e Fix javadoc compile errors that broke build.
26c50ebe0 fixed java CameraServer
46c659d6b Enable Java 8 doclint checking (except for missing tags).
6fdd49108 Fix javadoc warnings.
fe4535dfa Merge "Resolved artf3579: robot can no longer be enabled until robotInit() finishes in IterativeRobot; similar options available by overriding prestart() for other base classes."
636e2e13a Wrong package declaration in camera server
d3f5b7466 added CameraServer.java
8116bbd15 Merge "Fix various bugs in nivision wrappers."
37052246a Fix various bugs in nivision wrappers.
a649d3b55 Fix ControllerPower 5v faults and add javadocs. Fixes artf3918.
6a7e7cf61 Two param constructor added to C++/java CANTalon so caller can optionally specify the periodMs at which the talon control frame is sent. The param is capped in the HAL C++ class to [1ms, 95ms] so that zero and negative periods are caped to 1ms, and so that caller can't pass an absurdly large value, which causes TALON is appear disabled.
77997e52f Merge "added PDP methods to javalib"
e655072ef Synchronize access to buffered Joystick data.
0427fc34c Merge "Check for negative button value and add missing newline."
e33d80be1 Merge "Add USB serial port option. Uses kUSB for ALSR3"
8381eee18 Merge "Wrap IMAQdx functions."
1c24096cc Resolved artf3579: robot can no longer be enabled until robotInit() finishes in IterativeRobot; similar options available by overriding prestart() for other base classes.
3a684d28b PWM timing change for SP and SRX. added 3us to outer bounds
8786b242b Add USB serial port option. Uses kUSB for ALSR3
b29a4bebf Check for negative button value and add missing newline.
db0b42101 Wrap IMAQdx functions.
8efe99827 Make VictorSP and TalonSRX use correct bounds (give an extra 1us on min and max to ensure saturation). Fixes artf3914 for C++ and Java
ac6019884 Merge "Change vision defaults from "cam1" to cam0". Add some error reporting to Intermediate Vision example"
8a5ee71fd Merge "Make SetImaqError actually set the error"
af4ce1074 Merge "Image v22"
763604139 Don't use raw type for HALSetNewDataSem
745489fec Image v22
04f9ca4fe Change vision defaults from "cam1" to cam0". Add some error reporting to Intermediate Vision example
ca5dfbe49 Make SetImaqError actually set the error
07619a37a Merge "Add C function wrappers for CanTalonSRX."
34d3d756e Merge "Update javadoc for RobotDrive. Mecanum methods are implemented."
61a5fcce1 Merge "Squashed commit of the following:"
82c4563d3 Merge "getHALErrorMessage(): Add missing CTRE errors."
fa337bc74 Add C function wrappers for CanTalonSRX.
8ae7e973f getHALErrorMessage(): Add missing CTRE errors.
574f2e692 Java nivision: Add RawData to wrap void*.
827341caa Squashed commit of the following:
dd272e6bc Merge "Add Java nivision wrappers."
3bdaa63a2 Update javadoc for RobotDrive. Mecanum methods are implemented.
41b393c21 Merge "Fixed minor issues in CANTalon. Fixes artf3884, 3885, 3887."
11cf860ec Merge "Check and coerce rumble inputs to range of 0 - 1."
2168d2cb7 Merge "Require Jaguar version v108 or higher."
430722c4a Add Java nivision wrappers.
497f38fe0 Check and coerce rumble inputs to range of 0 - 1.
9f2dcdeab Fixed minor issues in CANTalon. Fixes artf3884, 3885, 3887.
ac07142e4 added PDP methods to javalib
19a7243bf C++ Added Get/clear routine for IntegralAccumulator Added missing status check in GetFirmwareVersion(). I don't expect this to affect anything.
e3ac0b628 Merge "Fixed issue in setting CANTalon values."
709a88ad6 Fixed issue in setting CANTalon values.
6b844b52e comment change and added SetModeSelect(int modeSelect,int demand) {
9056edf93 commented out system.out.prints in CANTalon.set()
ff2ea1287 Merge "Added C++ versions of the joystick query functions"
b41690b38 Added C++ versions of the joystick query functions
ce8e65d41 Merge "Changed AnalogPotentiometer to use angle specification and rail voltage."
66622b43e Fixed accidental confusion between seconds/milliseconds.
568b842c7 added setPosition to java. Great for zero-ing your relative sensors, also exists in cpp and LV.
4d142cdaf commented out throws in getP,getI,getD,getIzone, getRampRate. Getting/setting these should be available all the time.
2ae8f40a5 Changed AnalogPotentiometer to use angle specification and rail voltage.
483331657 Added more Talon SRX documentation and PID samples.
16f9db30a Merge "fixed bug artf3676 : Typing in a project name into the create command dialog in eclipse is broken"
e092742f4 fixed bug artf3676 : Typing in a project name into the create command dialog in eclipse is broken
4f6fa2482 added joystick and driverstation counts for POV, buttons, and axis
52408e265 Add classes for VictorSP and TalonSRX PWM control.
d986ffac8 Merge "Java-Installer"
bc3c5447e Java-Installer
b125e6b40 Merge "Various getters and setters added to C++. usleep added to the getters that require a little time for solicted response (getPIDF, getIzone, and getFirmwareVers. Tested against the TALON SRX unit test originally written for CanTalonSrx HAL class."
88a043bda Merge "Change Periodic Status rate to 20ms. Jaguar firmware v109 fixes issue with periodic status sending."
c57d01af9 Merge "Add USB IP to deploy fallbacks and make fallbacks work."
6abde412c Merge "Image v20"
5e6cd0bf9 Merge "Implement Joystick Outputs and Rumble (fixes artf3807)"
ec03c3068 Add USB IP to deploy fallbacks and make fallbacks work.
45f3b7610 Fix off-by-one in button checking (fixes artf3861)
dac04cb4a Implement Joystick Outputs and Rumble (fixes artf3807)
7d026be26 Various getters and setters added to C++. usleep added to the getters that require a little time for solicted response (getPIDF, getIzone, and getFirmwareVers. Tested against the TALON SRX unit test originally written for CanTalonSrx HAL class.
5893d28f3 Added support for basic PID in java Talon SRX.
cd0194590 Image v20
36c53667c Require Jaguar version v108 or higher.
ea610eb30 Getters for : AppliedThrotte, CloseLoopErr, Sensor/Ain/Enc Pos and Vel are now signed extended. Before this negative values would not de-serialize correctly. There are some redundant TALON fixes in this particular commit, hopefully it handles ok on Jenkins. Tested with Talon SRX Unit Test (firm 0.34)
d04476bb2 Wired close loop pos and vel to CANTalon::Set(). Did basic testing with close loop pos with talon slaving.
2bb0a32c1 Change Periodic Status rate to 20ms. Jaguar firmware v109 fixes issue with periodic status sending.
cdbe80315 Image v19 This updates the hal headers and ni libraries for image v19. There were very few changes this time around, only some network communications stuff. Also updated the minimum version number in the build properties to the new image version
517e708fd Merge "Reorded network table init to avoid error and added disabledInit to template (artf3841, artf3840)"
70825be69 Reorded network table init to avoid error and added disabledInit to template (artf3841, artf3840)
43532198c Merge "Artifact artf3520 : Need a PDP Clear Sticky Faults API"
4da9ebe1f Artifact artf3520 : Need a PDP Clear Sticky Faults API
9479793e1 Merge "Open scope of several data fields to be able to extend CommandGroup"
20e9f499b Merge "Add hasPeriodPassed function to java, for parity with C++ Timer API"
3d897cef5 Make robot programs deploy as lvuser for correct permissions (artf3860)
fa229f2b1 Added java joystick message spam fix (artf3836)
b1056cf6d Prevented missing joystick messages from coming out more than once a seccond (fixes artf3836)
8e707169a Add hasPeriodPassed function to java, for parity with C++ Timer API
47961c8b1 Open scope of several data fields to be able to extend CommandGroup
b59f4141c Merge "Open scope for gyro methods. Fixes FirstForge artf1699."
d62d82b28 Merge "Feed motor safety when StopMotor is called. Fixes artf1687 on FirstForge."
a9d30c038 Fixed a typo in the SRX sample project to correct a variable name error
6e0c84d94 Feed motor safety when StopMotor is called. Fixes artf1687 on FirstForge.
bb8ea17ac Open scope for gyro methods. Fixes FirstForge artf1699.
c683e24aa Merge changes If51bf61d,Ia6f4997b
7b371f6d7 Added Omar's new CanTalonSRX code.
f6de7bc96 Merge "Java debug launcher no longer waits for text marker to appear in console."
c00d9f152 Updated the names and descriptions for the c++ vision examples
6ec2d262c Added nicer Java interface for Talon SRX -- throttle mode works.
3c8b31608 Merge "Use standard eclipse dialogs instead of Swing dialogs"
29f36b0ea Merge "Overwrite instead of append during version check. Fixes artf3818"
486885e8b Merge changes Id7a97940,I6234fe06
020d97580 Merge "Fixed bug with SDFormat version changing."
28a41e4ac Added support for CAN Talon SRX in C++ and Java.
f590cda8f Merge "match templates with robot builder."
c98f54dbb match templates with robot builder.
81840b2c4 Add a getControlWord() call to the run thread in DS so that the program is kept alive
78ccb48fd Java debug launcher no longer waits for text marker to appear in console.
b9913d3e1 Overwrite instead of append during version check. Fixes artf3818
56430ccd7 Merge "Pipe java program output through NetConsole"
d412584f1 Merge "Tried to improve reliability of a couple of unit tests."
364a3afad Pipe java program output through NetConsole
97456f40f Don't buffer NetComms data and add IsDSAttached() check to C++ IsEnabled() method (fixes artf3747)
7e5ed03d2 Check if Joystick Button exists when requested and pass 0 and warn if it doesn't
14a1e6ae8 Get MatchTime from NetComms (fixes artf2538)
529f5b773 Use standard eclipse dialogs instead of Swing dialogs
91c70daf5 Tried to improve reliability of a couple of unit tests.
e86312cd6 Fixed bug with SDFormat version changing.
99dc3c90e Merge "Removed the tail command"
4ad8818a8 Added vision samples
e4babbe4d Removed the tail command
9ec516407 Merge "Handle cases where no DS is attached (initial m_controlWord, reportError, getAlliance and getLocation) fixes artf3778"
033e5f37b Merge "Add methods for checking Watchdog status, ds status, and brownout status"
e3d256e44 Merge "Change uint to int for channels on constructors which can take a single channel or single pointer to avoid ambiguous calls."
867e4080d Change uint to int for channels on constructors which can take a single channel or single pointer to avoid ambiguous calls.
4be9732e9 Moves C++ global build properties to properties file to match Java. Adds host reachability check and static IP fallback Adds roboRIO Image check Adds JRE check for Java
cd29e1c32 Handle cases where no DS is attached (initial m_controlWord, reportError, getAlliance and getLocation) fixes artf3778
e73b3ed7b Add methods for checking Watchdog status, ds status, and brownout status
d7a979408 Simulator makefiles: Set file extension based on platform
6234fe06f Fix CMakeLists.txt to not be platform specific
c7a90b2cc Merge "Fix write when used with long byte array."
e5443f0e7 Merge "Added in new headers and libraries for image version 18. This image contains a change to fix artf3773, which switched setDataSem to be a pthread_cond_t variable instead of a mutex. As a result, a few new HAL functions had to be exposed over JNI, specifically the functions for MultiWait."
0abe19a1a Merge "Added support for launching a simulation friendly SmartDashboard."
ccd64090b Fix write when used with long byte array.
c6891fc03 Added in new headers and libraries for image version 18. This image contains a change to fix artf3773, which switched setDataSem to be a pthread_cond_t variable instead of a mutex. As a result, a few new HAL functions had to be exposed over JNI, specifically the functions for MultiWait.
6f4d6ed99 Add support for vision in C++
0670ff145 Merge "Using netconsole-host to start programs and get output directed to netconsole and the log file (fixes artf3777, artf3750)"
655ade643 Using netconsole-host to start programs and get output directed to netconsole and the log file (fixes artf3777, artf3750)
7cfa0d04d Added support for launching a simulation friendly SmartDashboard.
f1476be27 Reverted accidental commits
9be6ee471 CANTalon throttle works.
9050ea7e3 Generalize CANJaguar and CANTalon with a CANSpeedController interface in C++
c1f68eb2b Stick the CanTalonSrx code in, get it to compile
fb53eea6b Merge "[artf3749] Repaired undefined behavior in takeMultiWait."
6c294e137 Increase timeout on network table test
988defee1 Merge "Adds the new shared object libraries and headers for image version 17"
279ae1cd9 Merge "Removed remains of the old toolchain method."
49f6b90d1 Merge "Removed the timing option from Iterative Robot Template since it conflicted with its purpose (artf3751)"
6cd5eeab6 Adds the new shared object libraries and headers for image version 17
c883c9e2f Removed release configuration from template (fixes artf3688)
54951c888 Removed remains of the old toolchain method.
739508ff8 Merge "First cut at pulling in riolog plugin."
f67849a9b [artf3749] Repaired undefined behavior in takeMultiWait.
7c5b3c628 Merge "Added the OutlineViewer to distribute with the plugins."
eb536ba34 Merge "Added default world files to examples."
19737ba44 Merge "Implement user API for roboRIO power methods (fixes artf3728 and artf3537)"
9f0bed2e6 Merge "Correct off-by-one error in DigOut PWM Gen B HAL code (fixes artf3705 for C++/Java)"
86e4c3b77 Merge "athena-deploy now calls the clean step to deal with a known ant issue where it does not detect changed constants. This addresses art3766."
e216d1abd Merge "Fix all the samples to build with the C++11/14 language features (constexpr)"
20aeb5c6c Added the OutlineViewer to distribute with the plugins.
3ad31dd4d Implement user API for roboRIO power methods (fixes artf3728 and artf3537)
4c5b8c8c4 Correct off-by-one error in DigOut PWM Gen B HAL code (fixes artf3705 for C++/Java)
747cdc8a5 Updated an incorrect voltage constant for the 5V input rail, and added parenthesis to make the order of operations explicit. Fix for artf3728
c3c7baa15 Removed the timing option from Iterative Robot Template since it conflicted with its purpose (artf3751)
2fdb7c8eb athena-deploy now calls the clean step to deal with a known ant issue where it does not detect changed constants. This addresses art3766.
1d0a6b8ac Fix all the samples to build with the C++11/14 language features (constexpr)
08fdf45f6 Added default world files to examples.
733847119 First cut at pulling in riolog plugin.
da0cc0c83 Merge "Fixes for 0 based joysticks and joystick axes in simulation."
6e0637e77 Merge "Upped the limits for the output on some PID tests."
8d49d8255 Merge "Move SerialPort to HAL and add SerialPort support for Java Squashed commit of the following:"
3b53f84c8 Fixes for 0 based joysticks and joystick axes in simulation.
05bb3cdd7 Upped the limits for the output on some PID tests.
18de3aebd Make sure the whole JVM exits if an exception is thrown. This prevents the DS thread, NT thread or any additional user thread from keeping the program alive when the main thread exits (fixes artf3743)
de5e5ab40 Merge "[artf3709] Fixed PIDController loop timing."
6b6e5d953 Move SerialPort to HAL and add SerialPort support for Java Squashed commit of the following:
fa20e6ca4 Check for fatal interrupt status on multiple interrupt methods to avoid hanging program (fixes artf3602)
e56aa87af Merge "Change Talon to use 1x update rate (fixes artf3733)"
63bb8e1f3 Merge "Remove unimplemented sendErrorStreamToDriverStation method (fixes artf3617)"
c1e63acc1 Merge "Use ByteBuffer for conversion from raw sensor bytes to Java types (fixes artf2673)"
68ba9bfea Merge "Detect projects which are duplicates on Windows due to casing (fixes artf3487)."
aa643d8ba Merge "Update Interrupt Javadocs (fixes artf3492 and artf3602)"
1f8a3d5bf Merge "DigitalInputs are now automatically added the LiveWindow in both C++ and Java"
2fa04c175 Merge "Don't raise exception for Joystick axis/POV out of active range. Shorten error message and change to Warning (filtered by DS by default)"
cd3db9631 Merge "Move user program to home\lvuser based on comments from Joe"
8ccb99d87 Merge "Added ignore support for intellij"
b14ca0847 Merge "[artf3717] Added isEnabled to Teleop Loops in Samples."
b898cec90 Change Talon to use 1x update rate (fixes artf3733)
687e2c671 [artf3709] Fixed PIDController loop timing.
594d0d802 Use ByteBuffer for conversion from raw sensor bytes to Java types (fixes artf2673)
0f825b717 Added ignore support for intellij
345ceafa0 DigitalInputs are now automatically added the LiveWindow in both C++ and Java
b030be68d Detect projects which are duplicates on Windows due to casing (fixes artf3487).
fba155804 Update Interrupt Javadocs (fixes artf3492 and artf3602)
97f954aef Remove unimplemented sendErrorStreamToDriverStation method (fixes artf3617)
80194e980 Merge "Added message to notify when simulation is unsupported."
767686ae2 [artf3717] Added isEnabled to Teleop Loops in Samples.
7f30b6bff Don't raise exception for Joystick axis/POV out of active range. Shorten error message and change to Warning (filtered by DS by default)
8c395ca29 Move user program to home\lvuser based on comments from Joe
5b2520c35 Merge "Fixed building of the frcsim-libwpilibsim-cpp deb."
fa8d7b843 Fixed building of the frcsim-libwpilibsim-cpp deb.
93100c0e6 Merge "Increases the runtime of the PID test to improve stability."
b80565d06 Merge "Decreases the amount of console spam during tests."
2d45cda74 Increases the runtime of the PID test to improve stability.
e4d90c6cb Decreases the amount of console spam during tests.
18bdb7fde Merge "Added C++ Encoder samples to Eclipse Plugin."
f6e8db50f Merge "Fixed New Project Wizard to have a radio option always selected"
20c60a5fe Added C++ Encoder samples to Eclipse Plugin.
66b7a8b66 Merge "Use either DO PWM A or B not A and B and update javadoc to reflect 6 generators (artf3698)"
8ebf88b74 Java DriverStation.InTest: Set correct flag.
b85b0c8eb Merge "Keep Notifier firing after FPGA rollover (fixes artf3582), simulation may still have an issue with counter rollover"
c58fde19f Increase the number of joystick ports to 6.
003dc0dc2 Pass errors to DS in C++ and Java
26419ec20 Don't use "final" in command-based template RobotMap.
383439369 Merge "Improves the general stability of the CANJaguarDefault tests"
97be9765c Changed the version to include time to fix issue with replacing.
0881ac0b2 Fixed issue where plugins don't show up on some installs.
1b7e5970f Merge "Added C++ sample for CAN monitoring of PDP."
bc84c7ac7 Improves the general stability of the CANJaguarDefault tests
fc34b9b80 Merge "Aggregate javadocs and use JavaFinal docs when building plugins (fixes artf3533)"
9af070a4a Added C++ sample for CAN monitoring of PDP.
93925bc02 Fixes the GyroTest
132804a4c Updates the test scripts to prevent a race time condition
9e6d68367 Merge "Increases tolerances for the PID tests"
f7e8b95a2 Increases tolerances for the PID tests
213e73c43 Merge "v16 Image"
455654a95 Merge "Fix joystick issues [artf3707]"
261b1857c make getControlMode public. Was public in 2014.
f3fe64a60 Keep Notifier firing after FPGA rollover (fixes artf3582), simulation may still have an issue with counter rollover
f108853e1 Merge "Added sample programs for Solenoids and Relays."
a56c0eb4a Fix joystick issues [artf3707]
8c01e9065 Fixes a bug with the test stand launch script
be30d3ab1 Fix CANJaguar brownout recovery in Java
53255a764 Merge "Relay: Allow "On" state to be set via SmartDashboard."
3abd352be Added sample programs for Solenoids and Relays.
70be534fe v16 Image
e677d52a2 Increases the allowed runtime for two network tables tests
62790c0f4 Use either DO PWM A or B not A and B and update javadoc to reflect 6 generators (artf3698)
cd75dc71e Merge "Recover from signals in Wait() [artf3495]"
a381b60e3 Merge "Added sample program for Motor Controller."
311a69026 Added sample program for Motor Controller.
a2f015c25 Merge "Dynamically generates tools zip file."
5c26b37d3 Dynamically generates tools zip file.
8dba364be Recover from signals in Wait() [artf3495]
76f9b3bbc Merge "Adding stdint.h to the Joystick.h makes the indexer work (fixes artf3505)"
bbeb0084a Merge "Set RobotBase instance in constructor [artf3652]"
e51c3daf0 Set RobotBase instance in constructor [artf3652]
dc89ec673 Adding stdint.h to the Joystick.h makes the indexer work (fixes artf3505)
fc7c01582 Fix warnings for javadocs
c52e29432 Merge "make preferences check for [ and ] in key"
53d50f470 Merge "updted licesne strings in eclipse plugins"
ca303e016 Merge "fixed template on checkedin java examples"
042a1dbc8 make preferences check for [ and ] in key
3c91de56d Merge "Fix segfault in DIO PWM generators [artf3653]"
0c2f3c19c Merge "Fix Java Joystick.getPOV()."
023d20abc Fix segfault in DIO PWM generators [artf3653]
5c702edd8 Support for pushing NetworkTables (java) to the maven repository.
d90bbc195 Merge "Removed vestigial POM file from NetworkTables"
3365d0dc1 Fix Java Joystick.getPOV().
615d62a21 Relay: Allow "On" state to be set via SmartDashboard.
78988584e Removed vestigial POM file from NetworkTables
294e224fc Merge "allow installation on eclipse 3.8 (ubuntu 14.04)"
436c92961 Merge "Add new joystick features"
341abbfaa Merge "Run the scheduler in disabled (fixes artf3631)"
eab34bbb8 Merge "Add SD methods with default values to match Java (fixes artf3648)"
5db532079 Merge "Add method to get Device ID to Can Jaguar (fixes artf3613)"
54eaa913f Merge "Make Java ignore section headers in Preferences file and start file with [Preferences] to match C++ (fixes artf3629)"
8a541a67c Add new joystick features
7fa0eea49 Merge "ADXL345_SPI: Report usage."
cc431354b Merge "Counter::setUpSource(AnalogTrigger): actually set the source."
65c10cd46 Aggregate javadocs and use JavaFinal docs when building plugins (fixes artf3533)
fea52a77a Add SD methods with default values to match Java (fixes artf3648)
4e31b6800 Add method to get Device ID to Can Jaguar (fixes artf3613)
f99b57b1f Run the scheduler in disabled (fixes artf3631)
dad3b68f3 Make Java ignore section headers in Preferences file and start file with [Preferences] to match C++ (fixes artf3629)
08c872317 Merge "Add error message to new project wizard if project already exists"
ce768ae34 ADXL345_SPI: Report usage.
217c50c28 allow installation on eclipse 3.8 (ubuntu 14.04)
fcc8230db Counter::setUpSource(AnalogTrigger): actually set the source.
d2c1bc174 updted licesne strings in eclipse plugins
6fe638e97 Fixed New Project Wizard to have a radio option always selected
07837c4ab fixed template on checkedin java examples
daee45780 Added additional NI libraries to make C++ builds work
807948282 Create HOME on windows
0b828eec6 Merge "Disable CANJaguar current PID test"
49e06bd13 Merge "Move interrupt methods to InterruptableSensorBase"
eca4d36a4 Disable CANJaguar current PID test
4d2a720f4 Move interrupt methods to InterruptableSensorBase
591e1de72 use WPILIB eclipse var & use luna to build
dc09233fc Merge "void* -> void by creating proxy fuction"
037d3b2fb void* -> void by creating proxy fuction
a3995a202 Fix bitfield indexing on PWM Latch
a71f07ed6 Merge "HAL: build shared library as well as static library."
cb81aa6fe Merge "Update headers and .sos to v15 image + most API changes"
ace43a6a1 Merge "DigitalOutput: Fix enablePWM()."
a4e8d65b7 Merge "Relay: In free(), set both forward and reverse to 0."
bfd88f1da Reserve network communications
a65cb500f Relay: In free(), set both forward and reverse to 0.
f27df43b5 DigitalOutput: Fix enablePWM().
7e9f183cf Update headers and .sos to v15 image + most API changes
2f2636139 Added Mecanum drive sample program
52ecbd38a HAL: build shared library as well as static library.
6089722c4 Merge "Too many bugs with LTO in GCC 4.9 & Binutils 2.24. Disabling. Maybe later."
244ecd23e Too many bugs with LTO in GCC 4.9 & Binutils 2.24. Disabling. Maybe later.
8aeacac30 Set Start Mode to remote to allow Debug As->WPILib Deploy to launch without error on Windows
45021c7f3 Merge "Figured out the madness: not launching properly (no copy)"
857a1abb0 Merge "Prevent leading zeroes in team number and warn user about them (fixes artf3429)"
c11f194cb Merge "Allow dataRecieved to be null in I2C transaction (fixes artf3603)"
8b806e11e Added Arcade C++ example and a hierarchy for C++ examples.
ba5111b99 Add a Motor Controller example java program
88bf4ee56 Merge "Added a hierarchy of example categories that looks very much like what's in LabVIEW and placed the one project in a bunch of categories as a proof of concept."
76295a574 Fix eclipse launching of tools (SmartDashboard, sfx, OutlineViewer, and RobotBuilder)
90a106ccf Added a hierarchy of example categories that looks very much like what's in LabVIEW and placed the one project in a bunch of categories as a proof of concept.
0fcef9490 Whoops, need to change the joystick port assignments to be zero based on the sample program.
3f38f3e84 Added a tank drive example for java
64abdb822 Allow dataRecieved to be null in I2C transaction (fixes artf3603)
aaa7eabd0 Prevent leading zeroes in team number and warn user about them (fixes artf3429)
1cef27134 Changed joystick port numbers to be zero-based for C++ and Java.
aaab77cdb Figured out the madness: not launching properly (no copy)
7e2c68214 Set debug flag user to lvuser to allow it to be deleted (fixes artf3415)
ad906da67 Merge "Squashed commit of the following:"
a6ea51ad0 Fix simulator builds (and don't clean, dh does that also)
d72ee199f Squashed commit of the following:
19b2d0523 Fix simulator builds (dh knows how to CMake)
26d789b89 Copy to the correct folder name
f50b05845 Merge changes I6b5d2767,I6f4b94d1,Iada981fc
39da9d67b JNI should ignore -lfrc and installing the new ld scripts
b6475d050 Renaming and merging WPILibC++ into Devices and simulator files
295f212c8 Change digital input to return boolean values to match Java
fa4a39dcc Initial linker script to abstract away the massive library list
66c653a21 Get the simulator build to accept c++11 languge
340a3d492 Fixing pedantics and using RTTI for command name
6710ac3a2 fixing all warnings and making sure they will stay fixed
9e62e60e6 Merge "Remove CPP Preferences page from WPILib preferences (code has already been deleted)"
e6c56e444 Modified simulation debs to exclude building the toolchain.
35f1aded6 Merge "Change RobotState functions to return actual values (this time with nullptrs) [artf3611]"
4904e1dc2 Change RobotState functions to return actual values (this time with nullptrs) [artf3611]
28b9c18e2 Merge "Add a getDeviceNumber method to CANJaguar"
a548b14b7 Add a getDeviceNumber method to CANJaguar
323022acf Remove "using namespace std;" from headers
1bcdd301e Merge "Fix changes where the default value was always being returned for many of the robot state status functions."
21f728c80 Moving to arm-frc-linux-gnueabi in cproject and attempting to use gdb (overwritten)
49d440ecc Merge changes I4f5a36e6,I248d27cc,I55769599,I7688b8cd
00486e2ec Fix changes where the default value was always being returned for many of the robot state status functions.
a3115dac1 Removing Toolchains!
1f35670a1 Enabling C++14 and removing path for new toolchains
d1d81e5e1 Remove unnecessary config for cproject/Simulate target
a7b166e3f Remove CPP Preferences page from WPILib preferences (code has already been deleted)
6c28e0966 Updated bootstrap file to install the new toolchains
8199fb28d Updating template .cproject to avoid specifiyng commands and defaults Fixes unknown GCC errors (supposedly)
f2920fd77 Enable C++14 and Wextra
ebd9667ba Expose and fix error where old subsystems were being referended after use in tests
3f0f7931b Changing cmake to test the tests (Jenkins)
cad83ed3c Bump the version number for the windows toolchains to force them to reload.
62d657942 Add missing semi-colon to cproject file
1d7b17a2b Merge "Add quotes around linker flag path to libs (fixes artf2390 / artf3453)"
738859c4e Fixed bug where mac toolchains always reinstall on Eclipse start
127ff0ac0 Fixing extraction recursion: use provided version
472f51fc7 Add version=current to global wpilib.properties file on any property save
887a4e94f Add error message to new project wizard if project already exists
0f0850ca9 Merge "Update to v14 headers and libraries"
ab27f795b Update to v14 headers and libraries
b16a03775 Store preferences in a directory writable by lvuser
1e812ac4d Added comments to the compressor class per artf3527.
ecc6815f6 Merge "Fix status buffer allocation in SolenoidBase"
ca9f5a676 Merge "Make all channel errors throw IndexOutOfBounds"
debf9e0ee Make all channel errors throw IndexOutOfBounds
15abbb36c Fix status buffer allocation in SolenoidBase
d9b974300 Add quotes around linker flag path to libs (fixes artf2390 / artf3453)
e60baf41a Added the "version=current" property to allow projects to correctly reference the updated installation
09cb3a22c Merge "Change the tail command for capturing the logs on deployment to check the file every second instead of continuously to avoid the 100% CPU time problem from artf3524"
27ecd3583 Change the tail command for capturing the logs on deployment to check the file every second instead of continuously to avoid the 100% CPU time problem from artf3524
ff6d18030 Revert "Fixing java version number to be current"
410b739c2 Fixing java version number to be current
2144b853d Set the cpp-version variable per-project
f87c517e6 Merge "Remove Version number from zips"
77dac9bd7 Remove Version number from zips
56cf287b3 Merge "require pthread and rt lib for Itests"
dc970d9a6 require pthread and rt lib for Itests
da2ea9ea8 remove/fix references to cRIO documentation. Edited comments related to sidecar, breakout, 9472. Some references were to unused methods in simulation that were removed.
b1ace7937 Fixes the MotorEncoderTest sometimes failing because a counter registers movement from the jaguar after reset.
2a8ade093 Adds the ability to run test classes with --repeat rule.
b7458e7ba Merge "Make Talon the default speed controller for RobotDrive"
3fddee51c Make Talon the default speed controller for RobotDrive
21967fcb2 Merge "Fixes testing framework typos & adds rule to keep unix line endings for .sh"
9b896eab7 Make DoubleSolenoid work in Java [artf3457]
f439adc2a Merge "fix for Artifact artf3431 : Solenoids initialize to random/arbitrary stat"
67cb85467 Fixes testing framework typos & adds rule to keep unix line endings for .sh
ef7c55402 Merge "Wrap CPP Lib and Include paths in quotes (fixes artf2390)"
359b4ec86 Merge "Added support for 32-bit builds."
21153fc63 Merge "Fix artf3476 move RobotState and HLReporting implementation set to somewhere they will get called"
daa8bd67e Added support for 32-bit builds.
e5e568fa7 Wrap CPP Lib and Include paths in quotes (fixes artf2390)
c9f6fcd96 Fix artf3447 Java only runs teleop - Correct off by one error in Control Word compares
778620b0a Fix artf3476 move RobotState and HLReporting implementation set to somewhere they will get called
d58c6f0c0 Merge "Kill program before debugging C++ so file upload doesn't fail"
a14d85421 Cpp tests without color for jenkins. Fixes startDS to not kill the driver station.
c5fc1dc5b Merge "Change SampleRobot template to use 0 based PWM"
cded5351d Test scripts have permission to run and fixes sshpass.
47169e0ce Adds test scripts to deploy, run and retrieve results from integration tests.
4ef798a0c Merge "Updates gitignore to use a file generated using http://www.gitignore.io"
7ec8d4e9a Updates gitignore to use a file generated using http://www.gitignore.io
17e7fc8f2 fix for Artifact artf3431 : Solenoids initialize to random/arbitrary stat
023f955a5 Change SampleRobot template to use 0 based PWM
52e358c18 Merge "Add Preferences to simulation"
7638e2b6e Kill program before debugging C++ so file upload doesn't fail
f9ab84d91 Integration tests now run with the Ant Junit test framework.
04fadb85f Add Preferences to simulation
698b371b1 Merge "Add OI and RobotMap files to Command Project template (fixes artf2407)"
6dde2c2b4 Merge "Adds interrupts to Java"
8ba0eada1 Adds interrupts to Java
bf5eaf657 Add OI and RobotMap files to Command Project template (fixes artf2407)
3baaea5a4 Squashed commit of the following:
2cc937f5e Fixes debugging in Java
23b6a980c Merge "Uses ${ant.java.version} for javac when compiling"
89b80db2d Merge "Fix PIDError property"
1f27d3688 Fix PIDError property
125dfac8b Merge "Fix Java IT build"
4215d1c79 Fix Java IT build
dddba82d1 Fix artf3337 - add include to define int32_t in CounterBase.h
78e2a8d1b Uses ${ant.java.version} for javac when compiling
687bc44ae Add new CTRE classes and update PDP tests
c82a94b26 Merge "Make Java tests run with TestNG"
d407fe546 Merge "Fixes for simulation parallel builds."
699949fdf Fixes for simulation parallel builds.
6d8997401 Make Java tests run with TestNG
e52315750 Merge "Fixed bug with joystick buttons/axes out of range."
3eba1c468 Merge "Add delays to make C++ ITs more reliable"
d466d17ed Add delays to make C++ ITs more reliable
9dfd6bde9 Adds a Vagrant configuration file and setup script
eded28ebf Fixed bug with joystick buttons/axes out of range.
c68ee3001 Added message to notify when simulation is unsupported.
777dc2113 Merge "Updated installer to point to the new location."
174f2c0e2 Merge "Increased build speed + caching of debs."
434caf81d Merge "Add back SampleRobot Template Add GettingStarted example based on IterativeRobot"
932717006 Merge "Beginning of gradle conversion."
597e209c0 Add back SampleRobot Template Add GettingStarted example based on IterativeRobot
ad1ace102 Increased build speed + caching of debs.
70d09de2e Fixed frcsim script to have the proper LOAD_LIBRARY_PATH.
f7e1753e0 Fix C++ linker settings
df3f3cc0e Updated installer to point to the new location.
25308e244 Beginning of gradle conversion.
6b3e2690d Fixed placement of libWPILibAthena.a
ae10d4390 Fixes for examples and Gazebo 3.1.
d4e377fc0 Merge "Adds the Trigger template and adds WPILib.h import to all templates"
9126646fe Adds the Trigger template and adds WPILib.h import to all templates
d3f632486 Merge "Added support for Jenkins to generate doxygen."
268459206 Added support for Jenkins to generate doxygen.
df390c275 Merge "Merged sources in wpilibJavaFinal."
1742634a9 Merge "Fix the example programs"
0f8f83500 Merged sources in wpilibJavaFinal.
d5c73c95d Fix the example programs
ca7dc5d6a Removed excessive linking.
66e1f2a18 Fixed a few bugs with C++ due to the merge.
1301d76d6 Fixes for HLUsageReporting due to Jonathan's exceptions.
a72ea14f9 Removed Simple Robot template option
14b2f1466 Merge "Implement DriverStation::GetBatteryVoltage"
d2cd5f357 Implement DriverStation::GetBatteryVoltage
7ecde3a33 Merge "Fix the default C++ linker settings"
81143fc53 Merge "Adds Exception throwing the basic robot systems are not properly initialized."
c58a86a3a Fix the default C++ linker settings
2f655bb49 Merge "Fixed bug with plugins not including all simulation dependencies."
657054c9e Fixed bug with plugins not including all simulation dependencies.
f4d542b21 Add FakeEncoderTest for C++
8db11a4c6 Fix to deal with the certificates on collabnet having expired.
14d784bca Fix import, resolves artf3339
7c8124d76 Allowed sharing of common C++ code between RoboRIO and Simulation.
b371600f0 Merge "Completed artf2675 - rename SimpleRobot -> SampleRobot."
6c3b002a8 Merge "Refactors the CANJaguar tests to be more straightforward."
0f9324764 Completed artf2675 - rename SimpleRobot -> SampleRobot.
54439e719 Refactors the CANJaguar tests to be more straightforward.
5b8279f40 Remove old driver station code
8abbcf53f Update to the v13 headers and libraries
b8eeeabbb Merge "Removes encoder.start() from the example programs"
9a2bd8c49 Removes encoder.start() from the example programs
4db634b34 Fix PCM channel indexes
57e670c18 Merge "Move PWM allocation to HAL to allow for checking against DIO allocation Re-number MXP DIO to match pinout (include SPI and I2C pins) (fixes artf2664) Change PWM MXP mapping to accommodate DIO re-mapping This re-implementation also fixes artf2668 for C++ and Java Change the test bench to reflect this change also"
59473ab7a Move PWM allocation to HAL to allow for checking against DIO allocation Re-number MXP DIO to match pinout (include SPI and I2C pins) (fixes artf2664) Change PWM MXP mapping to accommodate DIO re-mapping This re-implementation also fixes artf2668 for C++ and Java Change the test bench to reflect this change also
d1d4c7521 Merge "Fixed interrupt freeing in C++"
2356008d8 Fixed interrupt freeing in C++
deb335d96 Fixed DoubleSolenoid, added a double solenoid test
1ce03b9c4 DoubleSolenoid works in C++ now
a09f75934 The output range can be set on a PIDSubSystem
aab98c063 Adds Exception throwing the basic robot systems are not properly initialized.
741e28b85 Merge "Added version numbers to maven plugins"
f817f6d04 Added version numbers to maven plugins
7442a7ed7 Merge "Only update FRC Java Projects (fixes artf2627)"
765198f5f Merge "Updated some comments that mention the cRIO"
ed08ab298 Fixed voltage range checking and error message
4b22742cd Merge "Cleaned up C++ compiler warnings"
45f93e9ab Merge "Added support for building debs on jenkins."
049377c9e Added support for building debs on jenkins.
f4ace4a36 Cleaned up C++ compiler warnings
9ff420547 Updated some comments that mention the cRIO
1be31431b Merge "Removed the User LED functions"
32cafd0ef Removed the User LED functions
0216d1b33 Merge "Gyro deadband defaults to 0"
43c566bd8 Gyro deadband defaults to 0
b86c74722 Only set up once in the C++ tests
60a3fd069 Added gyro deadbands
b86c11493 Only update FRC Java Projects (fixes artf2627)
14f201cd3 Merge "getAnalogAverageValue should use a 32-bit int"
c49ea255b getAnalogAverageValue should use a 32-bit int
065e1c24e Update plugin menu text and make template menu options only show for correct language (fixes artf2408)
ecdb77e4b Update plugin target to use mDNS (causes Java debug to now use mDNS)
10aad6d1c Merge "Fixed a few more small TODOs"
e73c8d06e Fixed a few more small TODOs
dc341a448 Fixed a few simple SmartDashboard FIXMEs and TODOs
d521eb79b Analog interrupts in C++
f57a2dc5a Merge "Change deploys to use MDNS and to retry tail on missing file (fixes artf2663)"
7006d1ebc Change deploys to use MDNS and to retry tail on missing file (fixes artf2663)
c32e5707d Merge "Remove extra semi-colon"
c27da3587 Merge "Added an interrupt test for C++"
f18cccbc3 Remove extra semi-colon
b91b68143 Added an interrupt test for C++
b26667f86 Fixed the PCM test solenoid numbers
792e3b6cc Removed modules from the HAL and JNI bindings
fd4379a94 Makes the Counter.Mode an enum and adds Null Checking
a40cdf519 Implements the AnalogTriggerType as an enumeration
ba4e74d29 AnalogTrigger support in Java
38583789b Fixes the TiltPanCamera test (now GyroTest)
45e43b627 Merge "Changes the name of the AccelerometerTest to BuiltInAccelerometerTest"
e837d9083 Changes the name of the AccelerometerTest to BuiltInAccelerometerTest
e0e2b498a Merge "Accumulators wait for the next sample after reset"
8fe888dbc Accumulators wait for the next sample after reset
41bb0da4e Merge "Fixes bugs with the Gyro"
97ade3606 Fixes bugs with the Gyro
2735406bf Merge "Added a Java internal accelerometer test"
ab04e19aa Added a Java internal accelerometer test
a58288ae6 Merge "Refactors the RobotBase Setup into a method."
7905259e2 Refactors the RobotBase Setup into a method.
f018689d0 Merge "Completed artf2662: removed Start()/Stop() in Encoders and Counters."
0bb13d86e Completed artf2662: removed Start()/Stop() in Encoders and Counters.
526df3679 Merge "Added a C++ Preferences test"
d8da3e5f1 Added a C++ Preferences test
c0af23505 Removes the dependency-reduced-pom.xml from the repository.
7f6ca6824 Merge "HALInitialize should be the first thing called"
231bb55b2 HALInitialize should be the first thing called
76e488061 Removed cRIO tests, NetBeans stuff, and Ant stuff
5e8ea3846 Merge "Fixes the PDP test."
a5b72d62a Remove the last obsolete interface
a5e15b16f Fixes the PDP test.
264c38a67 Merge "Removed the old "parsing" interfaces"
20de3abe8 Merge "Updates the TimerTest to give a clearer output."
3536d4783 Updates the TimerTest to give a clearer output.
60a294fba Removed the old "parsing" interfaces
dc42a1129 Merge "The LiveWindow instance isn't a global static"
386dc1f16 Added AnalogTrigger tests
038478e43 The LiveWindow instance isn't a global static
26e90a988 Merge "Adds/Updates CANJava Testing Framework."
d5cd47bfa Merge "Minor updates to the C++ CANJaguar ITs"
1e35ef780 Adds/Updates CANJava Testing Framework.
65607b5bc Merge "Fixed CANJaguar::GetOutputVoltage for negative voltages"
30c0cc056 Minor updates to the C++ CANJaguar ITs
92bd69741 Fixes a bug where the testing framework would never set the implementation for the libraries.
ed0df5432 Fixed CANJaguar::GetOutputVoltage for negative voltages
6deb196e9 Support for the "USER" button on the RoboRIO
8b612f713 Merge "CANJaguar::Disable stops periodic setpoints"
d66bafb68 CANJaguar::Disable stops periodic setpoints
78d2ccd29 Merge "Added stack traces and better error reporting in C++"
06d59447b Merge "Adds missing Javadocs and @Overrides annotations to the PIDController in Java"
3475a4a8c Adds missing Javadocs and @Overrides annotations to the PIDController in Java
6af242b55 Merge "Fixes for javadoc eclipse plugin."
c72e70439 Fixes for javadoc eclipse plugin.
89fe909ae Added stack traces and better error reporting in C++
c1d8e4ef4 Make AnalogInput PIDGet return an average voltage. artf2391 for Java. Equivalent to Ia7f06ca2 Previously it returned a raw value instead of a voltage.
338120c3a Merge "Fixed wpi_setErrnoError to print the error name"
a7efbe0d7 Merge "Fixed Preferences in C++"
4c7828030 Merge "Correct voltage range in javadocs for RoboRIO"
5a3889a3a Correct voltage range in javadocs for RoboRIO
2fd4964b6 Merge "ADXL345_I2C: Make constructor explicit."
6ae639454 Merge "AnalogPotentiometer: Make constructors explicit."
310151132 AnalogPotentiometer: Make constructors explicit.
7f4e1e39a ADXL345_I2C: Make constructor explicit.
eebdc3d20 BuiltInAccelerometer: Add virtual destructor.
980ea96b0 Fixed Preferences in C++
1038f98e8 Fixed wpi_setErrnoError to print the error name
326aa2e85 Fixed a typo with the tGlobal commit
6071fc7fb Fixed CANJaguar percent scaling issue [artf2637]
f958b65ba CANJaguar can be disabled [artf2647]
f4f7588cf Merge "A few small changes to the C++ ITs"
80ecff6bd Merge "AnalogInput::PIDGet returns an average voltage[artf2391]"
e487c950e Merge "Only create one tGlobal object"
191e9d5d6 AnalogInput::PIDGet returns an average voltage[artf2391]
40fc8326a Only create one tGlobal object
fdbe750d3 A few small changes to the C++ ITs
3ec797a8c Updates the CANJaguar to free itself before throwing an exception in the constructor. This allows it to be allocated later without throwing an Allocation exception.
78e6cf720 Updates the AbstractComsSetup message to report JUnits multiple exceptions correctly. Adds a simple logger to the AbstractComsSetup that prints messages to the console based on the log level. Replaces all System.out prints with TestBench.out()
2481e98bc Fixes a deallocation of the Relay resource when calling free. Changes fake "Enum Classes" into real Enumerations
c81d510eb CANJaguar::ChangeControlMode marks the controlmode as unverified
3fb415910 Merge "Added missing call to m_ds.waitForData()"
2e1bd171a Added missing call to m_ds.waitForData()
25e7a077c Merge "Implemented FRCSim artf2628, fixed bugs in non-sim Relay.java and sim PWM.cpp."
dc48dc7f7 Implemented FRCSim artf2628, fixed bugs in non-sim Relay.java and sim PWM.cpp.
2dd45c3ea Fixed FRCSim artf2619, and misc reformatting.
461e35948 Merge "Remove the Kinect code from C++"
78dac49cf Remove the Kinect code from C++
66ba9a728 Fixed some bugs with CANJaguar verification in Java
c3d1e80a6 Merge "Fixed some bugs with CANJaguar verification in C++"
01ca19f78 Merge "Added a Jaguar brownout test in C++, cleaned up some C++ tests"
202bfb295 Added a Jaguar brownout test in C++, cleaned up some C++ tests
b0369342e Fixed some bugs with CANJaguar verification in C++
26d101caf Restructure WPILibJ to share code.
e84e0ebab Updates the TestBench to use parameters to run specific test methods or test/suite classes. Updates the test bench to only print "Waiting for enable" on one line with a counter. Updates all SubSuites to extend the AbstractTestSuite class. Also includes a small set of tests to prove the validity of the base AbstractTestSuite
0704a697c Merge "Updated the C++ TiltPanCameraTest"
13f97bb6e Merge "Added an Accelerometer interface"
5eddb69aa Updated the C++ TiltPanCameraTest
41c2b9402 Added an Accelerometer interface
99632e003 Merge "Fixed the Command-Based Robot template [artf2550]"
fe12394c9 Fixed the Command-Based Robot template [artf2550]
fbf196763 Merge "Removed AnalogModule, DigitalModule, and Module from C++"
b5fb35c0c Removed AnalogModule, DigitalModule, and Module from Java
48e8b2136 Merge "Add support for downloading models hosted on FIRSTForge."
e962c770b Merge "Fixed installation of frc_gazebo_plugins and a few minor fixes."
1b7a352cb Add support for downloading models hosted on FIRSTForge.
1a77cea13 Removed AnalogModule, DigitalModule, and Module from C++
afa39deec Fixed installation of frc_gazebo_plugins and a few minor fixes.
f27e16735 Adds resource tracking to CANJaguar in C++
d8a5ced01 Merge "Fixes a bug with ErrorBase where the correct error code would not be set when using wpi_setWPIErrorWithContext()"
8fe606a4b Fixes a bug with ErrorBase where the correct error code would not be set when using wpi_setWPIErrorWithContext()
6053a0cc2 Added BuiltInAccelerometer in Java and updated C++
be106b352 Merge "Added a C++ built-in accelerometer class"
ebaf2ef05 Merge "Added HAL methods for using the built-in accelerometer"
9f1a9a07c Added a C++ built-in accelerometer class
ec2a455bc Added HAL methods for using the built-in accelerometer
3d740a9a2 Adds Resource tracking to CANJaguar
1dd1e0be1 Merge "Adds a Unit Test for the Resource object in Java. Fixes a bug in the Resource class caused by allocating a negative resource value."
437e3ff26 Adds a Unit Test for the Resource object in Java. Fixes a bug in the Resource class caused by allocating a negative resource value.
f373c8708 Merge "The camera fixture tests now include an SPI accelerometer test"
54a657a7d The camera fixture tests now include an SPI accelerometer test
60d8508a6 Fix artf2636 Don't consume ByteBuffer when checking class specific status
02a28c8f0 Add allocation checking for I2C MXP. Update DIO counts in Lib layer until resource checking moves down to HAL
b12882897 Update Digital Pin count to reflect full 16 DIO on MXP
1a1a12316 Remove JNA hack no longer being used
d0fdb3e70 Merge "Port SPI to roboRIO. Java SPIDevice renamed to SPI and rewritten to match C++ API."
5d2e20eae Merge "More CANJaguar integration tests"
fc0eb4e95 Adds/updates the documentation for the CANJaguar Classes for C++ & Java. Also removes private unused methods in Java and an unused constructor.
968b69d37 More CANJaguar integration tests
343c7f4f3 Port SPI to roboRIO. Java SPIDevice renamed to SPI and rewritten to match C++ API.
80c5c09f7 Merge "Encoders and counters work on the MXP"
cb9df310d Encoders and counters work on the MXP
f566c087d Fix a few wrong messages in CANJaguar
7ca1b498e Merge "Added generic CAN methods to the HAL"
8bba58b9a Added generic CAN methods to the HAL
8ae64a12e Removed modules from the simulation infrastructure and refactored FRCPlugin.
3b4718fc9 Merge "Fixed FRCSim artf2609 - double ports handled wrong."
5800af49b Merge "Fixed FRCSim artf2599."
63fc4f6cf Merge "Makes the tests take parameters at runtime so that you can selectively run a suite without having to run the entire framework."
8b770ffb4 Makes the tests take parameters at runtime so that you can selectively run a suite without having to run the entire framework.
55fde6b61 Fixed FRCSim artf2609 - double ports handled wrong.
5ddacb43c Fixed FRCSim artf2599.
65c3c0ba0 Merge "Updated the HAL, wpilibj, and wpilibc for PCM and PDP"
fc3ed33f7 Merge "PDP and PCM updated to rely on CtreCanNode parent class, which uses new CAN API. CtreCanNode registers the periodic tx messages and provides an rx function to child classes for easy getters and setters. Some template magic to make the PDP and PCM getters/setters easy to stamp out."
255a3a5b1 Updated the HAL, wpilibj, and wpilibc for PCM and PDP
0ef5c3adf PDP and PCM updated to rely on CtreCanNode parent class, which uses new CAN API. CtreCanNode registers the periodic tx messages and provides an rx function to child classes for easy getters and setters. Some template magic to make the PDP and PCM getters/setters easy to stamp out.
37ebcabc4 Merge "Fixed periodic voltage status message"
244ee8d92 Merge "Fixed C++ deploy in Eclipse"
b97d2eb0c Fixed periodic voltage status message
ae8d22b0f Fixed C++ deploy in Eclipse
ff8016c08 Merge "Fixes CounterTest for C++"
f0fb3023a Merge "CANJaguar uses periodic status updates [artf2621]"
1d33edffe Fixes CounterTest for C++
5bd546f1f CANJaguar uses periodic status updates [artf2621]
d8003899f Merge "Fixed FRCSim artf2615: added more thorough cleaning system to Makefile."
f7bb5cd8f Merge "Re-tuned PID for PacGoat."
4f2d1d9d3 Fixed FRCSim artf2615: added more thorough cleaning system to Makefile.
981f941ca Changed .gitattributes to keep Unix line endings in the robot scripts
5ca2506a7 Merge "Fixed Java deploy script"
25f65a158 Merge "Java Ant script now works with run-at-startup"
15212967e Fixed Java deploy script
2aa030170 comment change
455506976 Merge "Made Java deploy work with run-at-startup"
ef5729b3d Made Java deploy work with run-at-startup
256b052a5 Java Ant script now works with run-at-startup
56cf73168 Re-tuned PID for PacGoat.
0926fa493 Merge changes I7e8735d9,Ida66361c
4de246876 Adds/Formats the CANJaguar.set() Javadocs
130485d76 Adds CANJaguar integration tests testing that in every control mode the motors can be rotated Adds a separate test suite for explicitly testing CAN
3b6e5b9b1 Merge changes I59b6180e,Ic86e922b
b2000a20d * Fix issue if I2C initialized before DigitalSystem.
9e6d04b2e Added v10 libraries
f380d9c10 Corrected the number of CAN init attempts in C++
1ba20bc1e added space for testing gi review
a0799718f Merge "Fixes a bug in the TiltPanCameraFixture that would cause the test to freeze and never complete instead of failing"
afe1b0b34 Merge "Adds CANJaguar Java Tests to the Integration Test Suite -Makes the MotorEncoderFixture Generic for a specific motor type -Adds Methods on the FakePotentiometerSource to allow raw values to be set -Adds Runtime Printing of the Tests to indicate where we are in the program if something unexpected happens"
072b92e55 Fixes a bug in the TiltPanCameraFixture that would cause the test to freeze and never complete instead of failing
b27791544 Adds CANJaguar Java Tests to the Integration Test Suite -Makes the MotorEncoderFixture Generic for a specific motor type -Adds Methods on the FakePotentiometerSource to allow raw values to be set -Adds Runtime Printing of the Tests to indicate where we are in the program if something unexpected happens
e4e199f06 Added support for simulation time.
15e378180 Merge "Fixed C++ side of artf2604 in FRCSim - synchronized C++ codebases, updated examples."
606eaa67b Merge "CANJaguar waits in the constructor for initial status data"
6273a407e Merge "Added a C++ CANJaguar test for initial status data"
1cafebc5a CANJaguar waits in the constructor for initial status data
06f8ff922 Added a C++ CANJaguar test for initial status data
cc76500fd Merge "* Add WriteBulk and ReadOnly to C++ I2C"
ff597e6ac Fixed C++ side of artf2604 in FRCSim - synchronized C++ codebases, updated examples.
02e19a014 Merge "Added PacGoat code for C++."
c7e17b8e3 Added PacGoat code for C++.
41897af45 Merge "CANJaguar in Java now requires control mode configuration data at compile time"
73ed1d42e Merge "CANJaguar in C++ now requires control mode configuration data at compile time"
f3593c698 CANJaguar in Java now requires control mode configuration data at compile time
abed665c6 CANJaguar in C++ now requires control mode configuration data at compile time
945c7519e Merge "Fixed Java PCM test"
81a0664c5 Fixed Java PCM test
12af2db15 Merge "Java CANJaguar changes"
1c8cd1dab Merge "Adds a missing Hamcrest dependency for the Java Integration Test system"
df9b702e0 Adds a missing Hamcrest dependency for the Java Integration Test system
0d62d0985 Added C++ support for solenoids.
1bbf35081 Java CANJaguar changes
31ab66ba2 Merge "Added support for PacGoat robot for artf2591."
de9657760 Adds an error if you try to use SetVoltageRampRate in the wrong control mode
605148456 * Add WriteBulk and ReadOnly to C++ I2C
40628a817 Added support for PacGoat robot for artf2591.
0f8c83f69 Merge "Adds CommandTests to the C++ Integration Test Suite Also adds/updates some comments in the Java Command Tests"
61ca86511 Adds CommandTests to the C++ Integration Test Suite Also adds/updates some comments in the Java Command Tests
f5862582e FRCSim artf2604: Synchronized the codebases of WPILibJ-Simulation and the main WPILibJ.
698f38d40 Fixed FRCSim artf2594 - JavaGazebo no longer crashes if gzserver hasn't started, and cleaned up some code in the area.
e9ade472e Merge "Updated CAN Jaguar for C++"
21b58aebd Updated CAN Jaguar for C++
08ed0b286 Fixed eclipse bug on windows when not run from command prompt.
801efe601 Merge "Makes the ToolChain Plugins platform specific so that you can no longer install multiple versions of the tool chains simultaneously. [artf2558]"
3927967ac Merge "Added PDP tests for java and C++, updated TestBench.h"
2cc2e6a9e Added PDP tests for java and C++, updated TestBench.h
2cb9d55ef Makes the ToolChain Plugins platform specific so that you can no longer install multiple versions of the tool chains simultaneously. [artf2558]
f598abf5b Fix FRCSim artf2589 and cleanup the surrounding code.
e69c1ea19 Merge "Some much need love for the eclipse plugins."
1fb6d9fd0 Updates/Tests the AnalogPotentiometer New constructor for the AnalogPotentiometer to allow users to pass it an AnalogInput into the constructor New FakePotentiometerSource to emulate a AnalogPotentiometer
60cfabca8 Merge "Changed the AnalogPot.cpp class, added AnalogPot test for CPP"
71a66d01c Changed the AnalogPot.cpp class, added AnalogPot test for CPP
c106939bc Some much need love for the eclipse plugins.
4a5a14ad8 FRCSim installation script upgrades to fix artf2579: Improved error-handling, added environment checking, added uninstallation option.
52654851d Add C++ Counter Test
d9c1a4edf Fixes for building the Java plugin to include the JNI.
9ff741278 Fixes for rebasing.
bd1aea0d2 Adds RelayCrossConnect tests as well as AnalogCrossConnect tests for java Also splits up the tests into multiple TestSuites so that the they are explicitly associated with the tests in the package that they are running
fc2f0e37b Adds JNI methods for the new CANSessionMUX
974362bd8 Updates CANJNI.cpp so that it compiles properly (CAN NOT WORKING)
85dff7d2e New netcomms .so and headers.
58021f739 Removed analog and digital module numbers
aa3b24092 Adds several more tests to the PID Test Class Adds Logger output to tests when they fail to allow the rest of the tests to run while you can follow the failure stack trace. This allows you to begin working on fixing the failure before the remainder of the tests have run.
fdfc33a38 Merge "Removes the print line from the Preferences class so that the write method no longer causes a system print"
4be3bc25a Removes the print line from the Preferences class so that the write method no longer causes a system print
c7e7f39c4 Merge "Updates the PID.free() method to release the NetworkTable listener. [artf2571] Documentation update on the Depreciated method. Removes the PID.setTolerance(Tolerance tolerance) method because it was private and never used"
94894931a Updates the PID.free() method to release the NetworkTable listener. [artf2571] Documentation update on the Depreciated method. Removes the PID.setTolerance(Tolerance tolerance) method because it was private and never used
cb56c9a14 Initial commit of the WPILib simulation support in an alpha quality state.
d5a509c7e Merge "Changed AnalogChannel to AnalogInput, added AnalogOutput for MXP"
3538e2c05 Changed AnalogChannel to AnalogInput, added AnalogOutput for MXP
a4708d850 Makes the PID Test run 10 times in order to determine how many times it fails out of 10 runs per motor. (Unstable Test!)
a46c24658 Moves the Talon to port 10 to reflect the hardware change
8d5c67e6a Added Omar's changes to the compressor interface
5d646536f C++ PCM integration tests
3c5d46c2a Merge "Added support for digital and analog IO pins on the MXP"
29c4534c5 Added support for digital and analog IO pins on the MXP
d019ec982 Merge "WPILibJ More Integration Tests Refactors the MotorEncoderTest to make use of the parameterized testing framework Adds a test for the Preferences Class Updates the TiltPanCameraTest to work Makes the TimerTest use math for long values Adds a Button Test to Test the internal Button Speeds up the FakeCounterSource/FakeEncoderSource to decrease test time Moves the AbstractComsSetup Block to a static method so that it only runs once Updates the logging.properties class so that tests are quieter"
81aab6645 Adds Java debug script and updates the Ant file to run with the plugins [artf2570]
8b19137ca WPILibJ More Integration Tests Refactors the MotorEncoderTest to make use of the parameterized testing framework Adds a test for the Preferences Class Updates the TiltPanCameraTest to work Makes the TimerTest use math for long values Adds a Button Test to Test the internal Button Speeds up the FakeCounterSource/FakeEncoderSource to decrease test time Moves the AbstractComsSetup Block to a static method so that it only runs once Updates the logging.properties class so that tests are quieter
85d9ead4e Sets the default PIDSourceParameter to be kDistance so there is no null pointer exception
eb00824a5 Updates the MotorEncoder and TestBench to clarify where setup/teardown methods are called
c90c38fa2 Adds a PIDTest to the integration tests. Contributors: Jonathan Leitschuh [artf2568]
59a1fb2c0 Makes the PIDController completely thread safe and ensures that freeing the PID Loop truly clears it [artf2567]
d418271a6 Updates the HAL to use the most recent control data [artf2557]
32dc451a7 Merge "Fixes the Preferences putting the preferences in a file 'file:' and instead puts it in the root directory [artf2566]"
63ae47b7e Fixes the Preferences putting the preferences in a file 'file:' and instead puts it in the root directory [artf2566]
35ac240d4 Switch to 0-based for all pins on the RoboRIO [artf2564]
59dfb4d21 Removed the old compressor code
cf798049e Disable driver station at C++ program start
a3e11f201 More C++ tests
09feff102 Integrates tests for Commands
97fead073 Merge "Adds/Updates the JavaIntegrationTest Framework"
70ccca881 Adds/Updates the JavaIntegrationTest Framework
c937c409a Made PIDController use pthreads in C++
36470d3b7 Made Java PCMCompressor methods public
4c61ab4ea Fixed C++ PWM values to be 16 bits
15c2798de Merge "Don't do doubles"
1e3a5389b Merge "Tilt pan camera test"
3227e779a Adds .cproject to the .gitignore to remove eclipse files
2e39540f2 Tilt pan camera test
bb50f4b13 C++ testing
a3b65a684 Don't do doubles
9a145db3d Merge "Updates the C++ servo class to have the PWM values that are on the spec sheet"
884a374f4 Updates the C++ servo class to have the PWM values that are on the spec sheet
187aa7a13 Support for the CAN power distribution panel
bf7ef4376 Changed the default logging level to WARNING This prevents excessive logging from the HAL. Put it back as needed
5d21444c4 Fixed a missing include
b219d1915 Fixed several files to use .hpp headers
2bf9db001 Merge "Adds/Extends several integration tests. Modifies Java Servo with correct values according to the datasheet assoiciated with the Hitec HS-322HD"
efeec5d98 Adds/Extends several integration tests. Modifies Java Servo with correct values according to the datasheet assoiciated with the Hitec HS-322HD
447cec4df Support for the CAN pneumatics module in C++ and Java
980d52bec Support for the CAN pneumatics module in C++ and Java
9b831ed34 Reverting back to static .a files for C++ and fixing lots of other assorted items
c1482cb26 Made CAN actually work in Java
db940d8c4 Adds Integration tests for WPILib
859983049 Added in LiveWindow initialization code, and the network tables dependecies for WPILibJ. - Fredric Silberberg
609fbfd8f Merge "Adds the Accumulator code to the AnalogJNI.cpp Disables the debug printlines from the AnalogJNI.cpp file"
6d8629a8b Adds the Accumulator code to the AnalogJNI.cpp Disables the debug printlines from the AnalogJNI.cpp file
04b6afb1c WPILibJ Integration Tests
6b83175b7 Merge "Fixed the package for CANJaguar.java"
9925598da Merge "Updated POM files to allow use of compile phase."
9a29c684a Fixed the package for CANJaguar.java
66c9aabec Merge "Updated CANJaguar.h/.cpp/.java for the RoboRIO"
736cb754f Updated POM files to allow use of compile phase.
b955ec994 Merge "Adds maven configuration information to use m2e This also removes all of the .project and .classpath files generated by eclipse"
da2e1769c Updated CANJaguar.h/.cpp/.java for the RoboRIO
85b0a46fd Adds maven configuration information to use m2e This also removes all of the .project and .classpath files generated by eclipse
ed6ac3bff Fixed digital channel routing
7e215ef18 Removed the old cRIO channel routing that was preventing encoders from working in C++
6e01adaa5 Revert "Modifies maven files to work with m2e" This commit causes Eclipse to give a vaugue error message when creating a new Robot Java Project or Robot C++ Project.
36241b0d6 Modifies maven files to work with m2e
12e811250 Driver Station
0227264de Merge "Added .classpath to the gitignore"
059cee8b2 Merge "Fixed the module order so the libraries are built before the plugins"
5d81894d1 Merge "WPILibJ Unit Tests"
21074eea4 Added .classpath to the gitignore
acb963612 WPILibJ Unit Tests
cdc94f062 Added .gitignore file
508425c97 Fixed some typos in pom files
9f64cf615 Fixed the module order so the libraries are built before the plugins
27896984f Added the new NI shared libraries and headers
848a043f9 Fixing some compile warnings in C++
1c943ff6f Changed the build.xml files to write the runjavaprogram and runcppprogram Still need to fix the debug c++, it has references to java
82795d6a3 Fix 2 path problems in some scripts
a42a7943b Init HAL from WPILibJ to remove segfaults
e4be9eb09 Added mvn profiles to define the cmake required properties depending on the build platform.
b7ad001b4 Fixing packaging
87e9b6ce5 toolchain name...
885c3ab83 reverting building opkg in maven/cmake (now uses ant)
af2368b6f Moving opkg build to deployment
c0222d4e2 Automatic SO downloading & updating
69d9ad70a CMake Changes
33134bef1 Java 8 Compilation Fixes
4546abc8c Version 4 Image
b1ef11610 Revert "Applied patch from Dustin Spicuzza to fix robot hang"
d3ef8de5e Applied patch from Dustin Spicuzza to fix robot hang
8d1fc91e8 .gitreview file
5f727e57a Eclipse toolchain installer now preserves executable bit on Linux
260636250 Changed the CPU Architecture
aad6d11f4 Renamed log.h to Log.h
938a422b2 Added human-readable error messages to the Maven and Java version enforcer rules
1a7526fc8 Disabled NetworkTables java Azalea build by default
5d1d9fcde Added enforcer rules to restrict Maven and Java versions
616acc26d Corrected incorrect relative path to parent POM
0d5410a11 Removed all repository definitions pointing to Jenkins (aka. frcbuilder)
3924a4b6f fixed the path name for sflt
aa40fd0c5 Replaced hardcoded forward slash with system correct separator
476dccdd3 Corrected <relativePath> that pointed to directory instead of pom.xml
bbc0a6b95 Corrected <relativePath> that pointed to directory instead of pom.xml
203debb46 Updated wpilibJavaJNI JDK include path to use default location in user's home directory
2bdd95d72 Set Azalea wpilibc off by default
9880ff3fd turn off network tables desktop and azalea builds by default
3e74499d4 Turn off Azalea hal by default
f2746b7d4 Merge branch 'master' of ssh://charris@usfirst.collab.net:29418/allwpilib
28848553a missing file from original commit and push
6a87f9057 Updated <relativePath> references to static-library
155af5966 Replaced hardcoded JDK include path with property
08d06bd22 Updated parent pom <relativePath> properties to be correct
f7146d423 JNI for java Normal vs recursive mutex HAL delineation
b62b60611 JNI implementation for Java Normal vs
4297b2bc9 Merge branch 'master' of ssh://usfirst.collab.net:29418/allwpilib
d09371bc0 Initial empty repository
3178911ee Initial checkin of unified hierarchy of WPILib 2015
REVERT: 00e090877 Fix bounds of SPI AutoRead sizes
REVERT: 8fce748cf Rename our allwpilib (which is now 2020) to not have 2019 in the name
Change-Id: I8247665e5386c0696e597eafeed095e26ef12c79
git-subtree-dir: third_party/allwpilib
git-subtree-split: 66b57f0323d55b8c875f0391f48e69880a3b4389
diff --git a/wpilibc/CMakeLists.txt b/wpilibc/CMakeLists.txt
index 977200a..6435040 100644
--- a/wpilibc/CMakeLists.txt
+++ b/wpilibc/CMakeLists.txt
@@ -17,14 +17,14 @@
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/wpilibc>)
wpilib_target_warnings(wpilibc)
-target_link_libraries(wpilibc PUBLIC cameraserver hal ntcore cscore wpiutil ${OpenCV_LIBS})
+target_link_libraries(wpilibc PUBLIC cameraserver hal ntcore cscore wpimath wpiutil ${OpenCV_LIBS})
set_property(TARGET wpilibc PROPERTY FOLDER "libraries")
install(TARGETS wpilibc EXPORT wpilibc DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpilibc")
-if (MSVC OR FLAT_INSTALL_WPILIB)
+if (WITH_FLAT_INSTALL)
set (wpilibc_config_dir ${wpilib_dest})
else()
set (wpilibc_config_dir share/wpilibc)
diff --git a/wpilibc/build.gradle b/wpilibc/build.gradle
index 4ee5766..ec85691 100644
--- a/wpilibc/build.gradle
+++ b/wpilibc/build.gradle
@@ -98,6 +98,7 @@
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
project(':hal').addHalDependency(it, 'shared')
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
+ lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
}
}
"${nativeName}"(NativeLibrarySpec) {
@@ -116,6 +117,7 @@
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
project(':hal').addHalDependency(it, 'shared')
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
+ lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
if (it instanceof SharedLibraryBinarySpec) {
cppCompiler.define 'DYNAMIC_CAMERA_SERVER'
@@ -152,6 +154,7 @@
lib project: ':cscore', library: 'cscore', linkage: 'shared'
project(':hal').addHalDependency(it, 'shared')
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
+ lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
@@ -201,6 +204,7 @@
lib project: ':cscore', library: 'cscore', linkage: 'shared'
project(':hal').addHalDependency(it, 'shared')
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
+ lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'opencv_shared')
lib library: nativeName, linkage: 'shared'
diff --git a/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp b/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp
index a760daa..aff0802 100644
--- a/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp
+++ b/wpilibc/src/main/native/cpp/ADXL345_I2C.cpp
@@ -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. */
@@ -21,7 +21,7 @@
m_simRange =
m_simDevice.CreateEnum("Range", true, {"2G", "4G", "8G", "16G"}, 0);
m_simX = m_simDevice.CreateDouble("X Accel", false, 0.0);
- m_simX = m_simDevice.CreateDouble("Y Accel", false, 0.0);
+ m_simY = m_simDevice.CreateDouble("Y Accel", false, 0.0);
m_simZ = m_simDevice.CreateDouble("Z Accel", false, 0.0);
}
// Turn on the measurements
diff --git a/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp b/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp
index 077a7ff..329b148 100644
--- a/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp
+++ b/wpilibc/src/main/native/cpp/ADXL345_SPI.cpp
@@ -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. */
@@ -20,7 +20,7 @@
m_simRange =
m_simDevice.CreateEnum("Range", true, {"2G", "4G", "8G", "16G"}, 0);
m_simX = m_simDevice.CreateDouble("X Accel", false, 0.0);
- m_simX = m_simDevice.CreateDouble("Y Accel", false, 0.0);
+ m_simY = m_simDevice.CreateDouble("Y Accel", false, 0.0);
m_simZ = m_simDevice.CreateDouble("Z Accel", false, 0.0);
}
m_spi.SetClockRate(500000);
diff --git a/wpilibc/src/main/native/cpp/ADXL362.cpp b/wpilibc/src/main/native/cpp/ADXL362.cpp
index 6ed8c8c..aff572f 100644
--- a/wpilibc/src/main/native/cpp/ADXL362.cpp
+++ b/wpilibc/src/main/native/cpp/ADXL362.cpp
@@ -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. */
@@ -40,7 +40,7 @@
m_simRange =
m_simDevice.CreateEnum("Range", true, {"2G", "4G", "8G", "16G"}, 0);
m_simX = m_simDevice.CreateDouble("X Accel", false, 0.0);
- m_simX = m_simDevice.CreateDouble("Y Accel", false, 0.0);
+ m_simY = m_simDevice.CreateDouble("Y Accel", false, 0.0);
m_simZ = m_simDevice.CreateDouble("Z Accel", false, 0.0);
}
diff --git a/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp b/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp
index 2cf2f73..8ea5b41 100644
--- a/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp
+++ b/wpilibc/src/main/native/cpp/ADXRS450_Gyro.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2015-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. */
@@ -32,7 +32,7 @@
ADXRS450_Gyro::ADXRS450_Gyro() : ADXRS450_Gyro(SPI::kOnboardCS0) {}
ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port)
- : m_spi(port), m_simDevice("ADXRS450_Gyro", port) {
+ : m_spi(port), m_port(port), m_simDevice("ADXRS450_Gyro", port) {
if (m_simDevice) {
m_simAngle = m_simDevice.CreateDouble("Angle", false, 0.0);
m_simRate = m_simDevice.CreateDouble("Rate", false, 0.0);
@@ -123,3 +123,5 @@
m_spi.SetAccumulatorIntegratedCenter(m_spi.GetAccumulatorIntegratedAverage());
m_spi.ResetAccumulator();
}
+
+int ADXRS450_Gyro::GetPort() const { return m_port; }
diff --git a/wpilibc/src/main/native/cpp/AddressableLED.cpp b/wpilibc/src/main/native/cpp/AddressableLED.cpp
index b0c3a45..81adc7b 100644
--- a/wpilibc/src/main/native/cpp/AddressableLED.cpp
+++ b/wpilibc/src/main/native/cpp/AddressableLED.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -94,36 +94,5 @@
}
void AddressableLED::LEDData::SetHSV(int h, int s, int v) {
- if (s == 0) {
- SetRGB(v, v, v);
- return;
- }
-
- int region = h / 30;
- int remainder = (h - (region * 30)) * 6;
-
- int p = (v * (255 - s)) >> 8;
- int q = (v * (255 - ((s * remainder) >> 8))) >> 8;
- int t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
-
- switch (region) {
- case 0:
- SetRGB(v, t, p);
- break;
- case 1:
- SetRGB(q, v, p);
- break;
- case 2:
- SetRGB(p, v, t);
- break;
- case 3:
- SetRGB(p, q, v);
- break;
- case 4:
- SetRGB(t, p, v);
- break;
- default:
- SetRGB(v, p, q);
- break;
- }
+ SetLED(Color::FromHSV(h, s, v));
}
diff --git a/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp b/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp
index be0c7d2..09bc2f5 100644
--- a/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp
+++ b/wpilibc/src/main/native/cpp/AnalogAccelerometer.cpp
@@ -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. */
@@ -9,6 +9,7 @@
#include <hal/FRCUsageReporting.h>
+#include "frc/Base.h"
#include "frc/WPIErrors.h"
#include "frc/smartdashboard/SendableBuilder.h"
#include "frc/smartdashboard/SendableRegistry.h"
@@ -52,8 +53,8 @@
void AnalogAccelerometer::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Accelerometer");
- builder.AddDoubleProperty("Value", [=]() { return GetAcceleration(); },
- nullptr);
+ builder.AddDoubleProperty(
+ "Value", [=]() { return GetAcceleration(); }, nullptr);
}
void AnalogAccelerometer::InitAccelerometer() {
diff --git a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp
index a194961..c1f4e8d 100644
--- a/wpilibc/src/main/native/cpp/AnalogEncoder.cpp
+++ b/wpilibc/src/main/native/cpp/AnalogEncoder.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -8,6 +8,7 @@
#include "frc/AnalogEncoder.h"
#include "frc/AnalogInput.h"
+#include "frc/Base.h"
#include "frc/Counter.h"
#include "frc/DriverStation.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -94,11 +95,13 @@
m_positionOffset = m_analogInput->GetVoltage();
}
+int AnalogEncoder::GetChannel() const { return m_analogInput->GetChannel(); }
+
void AnalogEncoder::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("AbsoluteEncoder");
- builder.AddDoubleProperty("Distance", [this] { return this->GetDistance(); },
- nullptr);
- builder.AddDoubleProperty("Distance Per Rotation",
- [this] { return this->GetDistancePerRotation(); },
- nullptr);
+ builder.AddDoubleProperty(
+ "Distance", [this] { return this->GetDistance(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Distance Per Rotation",
+ [this] { return this->GetDistancePerRotation(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/AnalogGyro.cpp b/wpilibc/src/main/native/cpp/AnalogGyro.cpp
index c891506..2ec4439 100644
--- a/wpilibc/src/main/native/cpp/AnalogGyro.cpp
+++ b/wpilibc/src/main/native/cpp/AnalogGyro.cpp
@@ -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. */
@@ -15,6 +15,7 @@
#include <hal/FRCUsageReporting.h>
#include "frc/AnalogInput.h"
+#include "frc/Base.h"
#include "frc/Timer.h"
#include "frc/WPIErrors.h"
#include "frc/smartdashboard/SendableRegistry.h"
@@ -160,3 +161,7 @@
HAL_CalibrateAnalogGyro(m_gyroHandle, &status);
wpi_setHALError(status);
}
+
+std::shared_ptr<AnalogInput> AnalogGyro::GetAnalogInput() const {
+ return m_analog;
+}
diff --git a/wpilibc/src/main/native/cpp/AnalogInput.cpp b/wpilibc/src/main/native/cpp/AnalogInput.cpp
index c8197b7..11c30ee 100644
--- a/wpilibc/src/main/native/cpp/AnalogInput.cpp
+++ b/wpilibc/src/main/native/cpp/AnalogInput.cpp
@@ -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. */
@@ -7,8 +7,6 @@
#include "frc/AnalogInput.h"
-#include <utility>
-
#include <hal/AnalogAccumulator.h>
#include <hal/AnalogInput.h>
#include <hal/FRCUsageReporting.h>
@@ -230,6 +228,6 @@
void AnalogInput::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Analog Input");
- builder.AddDoubleProperty("Value", [=]() { return GetAverageVoltage(); },
- nullptr);
+ builder.AddDoubleProperty(
+ "Value", [=]() { return GetAverageVoltage(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/AnalogOutput.cpp b/wpilibc/src/main/native/cpp/AnalogOutput.cpp
index 041b446..bd8126a 100644
--- a/wpilibc/src/main/native/cpp/AnalogOutput.cpp
+++ b/wpilibc/src/main/native/cpp/AnalogOutput.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -65,10 +65,11 @@
return voltage;
}
-int AnalogOutput::GetChannel() { return m_channel; }
+int AnalogOutput::GetChannel() const { return m_channel; }
void AnalogOutput::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Analog Output");
- builder.AddDoubleProperty("Value", [=]() { return GetVoltage(); },
- [=](double value) { SetVoltage(value); });
+ builder.AddDoubleProperty(
+ "Value", [=]() { return GetVoltage(); },
+ [=](double value) { SetVoltage(value); });
}
diff --git a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp
index b650ec7..c7aedd6 100644
--- a/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp
+++ b/wpilibc/src/main/native/cpp/AnalogPotentiometer.cpp
@@ -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. */
@@ -7,6 +7,7 @@
#include "frc/AnalogPotentiometer.h"
+#include "frc/Base.h"
#include "frc/RobotController.h"
#include "frc/smartdashboard/SendableBuilder.h"
#include "frc/smartdashboard/SendableRegistry.h"
@@ -34,7 +35,8 @@
}
double AnalogPotentiometer::Get() const {
- return (m_analog_input->GetVoltage() / RobotController::GetVoltage5V()) *
+ return (m_analog_input->GetAverageVoltage() /
+ RobotController::GetVoltage5V()) *
m_fullRange +
m_offset;
}
@@ -42,5 +44,7 @@
double AnalogPotentiometer::PIDGet() { return Get(); }
void AnalogPotentiometer::InitSendable(SendableBuilder& builder) {
- m_analog_input->InitSendable(builder);
+ builder.SetSmartDashboardType("Analog Input");
+ builder.AddDoubleProperty(
+ "Value", [=]() { return Get(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/AnalogTrigger.cpp b/wpilibc/src/main/native/cpp/AnalogTrigger.cpp
index ddbb7c8..45821ba 100644
--- a/wpilibc/src/main/native/cpp/AnalogTrigger.cpp
+++ b/wpilibc/src/main/native/cpp/AnalogTrigger.cpp
@@ -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. */
@@ -12,6 +12,7 @@
#include <hal/FRCUsageReporting.h>
#include "frc/AnalogInput.h"
+#include "frc/Base.h"
#include "frc/DutyCycle.h"
#include "frc/WPIErrors.h"
#include "frc/smartdashboard/SendableRegistry.h"
diff --git a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp
index d7cdef6..efc0fe6 100644
--- a/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp
+++ b/wpilibc/src/main/native/cpp/BuiltInAccelerometer.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -43,7 +43,10 @@
void BuiltInAccelerometer::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("3AxisAccelerometer");
- builder.AddDoubleProperty("X", [=]() { return GetX(); }, nullptr);
- builder.AddDoubleProperty("Y", [=]() { return GetY(); }, nullptr);
- builder.AddDoubleProperty("Z", [=]() { return GetZ(); }, nullptr);
+ builder.AddDoubleProperty(
+ "X", [=]() { return GetX(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Y", [=]() { return GetY(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Z", [=]() { return GetZ(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/CAN.cpp b/wpilibc/src/main/native/cpp/CAN.cpp
index 797b9ff..e56e435 100644
--- a/wpilibc/src/main/native/cpp/CAN.cpp
+++ b/wpilibc/src/main/native/cpp/CAN.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -70,6 +70,25 @@
wpi_setHALError(status);
}
+int CAN::WritePacketNoError(const uint8_t* data, int length, int apiId) {
+ int32_t status = 0;
+ HAL_WriteCANPacket(m_handle, data, length, apiId, &status);
+ return status;
+}
+
+int CAN::WritePacketRepeatingNoError(const uint8_t* data, int length, int apiId,
+ int repeatMs) {
+ int32_t status = 0;
+ HAL_WriteCANPacketRepeating(m_handle, data, length, apiId, repeatMs, &status);
+ return status;
+}
+
+int CAN::WriteRTRFrameNoError(int length, int apiId) {
+ int32_t status = 0;
+ HAL_WriteCANRTRFrame(m_handle, length, apiId, &status);
+ return status;
+}
+
void CAN::StopPacketRepeating(int apiId) {
int32_t status = 0;
HAL_StopCANPacketRepeating(m_handle, apiId, &status);
diff --git a/wpilibc/src/main/native/cpp/Compressor.cpp b/wpilibc/src/main/native/cpp/Compressor.cpp
index 29789be..e40758f 100644
--- a/wpilibc/src/main/native/cpp/Compressor.cpp
+++ b/wpilibc/src/main/native/cpp/Compressor.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -204,15 +204,18 @@
}
}
+int Compressor::GetModule() const { return m_module; }
+
void Compressor::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Compressor");
- builder.AddBooleanProperty("Enabled", [=]() { return Enabled(); },
- [=](bool value) {
- if (value)
- Start();
- else
- Stop();
- });
+ builder.AddBooleanProperty(
+ "Enabled", [=]() { return Enabled(); },
+ [=](bool value) {
+ if (value)
+ Start();
+ else
+ Stop();
+ });
builder.AddBooleanProperty(
"Pressure switch", [=]() { return GetPressureSwitchValue(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/Counter.cpp b/wpilibc/src/main/native/cpp/Counter.cpp
index d2158ca..ca74ab8 100644
--- a/wpilibc/src/main/native/cpp/Counter.cpp
+++ b/wpilibc/src/main/native/cpp/Counter.cpp
@@ -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. */
@@ -13,6 +13,7 @@
#include <hal/FRCUsageReporting.h>
#include "frc/AnalogTrigger.h"
+#include "frc/Base.h"
#include "frc/DigitalInput.h"
#include "frc/WPIErrors.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -332,5 +333,6 @@
void Counter::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Counter");
- builder.AddDoubleProperty("Value", [=]() { return Get(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Value", [=]() { return Get(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/DigitalInput.cpp b/wpilibc/src/main/native/cpp/DigitalInput.cpp
index 7210750..d82f570 100644
--- a/wpilibc/src/main/native/cpp/DigitalInput.cpp
+++ b/wpilibc/src/main/native/cpp/DigitalInput.cpp
@@ -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. */
@@ -8,7 +8,6 @@
#include "frc/DigitalInput.h"
#include <limits>
-#include <utility>
#include <hal/DIO.h>
#include <hal/FRCUsageReporting.h>
@@ -73,5 +72,6 @@
void DigitalInput::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Digital Input");
- builder.AddBooleanProperty("Value", [=]() { return Get(); }, nullptr);
+ builder.AddBooleanProperty(
+ "Value", [=]() { return Get(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/DigitalOutput.cpp b/wpilibc/src/main/native/cpp/DigitalOutput.cpp
index 6e9b09b..0bdc57c 100644
--- a/wpilibc/src/main/native/cpp/DigitalOutput.cpp
+++ b/wpilibc/src/main/native/cpp/DigitalOutput.cpp
@@ -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. */
@@ -8,7 +8,6 @@
#include "frc/DigitalOutput.h"
#include <limits>
-#include <utility>
#include <hal/DIO.h>
#include <hal/FRCUsageReporting.h>
@@ -154,6 +153,6 @@
void DigitalOutput::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Digital Output");
- builder.AddBooleanProperty("Value", [=]() { return Get(); },
- [=](bool value) { Set(value); });
+ builder.AddBooleanProperty(
+ "Value", [=]() { return Get(); }, [=](bool value) { Set(value); });
}
diff --git a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp
index c896ea8..67eb0b7 100644
--- a/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp
+++ b/wpilibc/src/main/native/cpp/DoubleSolenoid.cpp
@@ -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. */
@@ -92,6 +92,7 @@
bool forward = false;
bool reverse = false;
+
switch (value) {
case kOff:
forward = false;
@@ -106,6 +107,7 @@
reverse = true;
break;
}
+
int fstatus = 0;
HAL_SetSolenoid(m_forwardHandle, forward, &fstatus);
int rstatus = 0;
@@ -117,6 +119,7 @@
DoubleSolenoid::Value DoubleSolenoid::Get() const {
if (StatusIsFatal()) return kOff;
+
int fstatus = 0;
int rstatus = 0;
bool valueForward = HAL_GetSolenoid(m_forwardHandle, &fstatus);
@@ -125,9 +128,23 @@
wpi_setHALError(fstatus);
wpi_setHALError(rstatus);
- if (valueForward) return kForward;
- if (valueReverse) return kReverse;
- return kOff;
+ if (valueForward) {
+ return kForward;
+ } else if (valueReverse) {
+ return kReverse;
+ } else {
+ return kOff;
+ }
+}
+
+void DoubleSolenoid::Toggle() {
+ Value value = Get();
+
+ if (value == kForward) {
+ Set(kReverse);
+ } else if (value == kReverse) {
+ Set(kForward);
+ }
}
bool DoubleSolenoid::IsFwdSolenoidBlackListed() const {
diff --git a/wpilibc/src/main/native/cpp/DriverStation.cpp b/wpilibc/src/main/native/cpp/DriverStation.cpp
index 7c64883..dbb99f9 100644
--- a/wpilibc/src/main/native/cpp/DriverStation.cpp
+++ b/wpilibc/src/main/native/cpp/DriverStation.cpp
@@ -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. */
@@ -10,7 +10,6 @@
#include <chrono>
#include <hal/DriverStation.h>
-#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/Power.h>
#include <networktables/NetworkTable.h>
@@ -19,10 +18,8 @@
#include <wpi/SmallString.h>
#include <wpi/StringRef.h>
-#include "frc/AnalogInput.h"
#include "frc/MotorSafety.h"
#include "frc/Timer.h"
-#include "frc/Utility.h"
#include "frc/WPIErrors.h"
namespace frc {
@@ -68,6 +65,15 @@
static constexpr double kJoystickUnpluggedMessageInterval = 1.0;
+static int& GetDSLastCount() {
+ // 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{0};
+ return lastCount;
+}
+
DriverStation::~DriverStation() {
m_isRunning = false;
// Trigger a DS mutex release in case there is no driver station running.
@@ -325,6 +331,11 @@
return static_cast<bool>(descriptor.axisTypes);
}
+bool DriverStation::IsJoystickConnected(int stick) const {
+ return GetStickAxisCount(stick) > 0 || GetStickButtonCount(stick) > 0 ||
+ GetStickPOVCount(stick) > 0;
+}
+
bool DriverStation::IsEnabled() const {
HAL_ControlWord controlWord;
HAL_GetControlWord(&controlWord);
@@ -349,12 +360,24 @@
return controlWord.autonomous;
}
+bool DriverStation::IsAutonomousEnabled() const {
+ HAL_ControlWord controlWord;
+ HAL_GetControlWord(&controlWord);
+ return controlWord.autonomous && controlWord.enabled;
+}
+
bool DriverStation::IsOperatorControl() const {
HAL_ControlWord controlWord;
HAL_GetControlWord(&controlWord);
return !(controlWord.autonomous || controlWord.test);
}
+bool DriverStation::IsOperatorControlEnabled() const {
+ HAL_ControlWord controlWord;
+ HAL_GetControlWord(&controlWord);
+ return !controlWord.autonomous && !controlWord.test && controlWord.enabled;
+}
+
bool DriverStation::IsTest() const {
HAL_ControlWord controlWord;
HAL_GetControlWord(&controlWord);
@@ -367,7 +390,14 @@
return controlWord.dsAttached;
}
-bool DriverStation::IsNewControlData() const { return HAL_IsNewControlData(); }
+bool DriverStation::IsNewControlData() const {
+ std::unique_lock lock(m_waitForDataMutex);
+ int& lastCount = GetDSLastCount();
+ int currentCount = m_waitForDataCounter;
+ if (lastCount == currentCount) return false;
+ lastCount = currentCount;
+ return true;
+}
bool DriverStation::IsFMSAttached() const {
HAL_ControlWord controlWord;
@@ -448,7 +478,12 @@
std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
std::unique_lock lock(m_waitForDataMutex);
+ int& lastCount = GetDSLastCount();
int currentCount = m_waitForDataCounter;
+ if (lastCount != currentCount) {
+ lastCount = currentCount;
+ return true;
+ }
while (m_waitForDataCounter == currentCount) {
if (timeout > 0) {
auto timedOut = m_waitForDataCond.wait_until(lock, timeoutTime);
@@ -459,6 +494,7 @@
m_waitForDataCond.wait(lock);
}
}
+ lastCount = m_waitForDataCounter;
return true;
}
@@ -507,6 +543,14 @@
SendMatchData();
}
+void DriverStation::SilenceJoystickConnectionWarning(bool silence) {
+ m_silenceJoystickWarning = silence;
+}
+
+bool DriverStation::IsJoystickConnectionWarningSilenced() const {
+ return !IsFMSAttached() && m_silenceJoystickWarning;
+}
+
DriverStation::DriverStation() {
HAL_Initialize(500, 0);
m_waitForDataCounter = 0;
@@ -534,10 +578,12 @@
}
void DriverStation::ReportJoystickUnpluggedWarning(const wpi::Twine& message) {
- double currentTime = Timer::GetFPGATimestamp();
- if (currentTime > m_nextMessageTime) {
- ReportWarning(message);
- m_nextMessageTime = currentTime + kJoystickUnpluggedMessageInterval;
+ if (IsFMSAttached() || !m_silenceJoystickWarning) {
+ double currentTime = Timer::GetFPGATimestamp();
+ if (currentTime > m_nextMessageTime) {
+ ReportWarning(message);
+ m_nextMessageTime = currentTime + kJoystickUnpluggedMessageInterval;
+ }
}
}
diff --git a/wpilibc/src/main/native/cpp/DutyCycle.cpp b/wpilibc/src/main/native/cpp/DutyCycle.cpp
index 12f390e..7e4e98d 100644
--- a/wpilibc/src/main/native/cpp/DutyCycle.cpp
+++ b/wpilibc/src/main/native/cpp/DutyCycle.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -10,6 +10,7 @@
#include <hal/DutyCycle.h>
#include <hal/FRCUsageReporting.h>
+#include "frc/Base.h"
#include "frc/DigitalSource.h"
#include "frc/WPIErrors.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -93,8 +94,8 @@
void DutyCycle::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Duty Cycle");
- builder.AddDoubleProperty("Frequency",
- [this] { return this->GetFrequency(); }, nullptr);
- builder.AddDoubleProperty("Output", [this] { return this->GetOutput(); },
- nullptr);
+ builder.AddDoubleProperty(
+ "Frequency", [this] { return this->GetFrequency(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Output", [this] { return this->GetOutput(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp b/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp
index ea054ce..4fc5457 100644
--- a/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp
+++ b/wpilibc/src/main/native/cpp/DutyCycleEncoder.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -7,6 +7,7 @@
#include "frc/DutyCycleEncoder.h"
+#include "frc/Base.h"
#include "frc/Counter.h"
#include "frc/DigitalInput.h"
#include "frc/DigitalSource.h"
@@ -18,51 +19,37 @@
DutyCycleEncoder::DutyCycleEncoder(int channel)
: m_dutyCycle{std::make_shared<DutyCycle>(
- std::make_shared<DigitalInput>(channel))},
- m_analogTrigger{m_dutyCycle.get()},
- m_counter{} {
+ std::make_shared<DigitalInput>(channel))} {
Init();
}
DutyCycleEncoder::DutyCycleEncoder(DutyCycle& dutyCycle)
- : m_dutyCycle{&dutyCycle, NullDeleter<DutyCycle>{}},
- m_analogTrigger{m_dutyCycle.get()},
- m_counter{} {
+ : m_dutyCycle{&dutyCycle, NullDeleter<DutyCycle>{}} {
Init();
}
DutyCycleEncoder::DutyCycleEncoder(DutyCycle* dutyCycle)
- : m_dutyCycle{dutyCycle, NullDeleter<DutyCycle>{}},
- m_analogTrigger{m_dutyCycle.get()},
- m_counter{} {
+ : m_dutyCycle{dutyCycle, NullDeleter<DutyCycle>{}} {
Init();
}
DutyCycleEncoder::DutyCycleEncoder(std::shared_ptr<DutyCycle> dutyCycle)
- : m_dutyCycle{std::move(dutyCycle)},
- m_analogTrigger{m_dutyCycle.get()},
- m_counter{} {
+ : m_dutyCycle{std::move(dutyCycle)} {
Init();
}
DutyCycleEncoder::DutyCycleEncoder(DigitalSource& digitalSource)
- : m_dutyCycle{std::make_shared<DutyCycle>(digitalSource)},
- m_analogTrigger{m_dutyCycle.get()},
- m_counter{} {
+ : m_dutyCycle{std::make_shared<DutyCycle>(digitalSource)} {
Init();
}
DutyCycleEncoder::DutyCycleEncoder(DigitalSource* digitalSource)
- : m_dutyCycle{std::make_shared<DutyCycle>(digitalSource)},
- m_analogTrigger{m_dutyCycle.get()},
- m_counter{} {
+ : m_dutyCycle{std::make_shared<DutyCycle>(digitalSource)} {
Init();
}
DutyCycleEncoder::DutyCycleEncoder(std::shared_ptr<DigitalSource> digitalSource)
- : m_dutyCycle{std::make_shared<DutyCycle>(digitalSource)},
- m_analogTrigger{m_dutyCycle.get()},
- m_counter{} {
+ : m_dutyCycle{std::make_shared<DutyCycle>(digitalSource)} {
Init();
}
@@ -71,15 +58,19 @@
if (m_simDevice) {
m_simPosition = m_simDevice.CreateDouble("Position", false, 0.0);
+ m_simDistancePerRotation =
+ m_simDevice.CreateDouble("DistancePerRotation", false, 1.0);
m_simIsConnected = m_simDevice.CreateBoolean("Connected", false, true);
+ } else {
+ m_analogTrigger = std::make_unique<AnalogTrigger>(m_dutyCycle.get());
+ m_analogTrigger->SetLimitsDutyCycle(0.25, 0.75);
+ m_counter = std::make_unique<Counter>();
+ m_counter->SetUpSource(
+ m_analogTrigger->CreateOutput(AnalogTriggerType::kRisingPulse));
+ m_counter->SetDownSource(
+ m_analogTrigger->CreateOutput(AnalogTriggerType::kFallingPulse));
}
- m_analogTrigger.SetLimitsDutyCycle(0.25, 0.75);
- m_counter.SetUpSource(
- m_analogTrigger.CreateOutput(AnalogTriggerType::kRisingPulse));
- m_counter.SetDownSource(
- m_analogTrigger.CreateOutput(AnalogTriggerType::kFallingPulse));
-
SendableRegistry::GetInstance().AddLW(this, "DutyCycle Encoder",
m_dutyCycle->GetSourceChannel());
}
@@ -90,9 +81,9 @@
// As the values are not atomic, keep trying until we get 2 reads of the same
// value If we don't within 10 attempts, error
for (int i = 0; i < 10; i++) {
- auto counter = m_counter.Get();
+ auto counter = m_counter->Get();
auto pos = m_dutyCycle->GetOutput();
- auto counter2 = m_counter.Get();
+ auto counter2 = m_counter->Get();
auto pos2 = m_dutyCycle->GetOutput();
if (counter == counter2 && pos == pos2) {
units::turn_t turns{counter + pos - m_positionOffset};
@@ -109,6 +100,7 @@
void DutyCycleEncoder::SetDistancePerRotation(double distancePerRotation) {
m_distancePerRotation = distancePerRotation;
+ m_simDistancePerRotation.Set(distancePerRotation);
}
double DutyCycleEncoder::GetDistancePerRotation() const {
@@ -124,7 +116,7 @@
}
void DutyCycleEncoder::Reset() {
- m_counter.Reset();
+ if (m_counter) m_counter->Reset();
m_positionOffset = m_dutyCycle->GetOutput();
}
@@ -140,13 +132,21 @@
m_frequencyThreshold = frequency;
}
+int DutyCycleEncoder::GetFPGAIndex() const {
+ return m_dutyCycle->GetFPGAIndex();
+}
+
+int DutyCycleEncoder::GetSourceChannel() const {
+ return m_dutyCycle->GetSourceChannel();
+}
+
void DutyCycleEncoder::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("AbsoluteEncoder");
- builder.AddDoubleProperty("Distance", [this] { return this->GetDistance(); },
- nullptr);
- builder.AddDoubleProperty("Distance Per Rotation",
- [this] { return this->GetDistancePerRotation(); },
- nullptr);
- builder.AddDoubleProperty("Is Connected",
- [this] { return this->IsConnected(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Distance", [this] { return this->GetDistance(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Distance Per Rotation",
+ [this] { return this->GetDistancePerRotation(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Is Connected", [this] { return this->IsConnected(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/Encoder.cpp b/wpilibc/src/main/native/cpp/Encoder.cpp
index 963bcc6..87bb45f 100644
--- a/wpilibc/src/main/native/cpp/Encoder.cpp
+++ b/wpilibc/src/main/native/cpp/Encoder.cpp
@@ -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. */
@@ -12,6 +12,7 @@
#include <hal/Encoder.h>
#include <hal/FRCUsageReporting.h>
+#include "frc/Base.h"
#include "frc/DigitalInput.h"
#include "frc/WPIErrors.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -236,11 +237,12 @@
else
builder.SetSmartDashboardType("Encoder");
- builder.AddDoubleProperty("Speed", [=]() { return GetRate(); }, nullptr);
- builder.AddDoubleProperty("Distance", [=]() { return GetDistance(); },
- nullptr);
- builder.AddDoubleProperty("Distance per Tick",
- [=]() { return GetDistancePerPulse(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Speed", [=]() { return GetRate(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Distance", [=]() { return GetDistance(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Distance per Tick", [=]() { return GetDistancePerPulse(); }, nullptr);
}
void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
diff --git a/wpilibc/src/main/native/cpp/Error.cpp b/wpilibc/src/main/native/cpp/Error.cpp
index ee7dcbd..5e072c9 100644
--- a/wpilibc/src/main/native/cpp/Error.cpp
+++ b/wpilibc/src/main/native/cpp/Error.cpp
@@ -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. */
@@ -10,9 +10,9 @@
#include <wpi/Path.h>
#include <wpi/StackTrace.h>
+#include "frc/Base.h"
#include "frc/DriverStation.h"
#include "frc/Timer.h"
-#include "frc/Utility.h"
using namespace frc;
diff --git a/wpilibc/src/main/native/cpp/ErrorBase.cpp b/wpilibc/src/main/native/cpp/ErrorBase.cpp
index d098c07..8c7c5a2 100644
--- a/wpilibc/src/main/native/cpp/ErrorBase.cpp
+++ b/wpilibc/src/main/native/cpp/ErrorBase.cpp
@@ -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. */
@@ -8,17 +8,17 @@
#include "frc/ErrorBase.h"
#include <cerrno>
-#include <cstdio>
#include <cstring>
#include <set>
+#include <utility>
-#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <wpi/Format.h>
#include <wpi/SmallString.h>
+#include <wpi/mutex.h>
#include <wpi/raw_ostream.h>
-#include "frc/WPIErrors.h"
+#include "frc/Base.h"
using namespace frc;
diff --git a/wpilibc/src/main/native/cpp/Filesystem.cpp b/wpilibc/src/main/native/cpp/Filesystem.cpp
index 1546050..7d2ea1d 100644
--- a/wpilibc/src/main/native/cpp/Filesystem.cpp
+++ b/wpilibc/src/main/native/cpp/Filesystem.cpp
@@ -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. */
@@ -18,7 +18,7 @@
void frc::filesystem::GetOperatingDirectory(
wpi::SmallVectorImpl<char>& result) {
- if (RobotBase::IsReal()) {
+ if constexpr (RobotBase::IsReal()) {
wpi::sys::path::native("/home/lvuser", result);
} else {
frc::filesystem::GetLaunchDirectory(result);
@@ -27,5 +27,11 @@
void frc::filesystem::GetDeployDirectory(wpi::SmallVectorImpl<char>& result) {
frc::filesystem::GetOperatingDirectory(result);
- wpi::sys::path::append(result, "deploy");
+ if constexpr (RobotBase::IsReal()) {
+ wpi::sys::path::append(result, "deploy");
+ } else {
+ wpi::sys::path::append(result, "src");
+ wpi::sys::path::append(result, "main");
+ wpi::sys::path::append(result, "deploy");
+ }
}
diff --git a/wpilibc/src/main/native/cpp/GenericHID.cpp b/wpilibc/src/main/native/cpp/GenericHID.cpp
index a7dcfc0..4a264c8 100644
--- a/wpilibc/src/main/native/cpp/GenericHID.cpp
+++ b/wpilibc/src/main/native/cpp/GenericHID.cpp
@@ -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. */
@@ -8,7 +8,6 @@
#include "frc/GenericHID.h"
#include <hal/DriverStation.h>
-#include <hal/FRCUsageReporting.h>
#include "frc/DriverStation.h"
#include "frc/WPIErrors.h"
@@ -48,6 +47,10 @@
return m_ds->GetStickButtonCount(m_port);
}
+bool GenericHID::IsConnected() const {
+ return m_ds->IsJoystickConnected(m_port);
+}
+
GenericHID::HIDType GenericHID::GetType() const {
return static_cast<HIDType>(m_ds->GetJoystickType(m_port));
}
diff --git a/wpilibc/src/main/native/cpp/GyroBase.cpp b/wpilibc/src/main/native/cpp/GyroBase.cpp
index ec67675..ba9b2f0 100644
--- a/wpilibc/src/main/native/cpp/GyroBase.cpp
+++ b/wpilibc/src/main/native/cpp/GyroBase.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 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. */
@@ -25,5 +25,6 @@
void GyroBase::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Gyro");
- builder.AddDoubleProperty("Value", [=]() { return GetAngle(); }, nullptr);
+ builder.AddDoubleProperty(
+ "Value", [=]() { return GetAngle(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp b/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp
index 202c61d..744e349 100644
--- a/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp
+++ b/wpilibc/src/main/native/cpp/InterruptableSensorBase.cpp
@@ -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. */
@@ -7,8 +7,6 @@
#include "frc/InterruptableSensorBase.h"
-#include <hal/FRCUsageReporting.h>
-
#include "frc/Utility.h"
#include "frc/WPIErrors.h"
diff --git a/wpilibc/src/main/native/cpp/IterativeRobot.cpp b/wpilibc/src/main/native/cpp/IterativeRobot.cpp
index c8664a5..72fb79b 100644
--- a/wpilibc/src/main/native/cpp/IterativeRobot.cpp
+++ b/wpilibc/src/main/native/cpp/IterativeRobot.cpp
@@ -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. */
@@ -24,6 +24,10 @@
void IterativeRobot::StartCompetition() {
RobotInit();
+ if constexpr (IsSimulation()) {
+ SimulationInit();
+ }
+
// Tell the DS that the robot is ready to be enabled
HAL_ObserveUserProgramStarting();
diff --git a/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp b/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp
index 2997234..7b29130 100644
--- a/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp
+++ b/wpilibc/src/main/native/cpp/IterativeRobotBase.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -7,16 +7,12 @@
#include "frc/IterativeRobotBase.h"
-#include <cstdio>
-
#include <hal/DriverStation.h>
-#include <hal/FRCUsageReporting.h>
#include <wpi/Format.h>
#include <wpi/SmallString.h>
#include <wpi/raw_ostream.h>
#include "frc/DriverStation.h"
-#include "frc/Timer.h"
#include "frc/livewindow/LiveWindow.h"
#include "frc/shuffleboard/Shuffleboard.h"
#include "frc/smartdashboard/SmartDashboard.h"
@@ -34,6 +30,10 @@
wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
}
+void IterativeRobotBase::SimulationInit() {
+ wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
+}
+
void IterativeRobotBase::DisabledInit() {
wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
}
@@ -58,6 +58,14 @@
}
}
+void IterativeRobotBase::SimulationPeriodic() {
+ static bool firstRun = true;
+ if (firstRun) {
+ wpi::outs() << "Default " << __FUNCTION__ << "() method... Override me!\n";
+ firstRun = false;
+ }
+}
+
void IterativeRobotBase::DisabledPeriodic() {
static bool firstRun = true;
if (firstRun) {
@@ -161,6 +169,12 @@
m_watchdog.AddEpoch("LiveWindow::UpdateValues()");
Shuffleboard::Update();
m_watchdog.AddEpoch("Shuffleboard::Update()");
+
+ if constexpr (IsSimulation()) {
+ SimulationPeriodic();
+ m_watchdog.AddEpoch("SimulationPeriodic()");
+ }
+
m_watchdog.Disable();
// Warn on loop time overruns
diff --git a/wpilibc/src/main/native/cpp/Joystick.cpp b/wpilibc/src/main/native/cpp/Joystick.cpp
index 8d464cf..c2cdaea 100644
--- a/wpilibc/src/main/native/cpp/Joystick.cpp
+++ b/wpilibc/src/main/native/cpp/Joystick.cpp
@@ -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. */
@@ -12,9 +12,6 @@
#include <hal/FRCUsageReporting.h>
#include <wpi/math>
-#include "frc/DriverStation.h"
-#include "frc/WPIErrors.h"
-
using namespace frc;
Joystick::Joystick(int port) : GenericHID(port) {
diff --git a/wpilibc/src/main/native/cpp/NidecBrushless.cpp b/wpilibc/src/main/native/cpp/NidecBrushless.cpp
index 5bce36e..82a278e 100644
--- a/wpilibc/src/main/native/cpp/NidecBrushless.cpp
+++ b/wpilibc/src/main/native/cpp/NidecBrushless.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -70,6 +70,6 @@
builder.SetSmartDashboardType("Nidec Brushless");
builder.SetActuator(true);
builder.SetSafeState([=]() { StopMotor(); });
- builder.AddDoubleProperty("Value", [=]() { return Get(); },
- [=](double value) { Set(value); });
+ builder.AddDoubleProperty(
+ "Value", [=]() { return Get(); }, [=](double value) { Set(value); });
}
diff --git a/wpilibc/src/main/native/cpp/Notifier.cpp b/wpilibc/src/main/native/cpp/Notifier.cpp
index a7fa038..4280ce4 100644
--- a/wpilibc/src/main/native/cpp/Notifier.cpp
+++ b/wpilibc/src/main/native/cpp/Notifier.cpp
@@ -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. */
@@ -11,6 +11,7 @@
#include <hal/FRCUsageReporting.h>
#include <hal/Notifier.h>
+#include <hal/Threads.h>
#include <wpi/SmallString.h>
#include "frc/Timer.h"
@@ -54,6 +55,42 @@
});
}
+Notifier::Notifier(int priority, std::function<void()> handler) {
+ if (handler == nullptr)
+ wpi_setWPIErrorWithContext(NullParameter, "handler must not be nullptr");
+ m_handler = handler;
+ int32_t status = 0;
+ m_notifier = HAL_InitializeNotifier(&status);
+ wpi_setHALError(status);
+
+ m_thread = std::thread([=] {
+ int32_t status = 0;
+ HAL_SetCurrentThreadPriority(true, priority, &status);
+ for (;;) {
+ HAL_NotifierHandle notifier = m_notifier.load();
+ if (notifier == 0) break;
+ uint64_t curTime = HAL_WaitForNotifierAlarm(notifier, &status);
+ if (curTime == 0 || status != 0) break;
+
+ std::function<void()> handler;
+ {
+ std::scoped_lock lock(m_processMutex);
+ handler = m_handler;
+ if (m_periodic) {
+ m_expirationTime += m_period;
+ UpdateAlarm();
+ } else {
+ // need to update the alarm to cause it to wait again
+ UpdateAlarm(UINT64_MAX);
+ }
+ }
+
+ // call callback
+ if (handler) handler();
+ }
+ });
+}
+
Notifier::~Notifier() {
int32_t status = 0;
// atomically set handle to 0, then clean
@@ -129,6 +166,8 @@
}
void Notifier::Stop() {
+ std::scoped_lock lock(m_processMutex);
+ m_periodic = false;
int32_t status = 0;
HAL_CancelNotifierAlarm(m_notifier, &status);
wpi_setHALError(status);
diff --git a/wpilibc/src/main/native/cpp/PIDBase.cpp b/wpilibc/src/main/native/cpp/PIDBase.cpp
index c8f6fed..5802d98 100644
--- a/wpilibc/src/main/native/cpp/PIDBase.cpp
+++ b/wpilibc/src/main/native/cpp/PIDBase.cpp
@@ -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. */
@@ -229,16 +229,17 @@
void PIDBase::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("PIDController");
builder.SetSafeState([=]() { Reset(); });
- builder.AddDoubleProperty("p", [=]() { return GetP(); },
- [=](double value) { SetP(value); });
- builder.AddDoubleProperty("i", [=]() { return GetI(); },
- [=](double value) { SetI(value); });
- builder.AddDoubleProperty("d", [=]() { return GetD(); },
- [=](double value) { SetD(value); });
- builder.AddDoubleProperty("f", [=]() { return GetF(); },
- [=](double value) { SetF(value); });
- builder.AddDoubleProperty("setpoint", [=]() { return GetSetpoint(); },
- [=](double value) { SetSetpoint(value); });
+ builder.AddDoubleProperty(
+ "p", [=]() { return GetP(); }, [=](double value) { SetP(value); });
+ builder.AddDoubleProperty(
+ "i", [=]() { return GetI(); }, [=](double value) { SetI(value); });
+ builder.AddDoubleProperty(
+ "d", [=]() { return GetD(); }, [=](double value) { SetD(value); });
+ builder.AddDoubleProperty(
+ "f", [=]() { return GetF(); }, [=](double value) { SetF(value); });
+ builder.AddDoubleProperty(
+ "setpoint", [=]() { return GetSetpoint(); },
+ [=](double value) { SetSetpoint(value); });
}
void PIDBase::Calculate() {
diff --git a/wpilibc/src/main/native/cpp/PIDController.cpp b/wpilibc/src/main/native/cpp/PIDController.cpp
index 0c86f55..a90a645 100644
--- a/wpilibc/src/main/native/cpp/PIDController.cpp
+++ b/wpilibc/src/main/native/cpp/PIDController.cpp
@@ -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. */
@@ -80,6 +80,7 @@
void PIDController::InitSendable(SendableBuilder& builder) {
PIDBase::InitSendable(builder);
- builder.AddBooleanProperty("enabled", [=]() { return IsEnabled(); },
- [=](bool value) { SetEnabled(value); });
+ builder.AddBooleanProperty(
+ "enabled", [=]() { return IsEnabled(); },
+ [=](bool value) { SetEnabled(value); });
}
diff --git a/wpilibc/src/main/native/cpp/PWM.cpp b/wpilibc/src/main/native/cpp/PWM.cpp
index dabcd2e..c2cd2e2 100644
--- a/wpilibc/src/main/native/cpp/PWM.cpp
+++ b/wpilibc/src/main/native/cpp/PWM.cpp
@@ -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. */
@@ -199,6 +199,7 @@
builder.SetSmartDashboardType("PWM");
builder.SetActuator(true);
builder.SetSafeState([=]() { SetDisabled(); });
- builder.AddDoubleProperty("Value", [=]() { return GetRaw(); },
- [=](double value) { SetRaw(value); });
+ builder.AddDoubleProperty(
+ "Value", [=]() { return GetRaw(); },
+ [=](double value) { SetRaw(value); });
}
diff --git a/wpilibc/src/main/native/cpp/PWMSpeedController.cpp b/wpilibc/src/main/native/cpp/PWMSpeedController.cpp
index ea298de..ec0be7b 100644
--- a/wpilibc/src/main/native/cpp/PWMSpeedController.cpp
+++ b/wpilibc/src/main/native/cpp/PWMSpeedController.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 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. */
@@ -35,6 +35,7 @@
builder.SetSmartDashboardType("Speed Controller");
builder.SetActuator(true);
builder.SetSafeState([=]() { SetDisabled(); });
- builder.AddDoubleProperty("Value", [=]() { return GetSpeed(); },
- [=](double value) { SetSpeed(value); });
+ builder.AddDoubleProperty(
+ "Value", [=]() { return GetSpeed(); },
+ [=](double value) { SetSpeed(value); });
}
diff --git a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp
index 7d7d916..4070633 100644
--- a/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp
+++ b/wpilibc/src/main/native/cpp/PowerDistributionPanel.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -25,7 +25,7 @@
/**
* Initialize the PDP.
*/
-PowerDistributionPanel::PowerDistributionPanel(int module) {
+PowerDistributionPanel::PowerDistributionPanel(int module) : m_module(module) {
int32_t status = 0;
m_handle = HAL_InitializePDP(module, &status);
if (status != 0) {
@@ -136,13 +136,16 @@
}
}
+int PowerDistributionPanel::GetModule() const { return m_module; }
+
void PowerDistributionPanel::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("PowerDistributionPanel");
for (int i = 0; i < SensorUtil::kPDPChannels; ++i) {
- builder.AddDoubleProperty("Chan" + wpi::Twine(i),
- [=]() { return GetCurrent(i); }, nullptr);
+ builder.AddDoubleProperty(
+ "Chan" + wpi::Twine(i), [=]() { return GetCurrent(i); }, nullptr);
}
- builder.AddDoubleProperty("Voltage", [=]() { return GetVoltage(); }, nullptr);
- builder.AddDoubleProperty("TotalCurrent", [=]() { return GetTotalCurrent(); },
- nullptr);
+ builder.AddDoubleProperty(
+ "Voltage", [=]() { return GetVoltage(); }, nullptr);
+ builder.AddDoubleProperty(
+ "TotalCurrent", [=]() { return GetTotalCurrent(); }, nullptr);
}
diff --git a/wpilibc/src/main/native/cpp/Preferences.cpp b/wpilibc/src/main/native/cpp/Preferences.cpp
index 6014775..8c1eb87 100644
--- a/wpilibc/src/main/native/cpp/Preferences.cpp
+++ b/wpilibc/src/main/native/cpp/Preferences.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2011-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. */
@@ -58,36 +58,66 @@
entry.SetPersistent();
}
+void Preferences::InitString(wpi::StringRef key, wpi::StringRef value) {
+ auto entry = m_table->GetEntry(key);
+ entry.SetDefaultString(value);
+}
+
void Preferences::PutInt(wpi::StringRef key, int value) {
auto entry = m_table->GetEntry(key);
entry.SetDouble(value);
entry.SetPersistent();
}
+void Preferences::InitInt(wpi::StringRef key, int value) {
+ auto entry = m_table->GetEntry(key);
+ entry.SetDefaultDouble(value);
+}
+
void Preferences::PutDouble(wpi::StringRef key, double value) {
auto entry = m_table->GetEntry(key);
entry.SetDouble(value);
entry.SetPersistent();
}
+void Preferences::InitDouble(wpi::StringRef key, double value) {
+ auto entry = m_table->GetEntry(key);
+ entry.SetDefaultDouble(value);
+}
+
void Preferences::PutFloat(wpi::StringRef key, float value) {
auto entry = m_table->GetEntry(key);
entry.SetDouble(value);
entry.SetPersistent();
}
+void Preferences::InitFloat(wpi::StringRef key, float value) {
+ auto entry = m_table->GetEntry(key);
+ entry.SetDefaultDouble(value);
+}
+
void Preferences::PutBoolean(wpi::StringRef key, bool value) {
auto entry = m_table->GetEntry(key);
entry.SetBoolean(value);
entry.SetPersistent();
}
+void Preferences::InitBoolean(wpi::StringRef key, bool value) {
+ auto entry = m_table->GetEntry(key);
+ entry.SetDefaultBoolean(value);
+}
+
void Preferences::PutLong(wpi::StringRef key, int64_t value) {
auto entry = m_table->GetEntry(key);
entry.SetDouble(value);
entry.SetPersistent();
}
+void Preferences::InitLong(wpi::StringRef key, int64_t value) {
+ auto entry = m_table->GetEntry(key);
+ entry.SetDefaultDouble(value);
+}
+
bool Preferences::ContainsKey(wpi::StringRef key) {
return m_table->ContainsKey(key);
}
diff --git a/wpilibc/src/main/native/cpp/RobotController.cpp b/wpilibc/src/main/native/cpp/RobotController.cpp
index b1d7608..b33479f 100644
--- a/wpilibc/src/main/native/cpp/RobotController.cpp
+++ b/wpilibc/src/main/native/cpp/RobotController.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -8,7 +8,6 @@
#include "frc/RobotController.h"
#include <hal/CAN.h>
-#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/Power.h>
diff --git a/wpilibc/src/main/native/cpp/RobotDrive.cpp b/wpilibc/src/main/native/cpp/RobotDrive.cpp
index 5235fa2..9eafe0c 100644
--- a/wpilibc/src/main/native/cpp/RobotDrive.cpp
+++ b/wpilibc/src/main/native/cpp/RobotDrive.cpp
@@ -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. */
@@ -282,7 +282,7 @@
double yIn = y;
// Negate y for the joystick.
yIn = -yIn;
- // Compenstate for gyro angle.
+ // Compensate for gyro angle.
RotateVector(xIn, yIn, gyroAngle);
double wheelSpeeds[kMaxNumberOfMotors];
diff --git a/wpilibc/src/main/native/cpp/ScopedTracer.cpp b/wpilibc/src/main/native/cpp/ScopedTracer.cpp
new file mode 100644
index 0000000..2024a65
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/ScopedTracer.cpp
@@ -0,0 +1,22 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/ScopedTracer.h"
+
+#include <wpi/raw_ostream.h>
+
+using namespace frc;
+
+ScopedTracer::ScopedTracer(wpi::Twine name, wpi::raw_ostream& os)
+ : m_name(name.str()), m_os(os) {
+ m_tracer.ResetTimer();
+}
+
+ScopedTracer::~ScopedTracer() {
+ m_tracer.AddEpoch(m_name);
+ m_tracer.PrintEpochs(m_os);
+}
diff --git a/wpilibc/src/main/native/cpp/SensorUtil.cpp b/wpilibc/src/main/native/cpp/SensorUtil.cpp
index 8c02f1b..f86c72c 100644
--- a/wpilibc/src/main/native/cpp/SensorUtil.cpp
+++ b/wpilibc/src/main/native/cpp/SensorUtil.cpp
@@ -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. */
@@ -10,7 +10,6 @@
#include <hal/AnalogInput.h>
#include <hal/AnalogOutput.h>
#include <hal/DIO.h>
-#include <hal/FRCUsageReporting.h>
#include <hal/PDP.h>
#include <hal/PWM.h>
#include <hal/Ports.h>
@@ -21,6 +20,7 @@
const int SensorUtil::kDigitalChannels = HAL_GetNumDigitalChannels();
const int SensorUtil::kAnalogInputs = HAL_GetNumAnalogInputs();
+const int SensorUtil::kAnalogOutputs = HAL_GetNumAnalogOutputs();
const int SensorUtil::kSolenoidChannels = HAL_GetNumSolenoidChannels();
const int SensorUtil::kSolenoidModules = HAL_GetNumPCMModules();
const int SensorUtil::kPwmChannels = HAL_GetNumPWMChannels();
diff --git a/wpilibc/src/main/native/cpp/Servo.cpp b/wpilibc/src/main/native/cpp/Servo.cpp
index 4b6856a..5edcebc 100644
--- a/wpilibc/src/main/native/cpp/Servo.cpp
+++ b/wpilibc/src/main/native/cpp/Servo.cpp
@@ -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. */
@@ -57,8 +57,8 @@
void Servo::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Servo");
- builder.AddDoubleProperty("Value", [=]() { return Get(); },
- [=](double value) { Set(value); });
+ builder.AddDoubleProperty(
+ "Value", [=]() { return Get(); }, [=](double value) { Set(value); });
}
double Servo::GetServoAngleRange() const {
diff --git a/wpilibc/src/main/native/cpp/Solenoid.cpp b/wpilibc/src/main/native/cpp/Solenoid.cpp
index e0bde3c..b5abf20 100644
--- a/wpilibc/src/main/native/cpp/Solenoid.cpp
+++ b/wpilibc/src/main/native/cpp/Solenoid.cpp
@@ -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. */
@@ -56,6 +56,7 @@
void Solenoid::Set(bool on) {
if (StatusIsFatal()) return;
+
int32_t status = 0;
HAL_SetSolenoid(m_solenoidHandle, on, &status);
wpi_setHALError(status);
@@ -63,12 +64,16 @@
bool Solenoid::Get() const {
if (StatusIsFatal()) return false;
+
int32_t status = 0;
bool value = HAL_GetSolenoid(m_solenoidHandle, &status);
wpi_setHALError(status);
+
return value;
}
+void Solenoid::Toggle() { Set(!Get()); }
+
bool Solenoid::IsBlackListed() const {
int value = GetPCMSolenoidBlackList(m_moduleNumber) & (1 << m_channel);
return (value != 0);
@@ -93,6 +98,6 @@
builder.SetSmartDashboardType("Solenoid");
builder.SetActuator(true);
builder.SetSafeState([=]() { Set(false); });
- builder.AddBooleanProperty("Value", [=]() { return Get(); },
- [=](bool value) { Set(value); });
+ builder.AddBooleanProperty(
+ "Value", [=]() { return Get(); }, [=](bool value) { Set(value); });
}
diff --git a/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp b/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp
index a807afc..8fea1b2 100644
--- a/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp
+++ b/wpilibc/src/main/native/cpp/SpeedControllerGroup.cpp
@@ -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. */
@@ -8,9 +8,27 @@
#include "frc/SpeedControllerGroup.h"
#include "frc/smartdashboard/SendableBuilder.h"
+#include "frc/smartdashboard/SendableRegistry.h"
using namespace frc;
+// Can't use a delegated constructor here because of an MSVC bug.
+// https://developercommunity.visualstudio.com/content/problem/583/compiler-bug-with-delegating-a-constructor.html
+
+SpeedControllerGroup::SpeedControllerGroup(
+ std::vector<std::reference_wrapper<SpeedController>>&& speedControllers)
+ : m_speedControllers(std::move(speedControllers)) {
+ Initialize();
+}
+
+void SpeedControllerGroup::Initialize() {
+ for (auto& speedController : m_speedControllers)
+ SendableRegistry::GetInstance().AddChild(this, &speedController.get());
+ static int instances = 0;
+ ++instances;
+ SendableRegistry::GetInstance().Add(this, "SpeedControllerGroup", instances);
+}
+
void SpeedControllerGroup::Set(double speed) {
for (auto speedController : m_speedControllers) {
speedController.get().Set(m_isInverted ? -speed : speed);
@@ -48,6 +66,6 @@
builder.SetSmartDashboardType("Speed Controller");
builder.SetActuator(true);
builder.SetSafeState([=]() { StopMotor(); });
- builder.AddDoubleProperty("Value", [=]() { return Get(); },
- [=](double value) { Set(value); });
+ builder.AddDoubleProperty(
+ "Value", [=]() { return Get(); }, [=](double value) { Set(value); });
}
diff --git a/wpilibc/src/main/native/cpp/TimedRobot.cpp b/wpilibc/src/main/native/cpp/TimedRobot.cpp
index a9358dd..74e658a 100644
--- a/wpilibc/src/main/native/cpp/TimedRobot.cpp
+++ b/wpilibc/src/main/native/cpp/TimedRobot.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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,24 +24,44 @@
void TimedRobot::StartCompetition() {
RobotInit();
+ if constexpr (IsSimulation()) {
+ SimulationInit();
+ }
+
// Tell the DS that the robot is ready to be enabled
HAL_ObserveUserProgramStarting();
- m_expirationTime = units::second_t{Timer::GetFPGATimestamp()} + m_period;
- UpdateAlarm();
-
// Loop forever, calling the appropriate mode-dependent function
while (true) {
+ // We don't have to check there's an element in the queue first because
+ // there's always at least one (the constructor adds one). It's reenqueued
+ // at the end of the loop.
+ auto callback = m_callbacks.pop();
+
int32_t status = 0;
+ HAL_UpdateNotifierAlarm(
+ m_notifier, static_cast<uint64_t>(callback.expirationTime * 1e6),
+ &status);
+ wpi_setHALError(status);
+
uint64_t curTime = HAL_WaitForNotifierAlarm(m_notifier, &status);
if (curTime == 0 || status != 0) break;
- m_expirationTime += m_period;
+ callback.func();
- UpdateAlarm();
+ callback.expirationTime += callback.period;
+ m_callbacks.push(std::move(callback));
- // Call callback
- LoopFunc();
+ // Process all other callbacks that are ready to run
+ while (static_cast<uint64_t>(m_callbacks.top().expirationTime * 1e6) <=
+ curTime) {
+ callback = m_callbacks.pop();
+
+ callback.func();
+
+ callback.expirationTime += callback.period;
+ m_callbacks.push(std::move(callback));
+ }
}
}
@@ -57,6 +77,9 @@
TimedRobot::TimedRobot(double period) : TimedRobot(units::second_t(period)) {}
TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {
+ m_startTime = frc2::Timer::GetFPGATimestamp();
+ AddPeriodic([=] { LoopFunc(); }, period);
+
int32_t status = 0;
m_notifier = HAL_InitializeNotifier(&status);
wpi_setHALError(status);
@@ -75,9 +98,7 @@
HAL_CleanNotifier(m_notifier, &status);
}
-void TimedRobot::UpdateAlarm() {
- int32_t status = 0;
- HAL_UpdateNotifierAlarm(
- m_notifier, static_cast<uint64_t>(m_expirationTime * 1e6), &status);
- wpi_setHALError(status);
+void TimedRobot::AddPeriodic(std::function<void()> callback,
+ units::second_t period, units::second_t offset) {
+ m_callbacks.emplace(callback, m_startTime, period, offset);
}
diff --git a/wpilibc/src/main/native/cpp/Timer.cpp b/wpilibc/src/main/native/cpp/Timer.cpp
index c91bc13..b428e03 100644
--- a/wpilibc/src/main/native/cpp/Timer.cpp
+++ b/wpilibc/src/main/native/cpp/Timer.cpp
@@ -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. */
@@ -7,13 +7,7 @@
#include "frc/Timer.h"
-#include <chrono>
-#include <thread>
-
-#include <hal/FRCUsageReporting.h>
-
-#include "frc/DriverStation.h"
-#include "frc/RobotController.h"
+#include <units/time.h>
namespace frc {
@@ -25,8 +19,6 @@
using namespace frc;
-const double Timer::kRolloverTime = frc2::Timer::kRolloverTime.to<double>();
-
Timer::Timer() { Reset(); }
double Timer::Get() const { return m_timer.Get().to<double>(); }
diff --git a/wpilibc/src/main/native/cpp/Tracer.cpp b/wpilibc/src/main/native/cpp/Tracer.cpp
new file mode 100644
index 0000000..af5177a
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/Tracer.cpp
@@ -0,0 +1,55 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/Tracer.h"
+
+#include <wpi/Format.h>
+#include <wpi/SmallString.h>
+#include <wpi/raw_ostream.h>
+
+#include "frc/DriverStation.h"
+
+using namespace frc;
+
+Tracer::Tracer() { ResetTimer(); }
+
+void Tracer::ResetTimer() { m_startTime = hal::fpga_clock::now(); }
+
+void Tracer::ClearEpochs() {
+ ResetTimer();
+ m_epochs.clear();
+}
+
+void Tracer::AddEpoch(wpi::StringRef epochName) {
+ auto currentTime = hal::fpga_clock::now();
+ m_epochs[epochName] = currentTime - m_startTime;
+ m_startTime = currentTime;
+}
+
+void Tracer::PrintEpochs() {
+ wpi::SmallString<128> buf;
+ wpi::raw_svector_ostream os(buf);
+ PrintEpochs(os);
+ if (!buf.empty()) DriverStation::ReportWarning(buf);
+}
+
+void Tracer::PrintEpochs(wpi::raw_ostream& os) {
+ using std::chrono::duration_cast;
+ using std::chrono::microseconds;
+
+ auto now = hal::fpga_clock::now();
+ if (now - m_lastEpochsPrintTime > kMinPrintPeriod) {
+ m_lastEpochsPrintTime = now;
+ for (const auto& epoch : m_epochs) {
+ os << '\t' << epoch.getKey() << ": "
+ << wpi::format(
+ "%.6f",
+ duration_cast<microseconds>(epoch.getValue()).count() / 1.0e6)
+ << "s\n";
+ }
+ }
+}
diff --git a/wpilibc/src/main/native/cpp/Ultrasonic.cpp b/wpilibc/src/main/native/cpp/Ultrasonic.cpp
index fcd016e..dbd0d13 100644
--- a/wpilibc/src/main/native/cpp/Ultrasonic.cpp
+++ b/wpilibc/src/main/native/cpp/Ultrasonic.cpp
@@ -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. */
@@ -9,6 +9,7 @@
#include <hal/FRCUsageReporting.h>
+#include "frc/Base.h"
#include "frc/Counter.h"
#include "frc/DigitalInput.h"
#include "frc/DigitalOutput.h"
@@ -177,8 +178,8 @@
void Ultrasonic::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("Ultrasonic");
- builder.AddDoubleProperty("Value", [=]() { return GetRangeInches(); },
- nullptr);
+ builder.AddDoubleProperty(
+ "Value", [=]() { return GetRangeInches(); }, nullptr);
}
void Ultrasonic::Initialize() {
diff --git a/wpilibc/src/main/native/cpp/Utility.cpp b/wpilibc/src/main/native/cpp/Utility.cpp
index 11f6234..4b69cc8 100644
--- a/wpilibc/src/main/native/cpp/Utility.cpp
+++ b/wpilibc/src/main/native/cpp/Utility.cpp
@@ -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. */
@@ -12,19 +12,13 @@
#include <execinfo.h>
#endif
-#include <cstdio>
-#include <cstdlib>
-#include <cstring>
-
+#include <frc/Base.h>
#include <hal/DriverStation.h>
-#include <hal/FRCUsageReporting.h>
#include <wpi/Path.h>
#include <wpi/SmallString.h>
#include <wpi/StackTrace.h>
#include <wpi/raw_ostream.h>
-#include "frc/ErrorBase.h"
-
using namespace frc;
bool wpi_assert_impl(bool conditionValue, const wpi::Twine& conditionText,
diff --git a/wpilibc/src/main/native/cpp/Watchdog.cpp b/wpilibc/src/main/native/cpp/Watchdog.cpp
index e5be4fa..81c7cc8 100644
--- a/wpilibc/src/main/native/cpp/Watchdog.cpp
+++ b/wpilibc/src/main/native/cpp/Watchdog.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -7,16 +7,24 @@
#include "frc/Watchdog.h"
+#include <atomic>
+
+#include <hal/Notifier.h>
#include <wpi/Format.h>
-#include <wpi/PriorityQueue.h>
+#include <wpi/SmallString.h>
+#include <wpi/priority_queue.h>
#include <wpi/raw_ostream.h>
+#include "frc/DriverStation.h"
+#include "frc2/Timer.h"
+
using namespace frc;
-constexpr std::chrono::milliseconds Watchdog::kMinPrintPeriod;
-
-class Watchdog::Thread : public wpi::SafeThread {
+class Watchdog::Impl {
public:
+ Impl();
+ ~Impl();
+
template <typename T>
struct DerefGreater {
constexpr bool operator()(const T& lhs, const T& rhs) const {
@@ -24,56 +32,96 @@
}
};
- wpi::PriorityQueue<Watchdog*, std::vector<Watchdog*>, DerefGreater<Watchdog*>>
+ wpi::mutex m_mutex;
+ std::atomic<HAL_NotifierHandle> m_notifier;
+ wpi::priority_queue<Watchdog*, std::vector<Watchdog*>,
+ DerefGreater<Watchdog*>>
m_watchdogs;
+ void UpdateAlarm();
+
private:
- void Main() override;
+ void Main();
+
+ std::thread m_thread;
};
-void Watchdog::Thread::Main() {
- std::unique_lock lock(m_mutex);
+Watchdog::Impl::Impl() {
+ int32_t status = 0;
+ m_notifier = HAL_InitializeNotifier(&status);
+ wpi_setGlobalHALError(status);
+ HAL_SetNotifierName(m_notifier, "Watchdog", &status);
- while (m_active) {
- if (m_watchdogs.size() > 0) {
- if (m_cond.wait_until(lock, m_watchdogs.top()->m_expirationTime) ==
- std::cv_status::timeout) {
- if (m_watchdogs.size() == 0 ||
- m_watchdogs.top()->m_expirationTime > hal::fpga_clock::now()) {
- continue;
- }
+ m_thread = std::thread([=] { Main(); });
+}
- // If the condition variable timed out, that means a Watchdog timeout
- // has occurred, so call its timeout function.
- auto watchdog = m_watchdogs.top();
- m_watchdogs.pop();
+Watchdog::Impl::~Impl() {
+ int32_t status = 0;
+ // atomically set handle to 0, then clean
+ HAL_NotifierHandle handle = m_notifier.exchange(0);
+ HAL_StopNotifier(handle, &status);
+ wpi_setGlobalHALError(status);
- auto now = hal::fpga_clock::now();
- if (now - watchdog->m_lastTimeoutPrintTime > kMinPrintPeriod) {
- watchdog->m_lastTimeoutPrintTime = now;
- if (!watchdog->m_suppressTimeoutMessage) {
- wpi::outs() << "Watchdog not fed within "
- << wpi::format("%.6f",
- watchdog->m_timeout.count() / 1.0e9)
- << "s\n";
- }
- }
+ // Join the thread to ensure the handler has exited.
+ if (m_thread.joinable()) m_thread.join();
- // Set expiration flag before calling the callback so any manipulation
- // of the flag in the callback (e.g., calling Disable()) isn't
- // clobbered.
- watchdog->m_isExpired = true;
+ HAL_CleanNotifier(handle, &status);
+}
- lock.unlock();
- watchdog->m_callback();
- lock.lock();
+void Watchdog::Impl::UpdateAlarm() {
+ int32_t status = 0;
+ // Return if we are being destructed, or were not created successfully
+ auto notifier = m_notifier.load();
+ if (notifier == 0) return;
+ if (m_watchdogs.empty())
+ HAL_CancelNotifierAlarm(notifier, &status);
+ else
+ HAL_UpdateNotifierAlarm(
+ notifier,
+ static_cast<uint64_t>(m_watchdogs.top()->m_expirationTime.to<double>() *
+ 1e6),
+ &status);
+ wpi_setGlobalHALError(status);
+}
+
+void Watchdog::Impl::Main() {
+ for (;;) {
+ int32_t status = 0;
+ HAL_NotifierHandle notifier = m_notifier.load();
+ if (notifier == 0) break;
+ uint64_t curTime = HAL_WaitForNotifierAlarm(notifier, &status);
+ if (curTime == 0 || status != 0) break;
+
+ std::unique_lock lock(m_mutex);
+
+ if (m_watchdogs.empty()) continue;
+
+ // If the condition variable timed out, that means a Watchdog timeout
+ // has occurred, so call its timeout function.
+ auto watchdog = m_watchdogs.pop();
+
+ units::second_t now{curTime * 1e-6};
+ if (now - watchdog->m_lastTimeoutPrintTime > kMinPrintPeriod) {
+ watchdog->m_lastTimeoutPrintTime = now;
+ if (!watchdog->m_suppressTimeoutMessage) {
+ wpi::SmallString<128> buf;
+ wpi::raw_svector_ostream err(buf);
+ err << "Watchdog not fed within "
+ << wpi::format("%.6f", watchdog->m_timeout.to<double>()) << "s\n";
+ frc::DriverStation::ReportWarning(err.str());
}
- // Otherwise, a Watchdog removed itself from the queue (it notifies the
- // scheduler of this) or a spurious wakeup occurred, so just rewait with
- // the soonest watchdog timeout.
- } else {
- m_cond.wait(lock, [&] { return m_watchdogs.size() > 0 || !m_active; });
}
+
+ // Set expiration flag before calling the callback so any manipulation
+ // of the flag in the callback (e.g., calling Disable()) isn't
+ // clobbered.
+ watchdog->m_isExpired = true;
+
+ lock.unlock();
+ watchdog->m_callback();
+ lock.lock();
+
+ UpdateAlarm();
}
}
@@ -81,12 +129,32 @@
: Watchdog(units::second_t{timeout}, callback) {}
Watchdog::Watchdog(units::second_t timeout, std::function<void()> callback)
- : m_timeout(timeout), m_callback(callback), m_owner(&GetThreadOwner()) {}
+ : m_timeout(timeout), m_callback(callback), m_impl(GetImpl()) {}
Watchdog::~Watchdog() { Disable(); }
+Watchdog::Watchdog(Watchdog&& rhs) { *this = std::move(rhs); }
+
+Watchdog& Watchdog::operator=(Watchdog&& rhs) {
+ m_impl = rhs.m_impl;
+ std::scoped_lock lock(m_impl->m_mutex);
+ m_startTime = rhs.m_startTime;
+ m_timeout = rhs.m_timeout;
+ m_expirationTime = rhs.m_expirationTime;
+ m_callback = std::move(rhs.m_callback);
+ m_lastTimeoutPrintTime = rhs.m_lastTimeoutPrintTime;
+ m_suppressTimeoutMessage = rhs.m_suppressTimeoutMessage;
+ m_tracer = std::move(rhs.m_tracer);
+ m_isExpired = rhs.m_isExpired;
+ if (m_expirationTime != 0_s) {
+ m_impl->m_watchdogs.remove(&rhs);
+ m_impl->m_watchdogs.emplace(this);
+ }
+ return *this;
+}
+
double Watchdog::GetTime() const {
- return (hal::fpga_clock::now() - m_startTime).count() / 1.0e6;
+ return (frc2::Timer::GetFPGATimestamp() - m_startTime).to<double>();
}
void Watchdog::SetTimeout(double timeout) {
@@ -94,100 +162,69 @@
}
void Watchdog::SetTimeout(units::second_t timeout) {
- using std::chrono::duration_cast;
- using std::chrono::microseconds;
+ m_startTime = frc2::Timer::GetFPGATimestamp();
+ m_tracer.ClearEpochs();
- m_startTime = hal::fpga_clock::now();
- m_epochs.clear();
-
- // Locks mutex
- auto thr = m_owner->GetThread();
- if (!thr) return;
-
+ std::scoped_lock lock(m_impl->m_mutex);
m_timeout = timeout;
m_isExpired = false;
- thr->m_watchdogs.remove(this);
- m_expirationTime = m_startTime + duration_cast<microseconds>(m_timeout);
- thr->m_watchdogs.emplace(this);
- thr->m_cond.notify_all();
+ m_impl->m_watchdogs.remove(this);
+ m_expirationTime = m_startTime + m_timeout;
+ m_impl->m_watchdogs.emplace(this);
+ m_impl->UpdateAlarm();
}
double Watchdog::GetTimeout() const {
- // Locks mutex
- auto thr = m_owner->GetThread();
-
- return m_timeout.count() / 1.0e9;
+ std::scoped_lock lock(m_impl->m_mutex);
+ return m_timeout.to<double>();
}
bool Watchdog::IsExpired() const {
- // Locks mutex
- auto thr = m_owner->GetThread();
-
+ std::scoped_lock lock(m_impl->m_mutex);
return m_isExpired;
}
void Watchdog::AddEpoch(wpi::StringRef epochName) {
- auto currentTime = hal::fpga_clock::now();
- m_epochs[epochName] = currentTime - m_startTime;
- m_startTime = currentTime;
+ m_tracer.AddEpoch(epochName);
}
-void Watchdog::PrintEpochs() {
- auto now = hal::fpga_clock::now();
- if (now - m_lastEpochsPrintTime > kMinPrintPeriod) {
- m_lastEpochsPrintTime = now;
- for (const auto& epoch : m_epochs) {
- wpi::outs() << '\t' << epoch.getKey() << ": "
- << wpi::format("%.6f", epoch.getValue().count() / 1.0e6)
- << "s\n";
- }
- }
-}
+void Watchdog::PrintEpochs() { m_tracer.PrintEpochs(); }
void Watchdog::Reset() { Enable(); }
void Watchdog::Enable() {
- using std::chrono::duration_cast;
- using std::chrono::microseconds;
+ m_startTime = frc2::Timer::GetFPGATimestamp();
+ m_tracer.ClearEpochs();
- m_startTime = hal::fpga_clock::now();
- m_epochs.clear();
-
- // Locks mutex
- auto thr = m_owner->GetThread();
- if (!thr) return;
-
+ std::scoped_lock lock(m_impl->m_mutex);
m_isExpired = false;
- thr->m_watchdogs.remove(this);
- m_expirationTime = m_startTime + duration_cast<microseconds>(m_timeout);
- thr->m_watchdogs.emplace(this);
- thr->m_cond.notify_all();
+ m_impl->m_watchdogs.remove(this);
+ m_expirationTime = m_startTime + m_timeout;
+ m_impl->m_watchdogs.emplace(this);
+ m_impl->UpdateAlarm();
}
void Watchdog::Disable() {
- // Locks mutex
- auto thr = m_owner->GetThread();
- if (!thr) return;
+ std::scoped_lock lock(m_impl->m_mutex);
- thr->m_watchdogs.remove(this);
- thr->m_cond.notify_all();
+ if (m_expirationTime != 0_s) {
+ m_impl->m_watchdogs.remove(this);
+ m_expirationTime = 0_s;
+ m_impl->UpdateAlarm();
+ }
}
void Watchdog::SuppressTimeoutMessage(bool suppress) {
m_suppressTimeoutMessage = suppress;
}
-bool Watchdog::operator>(const Watchdog& rhs) {
+bool Watchdog::operator>(const Watchdog& rhs) const {
return m_expirationTime > rhs.m_expirationTime;
}
-wpi::SafeThreadOwner<Watchdog::Thread>& Watchdog::GetThreadOwner() {
- static wpi::SafeThreadOwner<Thread> inst = [] {
- wpi::SafeThreadOwner<Watchdog::Thread> inst;
- inst.Start();
- return inst;
- }();
- return inst;
+Watchdog::Impl* Watchdog::GetImpl() {
+ static Impl inst;
+ return &inst;
}
diff --git a/wpilibc/src/main/native/cpp/XboxController.cpp b/wpilibc/src/main/native/cpp/XboxController.cpp
index b294257..de77624 100644
--- a/wpilibc/src/main/native/cpp/XboxController.cpp
+++ b/wpilibc/src/main/native/cpp/XboxController.cpp
@@ -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. */
@@ -17,25 +17,25 @@
double XboxController::GetX(JoystickHand hand) const {
if (hand == kLeftHand) {
- return GetRawAxis(0);
+ return GetRawAxis(static_cast<int>(Axis::kLeftX));
} else {
- return GetRawAxis(4);
+ return GetRawAxis(static_cast<int>(Axis::kRightX));
}
}
double XboxController::GetY(JoystickHand hand) const {
if (hand == kLeftHand) {
- return GetRawAxis(1);
+ return GetRawAxis(static_cast<int>(Axis::kLeftY));
} else {
- return GetRawAxis(5);
+ return GetRawAxis(static_cast<int>(Axis::kRightY));
}
}
double XboxController::GetTriggerAxis(JoystickHand hand) const {
if (hand == kLeftHand) {
- return GetRawAxis(2);
+ return GetRawAxis(static_cast<int>(Axis::kLeftTrigger));
} else {
- return GetRawAxis(3);
+ return GetRawAxis(static_cast<int>(Axis::kRightTrigger));
}
}
diff --git a/wpilibc/src/main/native/cpp/controller/HolonomicDriveController.cpp b/wpilibc/src/main/native/cpp/controller/HolonomicDriveController.cpp
new file mode 100644
index 0000000..7482e22
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/controller/HolonomicDriveController.cpp
@@ -0,0 +1,70 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/controller/HolonomicDriveController.h"
+
+#include <units/angular_velocity.h>
+
+using namespace frc;
+
+HolonomicDriveController::HolonomicDriveController(
+ const frc2::PIDController& xController,
+ const frc2::PIDController& yController,
+ const ProfiledPIDController<units::radian>& thetaController)
+ : m_xController(xController),
+ m_yController(yController),
+ m_thetaController(thetaController) {}
+
+bool HolonomicDriveController::AtReference() const {
+ const auto& eTranslate = m_poseError.Translation();
+ const auto& eRotate = m_poseError.Rotation();
+ const auto& tolTranslate = m_poseTolerance.Translation();
+ const auto& tolRotate = m_poseTolerance.Rotation();
+ return units::math::abs(eTranslate.X()) < tolTranslate.X() &&
+ units::math::abs(eTranslate.Y()) < tolTranslate.Y() &&
+ units::math::abs(eRotate.Radians()) < tolRotate.Radians();
+}
+
+void HolonomicDriveController::SetTolerance(const Pose2d& tolerance) {
+ m_poseTolerance = tolerance;
+}
+
+ChassisSpeeds HolonomicDriveController::Calculate(
+ const Pose2d& currentPose, const Pose2d& poseRef,
+ units::meters_per_second_t linearVelocityRef, const Rotation2d& angleRef) {
+ // Calculate feedforward velocities (field-relative)
+ auto xFF = linearVelocityRef * poseRef.Rotation().Cos();
+ auto yFF = linearVelocityRef * poseRef.Rotation().Sin();
+ auto thetaFF = units::radians_per_second_t(m_thetaController.Calculate(
+ currentPose.Rotation().Radians(), angleRef.Radians()));
+
+ m_poseError = poseRef.RelativeTo(currentPose);
+
+ if (!m_enabled) {
+ return ChassisSpeeds::FromFieldRelativeSpeeds(xFF, yFF, thetaFF,
+ currentPose.Rotation());
+ }
+
+ // Calculate feedback velocities (based on position error).
+ auto xFeedback = units::meters_per_second_t(m_xController.Calculate(
+ currentPose.X().to<double>(), poseRef.X().to<double>()));
+ auto yFeedback = units::meters_per_second_t(m_yController.Calculate(
+ currentPose.Y().to<double>(), poseRef.Y().to<double>()));
+
+ // Return next output.
+ return ChassisSpeeds::FromFieldRelativeSpeeds(
+ xFF + xFeedback, yFF + yFeedback, thetaFF, currentPose.Rotation());
+}
+
+ChassisSpeeds HolonomicDriveController::Calculate(
+ const Pose2d& currentPose, const Trajectory::State& desiredState,
+ const Rotation2d& angleRef) {
+ return Calculate(currentPose, desiredState.pose, desiredState.velocity,
+ angleRef);
+}
+
+void HolonomicDriveController::SetEnabled(bool enabled) { m_enabled = enabled; }
diff --git a/wpilibc/src/main/native/cpp/controller/PIDController.cpp b/wpilibc/src/main/native/cpp/controller/PIDController.cpp
index 3abd4ba..7b9b623 100644
--- a/wpilibc/src/main/native/cpp/controller/PIDController.cpp
+++ b/wpilibc/src/main/native/cpp/controller/PIDController.cpp
@@ -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. */
@@ -12,6 +12,7 @@
#include <hal/FRCUsageReporting.h>
+#include "frc/controller/ControllerUtil.h"
#include "frc/smartdashboard/SendableBuilder.h"
#include "frc/smartdashboard/SendableRegistry.h"
@@ -26,6 +27,12 @@
frc::SendableRegistry::GetInstance().Add(this, "PIDController", instances);
}
+void PIDController::SetPID(double Kp, double Ki, double Kd) {
+ m_Kp = Kp;
+ m_Ki = Ki;
+ m_Kd = Kd;
+}
+
void PIDController::SetP(double Kp) { m_Kp = Kp; }
void PIDController::SetI(double Ki) { m_Ki = Ki; }
@@ -42,13 +49,7 @@
return units::second_t(m_period);
}
-void PIDController::SetSetpoint(double setpoint) {
- if (m_maximumInput > m_minimumInput) {
- m_setpoint = std::clamp(setpoint, m_minimumInput, m_maximumInput);
- } else {
- m_setpoint = setpoint;
- }
-}
+void PIDController::SetSetpoint(double setpoint) { m_setpoint = setpoint; }
double PIDController::GetSetpoint() const { return m_setpoint; }
@@ -60,11 +61,14 @@
void PIDController::EnableContinuousInput(double minimumInput,
double maximumInput) {
m_continuous = true;
- SetInputRange(minimumInput, maximumInput);
+ m_minimumInput = minimumInput;
+ m_maximumInput = maximumInput;
}
void PIDController::DisableContinuousInput() { m_continuous = false; }
+bool PIDController::IsContinuousInputEnabled() const { return m_continuous; }
+
void PIDController::SetIntegratorRange(double minimumIntegral,
double maximumIntegral) {
m_minimumIntegral = minimumIntegral;
@@ -77,15 +81,20 @@
m_velocityTolerance = velocityTolerance;
}
-double PIDController::GetPositionError() const {
- return GetContinuousError(m_positionError);
-}
+double PIDController::GetPositionError() const { return m_positionError; }
double PIDController::GetVelocityError() const { return m_velocityError; }
double PIDController::Calculate(double measurement) {
m_prevError = m_positionError;
- m_positionError = GetContinuousError(m_setpoint - measurement);
+
+ if (m_continuous) {
+ m_positionError = frc::GetModulusError<double>(
+ m_setpoint, measurement, m_minimumInput, m_maximumInput);
+ } else {
+ m_positionError = m_setpoint - measurement;
+ }
+
m_velocityError = (m_positionError - m_prevError) / m_period.to<double>();
if (m_Ki != 0) {
@@ -110,38 +119,13 @@
void PIDController::InitSendable(frc::SendableBuilder& builder) {
builder.SetSmartDashboardType("PIDController");
- builder.AddDoubleProperty("p", [this] { return GetP(); },
- [this](double value) { SetP(value); });
- builder.AddDoubleProperty("i", [this] { return GetI(); },
- [this](double value) { SetI(value); });
- builder.AddDoubleProperty("d", [this] { return GetD(); },
- [this](double value) { SetD(value); });
- builder.AddDoubleProperty("setpoint", [this] { return GetSetpoint(); },
- [this](double value) { SetSetpoint(value); });
-}
-
-double PIDController::GetContinuousError(double error) const {
- if (m_continuous && m_inputRange > 0) {
- error = std::fmod(error, m_inputRange);
- if (std::abs(error) > m_inputRange / 2) {
- if (error > 0) {
- return error - m_inputRange;
- } else {
- return error + m_inputRange;
- }
- }
- }
-
- return error;
-}
-
-void PIDController::SetInputRange(double minimumInput, double maximumInput) {
- m_minimumInput = minimumInput;
- m_maximumInput = maximumInput;
- m_inputRange = maximumInput - minimumInput;
-
- // Clamp setpoint to new input range
- if (m_maximumInput > m_minimumInput) {
- m_setpoint = std::clamp(m_setpoint, m_minimumInput, m_maximumInput);
- }
+ builder.AddDoubleProperty(
+ "p", [this] { return GetP(); }, [this](double value) { SetP(value); });
+ builder.AddDoubleProperty(
+ "i", [this] { return GetI(); }, [this](double value) { SetI(value); });
+ builder.AddDoubleProperty(
+ "d", [this] { return GetD(); }, [this](double value) { SetD(value); });
+ builder.AddDoubleProperty(
+ "setpoint", [this] { return GetSetpoint(); },
+ [this](double value) { SetSetpoint(value); });
}
diff --git a/wpilibc/src/main/native/cpp/controller/RamseteController.cpp b/wpilibc/src/main/native/cpp/controller/RamseteController.cpp
index c55c2e8..aad6937 100644
--- a/wpilibc/src/main/native/cpp/controller/RamseteController.cpp
+++ b/wpilibc/src/main/native/cpp/controller/RamseteController.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -9,6 +9,8 @@
#include <cmath>
+#include <units/math.h>
+
using namespace frc;
/**
@@ -45,11 +47,15 @@
const Pose2d& currentPose, const Pose2d& poseRef,
units::meters_per_second_t linearVelocityRef,
units::radians_per_second_t angularVelocityRef) {
+ if (!m_enabled) {
+ return ChassisSpeeds{linearVelocityRef, 0_mps, angularVelocityRef};
+ }
+
m_poseError = poseRef.RelativeTo(currentPose);
// Aliases for equation readability
- double eX = m_poseError.Translation().X().to<double>();
- double eY = m_poseError.Translation().Y().to<double>();
+ double eX = m_poseError.X().to<double>();
+ double eY = m_poseError.Y().to<double>();
double eTheta = m_poseError.Rotation().Radians().to<double>();
double vRef = linearVelocityRef.to<double>();
double omegaRef = angularVelocityRef.to<double>();
@@ -68,3 +74,5 @@
return Calculate(currentPose, desiredState.pose, desiredState.velocity,
desiredState.velocity * desiredState.curvature);
}
+
+void RamseteController::SetEnabled(bool enabled) { m_enabled = enabled; }
diff --git a/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp b/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp
index 2d30a2b..ce9aa05 100644
--- a/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp
+++ b/wpilibc/src/main/native/cpp/drive/DifferentialDrive.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -216,9 +216,9 @@
builder.SetSmartDashboardType("DifferentialDrive");
builder.SetActuator(true);
builder.SetSafeState([=] { StopMotor(); });
- builder.AddDoubleProperty("Left Motor Speed",
- [=]() { return m_leftMotor->Get(); },
- [=](double value) { m_leftMotor->Set(value); });
+ builder.AddDoubleProperty(
+ "Left Motor Speed", [=]() { return m_leftMotor->Get(); },
+ [=](double value) { m_leftMotor->Set(value); });
builder.AddDoubleProperty(
"Right Motor Speed",
[=]() { return m_rightMotor->Get() * m_rightSideInvertMultiplier; },
diff --git a/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp b/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp
index e03951b..983ce6a 100644
--- a/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp
+++ b/wpilibc/src/main/native/cpp/drive/KilloughDrive.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -107,13 +107,13 @@
builder.SetSmartDashboardType("KilloughDrive");
builder.SetActuator(true);
builder.SetSafeState([=] { StopMotor(); });
- builder.AddDoubleProperty("Left Motor Speed",
- [=]() { return m_leftMotor->Get(); },
- [=](double value) { m_leftMotor->Set(value); });
- builder.AddDoubleProperty("Right Motor Speed",
- [=]() { return m_rightMotor->Get(); },
- [=](double value) { m_rightMotor->Set(value); });
- builder.AddDoubleProperty("Back Motor Speed",
- [=]() { return m_backMotor->Get(); },
- [=](double value) { m_backMotor->Set(value); });
+ builder.AddDoubleProperty(
+ "Left Motor Speed", [=]() { return m_leftMotor->Get(); },
+ [=](double value) { m_leftMotor->Set(value); });
+ builder.AddDoubleProperty(
+ "Right Motor Speed", [=]() { return m_rightMotor->Get(); },
+ [=](double value) { m_rightMotor->Set(value); });
+ builder.AddDoubleProperty(
+ "Back Motor Speed", [=]() { return m_backMotor->Get(); },
+ [=](double value) { m_backMotor->Set(value); });
}
diff --git a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp
index 0102d6a..cb11d8a 100644
--- a/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp
+++ b/wpilibc/src/main/native/cpp/drive/MecanumDrive.cpp
@@ -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. */
@@ -120,9 +120,9 @@
[=](double value) {
m_frontRightMotor->Set(value * m_rightSideInvertMultiplier);
});
- builder.AddDoubleProperty("Rear Left Motor Speed",
- [=]() { return m_rearLeftMotor->Get(); },
- [=](double value) { m_rearLeftMotor->Set(value); });
+ builder.AddDoubleProperty(
+ "Rear Left Motor Speed", [=]() { return m_rearLeftMotor->Get(); },
+ [=](double value) { m_rearLeftMotor->Set(value); });
builder.AddDoubleProperty(
"Rear Right Motor Speed",
[=]() { return m_rearRightMotor->Get() * m_rightSideInvertMultiplier; },
diff --git a/wpilibc/src/main/native/cpp/frc2/Timer.cpp b/wpilibc/src/main/native/cpp/frc2/Timer.cpp
index 76721bc..36da4c6 100644
--- a/wpilibc/src/main/native/cpp/frc2/Timer.cpp
+++ b/wpilibc/src/main/native/cpp/frc2/Timer.cpp
@@ -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. */
@@ -10,8 +10,6 @@
#include <chrono>
#include <thread>
-#include <hal/FRCUsageReporting.h>
-
#include "frc/DriverStation.h"
#include "frc/RobotController.h"
@@ -36,9 +34,6 @@
using namespace frc2;
-// for compatibility with msvc12--see C2864
-const units::second_t Timer::kRolloverTime = units::second_t((1ll << 32) / 1e6);
-
Timer::Timer() { Reset(); }
Timer::Timer(const Timer& rhs)
@@ -77,13 +72,6 @@
std::scoped_lock lock(m_mutex);
if (m_running) {
- // If the current time is before the start time, then the FPGA clock rolled
- // over. Compensate by adding the ~71 minutes that it takes to roll over to
- // the current time.
- if (currentTime < m_startTime) {
- currentTime += kRolloverTime;
- }
-
result = (currentTime - m_startTime) + m_accumulatedTime;
} else {
result = m_accumulatedTime;
@@ -116,15 +104,22 @@
}
}
+bool Timer::HasElapsed(units::second_t period) const { return Get() > period; }
+
bool Timer::HasPeriodPassed(units::second_t period) {
+ return AdvanceIfElapsed(period);
+}
+
+bool Timer::AdvanceIfElapsed(units::second_t period) {
if (Get() > period) {
std::scoped_lock lock(m_mutex);
// Advance the start time by the period.
m_startTime += period;
// Don't set it to the current time... we want to avoid drift.
return true;
+ } else {
+ return false;
}
- return false;
}
units::second_t Timer::GetFPGATimestamp() {
diff --git a/wpilibc/src/main/native/cpp/geometry/Pose2d.cpp b/wpilibc/src/main/native/cpp/geometry/Pose2d.cpp
deleted file mode 100644
index 1754830..0000000
--- a/wpilibc/src/main/native/cpp/geometry/Pose2d.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/geometry/Pose2d.h"
-
-#include <cmath>
-
-#include <wpi/json.h>
-
-using namespace frc;
-
-Pose2d::Pose2d(Translation2d translation, Rotation2d rotation)
- : m_translation(translation), m_rotation(rotation) {}
-
-Pose2d::Pose2d(units::meter_t x, units::meter_t y, Rotation2d rotation)
- : m_translation(x, y), m_rotation(rotation) {}
-
-Pose2d Pose2d::operator+(const Transform2d& other) const {
- return TransformBy(other);
-}
-
-Pose2d& Pose2d::operator+=(const Transform2d& other) {
- m_translation += other.Translation().RotateBy(m_rotation);
- m_rotation += other.Rotation();
- return *this;
-}
-
-Transform2d Pose2d::operator-(const Pose2d& other) const {
- const auto pose = this->RelativeTo(other);
- return Transform2d(pose.Translation(), pose.Rotation());
-}
-
-bool Pose2d::operator==(const Pose2d& other) const {
- return m_translation == other.m_translation && m_rotation == other.m_rotation;
-}
-
-bool Pose2d::operator!=(const Pose2d& other) const {
- return !operator==(other);
-}
-
-Pose2d Pose2d::TransformBy(const Transform2d& other) const {
- return {m_translation + (other.Translation().RotateBy(m_rotation)),
- m_rotation + other.Rotation()};
-}
-
-Pose2d Pose2d::RelativeTo(const Pose2d& other) const {
- const Transform2d transform{other, *this};
- return {transform.Translation(), transform.Rotation()};
-}
-
-Pose2d Pose2d::Exp(const Twist2d& twist) const {
- const auto dx = twist.dx;
- const auto dy = twist.dy;
- const auto dtheta = twist.dtheta.to<double>();
-
- const auto sinTheta = std::sin(dtheta);
- const auto cosTheta = std::cos(dtheta);
-
- double s, c;
- if (std::abs(dtheta) < 1E-9) {
- s = 1.0 - 1.0 / 6.0 * dtheta * dtheta;
- c = 0.5 * dtheta;
- } else {
- s = sinTheta / dtheta;
- c = (1 - cosTheta) / dtheta;
- }
-
- const Transform2d transform{Translation2d{dx * s - dy * c, dx * c + dy * s},
- Rotation2d{cosTheta, sinTheta}};
-
- return *this + transform;
-}
-
-Twist2d Pose2d::Log(const Pose2d& end) const {
- const auto transform = end.RelativeTo(*this);
- const auto dtheta = transform.Rotation().Radians().to<double>();
- const auto halfDtheta = dtheta / 2.0;
-
- const auto cosMinusOne = transform.Rotation().Cos() - 1;
-
- double halfThetaByTanOfHalfDtheta;
-
- if (std::abs(cosMinusOne) < 1E-9) {
- halfThetaByTanOfHalfDtheta = 1.0 - 1.0 / 12.0 * dtheta * dtheta;
- } else {
- halfThetaByTanOfHalfDtheta =
- -(halfDtheta * transform.Rotation().Sin()) / cosMinusOne;
- }
-
- const Translation2d translationPart =
- transform.Translation().RotateBy(
- {halfThetaByTanOfHalfDtheta, -halfDtheta}) *
- std::hypot(halfThetaByTanOfHalfDtheta, halfDtheta);
-
- return {translationPart.X(), translationPart.Y(), units::radian_t(dtheta)};
-}
-
-void frc::to_json(wpi::json& json, const Pose2d& pose) {
- json = wpi::json{{"translation", pose.Translation()},
- {"rotation", pose.Rotation()}};
-}
-
-void frc::from_json(const wpi::json& json, Pose2d& pose) {
- pose = Pose2d{json.at("translation").get<Translation2d>(),
- json.at("rotation").get<Rotation2d>()};
-}
diff --git a/wpilibc/src/main/native/cpp/geometry/Rotation2d.cpp b/wpilibc/src/main/native/cpp/geometry/Rotation2d.cpp
deleted file mode 100644
index a3c4bea..0000000
--- a/wpilibc/src/main/native/cpp/geometry/Rotation2d.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/geometry/Rotation2d.h"
-
-#include <cmath>
-
-#include <wpi/json.h>
-
-using namespace frc;
-
-Rotation2d::Rotation2d(units::radian_t value)
- : m_value(value),
- m_cos(units::math::cos(value)),
- m_sin(units::math::sin(value)) {}
-
-Rotation2d::Rotation2d(double x, double y) {
- const auto magnitude = std::hypot(x, y);
- if (magnitude > 1e-6) {
- m_sin = y / magnitude;
- m_cos = x / magnitude;
- } else {
- m_sin = 0.0;
- m_cos = 1.0;
- }
- m_value = units::radian_t(std::atan2(m_sin, m_cos));
-}
-
-Rotation2d Rotation2d::operator+(const Rotation2d& other) const {
- return RotateBy(other);
-}
-
-Rotation2d& Rotation2d::operator+=(const Rotation2d& other) {
- double cos = Cos() * other.Cos() - Sin() * other.Sin();
- double sin = Cos() * other.Sin() + Sin() * other.Cos();
- m_cos = cos;
- m_sin = sin;
- m_value = units::radian_t(std::atan2(m_sin, m_cos));
- return *this;
-}
-
-Rotation2d Rotation2d::operator-(const Rotation2d& other) const {
- return *this + -other;
-}
-
-Rotation2d& Rotation2d::operator-=(const Rotation2d& other) {
- *this += -other;
- return *this;
-}
-
-Rotation2d Rotation2d::operator-() const { return Rotation2d(-m_value); }
-
-Rotation2d Rotation2d::operator*(double scalar) const {
- return Rotation2d(m_value * scalar);
-}
-
-bool Rotation2d::operator==(const Rotation2d& other) const {
- return units::math::abs(m_value - other.m_value) < 1E-9_rad;
-}
-
-bool Rotation2d::operator!=(const Rotation2d& other) const {
- return !operator==(other);
-}
-
-Rotation2d Rotation2d::RotateBy(const Rotation2d& other) const {
- return {Cos() * other.Cos() - Sin() * other.Sin(),
- Cos() * other.Sin() + Sin() * other.Cos()};
-}
-
-void frc::to_json(wpi::json& json, const Rotation2d& rotation) {
- json = wpi::json{{"radians", rotation.Radians().to<double>()}};
-}
-
-void frc::from_json(const wpi::json& json, Rotation2d& rotation) {
- rotation = Rotation2d{units::radian_t{json.at("radians").get<double>()}};
-}
diff --git a/wpilibc/src/main/native/cpp/geometry/Transform2d.cpp b/wpilibc/src/main/native/cpp/geometry/Transform2d.cpp
deleted file mode 100644
index 04f0419..0000000
--- a/wpilibc/src/main/native/cpp/geometry/Transform2d.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/geometry/Transform2d.h"
-
-#include "frc/geometry/Pose2d.h"
-
-using namespace frc;
-
-Transform2d::Transform2d(Pose2d initial, Pose2d final) {
- // We are rotating the difference between the translations
- // using a clockwise rotation matrix. This transforms the global
- // delta into a local delta (relative to the initial pose).
- m_translation = (final.Translation() - initial.Translation())
- .RotateBy(-initial.Rotation());
-
- m_rotation = final.Rotation() - initial.Rotation();
-}
-
-Transform2d::Transform2d(Translation2d translation, Rotation2d rotation)
- : m_translation(translation), m_rotation(rotation) {}
-
-bool Transform2d::operator==(const Transform2d& other) const {
- return m_translation == other.m_translation && m_rotation == other.m_rotation;
-}
-
-bool Transform2d::operator!=(const Transform2d& other) const {
- return !operator==(other);
-}
diff --git a/wpilibc/src/main/native/cpp/geometry/Translation2d.cpp b/wpilibc/src/main/native/cpp/geometry/Translation2d.cpp
deleted file mode 100644
index c3db7e3..0000000
--- a/wpilibc/src/main/native/cpp/geometry/Translation2d.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/geometry/Translation2d.h"
-
-#include <wpi/json.h>
-
-using namespace frc;
-
-Translation2d::Translation2d(units::meter_t x, units::meter_t y)
- : m_x(x), m_y(y) {}
-
-units::meter_t Translation2d::Distance(const Translation2d& other) const {
- return units::math::hypot(other.m_x - m_x, other.m_y - m_y);
-}
-
-units::meter_t Translation2d::Norm() const {
- return units::math::hypot(m_x, m_y);
-}
-
-Translation2d Translation2d::RotateBy(const Rotation2d& other) const {
- return {m_x * other.Cos() - m_y * other.Sin(),
- m_x * other.Sin() + m_y * other.Cos()};
-}
-
-Translation2d Translation2d::operator+(const Translation2d& other) const {
- return {X() + other.X(), Y() + other.Y()};
-}
-
-Translation2d& Translation2d::operator+=(const Translation2d& other) {
- m_x += other.m_x;
- m_y += other.m_y;
- return *this;
-}
-
-Translation2d Translation2d::operator-(const Translation2d& other) const {
- return *this + -other;
-}
-
-Translation2d& Translation2d::operator-=(const Translation2d& other) {
- *this += -other;
- return *this;
-}
-
-Translation2d Translation2d::operator-() const { return {-m_x, -m_y}; }
-
-Translation2d Translation2d::operator*(double scalar) const {
- return {scalar * m_x, scalar * m_y};
-}
-
-Translation2d& Translation2d::operator*=(double scalar) {
- m_x *= scalar;
- m_y *= scalar;
- return *this;
-}
-
-Translation2d Translation2d::operator/(double scalar) const {
- return *this * (1.0 / scalar);
-}
-
-bool Translation2d::operator==(const Translation2d& other) const {
- return units::math::abs(m_x - other.m_x) < 1E-9_m &&
- units::math::abs(m_y - other.m_y) < 1E-9_m;
-}
-
-bool Translation2d::operator!=(const Translation2d& other) const {
- return !operator==(other);
-}
-
-Translation2d& Translation2d::operator/=(double scalar) {
- *this *= (1.0 / scalar);
- return *this;
-}
-
-void frc::to_json(wpi::json& json, const Translation2d& translation) {
- json = wpi::json{{"x", translation.X().to<double>()},
- {"y", translation.Y().to<double>()}};
-}
-
-void frc::from_json(const wpi::json& json, Translation2d& translation) {
- translation = Translation2d{units::meter_t{json.at("x").get<double>()},
- units::meter_t{json.at("y").get<double>()}};
-}
diff --git a/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveOdometry.cpp b/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveOdometry.cpp
deleted file mode 100644
index 07a8e3b..0000000
--- a/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveOdometry.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/DifferentialDriveOdometry.h"
-
-#include <hal/FRCUsageReporting.h>
-
-using namespace frc;
-
-DifferentialDriveOdometry::DifferentialDriveOdometry(
- const Rotation2d& gyroAngle, const Pose2d& initialPose)
- : m_pose(initialPose) {
- m_previousAngle = m_pose.Rotation();
- m_gyroOffset = m_pose.Rotation() - gyroAngle;
- HAL_Report(HALUsageReporting::kResourceType_Odometry,
- HALUsageReporting::kOdometry_DifferentialDrive);
-}
-
-const Pose2d& DifferentialDriveOdometry::Update(const Rotation2d& gyroAngle,
- units::meter_t leftDistance,
- units::meter_t rightDistance) {
- auto deltaLeftDistance = leftDistance - m_prevLeftDistance;
- auto deltaRightDistance = rightDistance - m_prevRightDistance;
-
- m_prevLeftDistance = leftDistance;
- m_prevRightDistance = rightDistance;
-
- auto averageDeltaDistance = (deltaLeftDistance + deltaRightDistance) / 2.0;
- auto angle = gyroAngle + m_gyroOffset;
-
- auto newPose = m_pose.Exp(
- {averageDeltaDistance, 0_m, (angle - m_previousAngle).Radians()});
-
- m_previousAngle = angle;
- m_pose = {newPose.Translation(), angle};
-
- return m_pose;
-}
diff --git a/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveWheelSpeeds.cpp b/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveWheelSpeeds.cpp
deleted file mode 100644
index 5b13f0e..0000000
--- a/wpilibc/src/main/native/cpp/kinematics/DifferentialDriveWheelSpeeds.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/DifferentialDriveWheelSpeeds.h"
-
-using namespace frc;
-
-void DifferentialDriveWheelSpeeds::Normalize(
- units::meters_per_second_t attainableMaxSpeed) {
- auto realMaxSpeed =
- units::math::max(units::math::abs(left), units::math::abs(right));
-
- if (realMaxSpeed > attainableMaxSpeed) {
- left = left / realMaxSpeed * attainableMaxSpeed;
- right = right / realMaxSpeed * attainableMaxSpeed;
- }
-}
diff --git a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp b/wpilibc/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp
deleted file mode 100644
index cf6ebb5..0000000
--- a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveKinematics.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/MecanumDriveKinematics.h"
-
-using namespace frc;
-
-MecanumDriveWheelSpeeds MecanumDriveKinematics::ToWheelSpeeds(
- const ChassisSpeeds& chassisSpeeds, const Translation2d& centerOfRotation) {
- // We have a new center of rotation. We need to compute the matrix again.
- if (centerOfRotation != m_previousCoR) {
- auto fl = m_frontLeftWheel - centerOfRotation;
- auto fr = m_frontRightWheel - centerOfRotation;
- auto rl = m_rearLeftWheel - centerOfRotation;
- auto rr = m_rearRightWheel - centerOfRotation;
-
- SetInverseKinematics(fl, fr, rl, rr);
-
- m_previousCoR = centerOfRotation;
- }
-
- Eigen::Vector3d chassisSpeedsVector;
- chassisSpeedsVector << chassisSpeeds.vx.to<double>(),
- chassisSpeeds.vy.to<double>(), chassisSpeeds.omega.to<double>();
-
- Eigen::Matrix<double, 4, 1> wheelsMatrix =
- m_inverseKinematics * chassisSpeedsVector;
-
- MecanumDriveWheelSpeeds wheelSpeeds;
- wheelSpeeds.frontLeft = units::meters_per_second_t{wheelsMatrix(0, 0)};
- wheelSpeeds.frontRight = units::meters_per_second_t{wheelsMatrix(1, 0)};
- wheelSpeeds.rearLeft = units::meters_per_second_t{wheelsMatrix(2, 0)};
- wheelSpeeds.rearRight = units::meters_per_second_t{wheelsMatrix(3, 0)};
- return wheelSpeeds;
-}
-
-ChassisSpeeds MecanumDriveKinematics::ToChassisSpeeds(
- const MecanumDriveWheelSpeeds& wheelSpeeds) {
- Eigen::Matrix<double, 4, 1> wheelSpeedsMatrix;
- // clang-format off
- wheelSpeedsMatrix << wheelSpeeds.frontLeft.to<double>(), wheelSpeeds.frontRight.to<double>(),
- wheelSpeeds.rearLeft.to<double>(), wheelSpeeds.rearRight.to<double>();
- // clang-format on
-
- Eigen::Vector3d chassisSpeedsVector =
- m_forwardKinematics.solve(wheelSpeedsMatrix);
-
- return {units::meters_per_second_t{chassisSpeedsVector(0)},
- units::meters_per_second_t{chassisSpeedsVector(1)},
- units::radians_per_second_t{chassisSpeedsVector(2)}};
-}
-
-void MecanumDriveKinematics::SetInverseKinematics(Translation2d fl,
- Translation2d fr,
- Translation2d rl,
- Translation2d rr) {
- // clang-format off
- m_inverseKinematics << 1, -1, (-(fl.X() + fl.Y())).template to<double>(),
- 1, 1, (fr.X() - fr.Y()).template to<double>(),
- 1, 1, (rl.X() - rl.Y()).template to<double>(),
- 1, -1, (-(rr.X() + rr.Y())).template to<double>();
- // clang-format on
- m_inverseKinematics /= std::sqrt(2);
-}
diff --git a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveOdometry.cpp b/wpilibc/src/main/native/cpp/kinematics/MecanumDriveOdometry.cpp
deleted file mode 100644
index 3843483..0000000
--- a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveOdometry.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/MecanumDriveOdometry.h"
-
-#include <hal/FRCUsageReporting.h>
-
-using namespace frc;
-
-MecanumDriveOdometry::MecanumDriveOdometry(MecanumDriveKinematics kinematics,
- const Rotation2d& gyroAngle,
- const Pose2d& initialPose)
- : m_kinematics(kinematics), m_pose(initialPose) {
- m_previousAngle = m_pose.Rotation();
- m_gyroOffset = m_pose.Rotation() - gyroAngle;
- HAL_Report(HALUsageReporting::kResourceType_Odometry,
- HALUsageReporting::kOdometry_MecanumDrive);
-}
-
-const Pose2d& MecanumDriveOdometry::UpdateWithTime(
- units::second_t currentTime, const Rotation2d& gyroAngle,
- MecanumDriveWheelSpeeds wheelSpeeds) {
- units::second_t deltaTime =
- (m_previousTime >= 0_s) ? currentTime - m_previousTime : 0_s;
- m_previousTime = currentTime;
-
- auto angle = gyroAngle + m_gyroOffset;
-
- auto [dx, dy, dtheta] = m_kinematics.ToChassisSpeeds(wheelSpeeds);
- static_cast<void>(dtheta);
-
- auto newPose = m_pose.Exp(
- {dx * deltaTime, dy * deltaTime, (angle - m_previousAngle).Radians()});
-
- m_previousAngle = angle;
- m_pose = {newPose.Translation(), angle};
-
- return m_pose;
-}
diff --git a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveWheelSpeeds.cpp b/wpilibc/src/main/native/cpp/kinematics/MecanumDriveWheelSpeeds.cpp
deleted file mode 100644
index 1641ba8..0000000
--- a/wpilibc/src/main/native/cpp/kinematics/MecanumDriveWheelSpeeds.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/MecanumDriveWheelSpeeds.h"
-
-#include <algorithm>
-#include <array>
-#include <cmath>
-
-using namespace frc;
-
-void MecanumDriveWheelSpeeds::Normalize(
- units::meters_per_second_t attainableMaxSpeed) {
- std::array<units::meters_per_second_t, 4> wheelSpeeds{frontLeft, frontRight,
- rearLeft, rearRight};
- units::meters_per_second_t realMaxSpeed = *std::max_element(
- wheelSpeeds.begin(), wheelSpeeds.end(), [](const auto& a, const auto& b) {
- return units::math::abs(a) < units::math::abs(b);
- });
-
- if (realMaxSpeed > attainableMaxSpeed) {
- for (int i = 0; i < 4; ++i) {
- wheelSpeeds[i] = wheelSpeeds[i] / realMaxSpeed * attainableMaxSpeed;
- }
- frontLeft = wheelSpeeds[0];
- frontRight = wheelSpeeds[1];
- rearLeft = wheelSpeeds[2];
- rearRight = wheelSpeeds[3];
- }
-}
diff --git a/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp b/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp
index 10996e4..517ecf7 100644
--- a/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp
+++ b/wpilibc/src/main/native/cpp/livewindow/LiveWindow.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2012-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2012-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. */
@@ -104,10 +104,12 @@
// Force table generation now to make sure everything is defined
UpdateValuesUnsafe();
if (enabled) {
+ if (this->enabled) this->enabled();
} else {
m_impl->registry.ForeachLiveWindow(m_impl->dataHandle, [&](auto& cbdata) {
cbdata.builder.StopLiveWindowMode();
});
+ if (this->disabled) this->disabled();
}
m_impl->enabledEntry.SetBoolean(enabled);
}
diff --git a/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp b/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp
index b6f8ce9..663cc19 100644
--- a/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp
+++ b/wpilibc/src/main/native/cpp/shuffleboard/SendableCameraWrapper.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -30,7 +30,7 @@
} // namespace detail
void SendableCameraWrapper::InitSendable(SendableBuilder& builder) {
- builder.AddStringProperty(".ShuffleboardURI", [this] { return m_uri; },
- nullptr);
+ builder.AddStringProperty(
+ ".ShuffleboardURI", [this] { return m_uri; }, nullptr);
}
} // namespace frc
diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp
index bb9dc9e..d73f635 100644
--- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp
+++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardContainer.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -47,7 +47,7 @@
wpi::SmallVector<char, 16> storage;
auto titleRef = title.toStringRef(storage);
if (m_layouts.count(titleRef) == 0) {
- auto layout = std::make_unique<ShuffleboardLayout>(*this, type, titleRef);
+ auto layout = std::make_unique<ShuffleboardLayout>(*this, titleRef, type);
auto ptr = layout.get();
m_components.emplace_back(std::move(layout));
m_layouts.insert(std::make_pair(titleRef, ptr));
diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardInstance.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardInstance.cpp
index 9717a8e..3316b3e 100644
--- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardInstance.cpp
+++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardInstance.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -10,6 +10,7 @@
#include <hal/FRCUsageReporting.h>
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableInstance.h>
+#include <wpi/SmallVector.h>
#include <wpi/StringMap.h>
#include "frc/shuffleboard/Shuffleboard.h"
@@ -43,7 +44,7 @@
void ShuffleboardInstance::Update() {
if (m_impl->tabsChanged) {
- std::vector<std::string> tabTitles;
+ wpi::SmallVector<std::string, 16> tabTitles;
for (auto& entry : m_impl->tabs) {
tabTitles.emplace_back(entry.second.GetTitle());
}
diff --git a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp
index 8418b77..1cbfb80 100644
--- a/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp
+++ b/wpilibc/src/main/native/cpp/shuffleboard/ShuffleboardLayout.cpp
@@ -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. */
@@ -10,11 +10,11 @@
using namespace frc;
ShuffleboardLayout::ShuffleboardLayout(ShuffleboardContainer& parent,
- const wpi::Twine& name,
+ const wpi::Twine& title,
const wpi::Twine& type)
- : ShuffleboardValue(type),
- ShuffleboardComponent(parent, type, name),
- ShuffleboardContainer(name) {
+ : ShuffleboardValue(title),
+ ShuffleboardComponent(parent, title, type),
+ ShuffleboardContainer(title) {
m_isLayout = true;
}
diff --git a/wpilibc/src/main/native/cpp/simulation/ADXRS450_GyroSim.cpp b/wpilibc/src/main/native/cpp/simulation/ADXRS450_GyroSim.cpp
new file mode 100644
index 0000000..74a5180
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/ADXRS450_GyroSim.cpp
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/ADXRS450_GyroSim.h"
+
+#include <wpi/SmallString.h>
+#include <wpi/raw_ostream.h>
+
+#include "frc/ADXRS450_Gyro.h"
+#include "frc/simulation/SimDeviceSim.h"
+
+using namespace frc::sim;
+
+ADXRS450_GyroSim::ADXRS450_GyroSim(const frc::ADXRS450_Gyro& gyro) {
+ wpi::SmallString<128> fullname;
+ wpi::raw_svector_ostream os(fullname);
+ os << "ADXRS450_Gyro" << '[' << gyro.GetPort() << ']';
+ frc::sim::SimDeviceSim deviceSim{fullname.c_str()};
+ m_simAngle = deviceSim.GetDouble("Angle");
+ m_simRate = deviceSim.GetDouble("Rate");
+}
+
+void ADXRS450_GyroSim::SetAngle(units::degree_t angle) {
+ m_simAngle.Set(angle.to<double>());
+}
+
+void ADXRS450_GyroSim::SetRate(units::degrees_per_second_t rate) {
+ m_simRate.Set(rate.to<double>());
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/AddressableLEDSim.cpp b/wpilibc/src/main/native/cpp/simulation/AddressableLEDSim.cpp
new file mode 100644
index 0000000..743c51d
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/AddressableLEDSim.cpp
@@ -0,0 +1,119 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/AddressableLEDSim.h"
+
+#include <memory>
+#include <stdexcept>
+#include <utility>
+
+#include <hal/simulation/AddressableLEDData.h>
+
+using namespace frc;
+using namespace frc::sim;
+
+AddressableLEDSim::AddressableLEDSim() : m_index{0} {}
+
+AddressableLEDSim::AddressableLEDSim(const AddressableLED& addressableLED)
+ : m_index{0} {}
+
+AddressableLEDSim AddressableLEDSim::CreateForChannel(int pwmChannel) {
+ int index = HALSIM_FindAddressableLEDForChannel(pwmChannel);
+ if (index < 0)
+ throw std::out_of_range("no addressable LED found for PWM channel");
+ return AddressableLEDSim{index};
+}
+
+AddressableLEDSim AddressableLEDSim::CreateForIndex(int index) {
+ return AddressableLEDSim{index};
+}
+
+std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAddressableLEDInitializedCallback);
+ store->SetUid(HALSIM_RegisterAddressableLEDInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool AddressableLEDSim::GetInitialized() const {
+ return HALSIM_GetAddressableLEDInitialized(m_index);
+}
+
+void AddressableLEDSim::SetInitialized(bool initialized) {
+ HALSIM_SetAddressableLEDInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterOutputPortCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAddressableLEDOutputPortCallback);
+ store->SetUid(HALSIM_RegisterAddressableLEDOutputPortCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int AddressableLEDSim::GetOutputPort() const {
+ return HALSIM_GetAddressableLEDOutputPort(m_index);
+}
+
+void AddressableLEDSim::SetOutputPort(int outputPort) {
+ HALSIM_SetAddressableLEDOutputPort(m_index, outputPort);
+}
+
+std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterLengthCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAddressableLEDLengthCallback);
+ store->SetUid(HALSIM_RegisterAddressableLEDLengthCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int AddressableLEDSim::GetLength() const {
+ return HALSIM_GetAddressableLEDLength(m_index);
+}
+
+void AddressableLEDSim::SetLength(int length) {
+ HALSIM_SetAddressableLEDLength(m_index, length);
+}
+
+std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterRunningCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAddressableLEDRunningCallback);
+ store->SetUid(HALSIM_RegisterAddressableLEDRunningCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int AddressableLEDSim::GetRunning() const {
+ return HALSIM_GetAddressableLEDRunning(m_index);
+}
+
+void AddressableLEDSim::SetRunning(bool running) {
+ HALSIM_SetAddressableLEDRunning(m_index, running);
+}
+
+std::unique_ptr<CallbackStore> AddressableLEDSim::RegisterDataCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAddressableLEDDataCallback);
+ store->SetUid(HALSIM_RegisterAddressableLEDDataCallback(
+ m_index, &ConstBufferCallbackStoreThunk, store.get()));
+ return store;
+}
+
+int AddressableLEDSim::GetData(struct HAL_AddressableLEDData* data) const {
+ return HALSIM_GetAddressableLEDData(m_index, data);
+}
+
+void AddressableLEDSim::SetData(struct HAL_AddressableLEDData* data,
+ int length) {
+ HALSIM_SetAddressableLEDData(m_index, data, length);
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/AnalogEncoderSim.cpp b/wpilibc/src/main/native/cpp/simulation/AnalogEncoderSim.cpp
new file mode 100644
index 0000000..5fee737
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/AnalogEncoderSim.cpp
@@ -0,0 +1,41 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/AnalogEncoderSim.h"
+
+#include <wpi/SmallString.h>
+#include <wpi/raw_ostream.h>
+
+#include "frc/AnalogEncoder.h"
+#include "frc/simulation/SimDeviceSim.h"
+
+using namespace frc::sim;
+
+AnalogEncoderSim::AnalogEncoderSim(const frc::AnalogEncoder& encoder) {
+ wpi::SmallString<128> fullname;
+ wpi::raw_svector_ostream os(fullname);
+ os << "AnalogEncoder" << '[' << encoder.GetChannel() << ']';
+ frc::sim::SimDeviceSim deviceSim{fullname.c_str()};
+ m_positionSim = deviceSim.GetDouble("Position");
+}
+
+void AnalogEncoderSim::SetPosition(frc::Rotation2d angle) {
+ SetTurns(angle.Degrees());
+}
+
+void AnalogEncoderSim::SetTurns(units::turn_t turns) {
+ m_positionSim.Set(turns.to<double>());
+}
+
+units::turn_t AnalogEncoderSim::GetTurns() {
+ return units::turn_t{m_positionSim.Get()};
+}
+
+frc::Rotation2d AnalogEncoderSim::GetPosition() {
+ units::radian_t rads = GetTurns();
+ return frc::Rotation2d{rads};
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/AnalogGyroSim.cpp b/wpilibc/src/main/native/cpp/simulation/AnalogGyroSim.cpp
new file mode 100644
index 0000000..b7cab6b
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/AnalogGyroSim.cpp
@@ -0,0 +1,77 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/AnalogGyroSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/AnalogGyroData.h>
+
+#include "frc/AnalogGyro.h"
+#include "frc/AnalogInput.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+AnalogGyroSim::AnalogGyroSim(const AnalogGyro& gyro)
+ : m_index{gyro.GetAnalogInput()->GetChannel()} {}
+
+AnalogGyroSim::AnalogGyroSim(int channel) : m_index{channel} {}
+
+std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterAngleCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogGyroAngleCallback);
+ store->SetUid(HALSIM_RegisterAnalogGyroAngleCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double AnalogGyroSim::GetAngle() const {
+ return HALSIM_GetAnalogGyroAngle(m_index);
+}
+
+void AnalogGyroSim::SetAngle(double angle) {
+ HALSIM_SetAnalogGyroAngle(m_index, angle);
+}
+
+std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterRateCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogGyroRateCallback);
+ store->SetUid(HALSIM_RegisterAnalogGyroRateCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double AnalogGyroSim::GetRate() const {
+ return HALSIM_GetAnalogGyroRate(m_index);
+}
+
+void AnalogGyroSim::SetRate(double rate) {
+ HALSIM_SetAnalogGyroRate(m_index, rate);
+}
+
+std::unique_ptr<CallbackStore> AnalogGyroSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogGyroInitializedCallback);
+ store->SetUid(HALSIM_RegisterAnalogGyroInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool AnalogGyroSim::GetInitialized() const {
+ return HALSIM_GetAnalogGyroInitialized(m_index);
+}
+
+void AnalogGyroSim::SetInitialized(bool initialized) {
+ HALSIM_SetAnalogGyroInitialized(m_index, initialized);
+}
+
+void AnalogGyroSim::ResetData() { HALSIM_ResetAnalogGyroData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/AnalogInputSim.cpp b/wpilibc/src/main/native/cpp/simulation/AnalogInputSim.cpp
new file mode 100644
index 0000000..057a188
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/AnalogInputSim.cpp
@@ -0,0 +1,182 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/AnalogInputSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/AnalogInData.h>
+
+#include "frc/AnalogInput.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+AnalogInputSim::AnalogInputSim(const AnalogInput& analogInput)
+ : m_index{analogInput.GetChannel()} {}
+
+AnalogInputSim::AnalogInputSim(int channel) : m_index{channel} {}
+
+std::unique_ptr<CallbackStore> AnalogInputSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInInitializedCallback);
+ store->SetUid(HALSIM_RegisterAnalogInInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool AnalogInputSim::GetInitialized() const {
+ return HALSIM_GetAnalogInInitialized(m_index);
+}
+
+void AnalogInputSim::SetInitialized(bool initialized) {
+ HALSIM_SetAnalogInInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> AnalogInputSim::RegisterAverageBitsCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInAverageBitsCallback);
+ store->SetUid(HALSIM_RegisterAnalogInAverageBitsCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int AnalogInputSim::GetAverageBits() const {
+ return HALSIM_GetAnalogInAverageBits(m_index);
+}
+
+void AnalogInputSim::SetAverageBits(int averageBits) {
+ HALSIM_SetAnalogInAverageBits(m_index, averageBits);
+}
+
+std::unique_ptr<CallbackStore> AnalogInputSim::RegisterOversampleBitsCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInOversampleBitsCallback);
+ store->SetUid(HALSIM_RegisterAnalogInOversampleBitsCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int AnalogInputSim::GetOversampleBits() const {
+ return HALSIM_GetAnalogInOversampleBits(m_index);
+}
+
+void AnalogInputSim::SetOversampleBits(int oversampleBits) {
+ HALSIM_SetAnalogInOversampleBits(m_index, oversampleBits);
+}
+
+std::unique_ptr<CallbackStore> AnalogInputSim::RegisterVoltageCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInVoltageCallback);
+ store->SetUid(HALSIM_RegisterAnalogInVoltageCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double AnalogInputSim::GetVoltage() const {
+ return HALSIM_GetAnalogInVoltage(m_index);
+}
+
+void AnalogInputSim::SetVoltage(double voltage) {
+ HALSIM_SetAnalogInVoltage(m_index, voltage);
+}
+
+std::unique_ptr<CallbackStore>
+AnalogInputSim::RegisterAccumulatorInitializedCallback(NotifyCallback callback,
+ bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback,
+ &HALSIM_CancelAnalogInAccumulatorInitializedCallback);
+ store->SetUid(HALSIM_RegisterAnalogInAccumulatorInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool AnalogInputSim::GetAccumulatorInitialized() const {
+ return HALSIM_GetAnalogInAccumulatorInitialized(m_index);
+}
+
+void AnalogInputSim::SetAccumulatorInitialized(bool accumulatorInitialized) {
+ HALSIM_SetAnalogInAccumulatorInitialized(m_index, accumulatorInitialized);
+}
+
+std::unique_ptr<CallbackStore> AnalogInputSim::RegisterAccumulatorValueCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorValueCallback);
+ store->SetUid(HALSIM_RegisterAnalogInAccumulatorValueCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int64_t AnalogInputSim::GetAccumulatorValue() const {
+ return HALSIM_GetAnalogInAccumulatorValue(m_index);
+}
+
+void AnalogInputSim::SetAccumulatorValue(int64_t accumulatorValue) {
+ HALSIM_SetAnalogInAccumulatorValue(m_index, accumulatorValue);
+}
+
+std::unique_ptr<CallbackStore> AnalogInputSim::RegisterAccumulatorCountCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCountCallback);
+ store->SetUid(HALSIM_RegisterAnalogInAccumulatorCountCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int64_t AnalogInputSim::GetAccumulatorCount() const {
+ return HALSIM_GetAnalogInAccumulatorCount(m_index);
+}
+
+void AnalogInputSim::SetAccumulatorCount(int64_t accumulatorCount) {
+ HALSIM_SetAnalogInAccumulatorCount(m_index, accumulatorCount);
+}
+
+std::unique_ptr<CallbackStore>
+AnalogInputSim::RegisterAccumulatorCenterCallback(NotifyCallback callback,
+ bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorCenterCallback);
+ store->SetUid(HALSIM_RegisterAnalogInAccumulatorCenterCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int AnalogInputSim::GetAccumulatorCenter() const {
+ return HALSIM_GetAnalogInAccumulatorCenter(m_index);
+}
+
+void AnalogInputSim::SetAccumulatorCenter(int accumulatorCenter) {
+ HALSIM_SetAnalogInAccumulatorCenter(m_index, accumulatorCenter);
+}
+
+std::unique_ptr<CallbackStore>
+AnalogInputSim::RegisterAccumulatorDeadbandCallback(NotifyCallback callback,
+ bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogInAccumulatorDeadbandCallback);
+ store->SetUid(HALSIM_RegisterAnalogInAccumulatorDeadbandCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int AnalogInputSim::GetAccumulatorDeadband() const {
+ return HALSIM_GetAnalogInAccumulatorDeadband(m_index);
+}
+
+void AnalogInputSim::SetAccumulatorDeadband(int accumulatorDeadband) {
+ HALSIM_SetAnalogInAccumulatorDeadband(m_index, accumulatorDeadband);
+}
+
+void AnalogInputSim::ResetData() { HALSIM_ResetAnalogInData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/AnalogOutputSim.cpp b/wpilibc/src/main/native/cpp/simulation/AnalogOutputSim.cpp
new file mode 100644
index 0000000..4de9082
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/AnalogOutputSim.cpp
@@ -0,0 +1,59 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/AnalogOutputSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/AnalogOutData.h>
+
+#include "frc/AnalogOutput.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+AnalogOutputSim::AnalogOutputSim(const AnalogOutput& analogOutput)
+ : m_index{analogOutput.GetChannel()} {}
+
+AnalogOutputSim::AnalogOutputSim(int channel) : m_index{channel} {}
+
+std::unique_ptr<CallbackStore> AnalogOutputSim::RegisterVoltageCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogOutVoltageCallback);
+ store->SetUid(HALSIM_RegisterAnalogOutVoltageCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double AnalogOutputSim::GetVoltage() const {
+ return HALSIM_GetAnalogOutVoltage(m_index);
+}
+
+void AnalogOutputSim::SetVoltage(double voltage) {
+ HALSIM_SetAnalogOutVoltage(m_index, voltage);
+}
+
+std::unique_ptr<CallbackStore> AnalogOutputSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogOutInitializedCallback);
+ store->SetUid(HALSIM_RegisterAnalogOutInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool AnalogOutputSim::GetInitialized() const {
+ return HALSIM_GetAnalogOutInitialized(m_index);
+}
+
+void AnalogOutputSim::SetInitialized(bool initialized) {
+ HALSIM_SetAnalogOutInitialized(m_index, initialized);
+}
+
+void AnalogOutputSim::ResetData() { HALSIM_ResetAnalogOutData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/AnalogTriggerSim.cpp b/wpilibc/src/main/native/cpp/simulation/AnalogTriggerSim.cpp
new file mode 100644
index 0000000..3325827
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/AnalogTriggerSim.cpp
@@ -0,0 +1,89 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/AnalogTriggerSim.h"
+
+#include <memory>
+#include <stdexcept>
+#include <utility>
+
+#include <hal/simulation/AnalogTriggerData.h>
+
+#include "frc/AnalogTrigger.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+AnalogTriggerSim::AnalogTriggerSim(const AnalogTrigger& analogTrigger)
+ : m_index{analogTrigger.GetIndex()} {}
+
+AnalogTriggerSim AnalogTriggerSim::CreateForChannel(int channel) {
+ int index = HALSIM_FindAnalogTriggerForChannel(channel);
+ if (index < 0) throw std::out_of_range("no analog trigger found for channel");
+ return AnalogTriggerSim{index};
+}
+
+AnalogTriggerSim AnalogTriggerSim::CreateForIndex(int index) {
+ return AnalogTriggerSim{index};
+}
+
+std::unique_ptr<CallbackStore> AnalogTriggerSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAnalogTriggerInitializedCallback);
+ store->SetUid(HALSIM_RegisterAnalogTriggerInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool AnalogTriggerSim::GetInitialized() const {
+ return HALSIM_GetAnalogTriggerInitialized(m_index);
+}
+
+void AnalogTriggerSim::SetInitialized(bool initialized) {
+ HALSIM_SetAnalogTriggerInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore>
+AnalogTriggerSim::RegisterTriggerLowerBoundCallback(NotifyCallback callback,
+ bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback,
+ &HALSIM_CancelAnalogTriggerTriggerLowerBoundCallback);
+ store->SetUid(HALSIM_RegisterAnalogTriggerTriggerLowerBoundCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double AnalogTriggerSim::GetTriggerLowerBound() const {
+ return HALSIM_GetAnalogTriggerTriggerLowerBound(m_index);
+}
+
+void AnalogTriggerSim::SetTriggerLowerBound(double triggerLowerBound) {
+ HALSIM_SetAnalogTriggerTriggerLowerBound(m_index, triggerLowerBound);
+}
+
+std::unique_ptr<CallbackStore>
+AnalogTriggerSim::RegisterTriggerUpperBoundCallback(NotifyCallback callback,
+ bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback,
+ &HALSIM_CancelAnalogTriggerTriggerUpperBoundCallback);
+ store->SetUid(HALSIM_RegisterAnalogTriggerTriggerUpperBoundCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double AnalogTriggerSim::GetTriggerUpperBound() const {
+ return HALSIM_GetAnalogTriggerTriggerUpperBound(m_index);
+}
+
+void AnalogTriggerSim::SetTriggerUpperBound(double triggerUpperBound) {
+ HALSIM_SetAnalogTriggerTriggerUpperBound(m_index, triggerUpperBound);
+}
+
+void AnalogTriggerSim::ResetData() { HALSIM_ResetAnalogTriggerData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/BuiltInAccelerometerSim.cpp b/wpilibc/src/main/native/cpp/simulation/BuiltInAccelerometerSim.cpp
new file mode 100644
index 0000000..601ee6e
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/BuiltInAccelerometerSim.cpp
@@ -0,0 +1,112 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/BuiltInAccelerometerSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/AccelerometerData.h>
+
+#include "frc/BuiltInAccelerometer.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+BuiltInAccelerometerSim::BuiltInAccelerometerSim() : m_index{0} {}
+
+BuiltInAccelerometerSim::BuiltInAccelerometerSim(const BuiltInAccelerometer&)
+ : m_index{0} {}
+
+std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterActiveCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAccelerometerActiveCallback);
+ store->SetUid(HALSIM_RegisterAccelerometerActiveCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool BuiltInAccelerometerSim::GetActive() const {
+ return HALSIM_GetAccelerometerActive(m_index);
+}
+
+void BuiltInAccelerometerSim::SetActive(bool active) {
+ HALSIM_SetAccelerometerActive(m_index, active);
+}
+
+std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterRangeCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAccelerometerRangeCallback);
+ store->SetUid(HALSIM_RegisterAccelerometerRangeCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+HAL_AccelerometerRange BuiltInAccelerometerSim::GetRange() const {
+ return HALSIM_GetAccelerometerRange(m_index);
+}
+
+void BuiltInAccelerometerSim::SetRange(HAL_AccelerometerRange range) {
+ HALSIM_SetAccelerometerRange(m_index, range);
+}
+
+std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterXCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAccelerometerXCallback);
+ store->SetUid(HALSIM_RegisterAccelerometerXCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double BuiltInAccelerometerSim::GetX() const {
+ return HALSIM_GetAccelerometerX(m_index);
+}
+
+void BuiltInAccelerometerSim::SetX(double x) {
+ HALSIM_SetAccelerometerX(m_index, x);
+}
+
+std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterYCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAccelerometerYCallback);
+ store->SetUid(HALSIM_RegisterAccelerometerYCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double BuiltInAccelerometerSim::GetY() const {
+ return HALSIM_GetAccelerometerY(m_index);
+}
+
+void BuiltInAccelerometerSim::SetY(double y) {
+ HALSIM_SetAccelerometerY(m_index, y);
+}
+
+std::unique_ptr<CallbackStore> BuiltInAccelerometerSim::RegisterZCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelAccelerometerZCallback);
+ store->SetUid(HALSIM_RegisterAccelerometerZCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double BuiltInAccelerometerSim::GetZ() const {
+ return HALSIM_GetAccelerometerZ(m_index);
+}
+
+void BuiltInAccelerometerSim::SetZ(double z) {
+ HALSIM_SetAccelerometerZ(m_index, z);
+}
+
+void BuiltInAccelerometerSim::ResetData() {
+ HALSIM_ResetAccelerometerData(m_index);
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/CallbackStore.cpp b/wpilibc/src/main/native/cpp/simulation/CallbackStore.cpp
new file mode 100644
index 0000000..5c38372
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/CallbackStore.cpp
@@ -0,0 +1,80 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/CallbackStore.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+void frc::sim::CallbackStoreThunk(const char* name, void* param,
+ const HAL_Value* value) {
+ reinterpret_cast<CallbackStore*>(param)->callback(name, value);
+}
+
+void frc::sim::ConstBufferCallbackStoreThunk(const char* name, void* param,
+ const unsigned char* buffer,
+ unsigned int count) {
+ reinterpret_cast<CallbackStore*>(param)->constBufferCallback(name, buffer,
+ count);
+}
+
+CallbackStore::CallbackStore(int32_t i, NotifyCallback cb,
+ CancelCallbackNoIndexFunc ccf)
+ : index(i), callback(cb), cancelType(NoIndex) {
+ this->ccnif = ccf;
+}
+
+CallbackStore::CallbackStore(int32_t i, int32_t u, NotifyCallback cb,
+ CancelCallbackFunc ccf)
+ : index(i), uid(u), callback(cb), cancelType(Normal) {
+ this->ccf = ccf;
+}
+
+CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb,
+ CancelCallbackChannelFunc ccf)
+ : index(i), channel(c), uid(u), callback(cb), cancelType(Channel) {
+ this->cccf = ccf;
+}
+
+CallbackStore::CallbackStore(int32_t i, ConstBufferCallback cb,
+ CancelCallbackNoIndexFunc ccf)
+ : index(i), constBufferCallback(cb), cancelType(NoIndex) {
+ this->ccnif = ccf;
+}
+
+CallbackStore::CallbackStore(int32_t i, int32_t u, ConstBufferCallback cb,
+ CancelCallbackFunc ccf)
+ : index(i), uid(u), constBufferCallback(cb), cancelType(Normal) {
+ this->ccf = ccf;
+}
+
+CallbackStore::CallbackStore(int32_t i, int32_t c, int32_t u,
+ ConstBufferCallback cb,
+ CancelCallbackChannelFunc ccf)
+ : index(i),
+ channel(c),
+ uid(u),
+ constBufferCallback(cb),
+ cancelType(Channel) {
+ this->cccf = ccf;
+}
+
+CallbackStore::~CallbackStore() {
+ switch (cancelType) {
+ case Normal:
+ ccf(index, uid);
+ break;
+ case Channel:
+ cccf(index, channel, uid);
+ break;
+ case NoIndex:
+ ccnif(uid);
+ break;
+ }
+}
+
+void CallbackStore::SetUid(int32_t uid) { this->uid = uid; }
diff --git a/wpilibc/src/main/native/cpp/simulation/DIOSim.cpp b/wpilibc/src/main/native/cpp/simulation/DIOSim.cpp
new file mode 100644
index 0000000..9330735
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/DIOSim.cpp
@@ -0,0 +1,104 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/DIOSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/DIOData.h>
+
+#include "frc/DigitalInput.h"
+#include "frc/DigitalOutput.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+DIOSim::DIOSim(const DigitalInput& input) : m_index{input.GetChannel()} {}
+
+DIOSim::DIOSim(const DigitalOutput& output) : m_index{output.GetChannel()} {}
+
+DIOSim::DIOSim(int channel) : m_index{channel} {}
+
+std::unique_ptr<CallbackStore> DIOSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDIOInitializedCallback);
+ store->SetUid(HALSIM_RegisterDIOInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DIOSim::GetInitialized() const {
+ return HALSIM_GetDIOInitialized(m_index);
+}
+
+void DIOSim::SetInitialized(bool initialized) {
+ HALSIM_SetDIOInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> DIOSim::RegisterValueCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(m_index, -1, callback,
+ &HALSIM_CancelDIOValueCallback);
+ store->SetUid(HALSIM_RegisterDIOValueCallback(m_index, &CallbackStoreThunk,
+ store.get(), initialNotify));
+ return store;
+}
+
+bool DIOSim::GetValue() const { return HALSIM_GetDIOValue(m_index); }
+
+void DIOSim::SetValue(bool value) { HALSIM_SetDIOValue(m_index, value); }
+
+std::unique_ptr<CallbackStore> DIOSim::RegisterPulseLengthCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDIOPulseLengthCallback);
+ store->SetUid(HALSIM_RegisterDIOPulseLengthCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double DIOSim::GetPulseLength() const {
+ return HALSIM_GetDIOPulseLength(m_index);
+}
+
+void DIOSim::SetPulseLength(double pulseLength) {
+ HALSIM_SetDIOPulseLength(m_index, pulseLength);
+}
+
+std::unique_ptr<CallbackStore> DIOSim::RegisterIsInputCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDIOIsInputCallback);
+ store->SetUid(HALSIM_RegisterDIOIsInputCallback(m_index, &CallbackStoreThunk,
+ store.get(), initialNotify));
+ return store;
+}
+
+bool DIOSim::GetIsInput() const { return HALSIM_GetDIOIsInput(m_index); }
+
+void DIOSim::SetIsInput(bool isInput) {
+ HALSIM_SetDIOIsInput(m_index, isInput);
+}
+
+std::unique_ptr<CallbackStore> DIOSim::RegisterFilterIndexCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDIOFilterIndexCallback);
+ store->SetUid(HALSIM_RegisterDIOFilterIndexCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int DIOSim::GetFilterIndex() const { return HALSIM_GetDIOFilterIndex(m_index); }
+
+void DIOSim::SetFilterIndex(int filterIndex) {
+ HALSIM_SetDIOFilterIndex(m_index, filterIndex);
+}
+
+void DIOSim::ResetData() { HALSIM_ResetDIOData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp b/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp
new file mode 100644
index 0000000..51ed94a
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/DifferentialDrivetrainSim.cpp
@@ -0,0 +1,134 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/DifferentialDrivetrainSim.h"
+
+#include <frc/system/plant/LinearSystemId.h>
+
+#include "frc/system/RungeKutta.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+DifferentialDrivetrainSim::DifferentialDrivetrainSim(
+ const LinearSystem<2, 2, 2>& plant, units::meter_t trackWidth,
+ DCMotor driveMotor, double gearRatio, units::meter_t wheelRadius)
+ : m_plant(plant),
+ m_rb(trackWidth / 2.0),
+ m_wheelRadius(wheelRadius),
+ m_motor(driveMotor),
+ m_originalGearing(gearRatio),
+ m_currentGearing(gearRatio) {
+ m_x.setZero();
+ m_u.setZero();
+}
+
+DifferentialDrivetrainSim::DifferentialDrivetrainSim(
+ frc::DCMotor driveMotor, double gearing, units::kilogram_square_meter_t J,
+ units::kilogram_t mass, units::meter_t wheelRadius,
+ units::meter_t trackWidth)
+ : DifferentialDrivetrainSim(
+ frc::LinearSystemId::DrivetrainVelocitySystem(
+ driveMotor, mass, wheelRadius, trackWidth / 2.0, J, gearing),
+ trackWidth, driveMotor, gearing, wheelRadius) {}
+
+void DifferentialDrivetrainSim::SetInputs(units::volt_t leftVoltage,
+ units::volt_t rightVoltage) {
+ m_u << leftVoltage.to<double>(), rightVoltage.to<double>();
+}
+
+void DifferentialDrivetrainSim::SetGearing(double newGearing) {
+ m_currentGearing = newGearing;
+}
+
+void DifferentialDrivetrainSim::Update(units::second_t dt) {
+ m_x = RungeKutta([this](auto& x, auto& u) { return Dynamics(x, u); }, m_x,
+ m_u, dt);
+}
+
+double DifferentialDrivetrainSim::GetState(int state) const {
+ return m_x(state);
+}
+
+double DifferentialDrivetrainSim::GetGearing() const {
+ return m_currentGearing;
+}
+
+Eigen::Matrix<double, 7, 1> DifferentialDrivetrainSim::GetState() const {
+ return m_x;
+}
+
+Rotation2d DifferentialDrivetrainSim::GetHeading() const {
+ return Rotation2d(units::radian_t(m_x(State::kHeading)));
+}
+
+Pose2d DifferentialDrivetrainSim::GetPose() const {
+ return Pose2d(units::meter_t(m_x(State::kX)), units::meter_t(m_x(State::kY)),
+ Rotation2d(units::radian_t(m_x(State::kHeading))));
+}
+
+units::ampere_t DifferentialDrivetrainSim::GetCurrentDraw() const {
+ auto loadIleft =
+ m_motor.Current(units::radians_per_second_t(m_x(State::kLeftVelocity) *
+ m_currentGearing /
+ m_wheelRadius.to<double>()),
+ units::volt_t(m_u(0))) *
+ wpi::sgn(m_u(0));
+
+ auto loadIRight =
+ m_motor.Current(units::radians_per_second_t(m_x(State::kRightVelocity) *
+ m_currentGearing /
+ m_wheelRadius.to<double>()),
+ units::volt_t(m_u(1))) *
+ wpi::sgn(m_u(1));
+
+ return loadIleft + loadIRight;
+}
+
+void DifferentialDrivetrainSim::SetState(
+ const Eigen::Matrix<double, 7, 1>& state) {
+ m_x = state;
+}
+
+void DifferentialDrivetrainSim::SetPose(const frc::Pose2d& pose) {
+ m_x(State::kX) = pose.X().to<double>();
+ m_x(State::kY) = pose.Y().to<double>();
+ m_x(State::kHeading) = pose.Rotation().Radians().to<double>();
+ m_x(State::kLeftPosition) = 0;
+ m_x(State::kRightPosition) = 0;
+}
+
+Eigen::Matrix<double, 7, 1> DifferentialDrivetrainSim::Dynamics(
+ const Eigen::Matrix<double, 7, 1>& x,
+ const Eigen::Matrix<double, 2, 1>& u) {
+ // Because G^2 can be factored out of A, we can divide by the old ratio
+ // squared and multiply by the new ratio squared to get a new drivetrain
+ // model.
+ Eigen::Matrix<double, 4, 2> B;
+ B.block<2, 2>(0, 0) = m_plant.B() * m_currentGearing * m_currentGearing /
+ m_originalGearing / m_originalGearing;
+ B.block<2, 2>(2, 0).setZero();
+
+ // Because G can be factored out of B, we can divide by the old ratio and
+ // multiply by the new ratio to get a new drivetrain model.
+ Eigen::Matrix<double, 4, 4> A;
+ A.block<2, 2>(0, 0) = m_plant.A() * m_currentGearing / m_originalGearing;
+
+ A.block<2, 2>(2, 0).setIdentity();
+ A.block<4, 2>(0, 2).setZero();
+
+ double v = (x(State::kLeftVelocity) + x(State::kRightVelocity)) / 2.0;
+
+ Eigen::Matrix<double, 7, 1> xdot;
+ xdot(0) = v * std::cos(x(State::kHeading));
+ xdot(1) = v * std::sin(x(State::kHeading));
+ xdot(2) =
+ ((x(State::kRightVelocity) - x(State::kLeftVelocity)) / (2.0 * m_rb))
+ .to<double>();
+ xdot.block<4, 1>(3, 0) = A * x.block<4, 1>(3, 0) + B * u;
+ return xdot;
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/DigitalPWMSim.cpp b/wpilibc/src/main/native/cpp/simulation/DigitalPWMSim.cpp
new file mode 100644
index 0000000..2ee55ce
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/DigitalPWMSim.cpp
@@ -0,0 +1,81 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/DigitalPWMSim.h"
+
+#include <memory>
+#include <stdexcept>
+#include <utility>
+
+#include <hal/simulation/DigitalPWMData.h>
+
+#include "frc/DigitalOutput.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+DigitalPWMSim::DigitalPWMSim(const DigitalOutput& digitalOutput)
+ : m_index{digitalOutput.GetChannel()} {}
+
+DigitalPWMSim DigitalPWMSim::CreateForChannel(int channel) {
+ int index = HALSIM_FindDigitalPWMForChannel(channel);
+ if (index < 0) throw std::out_of_range("no digital PWM found for channel");
+ return DigitalPWMSim{index};
+}
+
+DigitalPWMSim DigitalPWMSim::CreateForIndex(int index) {
+ return DigitalPWMSim{index};
+}
+
+std::unique_ptr<CallbackStore> DigitalPWMSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDigitalPWMInitializedCallback);
+ store->SetUid(HALSIM_RegisterDigitalPWMInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DigitalPWMSim::GetInitialized() const {
+ return HALSIM_GetDigitalPWMInitialized(m_index);
+}
+
+void DigitalPWMSim::SetInitialized(bool initialized) {
+ HALSIM_SetDigitalPWMInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> DigitalPWMSim::RegisterDutyCycleCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDigitalPWMDutyCycleCallback);
+ store->SetUid(HALSIM_RegisterDigitalPWMDutyCycleCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double DigitalPWMSim::GetDutyCycle() const {
+ return HALSIM_GetDigitalPWMDutyCycle(m_index);
+}
+
+void DigitalPWMSim::SetDutyCycle(double dutyCycle) {
+ HALSIM_SetDigitalPWMDutyCycle(m_index, dutyCycle);
+}
+
+std::unique_ptr<CallbackStore> DigitalPWMSim::RegisterPinCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDigitalPWMPinCallback);
+ store->SetUid(HALSIM_RegisterDigitalPWMPinCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int DigitalPWMSim::GetPin() const { return HALSIM_GetDigitalPWMPin(m_index); }
+
+void DigitalPWMSim::SetPin(int pin) { HALSIM_SetDigitalPWMPin(m_index, pin); }
+
+void DigitalPWMSim::ResetData() { HALSIM_ResetDigitalPWMData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp b/wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp
new file mode 100644
index 0000000..8c0bf70
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/DriverStationSim.cpp
@@ -0,0 +1,255 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/DriverStationSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/DriverStationData.h>
+#include <hal/simulation/MockHooks.h>
+
+#include "frc/DriverStation.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+std::unique_ptr<CallbackStore> DriverStationSim::RegisterEnabledCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationEnabledCallback);
+ store->SetUid(HALSIM_RegisterDriverStationEnabledCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DriverStationSim::GetEnabled() { return HALSIM_GetDriverStationEnabled(); }
+
+void DriverStationSim::SetEnabled(bool enabled) {
+ HALSIM_SetDriverStationEnabled(enabled);
+}
+
+std::unique_ptr<CallbackStore> DriverStationSim::RegisterAutonomousCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationAutonomousCallback);
+ store->SetUid(HALSIM_RegisterDriverStationAutonomousCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DriverStationSim::GetAutonomous() {
+ return HALSIM_GetDriverStationAutonomous();
+}
+
+void DriverStationSim::SetAutonomous(bool autonomous) {
+ HALSIM_SetDriverStationAutonomous(autonomous);
+}
+
+std::unique_ptr<CallbackStore> DriverStationSim::RegisterTestCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationTestCallback);
+ store->SetUid(HALSIM_RegisterDriverStationTestCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DriverStationSim::GetTest() { return HALSIM_GetDriverStationTest(); }
+
+void DriverStationSim::SetTest(bool test) { HALSIM_SetDriverStationTest(test); }
+
+std::unique_ptr<CallbackStore> DriverStationSim::RegisterEStopCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationEStopCallback);
+ store->SetUid(HALSIM_RegisterDriverStationEStopCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DriverStationSim::GetEStop() { return HALSIM_GetDriverStationEStop(); }
+
+void DriverStationSim::SetEStop(bool eStop) {
+ HALSIM_SetDriverStationEStop(eStop);
+}
+
+std::unique_ptr<CallbackStore> DriverStationSim::RegisterFmsAttachedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationFmsAttachedCallback);
+ store->SetUid(HALSIM_RegisterDriverStationFmsAttachedCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DriverStationSim::GetFmsAttached() {
+ return HALSIM_GetDriverStationFmsAttached();
+}
+
+void DriverStationSim::SetFmsAttached(bool fmsAttached) {
+ HALSIM_SetDriverStationFmsAttached(fmsAttached);
+}
+
+std::unique_ptr<CallbackStore> DriverStationSim::RegisterDsAttachedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationDsAttachedCallback);
+ store->SetUid(HALSIM_RegisterDriverStationDsAttachedCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DriverStationSim::GetDsAttached() {
+ return HALSIM_GetDriverStationDsAttached();
+}
+
+void DriverStationSim::SetDsAttached(bool dsAttached) {
+ HALSIM_SetDriverStationDsAttached(dsAttached);
+}
+
+std::unique_ptr<CallbackStore>
+DriverStationSim::RegisterAllianceStationIdCallback(NotifyCallback callback,
+ bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationAllianceStationIdCallback);
+ store->SetUid(HALSIM_RegisterDriverStationAllianceStationIdCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+HAL_AllianceStationID DriverStationSim::GetAllianceStationId() {
+ return HALSIM_GetDriverStationAllianceStationId();
+}
+
+void DriverStationSim::SetAllianceStationId(
+ HAL_AllianceStationID allianceStationId) {
+ HALSIM_SetDriverStationAllianceStationId(allianceStationId);
+}
+
+std::unique_ptr<CallbackStore> DriverStationSim::RegisterMatchTimeCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelDriverStationMatchTimeCallback);
+ store->SetUid(HALSIM_RegisterDriverStationMatchTimeCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double DriverStationSim::GetMatchTime() {
+ return HALSIM_GetDriverStationMatchTime();
+}
+
+void DriverStationSim::SetMatchTime(double matchTime) {
+ HALSIM_SetDriverStationMatchTime(matchTime);
+}
+
+void DriverStationSim::NotifyNewData() {
+ HALSIM_NotifyDriverStationNewData();
+ DriverStation::GetInstance().WaitForData();
+}
+
+void DriverStationSim::SetSendError(bool shouldSend) {
+ if (shouldSend) {
+ HALSIM_SetSendError(nullptr);
+ } else {
+ HALSIM_SetSendError([](HAL_Bool isError, int32_t errorCode,
+ HAL_Bool isLVCode, const char* details,
+ const char* location, const char* callStack,
+ HAL_Bool printMsg) { return 0; });
+ }
+}
+
+void DriverStationSim::SetSendConsoleLine(bool shouldSend) {
+ if (shouldSend) {
+ HALSIM_SetSendConsoleLine(nullptr);
+ } else {
+ HALSIM_SetSendConsoleLine([](const char* line) { return 0; });
+ }
+}
+
+int64_t DriverStationSim::GetJoystickOutputs(int stick) {
+ int64_t outputs = 0;
+ int32_t leftRumble;
+ int32_t rightRumble;
+ HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
+ return outputs;
+}
+
+int DriverStationSim::GetJoystickRumble(int stick, int rumbleNum) {
+ int64_t outputs;
+ int32_t leftRumble = 0;
+ int32_t rightRumble = 0;
+ HALSIM_GetJoystickOutputs(stick, &outputs, &leftRumble, &rightRumble);
+ return rumbleNum == 0 ? leftRumble : rightRumble;
+}
+
+void DriverStationSim::SetJoystickButton(int stick, int button, bool state) {
+ HALSIM_SetJoystickButton(stick, button, state);
+}
+
+void DriverStationSim::SetJoystickAxis(int stick, int axis, double value) {
+ HALSIM_SetJoystickAxis(stick, axis, value);
+}
+
+void DriverStationSim::SetJoystickPOV(int stick, int pov, int value) {
+ HALSIM_SetJoystickPOV(stick, pov, value);
+}
+
+void DriverStationSim::SetJoystickButtons(int stick, uint32_t buttons) {
+ HALSIM_SetJoystickButtonsValue(stick, buttons);
+}
+
+void DriverStationSim::SetJoystickAxisCount(int stick, int count) {
+ HALSIM_SetJoystickAxisCount(stick, count);
+}
+
+void DriverStationSim::SetJoystickPOVCount(int stick, int count) {
+ HALSIM_SetJoystickPOVCount(stick, count);
+}
+
+void DriverStationSim::SetJoystickButtonCount(int stick, int count) {
+ HALSIM_SetJoystickButtonCount(stick, count);
+}
+
+void DriverStationSim::SetJoystickIsXbox(int stick, bool isXbox) {
+ HALSIM_SetJoystickIsXbox(stick, isXbox);
+}
+
+void DriverStationSim::SetJoystickType(int stick, int type) {
+ HALSIM_SetJoystickType(stick, type);
+}
+
+void DriverStationSim::SetJoystickName(int stick, const char* name) {
+ HALSIM_SetJoystickName(stick, name);
+}
+
+void DriverStationSim::SetJoystickAxisType(int stick, int axis, int type) {
+ HALSIM_SetJoystickAxisType(stick, axis, type);
+}
+
+void DriverStationSim::SetGameSpecificMessage(const char* message) {
+ HALSIM_SetGameSpecificMessage(message);
+}
+
+void DriverStationSim::SetEventName(const char* name) {
+ HALSIM_SetEventName(name);
+}
+
+void DriverStationSim::SetMatchType(DriverStation::MatchType type) {
+ HALSIM_SetMatchType(static_cast<HAL_MatchType>(static_cast<int>(type)));
+}
+
+void DriverStationSim::SetMatchNumber(int matchNumber) {
+ HALSIM_SetMatchNumber(matchNumber);
+}
+
+void DriverStationSim::SetReplayNumber(int replayNumber) {
+ HALSIM_SetReplayNumber(replayNumber);
+}
+
+void DriverStationSim::ResetData() { HALSIM_ResetDriverStationData(); }
diff --git a/wpilibc/src/main/native/cpp/simulation/DutyCycleEncoderSim.cpp b/wpilibc/src/main/native/cpp/simulation/DutyCycleEncoderSim.cpp
new file mode 100644
index 0000000..b12f00a
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/DutyCycleEncoderSim.cpp
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/DutyCycleEncoderSim.h"
+
+#include <wpi/SmallString.h>
+#include <wpi/raw_ostream.h>
+
+#include "frc/DutyCycleEncoder.h"
+#include "frc/simulation/SimDeviceSim.h"
+
+using namespace frc::sim;
+
+DutyCycleEncoderSim::DutyCycleEncoderSim(const frc::DutyCycleEncoder& encoder) {
+ wpi::SmallString<128> fullname;
+ wpi::raw_svector_ostream os(fullname);
+ os << "DutyCycleEncoder" << '[' << encoder.GetFPGAIndex() << ']';
+ frc::sim::SimDeviceSim deviceSim{fullname.c_str()};
+ m_simPosition = deviceSim.GetDouble("Position");
+ m_simDistancePerRotation = deviceSim.GetDouble("DistancePerRotation");
+}
+
+void DutyCycleEncoderSim::Set(units::turn_t turns) {
+ m_simPosition.Set(turns.to<double>());
+}
+
+void DutyCycleEncoderSim::SetDistance(double distance) {
+ m_simPosition.Set(distance / m_simDistancePerRotation.Get());
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/DutyCycleSim.cpp b/wpilibc/src/main/native/cpp/simulation/DutyCycleSim.cpp
new file mode 100644
index 0000000..7ec19fd
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/DutyCycleSim.cpp
@@ -0,0 +1,85 @@
+/*----------------------------------------------------------------------------*/
+/* 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 "frc/simulation/DutyCycleSim.h"
+
+#include <memory>
+#include <stdexcept>
+#include <utility>
+
+#include <hal/simulation/DutyCycleData.h>
+
+#include "frc/DutyCycle.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+DutyCycleSim::DutyCycleSim(const DutyCycle& dutyCycle)
+ : m_index{dutyCycle.GetFPGAIndex()} {}
+
+DutyCycleSim DutyCycleSim::CreateForChannel(int channel) {
+ int index = HALSIM_FindDutyCycleForChannel(channel);
+ if (index < 0) throw std::out_of_range("no duty cycle found for channel");
+ return DutyCycleSim{index};
+}
+
+DutyCycleSim DutyCycleSim::CreateForIndex(int index) {
+ return DutyCycleSim{index};
+}
+
+std::unique_ptr<CallbackStore> DutyCycleSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDutyCycleInitializedCallback);
+ store->SetUid(HALSIM_RegisterDutyCycleInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool DutyCycleSim::GetInitialized() const {
+ return HALSIM_GetDutyCycleInitialized(m_index);
+}
+
+void DutyCycleSim::SetInitialized(bool initialized) {
+ HALSIM_SetDutyCycleInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> DutyCycleSim::RegisterFrequencyCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDutyCycleFrequencyCallback);
+ store->SetUid(HALSIM_RegisterDutyCycleFrequencyCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int DutyCycleSim::GetFrequency() const {
+ return HALSIM_GetDutyCycleFrequency(m_index);
+}
+
+void DutyCycleSim::SetFrequency(int count) {
+ HALSIM_SetDutyCycleFrequency(m_index, count);
+}
+
+std::unique_ptr<CallbackStore> DutyCycleSim::RegisterOutputCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelDutyCycleOutputCallback);
+ store->SetUid(HALSIM_RegisterDutyCycleOutputCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double DutyCycleSim::GetOutput() const {
+ return HALSIM_GetDutyCycleOutput(m_index);
+}
+
+void DutyCycleSim::SetOutput(double period) {
+ HALSIM_SetDutyCycleOutput(m_index, period);
+}
+
+void DutyCycleSim::ResetData() { HALSIM_ResetDutyCycleData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp b/wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp
new file mode 100644
index 0000000..89c09cb
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/ElevatorSim.cpp
@@ -0,0 +1,98 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/ElevatorSim.h"
+
+#include <wpi/MathExtras.h>
+
+#include "frc/StateSpaceUtil.h"
+#include "frc/system/RungeKutta.h"
+#include "frc/system/plant/LinearSystemId.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+ElevatorSim::ElevatorSim(const LinearSystem<2, 1, 1>& plant,
+ const DCMotor& gearbox, double gearing,
+ units::meter_t drumRadius, units::meter_t minHeight,
+ units::meter_t maxHeight,
+ const std::array<double, 1>& measurementStdDevs)
+ : LinearSystemSim(plant, measurementStdDevs),
+ m_gearbox(gearbox),
+ m_drumRadius(drumRadius),
+ m_minHeight(minHeight),
+ m_maxHeight(maxHeight),
+ m_gearing(gearing) {}
+
+ElevatorSim::ElevatorSim(const DCMotor& gearbox, double gearing,
+ units::kilogram_t carriageMass,
+ units::meter_t drumRadius, units::meter_t minHeight,
+ units::meter_t maxHeight,
+ const std::array<double, 1>& measurementStdDevs)
+ : LinearSystemSim(LinearSystemId::ElevatorSystem(gearbox, carriageMass,
+ drumRadius, gearing),
+ measurementStdDevs),
+ m_gearbox(gearbox),
+ m_drumRadius(drumRadius),
+ m_minHeight(minHeight),
+ m_maxHeight(maxHeight),
+ m_gearing(gearing) {}
+
+bool ElevatorSim::HasHitLowerLimit(const Eigen::Matrix<double, 2, 1>& x) const {
+ return x(0) < m_minHeight.to<double>();
+}
+
+bool ElevatorSim::HasHitUpperLimit(const Eigen::Matrix<double, 2, 1>& x) const {
+ return x(0) > m_maxHeight.to<double>();
+}
+
+units::meter_t ElevatorSim::GetPosition() const {
+ return units::meter_t{m_x(0)};
+}
+
+units::meters_per_second_t ElevatorSim::GetVelocity() const {
+ return units::meters_per_second_t{m_x(1)};
+}
+
+units::ampere_t ElevatorSim::GetCurrentDraw() const {
+ // I = V / R - omega / (Kv * R)
+ // Reductions are greater than 1, so a reduction of 10:1 would mean the motor
+ // is spinning 10x faster than the output.
+
+ // v = r w, so w = v / r
+ units::meters_per_second_t velocity{m_x(1)};
+ units::radians_per_second_t motorVelocity =
+ velocity / m_drumRadius * m_gearing * 1_rad;
+
+ // Perform calculation and return.
+ return m_gearbox.Current(motorVelocity, units::volt_t{m_u(0)}) *
+ wpi::sgn(m_u(0));
+}
+
+void ElevatorSim::SetInputVoltage(units::volt_t voltage) {
+ SetInput(frc::MakeMatrix<1, 1>(voltage.to<double>()));
+}
+
+Eigen::Matrix<double, 2, 1> ElevatorSim::UpdateX(
+ const Eigen::Matrix<double, 2, 1>& currentXhat,
+ const Eigen::Matrix<double, 1, 1>& u, units::second_t dt) {
+ auto updatedXhat = RungeKutta(
+ [&](const Eigen::Matrix<double, 2, 1>& x,
+ const Eigen::Matrix<double, 1, 1>& u_)
+ -> Eigen::Matrix<double, 2, 1> {
+ return m_plant.A() * x + m_plant.B() * u_ + MakeMatrix<2, 1>(0.0, -9.8);
+ },
+ currentXhat, u, dt);
+ // Check for collision after updating x-hat.
+ if (HasHitLowerLimit(updatedXhat)) {
+ return MakeMatrix<2, 1>(m_minHeight.to<double>(), 0.0);
+ }
+ if (HasHitUpperLimit(updatedXhat)) {
+ return MakeMatrix<2, 1>(m_maxHeight.to<double>(), 0.0);
+ }
+ return updatedXhat;
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/EncoderSim.cpp b/wpilibc/src/main/native/cpp/simulation/EncoderSim.cpp
new file mode 100644
index 0000000..5bc5d52
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/EncoderSim.cpp
@@ -0,0 +1,189 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/EncoderSim.h"
+
+#include <memory>
+#include <stdexcept>
+#include <utility>
+
+#include <hal/simulation/EncoderData.h>
+
+#include "frc/Encoder.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+EncoderSim::EncoderSim(const Encoder& encoder)
+ : m_index{encoder.GetFPGAIndex()} {}
+
+EncoderSim EncoderSim::CreateForChannel(int channel) {
+ int index = HALSIM_FindEncoderForChannel(channel);
+ if (index < 0) throw std::out_of_range("no encoder found for channel");
+ return EncoderSim{index};
+}
+
+EncoderSim EncoderSim::CreateForIndex(int index) { return EncoderSim{index}; }
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderInitializedCallback);
+ store->SetUid(HALSIM_RegisterEncoderInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool EncoderSim::GetInitialized() const {
+ return HALSIM_GetEncoderInitialized(m_index);
+}
+
+void EncoderSim::SetInitialized(bool initialized) {
+ HALSIM_SetEncoderInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterCountCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderCountCallback);
+ store->SetUid(HALSIM_RegisterEncoderCountCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int EncoderSim::GetCount() const { return HALSIM_GetEncoderCount(m_index); }
+
+void EncoderSim::SetCount(int count) { HALSIM_SetEncoderCount(m_index, count); }
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterPeriodCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderPeriodCallback);
+ store->SetUid(HALSIM_RegisterEncoderPeriodCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double EncoderSim::GetPeriod() const {
+ return HALSIM_GetEncoderPeriod(m_index);
+}
+
+void EncoderSim::SetPeriod(double period) {
+ HALSIM_SetEncoderPeriod(m_index, period);
+}
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterResetCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderResetCallback);
+ store->SetUid(HALSIM_RegisterEncoderResetCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool EncoderSim::GetReset() const { return HALSIM_GetEncoderReset(m_index); }
+
+void EncoderSim::SetReset(bool reset) {
+ HALSIM_SetEncoderReset(m_index, reset);
+}
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterMaxPeriodCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderMaxPeriodCallback);
+ store->SetUid(HALSIM_RegisterEncoderMaxPeriodCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double EncoderSim::GetMaxPeriod() const {
+ return HALSIM_GetEncoderMaxPeriod(m_index);
+}
+
+void EncoderSim::SetMaxPeriod(double maxPeriod) {
+ HALSIM_SetEncoderMaxPeriod(m_index, maxPeriod);
+}
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterDirectionCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderDirectionCallback);
+ store->SetUid(HALSIM_RegisterEncoderDirectionCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool EncoderSim::GetDirection() const {
+ return HALSIM_GetEncoderDirection(m_index);
+}
+
+void EncoderSim::SetDirection(bool direction) {
+ HALSIM_SetEncoderDirection(m_index, direction);
+}
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterReverseDirectionCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderReverseDirectionCallback);
+ store->SetUid(HALSIM_RegisterEncoderReverseDirectionCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool EncoderSim::GetReverseDirection() const {
+ return HALSIM_GetEncoderReverseDirection(m_index);
+}
+
+void EncoderSim::SetReverseDirection(bool reverseDirection) {
+ HALSIM_SetEncoderReverseDirection(m_index, reverseDirection);
+}
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterSamplesToAverageCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderSamplesToAverageCallback);
+ store->SetUid(HALSIM_RegisterEncoderSamplesToAverageCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int EncoderSim::GetSamplesToAverage() const {
+ return HALSIM_GetEncoderSamplesToAverage(m_index);
+}
+
+void EncoderSim::SetSamplesToAverage(int samplesToAverage) {
+ HALSIM_SetEncoderSamplesToAverage(m_index, samplesToAverage);
+}
+
+std::unique_ptr<CallbackStore> EncoderSim::RegisterDistancePerPulseCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelEncoderDistancePerPulseCallback);
+ store->SetUid(HALSIM_RegisterEncoderDistancePerPulseCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double EncoderSim::GetDistancePerPulse() const {
+ return HALSIM_GetEncoderDistancePerPulse(m_index);
+}
+
+void EncoderSim::SetDistancePerPulse(double distancePerPulse) {
+ HALSIM_SetEncoderDistancePerPulse(m_index, distancePerPulse);
+}
+
+void EncoderSim::ResetData() { HALSIM_ResetEncoderData(m_index); }
+
+void EncoderSim::SetDistance(double distance) {
+ HALSIM_SetEncoderDistance(m_index, distance);
+}
+
+double EncoderSim::GetDistance() { return HALSIM_GetEncoderDistance(m_index); }
+
+void EncoderSim::SetRate(double rate) { HALSIM_SetEncoderRate(m_index, rate); }
+
+double EncoderSim::GetRate() { return HALSIM_GetEncoderRate(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/Field2d.cpp b/wpilibc/src/main/native/cpp/simulation/Field2d.cpp
new file mode 100644
index 0000000..a6098b6
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/Field2d.cpp
@@ -0,0 +1,49 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/Field2d.h"
+
+using namespace frc;
+
+Field2d::Field2d() : m_device{"Field2D"} {
+ if (m_device) {
+ m_x = m_device.CreateDouble("x", false, 0.0);
+ m_y = m_device.CreateDouble("y", false, 0.0);
+ m_rot = m_device.CreateDouble("rot", false, 0.0);
+ }
+}
+
+void Field2d::SetRobotPose(const Pose2d& pose) {
+ if (m_device) {
+ auto& translation = pose.Translation();
+ m_x.Set(translation.X().to<double>());
+ m_y.Set(translation.Y().to<double>());
+ m_rot.Set(pose.Rotation().Degrees().to<double>());
+ } else {
+ m_pose = pose;
+ }
+}
+
+void Field2d::SetRobotPose(units::meter_t x, units::meter_t y,
+ Rotation2d rotation) {
+ if (m_device) {
+ m_x.Set(x.to<double>());
+ m_y.Set(y.to<double>());
+ m_rot.Set(rotation.Degrees().to<double>());
+ } else {
+ m_pose = Pose2d{x, y, rotation};
+ }
+}
+
+Pose2d Field2d::GetRobotPose() {
+ if (m_device) {
+ return Pose2d{units::meter_t{m_x.Get()}, units::meter_t{m_y.Get()},
+ Rotation2d{units::degree_t{m_rot.Get()}}};
+ } else {
+ return m_pose;
+ }
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/FlywheelSim.cpp b/wpilibc/src/main/native/cpp/simulation/FlywheelSim.cpp
new file mode 100644
index 0000000..65fc3c8
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/FlywheelSim.cpp
@@ -0,0 +1,45 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/FlywheelSim.h"
+
+#include <wpi/MathExtras.h>
+
+#include "frc/system/plant/LinearSystemId.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+FlywheelSim::FlywheelSim(const LinearSystem<1, 1, 1>& plant,
+ const DCMotor& gearbox, double gearing,
+ const std::array<double, 1>& measurementStdDevs)
+ : LinearSystemSim<1, 1, 1>(plant, measurementStdDevs),
+ m_gearbox(gearbox),
+ m_gearing(gearing) {}
+
+FlywheelSim::FlywheelSim(const DCMotor& gearbox, double gearing,
+ units::kilogram_square_meter_t moi,
+ const std::array<double, 1>& measurementStdDevs)
+ : FlywheelSim(LinearSystemId::FlywheelSystem(gearbox, moi, gearing),
+ gearbox, gearing, measurementStdDevs) {}
+
+units::radians_per_second_t FlywheelSim::GetAngularVelocity() const {
+ return units::radians_per_second_t{GetOutput(0)};
+}
+
+units::ampere_t FlywheelSim::GetCurrentDraw() const {
+ // I = V / R - omega / (Kv * R)
+ // Reductions are greater than 1, so a reduction of 10:1 would mean the motor
+ // is spinning 10x faster than the output.
+ return m_gearbox.Current(GetAngularVelocity() * m_gearing,
+ units::volt_t{m_u(0)}) *
+ wpi::sgn(m_u(0));
+}
+
+void FlywheelSim::SetInputVoltage(units::volt_t voltage) {
+ SetInput(frc::MakeMatrix<1, 1>(voltage.to<double>()));
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/GenericHIDSim.cpp b/wpilibc/src/main/native/cpp/simulation/GenericHIDSim.cpp
new file mode 100644
index 0000000..8df265a
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/GenericHIDSim.cpp
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/GenericHIDSim.h"
+
+#include "frc/GenericHID.h"
+#include "frc/simulation/DriverStationSim.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+GenericHIDSim::GenericHIDSim(const GenericHID& joystick)
+ : m_port{joystick.GetPort()} {}
+
+GenericHIDSim::GenericHIDSim(int port) : m_port{port} {}
+
+void GenericHIDSim::NotifyNewData() { DriverStationSim::NotifyNewData(); }
+
+void GenericHIDSim::SetRawButton(int button, bool value) {
+ DriverStationSim::SetJoystickButton(m_port, button, value);
+}
+
+void GenericHIDSim::SetRawAxis(int axis, double value) {
+ DriverStationSim::SetJoystickAxis(m_port, axis, value);
+}
+
+void GenericHIDSim::SetPOV(int pov, int value) {
+ DriverStationSim::SetJoystickPOV(m_port, pov, value);
+}
+
+void GenericHIDSim::SetPOV(int value) { SetPOV(0, value); }
+
+void GenericHIDSim::SetAxisCount(int count) {
+ DriverStationSim::SetJoystickAxisCount(m_port, count);
+}
+
+void GenericHIDSim::SetPOVCount(int count) {
+ DriverStationSim::SetJoystickPOVCount(m_port, count);
+}
+
+void GenericHIDSim::SetButtonCount(int count) {
+ DriverStationSim::SetJoystickButtonCount(m_port, count);
+}
+
+void GenericHIDSim::SetType(GenericHID::HIDType type) {
+ DriverStationSim::SetJoystickType(m_port, type);
+}
+
+void GenericHIDSim::SetName(const char* name) {
+ DriverStationSim::SetJoystickName(m_port, name);
+}
+
+void GenericHIDSim::SetAxisType(int axis, int type) {
+ DriverStationSim::SetJoystickAxisType(m_port, axis, type);
+}
+
+bool GenericHIDSim::GetOutput(int outputNumber) {
+ int64_t outputs = GetOutputs();
+ return (outputs & (static_cast<int64_t>(1) << (outputNumber - 1))) != 0;
+}
+
+int64_t GenericHIDSim::GetOutputs() {
+ return DriverStationSim::GetJoystickOutputs(m_port);
+}
+
+double GenericHIDSim::GetRumble(GenericHID::RumbleType type) {
+ int value = DriverStationSim::GetJoystickRumble(
+ m_port, type == GenericHID::kLeftRumble ? 0 : 1);
+ return value / 65535.0;
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/JoystickSim.cpp b/wpilibc/src/main/native/cpp/simulation/JoystickSim.cpp
new file mode 100644
index 0000000..55f6089
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/JoystickSim.cpp
@@ -0,0 +1,63 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/JoystickSim.h"
+
+#include "frc/Joystick.h"
+#include "frc/simulation/GenericHIDSim.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+JoystickSim::JoystickSim(const Joystick& joystick)
+ : GenericHIDSim{joystick}, m_joystick{&joystick} {
+ // default to a reasonable joystick configuration
+ SetAxisCount(5);
+ SetButtonCount(12);
+ SetPOVCount(1);
+}
+
+JoystickSim::JoystickSim(int port) : GenericHIDSim{port} {
+ // default to a reasonable joystick configuration
+ SetAxisCount(5);
+ SetButtonCount(12);
+ SetPOVCount(1);
+}
+
+void JoystickSim::SetX(double value) {
+ SetRawAxis(
+ m_joystick ? m_joystick->GetXChannel() : Joystick::kDefaultXChannel,
+ value);
+}
+
+void JoystickSim::SetY(double value) {
+ SetRawAxis(
+ m_joystick ? m_joystick->GetYChannel() : Joystick::kDefaultYChannel,
+ value);
+}
+
+void JoystickSim::SetZ(double value) {
+ SetRawAxis(
+ m_joystick ? m_joystick->GetZChannel() : Joystick::kDefaultZChannel,
+ value);
+}
+
+void JoystickSim::SetTwist(double value) {
+ SetRawAxis(m_joystick ? m_joystick->GetTwistChannel()
+ : Joystick::kDefaultTwistChannel,
+ value);
+}
+
+void JoystickSim::SetThrottle(double value) {
+ SetRawAxis(m_joystick ? m_joystick->GetThrottleChannel()
+ : Joystick::kDefaultThrottleChannel,
+ value);
+}
+
+void JoystickSim::SetTrigger(bool state) { SetRawButton(1, state); }
+
+void JoystickSim::SetTop(bool state) { SetRawButton(2, state); }
diff --git a/wpilibc/src/main/native/cpp/simulation/Mechanism2D.cpp b/wpilibc/src/main/native/cpp/simulation/Mechanism2D.cpp
new file mode 100644
index 0000000..43178b1
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/Mechanism2D.cpp
@@ -0,0 +1,44 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/Mechanism2D.h"
+
+#include <wpi/SmallString.h>
+#include <wpi/Twine.h>
+#include <wpi/raw_ostream.h>
+
+using namespace frc;
+
+Mechanism2D::Mechanism2D() : m_device{"Mechanism2D"} {}
+
+void Mechanism2D::SetLigamentAngle(const wpi::Twine& ligamentPath,
+ float angle) {
+ if (m_device) {
+ wpi::SmallString<64> fullPathBuf;
+ wpi::StringRef fullPath =
+ (ligamentPath + "/angle").toNullTerminatedStringRef(fullPathBuf);
+ if (!createdItems.count(fullPath)) {
+ createdItems[fullPath] =
+ m_device.CreateDouble(fullPath.data(), false, angle);
+ }
+ createdItems[fullPath].Set(angle);
+ }
+}
+
+void Mechanism2D::SetLigamentLength(const wpi::Twine& ligamentPath,
+ float length) {
+ if (m_device) {
+ wpi::SmallString<64> fullPathBuf;
+ wpi::StringRef fullPath =
+ (ligamentPath + "/length").toNullTerminatedStringRef(fullPathBuf);
+ if (!createdItems.count(fullPath)) {
+ createdItems[fullPath] =
+ m_device.CreateDouble(fullPath.data(), false, length);
+ }
+ createdItems[fullPath].Set(length);
+ }
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/PCMSim.cpp b/wpilibc/src/main/native/cpp/simulation/PCMSim.cpp
new file mode 100644
index 0000000..5d0566a
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/PCMSim.cpp
@@ -0,0 +1,158 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/PCMSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/PCMData.h>
+
+#include "frc/Compressor.h"
+#include "frc/SensorUtil.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+PCMSim::PCMSim() : m_index{SensorUtil::GetDefaultSolenoidModule()} {}
+
+PCMSim::PCMSim(int module) : m_index{module} {}
+
+PCMSim::PCMSim(const Compressor& compressor)
+ : m_index{compressor.GetModule()} {}
+
+std::unique_ptr<CallbackStore> PCMSim::RegisterSolenoidInitializedCallback(
+ int channel, NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, channel, -1, callback,
+ &HALSIM_CancelPCMSolenoidInitializedCallback);
+ store->SetUid(HALSIM_RegisterPCMSolenoidInitializedCallback(
+ m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PCMSim::GetSolenoidInitialized(int channel) const {
+ return HALSIM_GetPCMSolenoidInitialized(m_index, channel);
+}
+
+void PCMSim::SetSolenoidInitialized(int channel, bool solenoidInitialized) {
+ HALSIM_SetPCMSolenoidInitialized(m_index, channel, solenoidInitialized);
+}
+
+std::unique_ptr<CallbackStore> PCMSim::RegisterSolenoidOutputCallback(
+ int channel, NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, channel, -1, callback, &HALSIM_CancelPCMSolenoidOutputCallback);
+ store->SetUid(HALSIM_RegisterPCMSolenoidOutputCallback(
+ m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PCMSim::GetSolenoidOutput(int channel) const {
+ return HALSIM_GetPCMSolenoidOutput(m_index, channel);
+}
+
+void PCMSim::SetSolenoidOutput(int channel, bool solenoidOutput) {
+ HALSIM_SetPCMSolenoidOutput(m_index, channel, solenoidOutput);
+}
+
+std::unique_ptr<CallbackStore> PCMSim::RegisterCompressorInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPCMCompressorInitializedCallback);
+ store->SetUid(HALSIM_RegisterPCMCompressorInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PCMSim::GetCompressorInitialized() const {
+ return HALSIM_GetPCMCompressorInitialized(m_index);
+}
+
+void PCMSim::SetCompressorInitialized(bool compressorInitialized) {
+ HALSIM_SetPCMCompressorInitialized(m_index, compressorInitialized);
+}
+
+std::unique_ptr<CallbackStore> PCMSim::RegisterCompressorOnCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPCMCompressorOnCallback);
+ store->SetUid(HALSIM_RegisterPCMCompressorOnCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PCMSim::GetCompressorOn() const {
+ return HALSIM_GetPCMCompressorOn(m_index);
+}
+
+void PCMSim::SetCompressorOn(bool compressorOn) {
+ HALSIM_SetPCMCompressorOn(m_index, compressorOn);
+}
+
+std::unique_ptr<CallbackStore> PCMSim::RegisterClosedLoopEnabledCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPCMClosedLoopEnabledCallback);
+ store->SetUid(HALSIM_RegisterPCMClosedLoopEnabledCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PCMSim::GetClosedLoopEnabled() const {
+ return HALSIM_GetPCMClosedLoopEnabled(m_index);
+}
+
+void PCMSim::SetClosedLoopEnabled(bool closedLoopEnabled) {
+ HALSIM_SetPCMClosedLoopEnabled(m_index, closedLoopEnabled);
+}
+
+std::unique_ptr<CallbackStore> PCMSim::RegisterPressureSwitchCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPCMPressureSwitchCallback);
+ store->SetUid(HALSIM_RegisterPCMPressureSwitchCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PCMSim::GetPressureSwitch() const {
+ return HALSIM_GetPCMPressureSwitch(m_index);
+}
+
+void PCMSim::SetPressureSwitch(bool pressureSwitch) {
+ HALSIM_SetPCMPressureSwitch(m_index, pressureSwitch);
+}
+
+std::unique_ptr<CallbackStore> PCMSim::RegisterCompressorCurrentCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPCMCompressorCurrentCallback);
+ store->SetUid(HALSIM_RegisterPCMCompressorCurrentCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double PCMSim::GetCompressorCurrent() const {
+ return HALSIM_GetPCMCompressorCurrent(m_index);
+}
+
+void PCMSim::SetCompressorCurrent(double compressorCurrent) {
+ HALSIM_SetPCMCompressorCurrent(m_index, compressorCurrent);
+}
+
+uint8_t PCMSim::GetAllSolenoidOutputs() const {
+ uint8_t ret = 0;
+ HALSIM_GetPCMAllSolenoids(m_index, &ret);
+ return ret;
+}
+
+void PCMSim::SetAllSolenoidOutputs(uint8_t outputs) {
+ HALSIM_SetPCMAllSolenoids(m_index, outputs);
+}
+
+void PCMSim::ResetData() { HALSIM_ResetPCMData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/PDPSim.cpp b/wpilibc/src/main/native/cpp/simulation/PDPSim.cpp
new file mode 100644
index 0000000..26d6a45
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/PDPSim.cpp
@@ -0,0 +1,98 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/PDPSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/PDPData.h>
+
+#include "frc/PowerDistributionPanel.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+PDPSim::PDPSim(int module) : m_index{module} {}
+
+PDPSim::PDPSim(const PowerDistributionPanel& pdp) : m_index{pdp.GetModule()} {}
+
+std::unique_ptr<CallbackStore> PDPSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPDPInitializedCallback);
+ store->SetUid(HALSIM_RegisterPDPInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PDPSim::GetInitialized() const {
+ return HALSIM_GetPDPInitialized(m_index);
+}
+
+void PDPSim::SetInitialized(bool initialized) {
+ HALSIM_SetPDPInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> PDPSim::RegisterTemperatureCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPDPTemperatureCallback);
+ store->SetUid(HALSIM_RegisterPDPTemperatureCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double PDPSim::GetTemperature() const {
+ return HALSIM_GetPDPTemperature(m_index);
+}
+
+void PDPSim::SetTemperature(double temperature) {
+ HALSIM_SetPDPTemperature(m_index, temperature);
+}
+
+std::unique_ptr<CallbackStore> PDPSim::RegisterVoltageCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPDPVoltageCallback);
+ store->SetUid(HALSIM_RegisterPDPVoltageCallback(m_index, &CallbackStoreThunk,
+ store.get(), initialNotify));
+ return store;
+}
+
+double PDPSim::GetVoltage() const { return HALSIM_GetPDPVoltage(m_index); }
+
+void PDPSim::SetVoltage(double voltage) {
+ HALSIM_SetPDPVoltage(m_index, voltage);
+}
+
+std::unique_ptr<CallbackStore> PDPSim::RegisterCurrentCallback(
+ int channel, NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, channel, -1, callback, &HALSIM_CancelPDPCurrentCallback);
+ store->SetUid(HALSIM_RegisterPDPCurrentCallback(
+ m_index, channel, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double PDPSim::GetCurrent(int channel) const {
+ return HALSIM_GetPDPCurrent(m_index, channel);
+}
+
+void PDPSim::SetCurrent(int channel, double current) {
+ HALSIM_SetPDPCurrent(m_index, channel, current);
+}
+
+void PDPSim::GetAllCurrents(double* currents) const {
+ HALSIM_GetPDPAllCurrents(m_index, currents);
+}
+
+void PDPSim::SetAllCurrents(const double* currents) {
+ HALSIM_SetPDPAllCurrents(m_index, currents);
+}
+
+void PDPSim::ResetData() { HALSIM_ResetPDPData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/PWMSim.cpp b/wpilibc/src/main/native/cpp/simulation/PWMSim.cpp
new file mode 100644
index 0000000..2fae8fb
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/PWMSim.cpp
@@ -0,0 +1,114 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/PWMSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/PWMData.h>
+
+#include "frc/PWM.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+PWMSim::PWMSim(const PWM& pwm) : m_index{pwm.GetChannel()} {}
+
+PWMSim::PWMSim(int channel) : m_index{channel} {}
+
+std::unique_ptr<CallbackStore> PWMSim::RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPWMInitializedCallback);
+ store->SetUid(HALSIM_RegisterPWMInitializedCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PWMSim::GetInitialized() const {
+ return HALSIM_GetPWMInitialized(m_index);
+}
+
+void PWMSim::SetInitialized(bool initialized) {
+ HALSIM_SetPWMInitialized(m_index, initialized);
+}
+
+std::unique_ptr<CallbackStore> PWMSim::RegisterRawValueCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPWMRawValueCallback);
+ store->SetUid(HALSIM_RegisterPWMRawValueCallback(m_index, &CallbackStoreThunk,
+ store.get(), initialNotify));
+ return store;
+}
+
+int PWMSim::GetRawValue() const { return HALSIM_GetPWMRawValue(m_index); }
+
+void PWMSim::SetRawValue(int rawValue) {
+ HALSIM_SetPWMRawValue(m_index, rawValue);
+}
+
+std::unique_ptr<CallbackStore> PWMSim::RegisterSpeedCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(m_index, -1, callback,
+ &HALSIM_CancelPWMSpeedCallback);
+ store->SetUid(HALSIM_RegisterPWMSpeedCallback(m_index, &CallbackStoreThunk,
+ store.get(), initialNotify));
+ return store;
+}
+
+double PWMSim::GetSpeed() const { return HALSIM_GetPWMSpeed(m_index); }
+
+void PWMSim::SetSpeed(double speed) { HALSIM_SetPWMSpeed(m_index, speed); }
+
+std::unique_ptr<CallbackStore> PWMSim::RegisterPositionCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPWMPositionCallback);
+ store->SetUid(HALSIM_RegisterPWMPositionCallback(m_index, &CallbackStoreThunk,
+ store.get(), initialNotify));
+ return store;
+}
+
+double PWMSim::GetPosition() const { return HALSIM_GetPWMPosition(m_index); }
+
+void PWMSim::SetPosition(double position) {
+ HALSIM_SetPWMPosition(m_index, position);
+}
+
+std::unique_ptr<CallbackStore> PWMSim::RegisterPeriodScaleCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPWMPeriodScaleCallback);
+ store->SetUid(HALSIM_RegisterPWMPeriodScaleCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int PWMSim::GetPeriodScale() const { return HALSIM_GetPWMPeriodScale(m_index); }
+
+void PWMSim::SetPeriodScale(int periodScale) {
+ HALSIM_SetPWMPeriodScale(m_index, periodScale);
+}
+
+std::unique_ptr<CallbackStore> PWMSim::RegisterZeroLatchCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelPWMZeroLatchCallback);
+ store->SetUid(HALSIM_RegisterPWMZeroLatchCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool PWMSim::GetZeroLatch() const { return HALSIM_GetPWMZeroLatch(m_index); }
+
+void PWMSim::SetZeroLatch(bool zeroLatch) {
+ HALSIM_SetPWMZeroLatch(m_index, zeroLatch);
+}
+
+void PWMSim::ResetData() { HALSIM_ResetPWMData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/RelaySim.cpp b/wpilibc/src/main/native/cpp/simulation/RelaySim.cpp
new file mode 100644
index 0000000..7f7aa65
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/RelaySim.cpp
@@ -0,0 +1,88 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/RelaySim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/RelayData.h>
+
+#include "frc/Relay.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+RelaySim::RelaySim(const Relay& relay) : m_index{relay.GetChannel()} {}
+
+RelaySim::RelaySim(int channel) : m_index{channel} {}
+
+std::unique_ptr<CallbackStore> RelaySim::RegisterInitializedForwardCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelRelayInitializedForwardCallback);
+ store->SetUid(HALSIM_RegisterRelayInitializedForwardCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RelaySim::GetInitializedForward() const {
+ return HALSIM_GetRelayInitializedForward(m_index);
+}
+
+void RelaySim::SetInitializedForward(bool initializedForward) {
+ HALSIM_SetRelayInitializedForward(m_index, initializedForward);
+}
+
+std::unique_ptr<CallbackStore> RelaySim::RegisterInitializedReverseCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelRelayInitializedReverseCallback);
+ store->SetUid(HALSIM_RegisterRelayInitializedReverseCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RelaySim::GetInitializedReverse() const {
+ return HALSIM_GetRelayInitializedReverse(m_index);
+}
+
+void RelaySim::SetInitializedReverse(bool initializedReverse) {
+ HALSIM_SetRelayInitializedReverse(m_index, initializedReverse);
+}
+
+std::unique_ptr<CallbackStore> RelaySim::RegisterForwardCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelRelayForwardCallback);
+ store->SetUid(HALSIM_RegisterRelayForwardCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RelaySim::GetForward() const { return HALSIM_GetRelayForward(m_index); }
+
+void RelaySim::SetForward(bool forward) {
+ HALSIM_SetRelayForward(m_index, forward);
+}
+
+std::unique_ptr<CallbackStore> RelaySim::RegisterReverseCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelRelayReverseCallback);
+ store->SetUid(HALSIM_RegisterRelayReverseCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RelaySim::GetReverse() const { return HALSIM_GetRelayReverse(m_index); }
+
+void RelaySim::SetReverse(bool reverse) {
+ HALSIM_SetRelayReverse(m_index, reverse);
+}
+
+void RelaySim::ResetData() { HALSIM_ResetRelayData(m_index); }
diff --git a/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp b/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp
new file mode 100644
index 0000000..0d1d104
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/RoboRioSim.cpp
@@ -0,0 +1,259 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/RoboRioSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/RoboRioData.h>
+
+using namespace frc;
+using namespace frc::sim;
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterFPGAButtonCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioFPGAButtonCallback);
+ store->SetUid(HALSIM_RegisterRoboRioFPGAButtonCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RoboRioSim::GetFPGAButton() { return HALSIM_GetRoboRioFPGAButton(); }
+
+void RoboRioSim::SetFPGAButton(bool fPGAButton) {
+ HALSIM_SetRoboRioFPGAButton(fPGAButton);
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterVInVoltageCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioVInVoltageCallback);
+ store->SetUid(HALSIM_RegisterRoboRioVInVoltageCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::volt_t RoboRioSim::GetVInVoltage() {
+ return units::volt_t(HALSIM_GetRoboRioVInVoltage());
+}
+
+void RoboRioSim::SetVInVoltage(units::volt_t vInVoltage) {
+ HALSIM_SetRoboRioVInVoltage(vInVoltage.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterVInCurrentCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioVInCurrentCallback);
+ store->SetUid(HALSIM_RegisterRoboRioVInCurrentCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::ampere_t RoboRioSim::GetVInCurrent() {
+ return units::ampere_t(HALSIM_GetRoboRioVInCurrent());
+}
+
+void RoboRioSim::SetVInCurrent(units::ampere_t vInCurrent) {
+ HALSIM_SetRoboRioVInCurrent(vInCurrent.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserVoltage6VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserVoltage6VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserVoltage6VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::volt_t RoboRioSim::GetUserVoltage6V() {
+ return units::volt_t(HALSIM_GetRoboRioUserVoltage6V());
+}
+
+void RoboRioSim::SetUserVoltage6V(units::volt_t userVoltage6V) {
+ HALSIM_SetRoboRioUserVoltage6V(userVoltage6V.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent6VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserCurrent6VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserCurrent6VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::ampere_t RoboRioSim::GetUserCurrent6V() {
+ return units::ampere_t(HALSIM_GetRoboRioUserCurrent6V());
+}
+
+void RoboRioSim::SetUserCurrent6V(units::ampere_t userCurrent6V) {
+ HALSIM_SetRoboRioUserCurrent6V(userCurrent6V.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive6VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserActive6VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserActive6VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RoboRioSim::GetUserActive6V() { return HALSIM_GetRoboRioUserActive6V(); }
+
+void RoboRioSim::SetUserActive6V(bool userActive6V) {
+ HALSIM_SetRoboRioUserActive6V(userActive6V);
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserVoltage5VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserVoltage5VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserVoltage5VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::volt_t RoboRioSim::GetUserVoltage5V() {
+ return units::volt_t(HALSIM_GetRoboRioUserVoltage5V());
+}
+
+void RoboRioSim::SetUserVoltage5V(units::volt_t userVoltage5V) {
+ HALSIM_SetRoboRioUserVoltage5V(userVoltage5V.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent5VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserCurrent5VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserCurrent5VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::ampere_t RoboRioSim::GetUserCurrent5V() {
+ return units::ampere_t(HALSIM_GetRoboRioUserCurrent5V());
+}
+
+void RoboRioSim::SetUserCurrent5V(units::ampere_t userCurrent5V) {
+ HALSIM_SetRoboRioUserCurrent5V(userCurrent5V.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive5VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserActive5VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserActive5VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RoboRioSim::GetUserActive5V() { return HALSIM_GetRoboRioUserActive5V(); }
+
+void RoboRioSim::SetUserActive5V(bool userActive5V) {
+ HALSIM_SetRoboRioUserActive5V(userActive5V);
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserVoltage3V3Callback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserVoltage3V3Callback);
+ store->SetUid(HALSIM_RegisterRoboRioUserVoltage3V3Callback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::volt_t RoboRioSim::GetUserVoltage3V3() {
+ return units::volt_t(HALSIM_GetRoboRioUserVoltage3V3());
+}
+
+void RoboRioSim::SetUserVoltage3V3(units::volt_t userVoltage3V3) {
+ HALSIM_SetRoboRioUserVoltage3V3(userVoltage3V3.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserCurrent3V3Callback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserCurrent3V3Callback);
+ store->SetUid(HALSIM_RegisterRoboRioUserCurrent3V3Callback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+units::ampere_t RoboRioSim::GetUserCurrent3V3() {
+ return units::ampere_t(HALSIM_GetRoboRioUserCurrent3V3());
+}
+
+void RoboRioSim::SetUserCurrent3V3(units::ampere_t userCurrent3V3) {
+ HALSIM_SetRoboRioUserCurrent3V3(userCurrent3V3.to<double>());
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserActive3V3Callback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserActive3V3Callback);
+ store->SetUid(HALSIM_RegisterRoboRioUserActive3V3Callback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool RoboRioSim::GetUserActive3V3() { return HALSIM_GetRoboRioUserActive3V3(); }
+
+void RoboRioSim::SetUserActive3V3(bool userActive3V3) {
+ HALSIM_SetRoboRioUserActive3V3(userActive3V3);
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserFaults6VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserFaults6VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserFaults6VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int RoboRioSim::GetUserFaults6V() { return HALSIM_GetRoboRioUserFaults6V(); }
+
+void RoboRioSim::SetUserFaults6V(int userFaults6V) {
+ HALSIM_SetRoboRioUserFaults6V(userFaults6V);
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserFaults5VCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserFaults5VCallback);
+ store->SetUid(HALSIM_RegisterRoboRioUserFaults5VCallback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int RoboRioSim::GetUserFaults5V() { return HALSIM_GetRoboRioUserFaults5V(); }
+
+void RoboRioSim::SetUserFaults5V(int userFaults5V) {
+ HALSIM_SetRoboRioUserFaults5V(userFaults5V);
+}
+
+std::unique_ptr<CallbackStore> RoboRioSim::RegisterUserFaults3V3Callback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ -1, callback, &HALSIM_CancelRoboRioUserFaults3V3Callback);
+ store->SetUid(HALSIM_RegisterRoboRioUserFaults3V3Callback(
+ &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int RoboRioSim::GetUserFaults3V3() { return HALSIM_GetRoboRioUserFaults3V3(); }
+
+void RoboRioSim::SetUserFaults3V3(int userFaults3V3) {
+ HALSIM_SetRoboRioUserFaults3V3(userFaults3V3);
+}
+
+void ResetData() { HALSIM_ResetRoboRioData(); }
diff --git a/wpilibc/src/main/native/cpp/simulation/SPIAccelerometerSim.cpp b/wpilibc/src/main/native/cpp/simulation/SPIAccelerometerSim.cpp
new file mode 100644
index 0000000..b71f99d
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/SPIAccelerometerSim.cpp
@@ -0,0 +1,107 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/SPIAccelerometerSim.h"
+
+#include <memory>
+#include <utility>
+
+#include <hal/simulation/SPIAccelerometerData.h>
+
+using namespace frc;
+using namespace frc::sim;
+
+SPIAccelerometerSim::SPIAccelerometerSim(int index) { m_index = index; }
+
+std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterActiveCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelSPIAccelerometerActiveCallback);
+ store->SetUid(HALSIM_RegisterSPIAccelerometerActiveCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+bool SPIAccelerometerSim::GetActive() const {
+ return HALSIM_GetSPIAccelerometerActive(m_index);
+}
+
+void SPIAccelerometerSim::SetActive(bool active) {
+ HALSIM_SetSPIAccelerometerActive(m_index, active);
+}
+
+std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterRangeCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelSPIAccelerometerRangeCallback);
+ store->SetUid(HALSIM_RegisterSPIAccelerometerRangeCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+int SPIAccelerometerSim::GetRange() const {
+ return HALSIM_GetSPIAccelerometerRange(m_index);
+}
+
+void SPIAccelerometerSim::SetRange(int range) {
+ HALSIM_SetSPIAccelerometerRange(m_index, range);
+}
+
+std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterXCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelSPIAccelerometerXCallback);
+ store->SetUid(HALSIM_RegisterSPIAccelerometerXCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double SPIAccelerometerSim::GetX() const {
+ return HALSIM_GetSPIAccelerometerX(m_index);
+}
+
+void SPIAccelerometerSim::SetX(double x) {
+ HALSIM_SetSPIAccelerometerX(m_index, x);
+}
+
+std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterYCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelSPIAccelerometerYCallback);
+ store->SetUid(HALSIM_RegisterSPIAccelerometerYCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double SPIAccelerometerSim::GetY() const {
+ return HALSIM_GetSPIAccelerometerY(m_index);
+}
+
+void SPIAccelerometerSim::SetY(double y) {
+ HALSIM_SetSPIAccelerometerY(m_index, y);
+}
+
+std::unique_ptr<CallbackStore> SPIAccelerometerSim::RegisterZCallback(
+ NotifyCallback callback, bool initialNotify) {
+ auto store = std::make_unique<CallbackStore>(
+ m_index, -1, callback, &HALSIM_CancelSPIAccelerometerZCallback);
+ store->SetUid(HALSIM_RegisterSPIAccelerometerZCallback(
+ m_index, &CallbackStoreThunk, store.get(), initialNotify));
+ return store;
+}
+
+double SPIAccelerometerSim::GetZ() const {
+ return HALSIM_GetSPIAccelerometerZ(m_index);
+}
+
+void SPIAccelerometerSim::SetZ(double z) {
+ HALSIM_SetSPIAccelerometerZ(m_index, z);
+}
+
+void SPIAccelerometerSim::ResetData() {
+ HALSIM_ResetSPIAccelerometerData(m_index);
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/SimDeviceSim.cpp b/wpilibc/src/main/native/cpp/simulation/SimDeviceSim.cpp
new file mode 100644
index 0000000..3d52cdf
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/SimDeviceSim.cpp
@@ -0,0 +1,47 @@
+/*----------------------------------------------------------------------------*/
+/* 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 "frc/simulation/SimDeviceSim.h"
+
+#include <string>
+#include <vector>
+
+#include <hal/SimDevice.h>
+#include <hal/simulation/SimDeviceData.h>
+
+using namespace frc;
+using namespace frc::sim;
+
+SimDeviceSim::SimDeviceSim(const char* name)
+ : m_handle{HALSIM_GetSimDeviceHandle(name)} {}
+
+hal::SimValue SimDeviceSim::GetValue(const char* name) const {
+ return HALSIM_GetSimValueHandle(m_handle, name);
+}
+
+hal::SimDouble SimDeviceSim::GetDouble(const char* name) const {
+ return HALSIM_GetSimValueHandle(m_handle, name);
+}
+
+hal::SimEnum SimDeviceSim::GetEnum(const char* name) const {
+ return HALSIM_GetSimValueHandle(m_handle, name);
+}
+
+hal::SimBoolean SimDeviceSim::GetBoolean(const char* name) const {
+ return HALSIM_GetSimValueHandle(m_handle, name);
+}
+
+std::vector<std::string> SimDeviceSim::GetEnumOptions(hal::SimEnum val) {
+ int32_t numOptions;
+ const char** options = HALSIM_GetSimValueEnumOptions(val, &numOptions);
+ std::vector<std::string> rv;
+ rv.reserve(numOptions);
+ for (int32_t i = 0; i < numOptions; ++i) rv.emplace_back(options[i]);
+ return rv;
+}
+
+void SimDeviceSim::ResetData() { HALSIM_ResetSimDeviceData(); }
diff --git a/wpilibc/src/main/native/cpp/simulation/SimHooks.cpp b/wpilibc/src/main/native/cpp/simulation/SimHooks.cpp
new file mode 100644
index 0000000..28c434c
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/SimHooks.cpp
@@ -0,0 +1,40 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/SimHooks.h"
+
+#include <hal/simulation/MockHooks.h>
+
+namespace frc {
+namespace sim {
+
+void SetRuntimeType(HAL_RuntimeType type) { HALSIM_SetRuntimeType(type); }
+
+void WaitForProgramStart() { HALSIM_WaitForProgramStart(); }
+
+void SetProgramStarted() { HALSIM_SetProgramStarted(); }
+
+bool GetProgramStarted() { return HALSIM_GetProgramStarted(); }
+
+void RestartTiming() { HALSIM_RestartTiming(); }
+
+void PauseTiming() { HALSIM_PauseTiming(); }
+
+void ResumeTiming() { HALSIM_ResumeTiming(); }
+
+bool IsTimingPaused() { return HALSIM_IsTimingPaused(); }
+
+void StepTiming(units::second_t delta) {
+ HALSIM_StepTiming(static_cast<uint64_t>(delta.to<double>() * 1e6));
+}
+
+void StepTimingAsync(units::second_t delta) {
+ HALSIM_StepTimingAsync(static_cast<uint64_t>(delta.to<double>() * 1e6));
+}
+
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/cpp/simulation/SingleJointedArmSim.cpp b/wpilibc/src/main/native/cpp/simulation/SingleJointedArmSim.cpp
new file mode 100644
index 0000000..b33a19e
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/SingleJointedArmSim.cpp
@@ -0,0 +1,108 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/SingleJointedArmSim.h"
+
+#include <cmath>
+
+#include <units/voltage.h>
+#include <wpi/MathExtras.h>
+
+#include "frc/system/RungeKutta.h"
+#include "frc/system/plant/LinearSystemId.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+SingleJointedArmSim::SingleJointedArmSim(
+ const LinearSystem<2, 1, 1>& system, const DCMotor& gearbox, double gearing,
+ units::meter_t armLength, units::radian_t minAngle,
+ units::radian_t maxAngle, units::kilogram_t mass, bool simulateGravity,
+ const std::array<double, 1>& measurementStdDevs)
+ : LinearSystemSim<2, 1, 1>(system, measurementStdDevs),
+ m_r(armLength),
+ m_minAngle(minAngle),
+ m_maxAngle(maxAngle),
+ m_mass(mass),
+ m_gearbox(gearbox),
+ m_gearing(gearing),
+ m_simulateGravity(simulateGravity) {}
+
+SingleJointedArmSim::SingleJointedArmSim(
+ const DCMotor& gearbox, double gearing, units::kilogram_square_meter_t moi,
+ units::meter_t armLength, units::radian_t minAngle,
+ units::radian_t maxAngle, units::kilogram_t mass, bool simulateGravity,
+ const std::array<double, 1>& measurementStdDevs)
+ : SingleJointedArmSim(
+ LinearSystemId::SingleJointedArmSystem(gearbox, moi, gearing),
+ gearbox, gearing, armLength, minAngle, maxAngle, mass,
+ simulateGravity, measurementStdDevs) {}
+
+bool SingleJointedArmSim::HasHitLowerLimit(
+ const Eigen::Matrix<double, 2, 1>& x) const {
+ return x(0) < m_minAngle.to<double>();
+}
+
+bool SingleJointedArmSim::HasHitUpperLimit(
+ const Eigen::Matrix<double, 2, 1>& x) const {
+ return x(0) > m_maxAngle.to<double>();
+}
+
+units::radian_t SingleJointedArmSim::GetAngle() const {
+ return units::radian_t{m_x(0)};
+}
+
+units::radians_per_second_t SingleJointedArmSim::GetVelocity() const {
+ return units::radians_per_second_t{m_x(1)};
+}
+
+units::ampere_t SingleJointedArmSim::GetCurrentDraw() const {
+ // Reductions are greater than 1, so a reduction of 10:1 would mean the motor
+ // is spinning 10x faster than the output
+ units::radians_per_second_t motorVelocity{m_x(1) * m_gearing};
+ return m_gearbox.Current(motorVelocity, units::volt_t{m_u(0)}) *
+ wpi::sgn(m_u(0));
+}
+
+void SingleJointedArmSim::SetInputVoltage(units::volt_t voltage) {
+ SetInput(frc::MakeMatrix<1, 1>(voltage.to<double>()));
+}
+
+Eigen::Matrix<double, 2, 1> SingleJointedArmSim::UpdateX(
+ const Eigen::Matrix<double, 2, 1>& currentXhat,
+ const Eigen::Matrix<double, 1, 1>& u, units::second_t dt) {
+ // Horizontal case:
+ // Torque = F * r = I * alpha
+ // alpha = F * r / I
+ // Since F = mg,
+ // alpha = m * g * r / I
+ // Finally, multiply RHS by cos(theta) to account for the arm angle
+ // This acceleration is added to the linear system dynamics x-dot = Ax + Bu
+ // We therefore find that f(x, u) = Ax + Bu + [[0] [m * g * r / I *
+ // std::cos(theta)]]
+
+ auto updatedXhat = RungeKutta(
+ [&](const auto& x, const auto& u) -> Eigen::Matrix<double, 2, 1> {
+ Eigen::Matrix<double, 2, 1> xdot = m_plant.A() * x + m_plant.B() * u;
+
+ if (m_simulateGravity) {
+ xdot += MakeMatrix<2, 1>(0.0, (m_mass * m_r * -9.8 * 3.0 /
+ (m_mass * m_r * m_r) * std::cos(x(0)))
+ .template to<double>());
+ }
+ return xdot;
+ },
+ currentXhat, u, dt);
+
+ // Check for collisions.
+ if (HasHitLowerLimit(updatedXhat)) {
+ return MakeMatrix<2, 1>(m_minAngle.to<double>(), 0.0);
+ } else if (HasHitUpperLimit(updatedXhat)) {
+ return MakeMatrix<2, 1>(m_maxAngle.to<double>(), 0.0);
+ }
+ return updatedXhat;
+}
diff --git a/wpilibc/src/main/native/cpp/simulation/XboxControllerSim.cpp b/wpilibc/src/main/native/cpp/simulation/XboxControllerSim.cpp
new file mode 100644
index 0000000..e3bbdce
--- /dev/null
+++ b/wpilibc/src/main/native/cpp/simulation/XboxControllerSim.cpp
@@ -0,0 +1,90 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/XboxControllerSim.h"
+
+#include "frc/XboxController.h"
+
+using namespace frc;
+using namespace frc::sim;
+
+XboxControllerSim::XboxControllerSim(const XboxController& joystick)
+ : GenericHIDSim{joystick} {
+ SetAxisCount(6);
+ SetButtonCount(10);
+}
+
+XboxControllerSim::XboxControllerSim(int port) : GenericHIDSim{port} {
+ SetAxisCount(6);
+ SetButtonCount(10);
+}
+
+void XboxControllerSim::SetX(GenericHID::JoystickHand hand, double value) {
+ if (hand == GenericHID::kLeftHand) {
+ SetRawAxis(static_cast<int>(XboxController::Axis::kLeftX), value);
+ } else {
+ SetRawAxis(static_cast<int>(XboxController::Axis::kRightX), value);
+ }
+}
+
+void XboxControllerSim::SetY(GenericHID::JoystickHand hand, double value) {
+ if (hand == GenericHID::kLeftHand) {
+ SetRawAxis(static_cast<int>(XboxController::Axis::kLeftY), value);
+ } else {
+ SetRawAxis(static_cast<int>(XboxController::Axis::kRightY), value);
+ }
+}
+
+void XboxControllerSim::SetTriggerAxis(GenericHID::JoystickHand hand,
+ double value) {
+ if (hand == GenericHID::kLeftHand) {
+ SetRawAxis(static_cast<int>(XboxController::Axis::kLeftTrigger), value);
+ } else {
+ SetRawAxis(static_cast<int>(XboxController::Axis::kRightTrigger), value);
+ }
+}
+
+void XboxControllerSim::SetBumper(GenericHID::JoystickHand hand, bool state) {
+ if (hand == GenericHID::kLeftHand) {
+ SetRawButton(static_cast<int>(XboxController::Button::kBumperLeft), state);
+ } else {
+ SetRawButton(static_cast<int>(XboxController::Button::kBumperRight), state);
+ }
+}
+
+void XboxControllerSim::SetStickButton(GenericHID::JoystickHand hand,
+ bool state) {
+ if (hand == GenericHID::kLeftHand) {
+ SetRawButton(static_cast<int>(XboxController::Button::kStickLeft), state);
+ } else {
+ SetRawButton(static_cast<int>(XboxController::Button::kStickRight), state);
+ }
+}
+
+void XboxControllerSim::SetAButton(bool state) {
+ SetRawButton(static_cast<int>(XboxController::Button::kA), state);
+}
+
+void XboxControllerSim::SetBButton(bool state) {
+ SetRawButton(static_cast<int>(XboxController::Button::kB), state);
+}
+
+void XboxControllerSim::SetXButton(bool state) {
+ SetRawButton(static_cast<int>(XboxController::Button::kX), state);
+}
+
+void XboxControllerSim::SetYButton(bool state) {
+ SetRawButton(static_cast<int>(XboxController::Button::kY), state);
+}
+
+void XboxControllerSim::SetBackButton(bool state) {
+ SetRawButton(static_cast<int>(XboxController::Button::kBack), state);
+}
+
+void XboxControllerSim::SetStartButton(bool state) {
+ SetRawButton(static_cast<int>(XboxController::Button::kStart), state);
+}
diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp
index d075deb..135f4be 100644
--- a/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp
+++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableBuilderImpl.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -32,7 +32,9 @@
for (auto& property : m_properties) {
if (property.update) property.update(property.entry, time);
}
- if (m_updateTable) m_updateTable();
+ for (auto& updateTable : m_updateTables) {
+ updateTable();
+ }
}
void SendableBuilderImpl::StartListeners() {
@@ -71,7 +73,7 @@
}
void SendableBuilderImpl::SetUpdateTable(std::function<void()> func) {
- m_updateTable = func;
+ m_updateTables.emplace_back(std::move(func));
}
nt::NetworkTableEntry SendableBuilderImpl::GetEntry(const wpi::Twine& key) {
diff --git a/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp b/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp
index 9d57ad6..4480313 100644
--- a/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp
+++ b/wpilibc/src/main/native/cpp/smartdashboard/SendableRegistry.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -163,7 +163,9 @@
void SendableRegistry::Move(Sendable* to, Sendable* from) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(from);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
UID compUid = it->getSecond();
m_impl->componentMap.erase(it);
m_impl->componentMap[to] = compUid;
@@ -188,14 +190,18 @@
std::string SendableRegistry::GetName(const Sendable* sendable) const {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return std::string{};
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return std::string{};
return m_impl->components[it->getSecond() - 1]->name;
}
void SendableRegistry::SetName(Sendable* sendable, const wpi::Twine& name) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
m_impl->components[it->getSecond() - 1]->name = name.str();
}
@@ -203,7 +209,9 @@
int channel) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
m_impl->components[it->getSecond() - 1]->SetName(moduleType, channel);
}
@@ -211,7 +219,9 @@
int moduleNumber, int channel) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
m_impl->components[it->getSecond() - 1]->SetName(moduleType, moduleNumber,
channel);
}
@@ -220,7 +230,9 @@
const wpi::Twine& name) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
auto& comp = *m_impl->components[it->getSecond() - 1];
comp.name = name.str();
comp.subsystem = subsystem.str();
@@ -229,7 +241,9 @@
std::string SendableRegistry::GetSubsystem(const Sendable* sendable) const {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return std::string{};
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return std::string{};
return m_impl->components[it->getSecond() - 1]->subsystem;
}
@@ -237,7 +251,9 @@
const wpi::Twine& subsystem) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
m_impl->components[it->getSecond() - 1]->subsystem = subsystem.str();
}
@@ -251,7 +267,9 @@
assert(handle >= 0);
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return nullptr;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return nullptr;
auto& comp = *m_impl->components[it->getSecond() - 1];
std::shared_ptr<void> rv;
if (static_cast<size_t>(handle) < comp.data.size())
@@ -267,7 +285,9 @@
assert(handle >= 0);
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return nullptr;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return nullptr;
auto& comp = *m_impl->components[it->getSecond() - 1];
if (static_cast<size_t>(handle) >= comp.data.size()) return nullptr;
return comp.data[handle];
@@ -276,14 +296,18 @@
void SendableRegistry::EnableLiveWindow(Sendable* sendable) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
m_impl->components[it->getSecond() - 1]->liveWindow = true;
}
void SendableRegistry::DisableLiveWindow(Sendable* sendable) {
std::scoped_lock lock(m_impl->mutex);
auto it = m_impl->componentMap.find(sendable);
- if (it == m_impl->componentMap.end()) return;
+ if (it == m_impl->componentMap.end() ||
+ !m_impl->components[it->getSecond() - 1])
+ return;
m_impl->components[it->getSecond() - 1]->liveWindow = false;
}
@@ -298,13 +322,17 @@
Sendable* SendableRegistry::GetSendable(UID uid) {
if (uid == 0) return nullptr;
std::scoped_lock lock(m_impl->mutex);
+ if ((uid - 1) >= m_impl->components.size() || !m_impl->components[uid - 1])
+ return nullptr;
return m_impl->components[uid - 1]->sendable;
}
void SendableRegistry::Publish(UID sendableUid,
std::shared_ptr<NetworkTable> table) {
std::scoped_lock lock(m_impl->mutex);
- if (sendableUid == 0) return;
+ if (sendableUid == 0 || (sendableUid - 1) >= m_impl->components.size() ||
+ !m_impl->components[sendableUid - 1])
+ return;
auto& comp = *m_impl->components[sendableUid - 1];
comp.builder = SendableBuilderImpl{}; // clear any current builder
comp.builder.SetTable(table);
@@ -316,6 +344,9 @@
void SendableRegistry::Update(UID sendableUid) {
if (sendableUid == 0) return;
std::scoped_lock lock(m_impl->mutex);
+ if ((sendableUid - 1) >= m_impl->components.size() ||
+ !m_impl->components[sendableUid - 1])
+ return;
m_impl->components[sendableUid - 1]->builder.UpdateTable();
}
@@ -327,7 +358,7 @@
wpi::SmallVector<Impl::Component*, 128> components;
for (auto&& comp : m_impl->components) components.emplace_back(comp.get());
for (auto comp : components) {
- if (comp->sendable && comp->liveWindow) {
+ if (comp && comp->sendable && comp->liveWindow) {
if (static_cast<size_t>(dataHandle) >= comp->data.size())
comp->data.resize(dataHandle + 1);
CallbackData cbdata{comp->sendable, comp->name,
diff --git a/wpilibc/src/main/native/cpp/spline/CubicHermiteSpline.cpp b/wpilibc/src/main/native/cpp/spline/CubicHermiteSpline.cpp
deleted file mode 100644
index 3991fec..0000000
--- a/wpilibc/src/main/native/cpp/spline/CubicHermiteSpline.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/spline/CubicHermiteSpline.h"
-
-using namespace frc;
-
-CubicHermiteSpline::CubicHermiteSpline(
- std::array<double, 2> xInitialControlVector,
- std::array<double, 2> xFinalControlVector,
- std::array<double, 2> yInitialControlVector,
- std::array<double, 2> yFinalControlVector) {
- const auto hermite = MakeHermiteBasis();
- const auto x =
- ControlVectorFromArrays(xInitialControlVector, xFinalControlVector);
- const auto y =
- ControlVectorFromArrays(yInitialControlVector, yFinalControlVector);
-
- // Populate first two rows with coefficients.
- m_coefficients.template block<1, 4>(0, 0) = hermite * x;
- m_coefficients.template block<1, 4>(1, 0) = hermite * y;
-
- // Populate Row 2 and Row 3 with the derivatives of the equations above.
- // Then populate row 4 and 5 with the second derivatives.
- for (int i = 0; i < 4; i++) {
- // Here, we are multiplying by (3 - i) to manually take the derivative. The
- // power of the term in index 0 is 3, index 1 is 2 and so on. To find the
- // coefficient of the derivative, we can use the power rule and multiply
- // the existing coefficient by its power.
- m_coefficients.template block<2, 1>(2, i) =
- m_coefficients.template block<2, 1>(0, i) * (3 - i);
- }
-
- for (int i = 0; i < 3; i++) {
- // Here, we are multiplying by (2 - i) to manually take the derivative. The
- // power of the term in index 0 is 2, index 1 is 1 and so on. To find the
- // coefficient of the derivative, we can use the power rule and multiply
- // the existing coefficient by its power.
- m_coefficients.template block<2, 1>(4, i) =
- m_coefficients.template block<2, 1>(2, i) * (2 - i);
- }
-}
diff --git a/wpilibc/src/main/native/cpp/spline/QuinticHermiteSpline.cpp b/wpilibc/src/main/native/cpp/spline/QuinticHermiteSpline.cpp
deleted file mode 100644
index bb8ad3c..0000000
--- a/wpilibc/src/main/native/cpp/spline/QuinticHermiteSpline.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/spline/QuinticHermiteSpline.h"
-
-using namespace frc;
-
-QuinticHermiteSpline::QuinticHermiteSpline(
- std::array<double, 3> xInitialControlVector,
- std::array<double, 3> xFinalControlVector,
- std::array<double, 3> yInitialControlVector,
- std::array<double, 3> yFinalControlVector) {
- const auto hermite = MakeHermiteBasis();
- const auto x =
- ControlVectorFromArrays(xInitialControlVector, xFinalControlVector);
- const auto y =
- ControlVectorFromArrays(yInitialControlVector, yFinalControlVector);
-
- // Populate first two rows with coefficients.
- m_coefficients.template block<1, 6>(0, 0) = (hermite * x).transpose();
- m_coefficients.template block<1, 6>(1, 0) = (hermite * y).transpose();
-
- // Populate Row 2 and Row 3 with the derivatives of the equations above.
- // Then populate row 4 and 5 with the second derivatives.
- for (int i = 0; i < 6; i++) {
- // Here, we are multiplying by (5 - i) to manually take the derivative. The
- // power of the term in index 0 is 5, index 1 is 4 and so on. To find the
- // coefficient of the derivative, we can use the power rule and multiply
- // the existing coefficient by its power.
- m_coefficients.template block<2, 1>(2, i) =
- m_coefficients.template block<2, 1>(0, i) * (5 - i);
- }
- for (int i = 0; i < 5; i++) {
- // Here, we are multiplying by (4 - i) to manually take the derivative. The
- // power of the term in index 0 is 4, index 1 is 3 and so on. To find the
- // coefficient of the derivative, we can use the power rule and multiply
- // the existing coefficient by its power.
- m_coefficients.template block<2, 1>(4, i) =
- m_coefficients.template block<2, 1>(2, i) * (4 - i);
- }
-}
diff --git a/wpilibc/src/main/native/cpp/spline/SplineHelper.cpp b/wpilibc/src/main/native/cpp/spline/SplineHelper.cpp
deleted file mode 100644
index cbfc8c1..0000000
--- a/wpilibc/src/main/native/cpp/spline/SplineHelper.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/spline/SplineHelper.h"
-
-#include <cstddef>
-
-using namespace frc;
-
-std::vector<CubicHermiteSpline> SplineHelper::CubicSplinesFromControlVectors(
- const Spline<3>::ControlVector& start, std::vector<Translation2d> waypoints,
- const Spline<3>::ControlVector& end) {
- std::vector<CubicHermiteSpline> splines;
-
- std::array<double, 2> xInitial = start.x;
- std::array<double, 2> yInitial = start.y;
- std::array<double, 2> xFinal = end.x;
- std::array<double, 2> yFinal = end.y;
-
- if (waypoints.size() > 1) {
- waypoints.emplace(waypoints.begin(),
- Translation2d{units::meter_t(xInitial[0]),
- units::meter_t(yInitial[0])});
- waypoints.emplace_back(
- Translation2d{units::meter_t(xFinal[0]), units::meter_t(yFinal[0])});
-
- // Populate tridiagonal system for clamped cubic
- /* See:
- https://www.uio.no/studier/emner/matnat/ifi/nedlagte-emner/INF-MAT4350/h08
- /undervisningsmateriale/chap7alecture.pdf
- */
-
- // Above-diagonal of tridiagonal matrix, zero-padded
- std::vector<double> a;
- // Diagonal of tridiagonal matrix
- std::vector<double> b(waypoints.size() - 2, 4.0);
- // Below-diagonal of tridiagonal matrix, zero-padded
- std::vector<double> c;
- // rhs vectors
- std::vector<double> dx, dy;
- // solution vectors
- std::vector<double> fx(waypoints.size() - 2, 0.0),
- fy(waypoints.size() - 2, 0.0);
-
- // populate above-diagonal and below-diagonal vectors
- a.emplace_back(0);
- for (size_t i = 0; i < waypoints.size() - 3; ++i) {
- a.emplace_back(1);
- c.emplace_back(1);
- }
- c.emplace_back(0);
-
- // populate rhs vectors
- dx.emplace_back(
- 3 * (waypoints[2].X().to<double>() - waypoints[0].X().to<double>()) -
- xInitial[1]);
- dy.emplace_back(
- 3 * (waypoints[2].Y().to<double>() - waypoints[0].Y().to<double>()) -
- yInitial[1]);
- if (waypoints.size() > 4) {
- for (size_t i = 1; i <= waypoints.size() - 4; ++i) {
- dx.emplace_back(3 * (waypoints[i + 1].X().to<double>() -
- waypoints[i - 1].X().to<double>()));
- dy.emplace_back(3 * (waypoints[i + 1].Y().to<double>() -
- waypoints[i - 1].Y().to<double>()));
- }
- }
- dx.emplace_back(3 * (waypoints[waypoints.size() - 1].X().to<double>() -
- waypoints[waypoints.size() - 3].X().to<double>()) -
- xFinal[1]);
- dy.emplace_back(3 * (waypoints[waypoints.size() - 1].Y().to<double>() -
- waypoints[waypoints.size() - 3].Y().to<double>()) -
- yFinal[1]);
-
- // Compute solution to tridiagonal system
- ThomasAlgorithm(a, b, c, dx, &fx);
- ThomasAlgorithm(a, b, c, dy, &fy);
-
- fx.emplace(fx.begin(), xInitial[1]);
- fx.emplace_back(xFinal[1]);
- fy.emplace(fy.begin(), yInitial[1]);
- fy.emplace_back(yFinal[1]);
-
- for (size_t i = 0; i < fx.size() - 1; ++i) {
- // Create the spline.
- const CubicHermiteSpline spline{
- {waypoints[i].X().to<double>(), fx[i]},
- {waypoints[i + 1].X().to<double>(), fx[i + 1]},
- {waypoints[i].Y().to<double>(), fy[i]},
- {waypoints[i + 1].Y().to<double>(), fy[i + 1]}};
-
- splines.push_back(spline);
- }
- } else if (waypoints.size() == 1) {
- const double xDeriv =
- (3 * (xFinal[0] - xInitial[0]) - xFinal[1] - xInitial[1]) / 4.0;
- const double yDeriv =
- (3 * (yFinal[0] - yInitial[0]) - yFinal[1] - yInitial[1]) / 4.0;
-
- std::array<double, 2> midXControlVector{waypoints[0].X().to<double>(),
- xDeriv};
- std::array<double, 2> midYControlVector{waypoints[0].Y().to<double>(),
- yDeriv};
-
- splines.emplace_back(xInitial, midXControlVector, yInitial,
- midYControlVector);
- splines.emplace_back(midXControlVector, xFinal, midYControlVector, yFinal);
-
- } else {
- // Create the spline.
- const CubicHermiteSpline spline{xInitial, xFinal, yInitial, yFinal};
- splines.push_back(spline);
- }
-
- return splines;
-}
-
-std::vector<QuinticHermiteSpline>
-SplineHelper::QuinticSplinesFromControlVectors(
- const std::vector<Spline<5>::ControlVector>& controlVectors) {
- std::vector<QuinticHermiteSpline> splines;
- for (size_t i = 0; i < controlVectors.size() - 1; ++i) {
- auto& xInitial = controlVectors[i].x;
- auto& yInitial = controlVectors[i].y;
- auto& xFinal = controlVectors[i + 1].x;
- auto& yFinal = controlVectors[i + 1].y;
- splines.emplace_back(xInitial, xFinal, yInitial, yFinal);
- }
- return splines;
-}
-
-std::array<Spline<3>::ControlVector, 2>
-SplineHelper::CubicControlVectorsFromWaypoints(
- const Pose2d& start, const std::vector<Translation2d>& interiorWaypoints,
- const Pose2d& end) {
- double scalar;
- if (interiorWaypoints.empty()) {
- scalar = 1.2 * start.Translation().Distance(end.Translation()).to<double>();
- } else {
- scalar =
- 1.2 *
- start.Translation().Distance(interiorWaypoints.front()).to<double>();
- }
- const auto initialCV = CubicControlVector(scalar, start);
- if (!interiorWaypoints.empty()) {
- scalar =
- 1.2 * end.Translation().Distance(interiorWaypoints.back()).to<double>();
- }
- const auto finalCV = CubicControlVector(scalar, end);
- return {initialCV, finalCV};
-}
-
-std::vector<Spline<5>::ControlVector>
-SplineHelper::QuinticControlVectorsFromWaypoints(
- const std::vector<Pose2d>& waypoints) {
- std::vector<Spline<5>::ControlVector> vectors;
- for (size_t i = 0; i < waypoints.size() - 1; ++i) {
- auto& p0 = waypoints[i];
- auto& p1 = waypoints[i + 1];
-
- // This just makes the splines look better.
- const auto scalar =
- 1.2 * p0.Translation().Distance(p1.Translation()).to<double>();
-
- vectors.push_back(QuinticControlVector(scalar, p0));
- vectors.push_back(QuinticControlVector(scalar, p1));
- }
- return vectors;
-}
-
-void SplineHelper::ThomasAlgorithm(const std::vector<double>& a,
- const std::vector<double>& b,
- const std::vector<double>& c,
- const std::vector<double>& d,
- std::vector<double>* solutionVector) {
- auto& f = *solutionVector;
- size_t N = d.size();
-
- // Create the temporary vectors
- // Note that this is inefficient as it is possible to call
- // this function many times. A better implementation would
- // pass these temporary matrices by non-const reference to
- // save excess allocation and deallocation
- std::vector<double> c_star(N, 0.0);
- std::vector<double> d_star(N, 0.0);
-
- // This updates the coefficients in the first row
- // Note that we should be checking for division by zero here
- c_star[0] = c[0] / b[0];
- d_star[0] = d[0] / b[0];
-
- // Create the c_star and d_star coefficients in the forward sweep
- for (size_t i = 1; i < N; ++i) {
- double m = 1.0 / (b[i] - a[i] * c_star[i - 1]);
- c_star[i] = c[i] * m;
- d_star[i] = (d[i] - a[i] * d_star[i - 1]) * m;
- }
-
- f[N - 1] = d_star[N - 1];
- // This is the reverse sweep, used to update the solution vector f
- for (int i = N - 2; i >= 0; i--) {
- f[i] = d_star[i] - c_star[i] * f[i + 1];
- }
-}
diff --git a/wpilibc/src/main/native/cpp/spline/SplineParameterizer.cpp b/wpilibc/src/main/native/cpp/spline/SplineParameterizer.cpp
deleted file mode 100644
index f3c42c6..0000000
--- a/wpilibc/src/main/native/cpp/spline/SplineParameterizer.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/spline/SplineParameterizer.h"
-
-constexpr units::meter_t frc::SplineParameterizer::kMaxDx;
-constexpr units::meter_t frc::SplineParameterizer::kMaxDy;
-constexpr units::radian_t frc::SplineParameterizer::kMaxDtheta;
diff --git a/wpilibc/src/main/native/cpp/trajectory/Trajectory.cpp b/wpilibc/src/main/native/cpp/trajectory/Trajectory.cpp
deleted file mode 100644
index 84d4f37..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/Trajectory.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/Trajectory.h"
-
-#include <wpi/json.h>
-
-using namespace frc;
-
-bool Trajectory::State::operator==(const Trajectory::State& other) const {
- return t == other.t && velocity == other.velocity &&
- acceleration == other.acceleration && pose == other.pose &&
- curvature == other.curvature;
-}
-
-bool Trajectory::State::operator!=(const Trajectory::State& other) const {
- return !operator==(other);
-}
-
-Trajectory::State Trajectory::State::Interpolate(State endValue,
- double i) const {
- // Find the new [t] value.
- const auto newT = Lerp(t, endValue.t, i);
-
- // Find the delta time between the current state and the interpolated state.
- const auto deltaT = newT - t;
-
- // If delta time is negative, flip the order of interpolation.
- if (deltaT < 0_s) return endValue.Interpolate(*this, 1.0 - i);
-
- // Check whether the robot is reversing at this stage.
- const auto reversing =
- velocity < 0_mps ||
- (units::math::abs(velocity) < 1E-9_mps && acceleration < 0_mps_sq);
-
- // Calculate the new velocity.
- // v = v_0 + at
- const units::meters_per_second_t newV = velocity + (acceleration * deltaT);
-
- // Calculate the change in position.
- // delta_s = v_0 t + 0.5 at^2
- const units::meter_t newS =
- (velocity * deltaT + 0.5 * acceleration * deltaT * deltaT) *
- (reversing ? -1.0 : 1.0);
-
- // Return the new state. To find the new position for the new state, we need
- // to interpolate between the two endpoint poses. The fraction for
- // interpolation is the change in position (delta s) divided by the total
- // distance between the two endpoints.
- const double interpolationFrac =
- newS / endValue.pose.Translation().Distance(pose.Translation());
-
- return {newT, newV, acceleration,
- Lerp(pose, endValue.pose, interpolationFrac),
- Lerp(curvature, endValue.curvature, interpolationFrac)};
-}
-
-Trajectory::Trajectory(const std::vector<State>& states) : m_states(states) {
- m_totalTime = states.back().t;
-}
-
-Trajectory::State Trajectory::Sample(units::second_t t) const {
- if (t <= m_states.front().t) return m_states.front();
- if (t >= m_totalTime) return m_states.back();
-
- // To get the element that we want, we will use a binary search algorithm
- // instead of iterating over a for-loop. A binary search is O(std::log(n))
- // whereas searching using a loop is O(n).
-
- // This starts at 1 because we use the previous state later on for
- // interpolation.
- int low = 1;
- int high = m_states.size() - 1;
-
- while (low != high) {
- int mid = (low + high) / 2;
- if (m_states[mid].t < t) {
- // This index and everything under it are less than the requested
- // timestamp. Therefore, we can discard them.
- low = mid + 1;
- } else {
- // t is at least as large as the element at this index. This means that
- // anything after it cannot be what we are looking for.
- high = mid;
- }
- }
-
- // High and Low should be the same.
-
- // The sample's timestamp is now greater than or equal to the requested
- // timestamp. If it is greater, we need to interpolate between the
- // previous state and the current state to get the exact state that we
- // want.
- const auto sample = m_states[low];
- const auto prevSample = m_states[low - 1];
-
- // If the difference in states is negligible, then we are spot on!
- if (units::math::abs(sample.t - prevSample.t) < 1E-9_s) {
- return sample;
- }
- // Interpolate between the two states for the state that we want.
- return prevSample.Interpolate(sample,
- (t - prevSample.t) / (sample.t - prevSample.t));
-}
-
-Trajectory Trajectory::TransformBy(const Transform2d& transform) {
- auto& firstState = m_states[0];
- auto& firstPose = firstState.pose;
-
- // Calculate the transformed first pose.
- auto newFirstPose = firstPose + transform;
- auto newStates = m_states;
- newStates[0].pose = newFirstPose;
-
- for (unsigned int i = 1; i < newStates.size(); i++) {
- auto& state = newStates[i];
- // We are transforming relative to the coordinate frame of the new initial
- // pose.
- state.pose = newFirstPose + (state.pose - firstPose);
- }
-
- return Trajectory(newStates);
-}
-
-Trajectory Trajectory::RelativeTo(const Pose2d& pose) {
- auto newStates = m_states;
- for (auto& state : newStates) {
- state.pose = state.pose.RelativeTo(pose);
- }
- return Trajectory(newStates);
-}
-
-void frc::to_json(wpi::json& json, const Trajectory::State& state) {
- json = wpi::json{{"time", state.t.to<double>()},
- {"velocity", state.velocity.to<double>()},
- {"acceleration", state.acceleration.to<double>()},
- {"pose", state.pose},
- {"curvature", state.curvature.to<double>()}};
-}
-
-void frc::from_json(const wpi::json& json, Trajectory::State& state) {
- state.pose = json.at("pose").get<Pose2d>();
- state.t = units::second_t{json.at("time").get<double>()};
- state.velocity =
- units::meters_per_second_t{json.at("velocity").get<double>()};
- state.acceleration =
- units::meters_per_second_squared_t{json.at("acceleration").get<double>()};
- state.curvature = frc::curvature_t{json.at("curvature").get<double>()};
-}
diff --git a/wpilibc/src/main/native/cpp/trajectory/TrajectoryGenerator.cpp b/wpilibc/src/main/native/cpp/trajectory/TrajectoryGenerator.cpp
deleted file mode 100644
index 3c95472..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/TrajectoryGenerator.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/TrajectoryGenerator.h"
-
-#include <utility>
-
-#include "frc/DriverStation.h"
-#include "frc/spline/SplineHelper.h"
-#include "frc/spline/SplineParameterizer.h"
-#include "frc/trajectory/TrajectoryParameterizer.h"
-
-using namespace frc;
-
-const Trajectory TrajectoryGenerator::kDoNothingTrajectory(
- std::vector<Trajectory::State>{Trajectory::State()});
-
-Trajectory TrajectoryGenerator::GenerateTrajectory(
- Spline<3>::ControlVector initial,
- const std::vector<Translation2d>& interiorWaypoints,
- Spline<3>::ControlVector end, const TrajectoryConfig& config) {
- const Transform2d flip{Translation2d(), Rotation2d(180_deg)};
-
- // Make theta normal for trajectory generation if path is reversed.
- // Flip the headings.
- if (config.IsReversed()) {
- initial.x[1] *= -1;
- initial.y[1] *= -1;
- end.x[1] *= -1;
- end.y[1] *= -1;
- }
-
- std::vector<frc::SplineParameterizer::PoseWithCurvature> points;
- try {
- points =
- SplinePointsFromSplines(SplineHelper::CubicSplinesFromControlVectors(
- initial, interiorWaypoints, end));
- } catch (SplineParameterizer::MalformedSplineException& e) {
- DriverStation::ReportError(e.what());
- return kDoNothingTrajectory;
- }
-
- // After trajectory generation, flip theta back so it's relative to the
- // field. Also fix curvature.
- if (config.IsReversed()) {
- for (auto& point : points) {
- point = {point.first + flip, -point.second};
- }
- }
-
- return TrajectoryParameterizer::TimeParameterizeTrajectory(
- points, config.Constraints(), config.StartVelocity(),
- config.EndVelocity(), config.MaxVelocity(), config.MaxAcceleration(),
- config.IsReversed());
-}
-
-Trajectory TrajectoryGenerator::GenerateTrajectory(
- const Pose2d& start, const std::vector<Translation2d>& interiorWaypoints,
- const Pose2d& end, const TrajectoryConfig& config) {
- auto [startCV, endCV] = SplineHelper::CubicControlVectorsFromWaypoints(
- start, interiorWaypoints, end);
- return GenerateTrajectory(startCV, interiorWaypoints, endCV, config);
-}
-
-Trajectory TrajectoryGenerator::GenerateTrajectory(
- std::vector<Spline<5>::ControlVector> controlVectors,
- const TrajectoryConfig& config) {
- const Transform2d flip{Translation2d(), Rotation2d(180_deg)};
- // Make theta normal for trajectory generation if path is reversed.
- if (config.IsReversed()) {
- for (auto& vector : controlVectors) {
- // Flip the headings.
- vector.x[1] *= -1;
- vector.y[1] *= -1;
- }
- }
-
- std::vector<frc::SplineParameterizer::PoseWithCurvature> points;
- try {
- points = SplinePointsFromSplines(
- SplineHelper::QuinticSplinesFromControlVectors(controlVectors));
- } catch (SplineParameterizer::MalformedSplineException& e) {
- DriverStation::ReportError(e.what());
- return kDoNothingTrajectory;
- }
-
- // After trajectory generation, flip theta back so it's relative to the
- // field. Also fix curvature.
- if (config.IsReversed()) {
- for (auto& point : points) {
- point = {point.first + flip, -point.second};
- }
- }
-
- return TrajectoryParameterizer::TimeParameterizeTrajectory(
- points, config.Constraints(), config.StartVelocity(),
- config.EndVelocity(), config.MaxVelocity(), config.MaxAcceleration(),
- config.IsReversed());
-}
-
-Trajectory TrajectoryGenerator::GenerateTrajectory(
- const std::vector<Pose2d>& waypoints, const TrajectoryConfig& config) {
- return GenerateTrajectory(
- SplineHelper::QuinticControlVectorsFromWaypoints(waypoints), config);
-}
diff --git a/wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp b/wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp
deleted file mode 100644
index 131ae8a..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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. */
-/*----------------------------------------------------------------------------*/
-
-/*
- * MIT License
- *
- * Copyright (c) 2018 Team 254
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "frc/trajectory/TrajectoryParameterizer.h"
-
-using namespace frc;
-
-Trajectory TrajectoryParameterizer::TimeParameterizeTrajectory(
- const std::vector<PoseWithCurvature>& points,
- const std::vector<std::unique_ptr<TrajectoryConstraint>>& constraints,
- units::meters_per_second_t startVelocity,
- units::meters_per_second_t endVelocity,
- units::meters_per_second_t maxVelocity,
- units::meters_per_second_squared_t maxAcceleration, bool reversed) {
- std::vector<ConstrainedState> constrainedStates(points.size());
-
- ConstrainedState predecessor{points.front(), 0_m, startVelocity,
- -maxAcceleration, maxAcceleration};
-
- constrainedStates[0] = predecessor;
-
- // Forward pass
- for (unsigned int i = 0; i < points.size(); i++) {
- auto& constrainedState = constrainedStates[i];
- constrainedState.pose = points[i];
-
- // Begin constraining based on predecessor
- units::meter_t ds = constrainedState.pose.first.Translation().Distance(
- predecessor.pose.first.Translation());
- constrainedState.distance = ds + predecessor.distance;
-
- // We may need to iterate to find the maximum end velocity and common
- // acceleration, since acceleration limits may be a function of velocity.
- while (true) {
- // Enforce global max velocity and max reachable velocity by global
- // acceleration limit. vf = std::sqrt(vi^2 + 2*a*d).
-
- constrainedState.maxVelocity = units::math::min(
- maxVelocity,
- units::math::sqrt(predecessor.maxVelocity * predecessor.maxVelocity +
- predecessor.maxAcceleration * ds * 2.0));
-
- constrainedState.minAcceleration = -maxAcceleration;
- constrainedState.maxAcceleration = maxAcceleration;
-
- // At this point, the constrained state is fully constructed apart from
- // all the custom-defined user constraints.
- for (const auto& constraint : constraints) {
- constrainedState.maxVelocity = units::math::min(
- constrainedState.maxVelocity,
- constraint->MaxVelocity(constrainedState.pose.first,
- constrainedState.pose.second,
- constrainedState.maxVelocity));
- }
-
- // Now enforce all acceleration limits.
- EnforceAccelerationLimits(reversed, constraints, &constrainedState);
-
- if (ds.to<double>() < kEpsilon) break;
-
- // If the actual acceleration for this state is higher than the max
- // acceleration that we applied, then we need to reduce the max
- // acceleration of the predecessor and try again.
- units::meters_per_second_squared_t actualAcceleration =
- (constrainedState.maxVelocity * constrainedState.maxVelocity -
- predecessor.maxVelocity * predecessor.maxVelocity) /
- (ds * 2.0);
-
- // If we violate the max acceleration constraint, let's modify the
- // predecessor.
- if (constrainedState.maxAcceleration < actualAcceleration - 1E-6_mps_sq) {
- predecessor.maxAcceleration = constrainedState.maxAcceleration;
- } else {
- // Constrain the predecessor's max acceleration to the current
- // acceleration.
- if (actualAcceleration > predecessor.minAcceleration + 1E-6_mps_sq) {
- predecessor.maxAcceleration = actualAcceleration;
- }
- // If the actual acceleration is less than the predecessor's min
- // acceleration, it will be repaired in the backward pass.
- break;
- }
- }
- predecessor = constrainedState;
- }
-
- ConstrainedState successor{points.back(), constrainedStates.back().distance,
- endVelocity, -maxAcceleration, maxAcceleration};
-
- // Backward pass
- for (int i = points.size() - 1; i >= 0; i--) {
- auto& constrainedState = constrainedStates[i];
- units::meter_t ds =
- constrainedState.distance - successor.distance; // negative
-
- while (true) {
- // Enforce max velocity limit (reverse)
- // vf = std::sqrt(vi^2 + 2*a*d), where vi = successor.
- units::meters_per_second_t newMaxVelocity =
- units::math::sqrt(successor.maxVelocity * successor.maxVelocity +
- successor.minAcceleration * ds * 2.0);
-
- // No more limits to impose! This state can be finalized.
- if (newMaxVelocity >= constrainedState.maxVelocity) break;
-
- constrainedState.maxVelocity = newMaxVelocity;
-
- // Check all acceleration constraints with the new max velocity.
- EnforceAccelerationLimits(reversed, constraints, &constrainedState);
-
- if (ds.to<double>() > -kEpsilon) break;
-
- // If the actual acceleration for this state is lower than the min
- // acceleration, then we need to lower the min acceleration of the
- // successor and try again.
- units::meters_per_second_squared_t actualAcceleration =
- (constrainedState.maxVelocity * constrainedState.maxVelocity -
- successor.maxVelocity * successor.maxVelocity) /
- (ds * 2.0);
- if (constrainedState.minAcceleration > actualAcceleration + 1E-6_mps_sq) {
- successor.minAcceleration = constrainedState.minAcceleration;
- } else {
- successor.minAcceleration = actualAcceleration;
- break;
- }
- }
- successor = constrainedState;
- }
-
- // Now we can integrate the constrained states forward in time to obtain our
- // trajectory states.
-
- std::vector<Trajectory::State> states(points.size());
- units::second_t t = 0_s;
- units::meter_t s = 0_m;
- units::meters_per_second_t v = 0_mps;
-
- for (unsigned int i = 0; i < constrainedStates.size(); i++) {
- auto state = constrainedStates[i];
-
- // Calculate the change in position between the current state and the
- // previous state.
- units::meter_t ds = state.distance - s;
-
- // Calculate the acceleration between the current state and the previous
- // state.
- units::meters_per_second_squared_t accel =
- (state.maxVelocity * state.maxVelocity - v * v) / (ds * 2);
-
- // Calculate dt.
- units::second_t dt = 0_s;
- if (i > 0) {
- states.at(i - 1).acceleration = reversed ? -accel : accel;
- if (units::math::abs(accel) > 1E-6_mps_sq) {
- // v_f = v_0 + a * t
- dt = (state.maxVelocity - v) / accel;
- } else if (units::math::abs(v) > 1E-6_mps) {
- // delta_x = v * t
- dt = ds / v;
- } else {
- throw std::runtime_error(
- "Something went wrong during trajectory generation.");
- }
- }
-
- v = state.maxVelocity;
- s = state.distance;
-
- t += dt;
-
- states[i] = {t, reversed ? -v : v, reversed ? -accel : accel,
- state.pose.first, state.pose.second};
- }
-
- return Trajectory(states);
-}
-
-void TrajectoryParameterizer::EnforceAccelerationLimits(
- bool reverse,
- const std::vector<std::unique_ptr<TrajectoryConstraint>>& constraints,
- ConstrainedState* state) {
- for (auto&& constraint : constraints) {
- double factor = reverse ? -1.0 : 1.0;
-
- auto minMaxAccel = constraint->MinMaxAcceleration(
- state->pose.first, state->pose.second, state->maxVelocity * factor);
-
- state->minAcceleration = units::math::max(
- state->minAcceleration,
- reverse ? -minMaxAccel.maxAcceleration : minMaxAccel.minAcceleration);
-
- state->maxAcceleration = units::math::min(
- state->maxAcceleration,
- reverse ? -minMaxAccel.minAcceleration : minMaxAccel.maxAcceleration);
- }
-}
diff --git a/wpilibc/src/main/native/cpp/trajectory/TrajectoryUtil.cpp b/wpilibc/src/main/native/cpp/trajectory/TrajectoryUtil.cpp
deleted file mode 100644
index f3cf30d..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/TrajectoryUtil.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/TrajectoryUtil.h"
-
-#include <system_error>
-
-#include <wpi/SmallString.h>
-#include <wpi/json.h>
-#include <wpi/raw_istream.h>
-#include <wpi/raw_ostream.h>
-
-using namespace frc;
-
-void TrajectoryUtil::ToPathweaverJson(const Trajectory& trajectory,
- const wpi::Twine& path) {
- std::error_code error_code;
-
- wpi::SmallString<128> buf;
- wpi::raw_fd_ostream output{path.toStringRef(buf), error_code};
- if (error_code) {
- throw std::runtime_error(("Cannot open file: " + path).str());
- }
-
- wpi::json json = trajectory.States();
- output << json;
- output.flush();
-}
-
-Trajectory TrajectoryUtil::FromPathweaverJson(const wpi::Twine& path) {
- std::error_code error_code;
-
- wpi::SmallString<128> buf;
- wpi::raw_fd_istream input{path.toStringRef(buf), error_code};
- if (error_code) {
- throw std::runtime_error(("Cannot open file: " + path).str());
- }
-
- wpi::json json;
- input >> json;
-
- return Trajectory{json.get<std::vector<Trajectory::State>>()};
-}
-
-std::string TrajectoryUtil::SerializeTrajectory(const Trajectory& trajectory) {
- wpi::json json = trajectory.States();
- return json.dump();
-}
-
-Trajectory TrajectoryUtil::DeserializeTrajectory(
- const wpi::StringRef json_str) {
- wpi::json json = wpi::json::parse(json_str);
- return Trajectory{json.get<std::vector<Trajectory::State>>()};
-}
diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/CentripetalAccelerationConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/CentripetalAccelerationConstraint.cpp
deleted file mode 100644
index bf45c34..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/constraint/CentripetalAccelerationConstraint.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/constraint/CentripetalAccelerationConstraint.h"
-
-using namespace frc;
-
-CentripetalAccelerationConstraint::CentripetalAccelerationConstraint(
- units::meters_per_second_squared_t maxCentripetalAcceleration)
- : m_maxCentripetalAcceleration(maxCentripetalAcceleration) {}
-
-units::meters_per_second_t CentripetalAccelerationConstraint::MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) {
- // ac = v^2 / r
- // k (curvature) = 1 / r
-
- // therefore, ac = v^2 * k
- // ac / k = v^2
- // v = std::sqrt(ac / k)
-
- // We have to multiply by 1_rad here to get the units to cancel out nicely.
- // The units library defines a unit for radians although it is technically
- // unitless.
- return units::math::sqrt(m_maxCentripetalAcceleration /
- units::math::abs(curvature) * 1_rad);
-}
-
-TrajectoryConstraint::MinMax
-CentripetalAccelerationConstraint::MinMaxAcceleration(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) {
- // The acceleration of the robot has no impact on the centripetal acceleration
- // of the robot.
- return {};
-}
diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveKinematicsConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveKinematicsConstraint.cpp
deleted file mode 100644
index 8b88bf4..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveKinematicsConstraint.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h"
-
-using namespace frc;
-
-DifferentialDriveKinematicsConstraint::DifferentialDriveKinematicsConstraint(
- DifferentialDriveKinematics kinematics, units::meters_per_second_t maxSpeed)
- : m_kinematics(kinematics), m_maxSpeed(maxSpeed) {}
-
-units::meters_per_second_t DifferentialDriveKinematicsConstraint::MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) {
- auto wheelSpeeds =
- m_kinematics.ToWheelSpeeds({velocity, 0_mps, velocity * curvature});
- wheelSpeeds.Normalize(m_maxSpeed);
-
- return m_kinematics.ToChassisSpeeds(wheelSpeeds).vx;
-}
-
-TrajectoryConstraint::MinMax
-DifferentialDriveKinematicsConstraint::MinMaxAcceleration(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) {
- return {};
-}
diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveVoltageConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveVoltageConstraint.cpp
deleted file mode 100644
index 3d6b61c..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/constraint/DifferentialDriveVoltageConstraint.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h"
-
-#include <algorithm>
-#include <limits>
-
-#include <wpi/MathExtras.h>
-
-using namespace frc;
-
-DifferentialDriveVoltageConstraint::DifferentialDriveVoltageConstraint(
- SimpleMotorFeedforward<units::meter> feedforward,
- DifferentialDriveKinematics kinematics, units::volt_t maxVoltage)
- : m_feedforward(feedforward),
- m_kinematics(kinematics),
- m_maxVoltage(maxVoltage) {}
-
-units::meters_per_second_t DifferentialDriveVoltageConstraint::MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) {
- return units::meters_per_second_t(std::numeric_limits<double>::max());
-}
-
-TrajectoryConstraint::MinMax
-DifferentialDriveVoltageConstraint::MinMaxAcceleration(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) {
- auto wheelSpeeds =
- m_kinematics.ToWheelSpeeds({speed, 0_mps, speed * curvature});
-
- auto maxWheelSpeed = std::max(wheelSpeeds.left, wheelSpeeds.right);
- auto minWheelSpeed = std::min(wheelSpeeds.left, wheelSpeeds.right);
-
- // Calculate maximum/minimum possible accelerations from motor dynamics
- // and max/min wheel speeds
- auto maxWheelAcceleration =
- m_feedforward.MaxAchievableAcceleration(m_maxVoltage, maxWheelSpeed);
- auto minWheelAcceleration =
- m_feedforward.MinAchievableAcceleration(m_maxVoltage, minWheelSpeed);
-
- // Robot chassis turning on radius = 1/|curvature|. Outer wheel has radius
- // increased by half of the trackwidth T. Inner wheel has radius decreased
- // by half of the trackwidth. Achassis / radius = Aouter / (radius + T/2), so
- // Achassis = Aouter * radius / (radius + T/2) = Aouter / (1 + |curvature|T/2)
- // Inner wheel is similar.
-
- // sgn(speed) term added to correctly account for which wheel is on
- // outside of turn:
- // If moving forward, max acceleration constraint corresponds to wheel on
- // outside of turn
- // If moving backward, max acceleration constraint corresponds to wheel on
- // inside of turn
- auto maxChassisAcceleration =
- maxWheelAcceleration /
- (1 + m_kinematics.trackWidth * units::math::abs(curvature) *
- wpi::sgn(speed) / (2_rad));
- auto minChassisAcceleration =
- minWheelAcceleration /
- (1 - m_kinematics.trackWidth * units::math::abs(curvature) *
- wpi::sgn(speed) / (2_rad));
-
- // Negate acceleration corresponding to wheel on inside of turn
- // if center of turn is inside of wheelbase
- if ((m_kinematics.trackWidth / 2) > 1_rad / units::math::abs(curvature)) {
- if (speed > 0_mps) {
- minChassisAcceleration = -minChassisAcceleration;
- } else {
- maxChassisAcceleration = -maxChassisAcceleration;
- }
- }
-
- return {minChassisAcceleration, maxChassisAcceleration};
-}
diff --git a/wpilibc/src/main/native/cpp/trajectory/constraint/MecanumDriveKinematicsConstraint.cpp b/wpilibc/src/main/native/cpp/trajectory/constraint/MecanumDriveKinematicsConstraint.cpp
deleted file mode 100644
index 2fd8151..0000000
--- a/wpilibc/src/main/native/cpp/trajectory/constraint/MecanumDriveKinematicsConstraint.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h"
-
-using namespace frc;
-
-MecanumDriveKinematicsConstraint::MecanumDriveKinematicsConstraint(
- MecanumDriveKinematics kinematics, units::meters_per_second_t maxSpeed)
- : m_kinematics(kinematics), m_maxSpeed(maxSpeed) {}
-
-units::meters_per_second_t MecanumDriveKinematicsConstraint::MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) {
- auto xVelocity = velocity * pose.Rotation().Cos();
- auto yVelocity = velocity * pose.Rotation().Sin();
- auto wheelSpeeds =
- m_kinematics.ToWheelSpeeds({xVelocity, yVelocity, velocity * curvature});
- wheelSpeeds.Normalize(m_maxSpeed);
-
- auto normSpeeds = m_kinematics.ToChassisSpeeds(wheelSpeeds);
-
- return units::math::hypot(normSpeeds.vx, normSpeeds.vy);
-}
-
-TrajectoryConstraint::MinMax
-MecanumDriveKinematicsConstraint::MinMaxAcceleration(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) {
- return {};
-}
diff --git a/wpilibc/src/main/native/cppcs/RobotBase.cpp b/wpilibc/src/main/native/cppcs/RobotBase.cpp
index eaf4ddc..5f34e77 100644
--- a/wpilibc/src/main/native/cppcs/RobotBase.cpp
+++ b/wpilibc/src/main/native/cppcs/RobotBase.cpp
@@ -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. */
@@ -17,6 +17,7 @@
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <networktables/NetworkTableInstance.h>
+#include <wpimath/MathShared.h>
#include "WPILibVersion.h"
#include "frc/DriverStation.h"
@@ -68,6 +69,47 @@
return std::make_pair(RobotBase::GetThreadId(), true);
}
};
+class WPILibMathShared : public wpi::math::MathShared {
+ public:
+ void ReportError(const wpi::Twine& error) override {
+ DriverStation::ReportError(error);
+ }
+
+ void ReportUsage(wpi::math::MathUsageId id, int count) override {
+ switch (id) {
+ case wpi::math::MathUsageId::kKinematics_DifferentialDrive:
+ HAL_Report(HALUsageReporting::kResourceType_Kinematics,
+ HALUsageReporting::kKinematics_DifferentialDrive);
+ break;
+ case wpi::math::MathUsageId::kKinematics_MecanumDrive:
+ HAL_Report(HALUsageReporting::kResourceType_Kinematics,
+ HALUsageReporting::kKinematics_MecanumDrive);
+ break;
+ case wpi::math::MathUsageId::kKinematics_SwerveDrive:
+ HAL_Report(HALUsageReporting::kResourceType_Kinematics,
+ HALUsageReporting::kKinematics_SwerveDrive);
+ break;
+ case wpi::math::MathUsageId::kTrajectory_TrapezoidProfile:
+ HAL_Report(HALUsageReporting::kResourceType_TrapezoidProfile, count);
+ break;
+ case wpi::math::MathUsageId::kFilter_Linear:
+ HAL_Report(HALUsageReporting::kResourceType_LinearFilter, count);
+ break;
+ case wpi::math::MathUsageId::kOdometry_DifferentialDrive:
+ HAL_Report(HALUsageReporting::kResourceType_Odometry,
+ HALUsageReporting::kOdometry_DifferentialDrive);
+ break;
+ case wpi::math::MathUsageId::kOdometry_SwerveDrive:
+ HAL_Report(HALUsageReporting::kResourceType_Odometry,
+ HALUsageReporting::kOdometry_SwerveDrive);
+ break;
+ case wpi::math::MathUsageId::kOdometry_MecanumDrive:
+ HAL_Report(HALUsageReporting::kResourceType_Odometry,
+ HALUsageReporting::kOdometry_MecanumDrive);
+ break;
+ }
+ }
+};
} // namespace
static void SetupCameraServerShared() {
@@ -88,8 +130,6 @@
if (symbol) {
auto setCameraServerShared = (SetCameraServerSharedFP)symbol;
setCameraServerShared(new WPILibCameraServerShared{});
- wpi::outs() << "Set Camera Server Shared\n";
- wpi::outs().flush();
} else {
wpi::outs() << "Camera Server Shared Symbol Missing\n";
wpi::outs().flush();
@@ -103,14 +143,27 @@
#endif
}
+static void SetupMathShared() {
+ wpi::math::MathSharedStore::SetMathShared(
+ std::make_unique<WPILibMathShared>());
+}
+
bool RobotBase::IsEnabled() const { return m_ds.IsEnabled(); }
bool RobotBase::IsDisabled() const { return m_ds.IsDisabled(); }
bool RobotBase::IsAutonomous() const { return m_ds.IsAutonomous(); }
+bool RobotBase::IsAutonomousEnabled() const {
+ return m_ds.IsAutonomousEnabled();
+}
+
bool RobotBase::IsOperatorControl() const { return m_ds.IsOperatorControl(); }
+bool RobotBase::IsOperatorControlEnabled() const {
+ return m_ds.IsOperatorControlEnabled();
+}
+
bool RobotBase::IsTest() const { return m_ds.IsTest(); }
bool RobotBase::IsNewDataAvailable() const { return m_ds.IsNewControlData(); }
@@ -121,6 +174,7 @@
m_threadId = std::this_thread::get_id();
SetupCameraServerShared();
+ SetupMathShared();
auto inst = nt::NetworkTableInstance::GetDefault();
inst.SetNetworkIdentity("Robot");
diff --git a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h
index ccdb75c..309fab3 100644
--- a/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h
+++ b/wpilibc/src/main/native/include/frc/ADXRS450_Gyro.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2015-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. */
@@ -27,6 +27,7 @@
* determine the heading.
*
* This class is for the digital ADXRS450 gyro sensor that connects via SPI.
+ * Only one instance of an ADXRS Gyro is supported.
*/
class ADXRS450_Gyro : public GyroBase {
public:
@@ -50,21 +51,19 @@
/**
* Return the actual angle in degrees that the robot is currently facing.
*
- * The angle is based on the current accumulator value corrected by the
- * oversampling rate, the gyro type and the A/D calibration values.
+ * The angle is based on integration of the returned rate from the gyro.
* The angle is continuous, that is it will continue from 360->361 degrees.
* This allows algorithms that wouldn't want to see a discontinuity in the
* gyro output as it sweeps from 360 to 0 on the second time around.
*
- * @return the current heading of the robot in degrees. This heading is based
- * on integration of the returned rate from the gyro.
+ * @return the current heading of the robot in degrees.
*/
double GetAngle() const override;
/**
* Return the rate of rotation of the gyro
*
- * The rate is based on the most recent reading of the gyro analog value
+ * The rate is based on the most recent reading of the gyro.
*
* @return the current rate in degrees per second
*/
@@ -93,8 +92,16 @@
*/
void Calibrate() override;
+ /**
+ * Get the SPI port number.
+ *
+ * @return The SPI port number.
+ */
+ int GetPort() const;
+
private:
SPI m_spi;
+ SPI::Port m_port;
hal::SimDevice m_simDevice;
hal::SimDouble m_simAngle;
diff --git a/wpilibc/src/main/native/include/frc/AddressableLED.h b/wpilibc/src/main/native/include/frc/AddressableLED.h
index 5534ae4..3bcbab5 100644
--- a/wpilibc/src/main/native/include/frc/AddressableLED.h
+++ b/wpilibc/src/main/native/include/frc/AddressableLED.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -11,7 +11,7 @@
#include <hal/AddressableLEDTypes.h>
#include <hal/Types.h>
-#include <units/units.h>
+#include <units/time.h>
#include <wpi/ArrayRef.h>
#include "frc/ErrorBase.h"
@@ -22,6 +22,8 @@
/**
* A class for driving addressable LEDs, such as WS2812s and NeoPixels.
+ *
+ * <p>Only 1 LED driver is currently supported by the roboRIO.
*/
class AddressableLED : public ErrorBase {
public:
@@ -83,7 +85,7 @@
/**
* Constructs a new driver for a specific port.
*
- * @param port the output port to use (Must be a PWM port)
+ * @param port the output port to use (Must be a PWM header)
*/
explicit AddressableLED(int port);
@@ -95,6 +97,8 @@
* <p>Calling this is an expensive call, so its best to call it once, then
* just update data.
*
+ * <p>The max length is 5460 LEDs.
+ *
* @param length the strip length
*/
void SetLength(int length);
@@ -147,7 +151,7 @@
/**
* Starts the output.
*
- * <p>The output writes continously.
+ * <p>The output writes continuously.
*/
void Start();
diff --git a/wpilibc/src/main/native/include/frc/AnalogEncoder.h b/wpilibc/src/main/native/include/frc/AnalogEncoder.h
index 872db87..3dc22ea 100644
--- a/wpilibc/src/main/native/include/frc/AnalogEncoder.h
+++ b/wpilibc/src/main/native/include/frc/AnalogEncoder.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -11,7 +11,7 @@
#include <hal/SimDevice.h>
#include <hal/Types.h>
-#include <units/units.h>
+#include <units/angle.h>
#include "frc/AnalogTrigger.h"
#include "frc/Counter.h"
@@ -108,6 +108,13 @@
*/
double GetDistance() const;
+ /**
+ * Get the channel number.
+ *
+ * @return The channel number.
+ */
+ int GetChannel() const;
+
void InitSendable(SendableBuilder& builder) override;
private:
diff --git a/wpilibc/src/main/native/include/frc/AnalogGyro.h b/wpilibc/src/main/native/include/frc/AnalogGyro.h
index bcc67c9..b59df5b 100644
--- a/wpilibc/src/main/native/include/frc/AnalogGyro.h
+++ b/wpilibc/src/main/native/include/frc/AnalogGyro.h
@@ -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. */
@@ -186,6 +186,13 @@
void Calibrate() override;
+ /**
+ * Gets the analog input for the gyro.
+ *
+ * @return AnalogInput
+ */
+ std::shared_ptr<AnalogInput> GetAnalogInput() const;
+
protected:
std::shared_ptr<AnalogInput> m_analog;
diff --git a/wpilibc/src/main/native/include/frc/AnalogOutput.h b/wpilibc/src/main/native/include/frc/AnalogOutput.h
index 1cecd70..026986b 100644
--- a/wpilibc/src/main/native/include/frc/AnalogOutput.h
+++ b/wpilibc/src/main/native/include/frc/AnalogOutput.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -55,7 +55,7 @@
/**
* Get the channel of this AnalogOutput.
*/
- int GetChannel();
+ int GetChannel() const;
void InitSendable(SendableBuilder& builder) override;
diff --git a/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h b/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h
index 446a920..ed943f7 100644
--- a/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h
+++ b/wpilibc/src/main/native/include/frc/AnalogPotentiometer.h
@@ -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. */
@@ -42,11 +42,12 @@
* This will calculate the result from the fullRange times the fraction of the
* supply voltage, plus the offset.
*
- * @param channel The channel number on the roboRIO to represent. 0-3 are
- * on-board 4-7 are on the MXP port.
- * @param fullRange The angular value (in desired units) representing the full
+ * @param channel The Analog Input channel number on the roboRIO the
+ * potentiometer is plugged into. 0-3 are on-board and 4-7
+ * are on the MXP port.
+ * @param fullRange The value (in desired units) representing the full
* 0-5V range of the input.
- * @param offset The angular value (in desired units) representing the
+ * @param offset The value (in desired units) representing the
* angular output at 0V.
*/
explicit AnalogPotentiometer(int channel, double fullRange = 1.0,
@@ -66,9 +67,9 @@
* supply voltage, plus the offset.
*
* @param channel The existing Analog Input pointer
- * @param fullRange The angular value (in desired units) representing the full
+ * @param fullRange The value (in desired units) representing the full
* 0-5V range of the input.
- * @param offset The angular value (in desired units) representing the
+ * @param offset The value (in desired units) representing the
* angular output at 0V.
*/
explicit AnalogPotentiometer(AnalogInput* input, double fullRange = 1.0,
@@ -88,9 +89,9 @@
* supply voltage, plus the offset.
*
* @param channel The existing Analog Input pointer
- * @param fullRange The angular value (in desired units) representing the full
+ * @param fullRange The value (in desired units) representing the full
* 0-5V range of the input.
- * @param offset The angular value (in desired units) representing the
+ * @param offset The value (in desired units) representing the
* angular output at 0V.
*/
explicit AnalogPotentiometer(std::shared_ptr<AnalogInput> input,
@@ -102,7 +103,7 @@
AnalogPotentiometer& operator=(AnalogPotentiometer&&) = default;
/**
- * Get the current reading of the potentiomer.
+ * Get the current reading of the potentiometer.
*
* @return The current position of the potentiometer (in the units used for
* fullRange and offset).
diff --git a/wpilibc/src/main/native/include/frc/AnalogTrigger.h b/wpilibc/src/main/native/include/frc/AnalogTrigger.h
index 7554bd9..d465652 100644
--- a/wpilibc/src/main/native/include/frc/AnalogTrigger.h
+++ b/wpilibc/src/main/native/include/frc/AnalogTrigger.h
@@ -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. */
@@ -101,17 +101,6 @@
void SetAveraged(bool useAveragedValue);
/**
- * Configure the analog trigger to use the duty cycle vs. raw values.
- *
- * If the value is true, then the duty cycle value is selected for the analog
- * trigger, otherwise the immediate value is used.
- *
- * @param useDutyCycle If true, use the duty cycle value, otherwise use the
- * instantaneous reading
- */
- void SetDutyCycle(bool useDutyCycle);
-
- /**
* Configure the analog trigger to use a filtered value.
*
* The analog trigger will operate with a 3 point average rejection filter.
diff --git a/wpilibc/src/main/native/include/frc/CAN.h b/wpilibc/src/main/native/include/frc/CAN.h
index ed861fb..612d533 100644
--- a/wpilibc/src/main/native/include/frc/CAN.h
+++ b/wpilibc/src/main/native/include/frc/CAN.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -10,7 +10,6 @@
#include <stdint.h>
#include <hal/CANAPITypes.h>
-#include <wpi/ArrayRef.h>
#include "frc/ErrorBase.h"
@@ -94,6 +93,38 @@
void WriteRTRFrame(int length, int apiId);
/**
+ * Write a packet to the CAN device with a specific ID. This ID is 10 bits.
+ *
+ * @param data The data to write (8 bytes max)
+ * @param length The data length to write
+ * @param apiId The API ID to write.
+ */
+ int WritePacketNoError(const uint8_t* data, int length, int apiId);
+
+ /**
+ * Write a repeating packet to the CAN device with a specific ID. This ID is
+ * 10 bits. The RoboRIO will automatically repeat the packet at the specified
+ * interval
+ *
+ * @param data The data to write (8 bytes max)
+ * @param length The data length to write
+ * @param apiId The API ID to write.
+ * @param repeatMs The period to repeat the packet at.
+ */
+ int WritePacketRepeatingNoError(const uint8_t* data, int length, int apiId,
+ int repeatMs);
+
+ /**
+ * Write an RTR frame to the CAN device with a specific ID. This ID is 10
+ * bits. The length by spec must match what is returned by the responding
+ * device
+ *
+ * @param length The length to request (0 to 8)
+ * @param apiId The API ID to write.
+ */
+ int WriteRTRFrameNoError(int length, int apiId);
+
+ /**
* Stop a repeating packet with a specific ID. This ID is 10 bits.
*
* @param apiId The API ID to stop repeating
diff --git a/wpilibc/src/main/native/include/frc/Compressor.h b/wpilibc/src/main/native/include/frc/Compressor.h
index a5e512c..d1a4dca 100644
--- a/wpilibc/src/main/native/include/frc/Compressor.h
+++ b/wpilibc/src/main/native/include/frc/Compressor.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -171,6 +171,13 @@
*/
void ClearAllPCMStickyFaults();
+ /**
+ * Gets module number (CAN ID).
+ *
+ * @return Module number
+ */
+ int GetModule() const;
+
void InitSendable(SendableBuilder& builder) override;
protected:
diff --git a/wpilibc/src/main/native/include/frc/Controller.h b/wpilibc/src/main/native/include/frc/Controller.h
index 4124046..c6b25ab 100644
--- a/wpilibc/src/main/native/include/frc/Controller.h
+++ b/wpilibc/src/main/native/include/frc/Controller.h
@@ -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. */
@@ -17,10 +17,12 @@
* Common interface for controllers. Controllers run control loops, the most
* common are PID controllers and their variants, but this includes anything
* that is controlling an actuator in a separate thread.
+ *
+ * @deprecated Only used by the deprecated PIDController
*/
class Controller {
public:
- WPI_DEPRECATED("None of the 2020 FRC controllers use this.")
+ WPI_DEPRECATED("Only used by the deprecated PIDController")
Controller() = default;
virtual ~Controller() = default;
diff --git a/wpilibc/src/main/native/include/frc/DMASample.h b/wpilibc/src/main/native/include/frc/DMASample.h
index 4592930..c286c8d 100644
--- a/wpilibc/src/main/native/include/frc/DMASample.h
+++ b/wpilibc/src/main/native/include/frc/DMASample.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -11,7 +11,7 @@
#include <hal/AnalogInput.h>
#include <hal/DMA.h>
-#include <units/units.h>
+#include <units/time.h>
#include "frc/AnalogInput.h"
#include "frc/Counter.h"
diff --git a/wpilibc/src/main/native/include/frc/DoubleSolenoid.h b/wpilibc/src/main/native/include/frc/DoubleSolenoid.h
index 6722976..302c52c 100644
--- a/wpilibc/src/main/native/include/frc/DoubleSolenoid.h
+++ b/wpilibc/src/main/native/include/frc/DoubleSolenoid.h
@@ -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. */
@@ -69,6 +69,15 @@
virtual Value Get() const;
/**
+ * Toggle the value of the solenoid.
+ *
+ * If the solenoid is set to forward, it'll be set to reverse. If the solenoid
+ * is set to reverse, it'll be set to forward. If the solenoid is set to off,
+ * nothing happens.
+ */
+ void Toggle();
+
+ /**
* Check if the forward solenoid is blacklisted.
*
* If a solenoid is shorted, it is added to the blacklist and disabled until
diff --git a/wpilibc/src/main/native/include/frc/DriverStation.h b/wpilibc/src/main/native/include/frc/DriverStation.h
index 4508701..a6c40d6 100644
--- a/wpilibc/src/main/native/include/frc/DriverStation.h
+++ b/wpilibc/src/main/native/include/frc/DriverStation.h
@@ -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. */
@@ -16,11 +16,9 @@
#include <hal/DriverStationTypes.h>
#include <wpi/Twine.h>
#include <wpi/condition_variable.h>
-#include <wpi/deprecated.h>
#include <wpi/mutex.h>
#include "frc/ErrorBase.h"
-#include "frc/RobotState.h"
namespace frc {
@@ -184,6 +182,17 @@
int GetJoystickAxisType(int stick, int axis) const;
/**
+ * Returns if a joystick is connected to the Driver Station.
+ *
+ * This makes a best effort guess by looking at the reported number of axis,
+ * buttons, and POVs attached.
+ *
+ * @param stick The joystick port number
+ * @return true if a joystick is connected
+ */
+ bool IsJoystickConnected(int stick) const;
+
+ /**
* Check if the DS has enabled the robot.
*
* @return True if the robot is enabled and the DS is connected
@@ -212,6 +221,15 @@
bool IsAutonomous() const;
/**
+ * Check if the DS is commanding autonomous mode and if it has enabled the
+ * robot.
+ *
+ * @return True if the robot is being commanded to be in autonomous mode and
+ * enabled.
+ */
+ bool IsAutonomousEnabled() const;
+
+ /**
* Check if the DS is commanding teleop mode.
*
* @return True if the robot is being commanded to be in teleop mode
@@ -219,6 +237,14 @@
bool IsOperatorControl() const;
/**
+ * Check if the DS is commanding teleop mode and if it has enabled the robot.
+ *
+ * @return True if the robot is being commanded to be in teleop mode and
+ * enabled.
+ */
+ bool IsOperatorControlEnabled() const;
+
+ /**
* Check if the DS is commanding test mode.
*
* @return True if the robot is being commanded to be in test mode
@@ -313,6 +339,9 @@
*
* This is a good way to delay processing until there is new driver station
* data to act on.
+ *
+ * Checks if new control data has arrived since the last waitForData call
+ * on the current thread. If new data has not arrived, returns immediately.
*/
void WaitForData();
@@ -320,6 +349,9 @@
* Wait until a new packet comes from the driver station, or wait for a
* timeout.
*
+ * Checks if new control data has arrived since the last waitForData call
+ * on the current thread. If new data has not arrived, returns immediately.
+ *
* If the timeout is less then or equal to 0, wait indefinitely.
*
* Timeout is in milliseconds
@@ -345,7 +377,7 @@
* Warning: This is not an official time (so it cannot be used to dispute ref
* calls or guarantee that a function will trigger before the match ends).
*
- * The Practice Match function of the DS approximates the behaviour seen on
+ * The Practice Match function of the DS approximates the behavior seen on
* the field.
*
* @return Time remaining in current match period (auto or teleop)
@@ -399,6 +431,23 @@
*/
void WakeupWaitForData();
+ /**
+ * Allows the user to specify whether they want joystick connection warnings
+ * to be printed to the console. This setting is ignored when the FMS is
+ * connected -- warnings will always be on in that scenario.
+ *
+ * @param silence Whether warning messages should be silenced.
+ */
+ void SilenceJoystickConnectionWarning(bool silence);
+
+ /**
+ * Returns whether joystick connection warnings are silenced. This will
+ * always return false when connected to the FMS.
+ *
+ * @return Whether joystick connection warnings are silenced.
+ */
+ bool IsJoystickConnectionWarningSilenced() const;
+
protected:
/**
* Copy data from the DS task for the user.
@@ -446,10 +495,12 @@
std::thread m_dsThread;
std::atomic<bool> m_isRunning{false};
- wpi::mutex m_waitForDataMutex;
+ mutable wpi::mutex m_waitForDataMutex;
wpi::condition_variable m_waitForDataCond;
int m_waitForDataCounter;
+ bool m_silenceJoystickWarning = false;
+
// Robot state status variables
bool m_userInDisabled = false;
bool m_userInAutonomous = false;
diff --git a/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h b/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h
index 92864a8..17b038f 100644
--- a/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h
+++ b/wpilibc/src/main/native/include/frc/DutyCycleEncoder.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -11,7 +11,7 @@
#include <hal/SimDevice.h>
#include <hal/Types.h>
-#include <units/units.h>
+#include <units/angle.h>
#include "frc/AnalogTrigger.h"
#include "frc/Counter.h"
@@ -154,14 +154,28 @@
*/
double GetDistance() const;
+ /**
+ * Get the FPGA index for the DutyCycleEncoder.
+ *
+ * @return the FPGA index
+ */
+ int GetFPGAIndex() const;
+
+ /**
+ * Get the channel of the source.
+ *
+ * @return the source channel
+ */
+ int GetSourceChannel() const;
+
void InitSendable(SendableBuilder& builder) override;
private:
void Init();
std::shared_ptr<DutyCycle> m_dutyCycle;
- AnalogTrigger m_analogTrigger;
- Counter m_counter;
+ std::unique_ptr<AnalogTrigger> m_analogTrigger;
+ std::unique_ptr<Counter> m_counter;
int m_frequencyThreshold = 100;
double m_positionOffset = 0;
double m_distancePerRotation = 1.0;
@@ -169,6 +183,7 @@
hal::SimDevice m_simDevice;
hal::SimDouble m_simPosition;
+ hal::SimDouble m_simDistancePerRotation;
hal::SimBoolean m_simIsConnected;
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/Encoder.h b/wpilibc/src/main/native/include/frc/Encoder.h
index 60552f6..76f9d1c 100644
--- a/wpilibc/src/main/native/include/frc/Encoder.h
+++ b/wpilibc/src/main/native/include/frc/Encoder.h
@@ -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. */
@@ -192,6 +192,9 @@
* the FPGA will report the device stopped. This is expressed
* in seconds.
*/
+ WPI_DEPRECATED(
+ "Use SetMinRate() in favor of this method. This takes unscaled periods "
+ "and SetMinRate() scales using value from SetDistancePerPulse().")
void SetMaxPeriod(double maxPeriod) override;
/**
diff --git a/wpilibc/src/main/native/include/frc/Error.h b/wpilibc/src/main/native/include/frc/Error.h
index 8eafd10..d63fb62 100644
--- a/wpilibc/src/main/native/include/frc/Error.h
+++ b/wpilibc/src/main/native/include/frc/Error.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 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. */
@@ -7,8 +7,6 @@
#pragma once
-#include <stdint.h>
-
#include <string>
#include <wpi/StringRef.h>
@@ -19,8 +17,6 @@
#undef GetMessage
#endif
-#include "frc/Base.h"
-
namespace frc {
class ErrorBase;
diff --git a/wpilibc/src/main/native/include/frc/ErrorBase.h b/wpilibc/src/main/native/include/frc/ErrorBase.h
index e9168aa..0ced9a2 100644
--- a/wpilibc/src/main/native/include/frc/ErrorBase.h
+++ b/wpilibc/src/main/native/include/frc/ErrorBase.h
@@ -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. */
@@ -11,9 +11,7 @@
#include <wpi/StringRef.h>
#include <wpi/Twine.h>
-#include <wpi/mutex.h>
-#include "frc/Base.h"
#include "frc/Error.h"
// Forward declared manually to avoid needing to pull in entire HAL header.
diff --git a/wpilibc/src/main/native/include/frc/Filesystem.h b/wpilibc/src/main/native/include/frc/Filesystem.h
index b7ef3f1..f196f7a 100644
--- a/wpilibc/src/main/native/include/frc/Filesystem.h
+++ b/wpilibc/src/main/native/include/frc/Filesystem.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -34,7 +34,7 @@
* Obtains the deploy directory of the program, which is the remote location
* src/main/deploy is deployed to by default. On the roboRIO, this is
* /home/lvuser/deploy. In simulation, it is where the simulation was launched
- * from, in the subdirectory "deploy" (`pwd`/deploy).
+ * from, in the subdirectory "src/main/deploy" (`pwd`/src/main/deploy).
*
* @param result The result of the operating directory lookup
*/
diff --git a/wpilibc/src/main/native/include/frc/GearTooth.h b/wpilibc/src/main/native/include/frc/GearTooth.h
index 1c3df5b..2d1f792 100644
--- a/wpilibc/src/main/native/include/frc/GearTooth.h
+++ b/wpilibc/src/main/native/include/frc/GearTooth.h
@@ -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. */
@@ -22,6 +22,8 @@
* Implements the gear tooth sensor supplied by FIRST. Currently there is no
* reverse sensing on the gear tooth sensor, but in future versions we might
* implement the necessary timing in the FPGA to sense direction.
+ *
+ * @deprecated No longer used per FMS usage reporting
*/
class GearTooth : public Counter {
public:
diff --git a/wpilibc/src/main/native/include/frc/GenericHID.h b/wpilibc/src/main/native/include/frc/GenericHID.h
index aae10cf..001b984 100644
--- a/wpilibc/src/main/native/include/frc/GenericHID.h
+++ b/wpilibc/src/main/native/include/frc/GenericHID.h
@@ -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. */
@@ -62,6 +62,9 @@
* the state of each button. The appropriate button is returned as a boolean
* value.
*
+ * This method returns true if the button is being held down at the time
+ * that this method is being called.
+ *
* @param button The button number to be read (starting at 1)
* @return The state of the button.
*/
@@ -71,6 +74,10 @@
* Whether the button was pressed since the last check. Button indexes begin
* at 1.
*
+ * This method returns true if the button went from not pressed to held down
+ * since the last time this method was called. This is useful if you only
+ * want to call a function once when you press the button.
+ *
* @param button The button index, beginning at 1.
* @return Whether the button was pressed since the last check.
*/
@@ -80,6 +87,10 @@
* Whether the button was released since the last check. Button indexes begin
* at 1.
*
+ * This method returns true if the button went from held down to not pressed
+ * since the last time this method was called. This is useful if you only
+ * want to call a function once when you release the button.
+ *
* @param button The button index, beginning at 1.
* @return Whether the button was released since the last check.
*/
@@ -126,6 +137,13 @@
int GetButtonCount() const;
/**
+ * Get if the HID is connected.
+ *
+ * @return true if the HID is connected
+ */
+ bool IsConnected() const;
+
+ /**
* Get the type of the HID.
*
* @return the type of the HID.
diff --git a/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h b/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h
index 8c2a564..42b7434 100644
--- a/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h
+++ b/wpilibc/src/main/native/include/frc/InterruptableSensorBase.h
@@ -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. */
@@ -115,9 +115,8 @@
/**
* Return the timestamp for the rising interrupt that occurred most recently.
*
- * This is in the same time domain as GetClock().
- * The rising-edge interrupt should be enabled with
- * {@link #DigitalInput.SetUpSourceEdge}
+ * This is in the same time domain as GetClock(). The rising-edge interrupt
+ * should be enabled with SetUpSourceEdge().
*
* @return Timestamp in seconds since boot.
*/
diff --git a/wpilibc/src/main/native/include/frc/IterativeRobot.h b/wpilibc/src/main/native/include/frc/IterativeRobot.h
index 447c477..24fdba3 100644
--- a/wpilibc/src/main/native/include/frc/IterativeRobot.h
+++ b/wpilibc/src/main/native/include/frc/IterativeRobot.h
@@ -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. */
@@ -21,6 +21,9 @@
*
* Periodic() functions from the base class are called each time a new packet is
* received from the driver station.
+ *
+ * @deprecated Use TimedRobot instead. It's a drop-in replacement that provides
+ * more regular execution periods.
*/
class IterativeRobot : public IterativeRobotBase {
public:
@@ -33,7 +36,7 @@
/**
* Provide an alternate "main loop" via StartCompetition().
*
- * This specific StartCompetition() implements "main loop" behaviour synced
+ * This specific StartCompetition() implements "main loop" behavior synced
* with the DS packets.
*/
void StartCompetition() override;
diff --git a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h
index b78765a..66897aa 100644
--- a/wpilibc/src/main/native/include/frc/IterativeRobotBase.h
+++ b/wpilibc/src/main/native/include/frc/IterativeRobotBase.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -7,7 +7,7 @@
#pragma once
-#include <units/units.h>
+#include <units/time.h>
#include <wpi/deprecated.h>
#include "frc/RobotBase.h"
@@ -62,6 +62,16 @@
virtual void RobotInit();
/**
+ * Robot-wide simulation initialization code should go here.
+ *
+ * Users should override this method for default Robot-wide simulation
+ * related initialization which will be called when the robot is first
+ * started. It will be called exactly one time after RobotInit is called
+ * only when the robot is in simulation.
+ */
+ virtual void SimulationInit();
+
+ /**
* Initialization code for disabled mode should go here.
*
* Users should override this method for initialization code which will be
@@ -103,6 +113,13 @@
virtual void RobotPeriodic();
/**
+ * Periodic simulation code should go here.
+ *
+ * This function is called in a simulated robot after user code executes.
+ */
+ virtual void SimulationPeriodic();
+
+ /**
* Periodic code for disabled mode should go here.
*
* Users should override this method for code which will be called each time a
@@ -138,13 +155,15 @@
*/
virtual void TestPeriodic();
- protected:
/**
* Constructor for IterativeRobotBase.
*
* @param period Period in seconds.
+ *
+ * @deprecated Use IterativeRobotBase(units::second_t period) with unit-safety
+ * instead
*/
- WPI_DEPRECATED("Use ctor with unit-safety instead.")
+ WPI_DEPRECATED("Use constructor with unit-safety instead.")
explicit IterativeRobotBase(double period);
/**
@@ -156,6 +175,7 @@
virtual ~IterativeRobotBase() = default;
+ protected:
IterativeRobotBase(IterativeRobotBase&&) = default;
IterativeRobotBase& operator=(IterativeRobotBase&&) = default;
diff --git a/wpilibc/src/main/native/include/frc/Joystick.h b/wpilibc/src/main/native/include/frc/Joystick.h
index 4ae398c..0975e6d 100644
--- a/wpilibc/src/main/native/include/frc/Joystick.h
+++ b/wpilibc/src/main/native/include/frc/Joystick.h
@@ -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. */
@@ -9,8 +9,6 @@
#include <array>
-#include <wpi/deprecated.h>
-
#include "frc/GenericHID.h"
namespace frc {
diff --git a/wpilibc/src/main/native/include/frc/LinearFilter.h b/wpilibc/src/main/native/include/frc/LinearFilter.h
deleted file mode 100644
index 2b83a32..0000000
--- a/wpilibc/src/main/native/include/frc/LinearFilter.h
+++ /dev/null
@@ -1,194 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2015-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 <cassert>
-#include <cmath>
-#include <initializer_list>
-#include <vector>
-
-#include <hal/FRCUsageReporting.h>
-#include <units/units.h>
-#include <wpi/ArrayRef.h>
-#include <wpi/circular_buffer.h>
-
-namespace frc {
-
-/**
- * This class implements a linear, digital filter. All types of FIR and IIR
- * filters are supported. Static factory methods are provided to create commonly
- * used types of filters.
- *
- * Filters are of the form:<br>
- * y[n] = (b0 * x[n] + b1 * x[n-1] + … + bP * x[n-P]) -
- * (a0 * y[n-1] + a2 * y[n-2] + … + aQ * y[n-Q])
- *
- * Where:<br>
- * y[n] is the output at time "n"<br>
- * x[n] is the input at time "n"<br>
- * y[n-1] is the output from the LAST time step ("n-1")<br>
- * x[n-1] is the input from the LAST time step ("n-1")<br>
- * b0 … bP are the "feedforward" (FIR) gains<br>
- * a0 … aQ are the "feedback" (IIR) gains<br>
- * IMPORTANT! Note the "-" sign in front of the feedback term! This is a common
- * convention in signal processing.
- *
- * What can linear filters do? Basically, they can filter, or diminish, the
- * effects of undesirable input frequencies. High frequencies, or rapid changes,
- * can be indicative of sensor noise or be otherwise undesirable. A "low pass"
- * filter smooths out the signal, reducing the impact of these high frequency
- * components. Likewise, a "high pass" filter gets rid of slow-moving signal
- * components, letting you detect large changes more easily.
- *
- * Example FRC applications of filters:
- * - Getting rid of noise from an analog sensor input (note: the roboRIO's FPGA
- * can do this faster in hardware)
- * - Smoothing out joystick input to prevent the wheels from slipping or the
- * robot from tipping
- * - Smoothing motor commands so that unnecessary strain isn't put on
- * electrical or mechanical components
- * - If you use clever gains, you can make a PID controller out of this class!
- *
- * For more on filters, we highly recommend the following articles:<br>
- * https://en.wikipedia.org/wiki/Linear_filter<br>
- * https://en.wikipedia.org/wiki/Iir_filter<br>
- * https://en.wikipedia.org/wiki/Fir_filter<br>
- *
- * Note 1: Calculate() should be called by the user on a known, regular period.
- * You can use a Notifier for this or do it "inline" with code in a
- * periodic function.
- *
- * Note 2: For ALL filters, gains are necessarily a function of frequency. If
- * you make a filter that works well for you at, say, 100Hz, you will most
- * definitely need to adjust the gains if you then want to run it at 200Hz!
- * Combining this with Note 1 - the impetus is on YOU as a developer to make
- * sure Calculate() gets called at the desired, constant frequency!
- */
-template <class T>
-class LinearFilter {
- public:
- /**
- * Create a linear FIR or IIR filter.
- *
- * @param ffGains The "feed forward" or FIR gains.
- * @param fbGains The "feed back" or IIR gains.
- */
- LinearFilter(wpi::ArrayRef<double> ffGains, wpi::ArrayRef<double> fbGains)
- : m_inputs(ffGains.size()),
- m_outputs(fbGains.size()),
- m_inputGains(ffGains),
- m_outputGains(fbGains) {
- static int instances = 0;
- instances++;
- HAL_Report(HALUsageReporting::kResourceType_LinearFilter, instances);
- }
-
- /**
- * Create a linear FIR or IIR filter.
- *
- * @param ffGains The "feed forward" or FIR gains.
- * @param fbGains The "feed back" or IIR gains.
- */
- LinearFilter(std::initializer_list<double> ffGains,
- std::initializer_list<double> fbGains)
- : LinearFilter(wpi::makeArrayRef(ffGains.begin(), ffGains.end()),
- wpi::makeArrayRef(fbGains.begin(), fbGains.end())) {}
-
- // Static methods to create commonly used filters
- /**
- * Creates a one-pole IIR low-pass filter of the form:<br>
- * y[n] = (1 - gain) * x[n] + gain * y[n-1]<br>
- * where gain = e<sup>-dt / T</sup>, T is the time constant in seconds
- *
- * This filter is stable for time constants greater than zero.
- *
- * @param timeConstant The discrete-time time constant in seconds.
- * @param period The period in seconds between samples taken by the
- * user.
- */
- static LinearFilter<T> SinglePoleIIR(double timeConstant,
- units::second_t period) {
- double gain = std::exp(-period.to<double>() / timeConstant);
- return LinearFilter(1.0 - gain, -gain);
- }
-
- /**
- * Creates a first-order high-pass filter of the form:<br>
- * y[n] = gain * x[n] + (-gain) * x[n-1] + gain * y[n-1]<br>
- * where gain = e<sup>-dt / T</sup>, T is the time constant in seconds
- *
- * This filter is stable for time constants greater than zero.
- *
- * @param timeConstant The discrete-time time constant in seconds.
- * @param period The period in seconds between samples taken by the
- * user.
- */
- static LinearFilter<T> HighPass(double timeConstant, units::second_t period) {
- double gain = std::exp(-period.to<double>() / timeConstant);
- return LinearFilter({gain, -gain}, {-gain});
- }
-
- /**
- * Creates a K-tap FIR moving average filter of the form:<br>
- * y[n] = 1/k * (x[k] + x[k-1] + … + x[0])
- *
- * This filter is always stable.
- *
- * @param taps The number of samples to average over. Higher = smoother but
- * slower
- */
- static LinearFilter<T> MovingAverage(int taps) {
- assert(taps > 0);
-
- std::vector<double> gains(taps, 1.0 / taps);
- return LinearFilter(gains, {});
- }
-
- /**
- * Reset the filter state.
- */
- void Reset() {
- m_inputs.reset();
- m_outputs.reset();
- }
-
- /**
- * Calculates the next value of the filter.
- *
- * @param input Current input value.
- *
- * @return The filtered value at this step
- */
- T Calculate(T input) {
- T retVal = T(0.0);
-
- // Rotate the inputs
- m_inputs.push_front(input);
-
- // Calculate the new value
- for (size_t i = 0; i < m_inputGains.size(); i++) {
- retVal += m_inputs[i] * m_inputGains[i];
- }
- for (size_t i = 0; i < m_outputGains.size(); i++) {
- retVal -= m_outputs[i] * m_outputGains[i];
- }
-
- // Rotate the outputs
- m_outputs.push_front(retVal);
-
- return retVal;
- }
-
- private:
- wpi::circular_buffer<T> m_inputs;
- wpi::circular_buffer<T> m_outputs;
- std::vector<double> m_inputGains;
- std::vector<double> m_outputGains;
-};
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/MedianFilter.h b/wpilibc/src/main/native/include/frc/MedianFilter.h
deleted file mode 100644
index b5d499b..0000000
--- a/wpilibc/src/main/native/include/frc/MedianFilter.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <algorithm>
-#include <vector>
-
-#include <wpi/Algorithm.h>
-#include <wpi/circular_buffer.h>
-
-namespace frc {
-/**
- * A class that implements a moving-window median filter. Useful for reducing
- * measurement noise, especially with processes that generate occasional,
- * extreme outliers (such as values from vision processing, LIDAR, or ultrasonic
- * sensors).
- */
-template <class T>
-class MedianFilter {
- public:
- /**
- * Creates a new MedianFilter.
- *
- * @param size The number of samples in the moving window.
- */
- explicit MedianFilter(size_t size) : m_valueBuffer(size), m_size{size} {}
-
- /**
- * Calculates the moving-window median for the next value of the input stream.
- *
- * @param next The next input value.
- * @return The median of the moving window, updated to include the next value.
- */
- T Calculate(T next) {
- // Insert next value at proper point in sorted array
- wpi::insert_sorted(m_orderedValues, next);
-
- size_t curSize = m_orderedValues.size();
-
- // If buffer is at max size, pop element off of end of circular buffer
- // and remove from ordered list
- if (curSize > m_size) {
- m_orderedValues.erase(std::find(m_orderedValues.begin(),
- m_orderedValues.end(),
- m_valueBuffer.pop_back()));
- curSize = curSize - 1;
- }
-
- // Add next value to circular buffer
- m_valueBuffer.push_front(next);
-
- if (curSize % 2 == 1) {
- // If size is odd, return middle element of sorted list
- return m_orderedValues[curSize / 2];
- } else {
- // If size is even, return average of middle elements
- return (m_orderedValues[curSize / 2 - 1] + m_orderedValues[curSize / 2]) /
- 2.0;
- }
- }
-
- /**
- * Resets the filter, clearing the window of all elements.
- */
- void Reset() {
- m_orderedValues.clear();
- m_valueBuffer.reset();
- }
-
- private:
- wpi::circular_buffer<T> m_valueBuffer;
- std::vector<T> m_orderedValues;
- size_t m_size;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/Notifier.h b/wpilibc/src/main/native/include/frc/Notifier.h
index 24ffba3..c9348a6 100644
--- a/wpilibc/src/main/native/include/frc/Notifier.h
+++ b/wpilibc/src/main/native/include/frc/Notifier.h
@@ -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. */
@@ -12,10 +12,11 @@
#include <atomic>
#include <functional>
#include <thread>
+#include <type_traits>
#include <utility>
#include <hal/Types.h>
-#include <units/units.h>
+#include <units/time.h>
#include <wpi/Twine.h>
#include <wpi/deprecated.h>
#include <wpi/mutex.h>
@@ -34,12 +35,34 @@
*/
explicit Notifier(std::function<void()> handler);
- template <typename Callable, typename Arg, typename... Args>
+ template <
+ typename Callable, typename Arg, typename... Args,
+ typename = std::enable_if_t<std::is_invocable_v<Callable, Arg, Args...>>>
Notifier(Callable&& f, Arg&& arg, Args&&... args)
: Notifier(std::bind(std::forward<Callable>(f), std::forward<Arg>(arg),
std::forward<Args>(args)...)) {}
/**
+ * Create a Notifier for timer event notification.
+ *
+ * This overload makes the underlying thread run with a real-time priority.
+ * This is useful for reducing scheduling jitter on processes which are
+ * sensitive to timing variance, like model-based control.
+ *
+ * @param priority The FIFO real-time scheduler priority ([0..100] where a
+ * lower number represents higher priority).
+ * @param handler The handler is called at the notification time which is set
+ * using StartSingle or StartPeriodic.
+ */
+ explicit Notifier(int priority, std::function<void()> handler);
+
+ template <typename Callable, typename Arg, typename... Args>
+ Notifier(int priority, Callable&& f, Arg&& arg, Args&&... args)
+ : Notifier(priority,
+ std::bind(std::forward<Callable>(f), std::forward<Arg>(arg),
+ std::forward<Args>(args)...)) {}
+
+ /**
* Free the resources for a timer event.
*/
virtual ~Notifier();
@@ -66,6 +89,9 @@
*
* A timer event is queued for a single event after the specified delay.
*
+ * @deprecated Use unit-safe StartSingle(units::second_t delay) method
+ * instead.
+ *
* @param delay Seconds to wait before the handler is called.
*/
WPI_DEPRECATED("Use unit-safe StartSingle method instead.")
@@ -87,6 +113,9 @@
* interrupt occurs, the event will be immediately requeued for the same time
* interval.
*
+ * @deprecated Use unit-safe StartPeriodic(units::second_t period) method
+ * instead
+ *
* @param period Period in seconds to call the handler starting one period
* after the call to this method.
*/
@@ -106,9 +135,9 @@
void StartPeriodic(units::second_t period);
/**
- * Stop timer events from occuring.
+ * Stop timer events from occurring.
*
- * Stop any repeating timer events from occuring. This will also remove any
+ * Stop any repeating timer events from occurring. This will also remove any
* single notification events from the queue.
*
* If a timer-based call to the registered handler is in progress, this
diff --git a/wpilibc/src/main/native/include/frc/PIDBase.h b/wpilibc/src/main/native/include/frc/PIDBase.h
index 513d46b..79d8eba 100644
--- a/wpilibc/src/main/native/include/frc/PIDBase.h
+++ b/wpilibc/src/main/native/include/frc/PIDBase.h
@@ -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. */
@@ -35,6 +35,8 @@
* This feedback controller runs in discrete time, so time deltas are not used
* in the integral and derivative calculations. Therefore, the sample rate
* affects the controller's behavior for a given set of PID constants.
+ *
+ * @deprecated All APIs which use this have been deprecated.
*/
class PIDBase : public PIDInterface,
public PIDOutput,
diff --git a/wpilibc/src/main/native/include/frc/PIDController.h b/wpilibc/src/main/native/include/frc/PIDController.h
index 88b0786..39e4deb 100644
--- a/wpilibc/src/main/native/include/frc/PIDController.h
+++ b/wpilibc/src/main/native/include/frc/PIDController.h
@@ -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. */
@@ -33,6 +33,8 @@
* This feedback controller runs in discrete time, so time deltas are not used
* in the integral and derivative calculations. Therefore, the sample rate
* affects the controller's behavior for a given set of PID constants.
+ *
+ * @deprecated Use frc2::PIDController class instead.
*/
class PIDController : public PIDBase, public Controller {
public:
@@ -46,7 +48,7 @@
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
- * differental terms. The default is 0.05 (50ms).
+ * differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, PIDSource* source,
@@ -62,7 +64,7 @@
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
- * differental terms. The default is 0.05 (50ms).
+ * differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, double f, PIDSource* source,
@@ -78,7 +80,7 @@
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
- * differental terms. The default is 0.05 (50ms).
+ * differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, PIDSource& source,
@@ -94,7 +96,7 @@
* @param output The PIDOutput object that is set to the output value
* @param period the loop time for doing calculations in seconds. This
* particularly affects calculations of the integral and
- * differental terms. The default is 0.05 (50ms).
+ * differential terms. The default is 0.05 (50ms).
*/
WPI_DEPRECATED("Use frc2::PIDController class instead.")
PIDController(double p, double i, double d, double f, PIDSource& source,
diff --git a/wpilibc/src/main/native/include/frc/PIDInterface.h b/wpilibc/src/main/native/include/frc/PIDInterface.h
index 8162aa5..8d847a6 100644
--- a/wpilibc/src/main/native/include/frc/PIDInterface.h
+++ b/wpilibc/src/main/native/include/frc/PIDInterface.h
@@ -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. */
@@ -11,6 +11,11 @@
namespace frc {
+/**
+ * Interface for PID Control Loop.
+ *
+ * @deprecated All APIs which use this have been deprecated.
+ */
class PIDInterface {
public:
WPI_DEPRECATED("All APIs which use this have been deprecated.")
diff --git a/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h b/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h
index 433874b..9ec00a3 100644
--- a/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h
+++ b/wpilibc/src/main/native/include/frc/PowerDistributionPanel.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -85,10 +85,16 @@
*/
void ClearStickyFaults();
+ /**
+ * Gets module number (CAN ID).
+ */
+ int GetModule() const;
+
void InitSendable(SendableBuilder& builder) override;
private:
hal::Handle<HAL_PDPHandle> m_handle;
+ int m_module;
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/Preferences.h b/wpilibc/src/main/native/include/frc/Preferences.h
index 57678a8..f04b012 100644
--- a/wpilibc/src/main/native/include/frc/Preferences.h
+++ b/wpilibc/src/main/native/include/frc/Preferences.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2011-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. */
@@ -122,6 +122,12 @@
void PutString(wpi::StringRef key, wpi::StringRef value);
/**
+ * Puts the given string into the preferences table if it doesn't
+ * already exist.
+ */
+ void InitString(wpi::StringRef key, wpi::StringRef value);
+
+ /**
* Puts the given int into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
@@ -132,6 +138,12 @@
void PutInt(wpi::StringRef key, int value);
/**
+ * Puts the given int into the preferences table if it doesn't
+ * already exist.
+ */
+ void InitInt(wpi::StringRef key, int value);
+
+ /**
* Puts the given double into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
@@ -142,6 +154,12 @@
void PutDouble(wpi::StringRef key, double value);
/**
+ * Puts the given double into the preferences table if it doesn't
+ * already exist.
+ */
+ void InitDouble(wpi::StringRef key, double value);
+
+ /**
* Puts the given float into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
@@ -152,6 +170,12 @@
void PutFloat(wpi::StringRef key, float value);
/**
+ * Puts the given float into the preferences table if it doesn't
+ * already exist.
+ */
+ void InitFloat(wpi::StringRef key, float value);
+
+ /**
* Puts the given boolean into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
@@ -162,6 +186,12 @@
void PutBoolean(wpi::StringRef key, bool value);
/**
+ * Puts the given boolean into the preferences table if it doesn't
+ * already exist.
+ */
+ void InitBoolean(wpi::StringRef key, bool value);
+
+ /**
* Puts the given long (int64_t) into the preferences table.
*
* The key may not have any whitespace nor an equals sign.
@@ -172,6 +202,12 @@
void PutLong(wpi::StringRef key, int64_t value);
/**
+ * Puts the given long into the preferences table if it doesn't
+ * already exist.
+ */
+ void InitLong(wpi::StringRef key, int64_t value);
+
+ /**
* Returns whether or not there is a key with the given name.
*
* @param key the key
diff --git a/wpilibc/src/main/native/include/frc/RobotBase.h b/wpilibc/src/main/native/include/frc/RobotBase.h
index 725aa97..66d5637 100644
--- a/wpilibc/src/main/native/include/frc/RobotBase.h
+++ b/wpilibc/src/main/native/include/frc/RobotBase.h
@@ -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. */
@@ -10,6 +10,7 @@
#include <chrono>
#include <thread>
+#include <hal/HALBase.h>
#include <hal/Main.h>
#include <wpi/condition_variable.h>
#include <wpi/mutex.h>
@@ -89,6 +90,8 @@
impl::RunRobot<Robot>(m, &robot);
}
+ HAL_Shutdown();
+
return 0;
}
@@ -134,6 +137,14 @@
bool IsAutonomous() const;
/**
+ * Determine if the robot is currently in Autonomous mode and enabled.
+ *
+ * @return True if the robot us currently operating Autonomously while enabled
+ * as determined by the field controls.
+ */
+ bool IsAutonomousEnabled() const;
+
+ /**
* Determine if the robot is currently in Operator Control mode.
*
* @return True if the robot is currently operating in Tele-Op mode as
@@ -142,6 +153,14 @@
bool IsOperatorControl() const;
/**
+ * Determine if the robot is current in Operator Control mode and enabled.
+ *
+ * @return True if the robot is currently operating in Tele-Op mode while
+ * wnabled as determined by the field-controls.
+ */
+ bool IsOperatorControlEnabled() const;
+
+ /**
* Determine if the robot is currently in Test mode.
*
* @return True if the robot is currently running tests as determined by the
@@ -166,6 +185,11 @@
virtual void EndCompetition() = 0;
+ /**
+ * Get if the robot is real.
+ *
+ * @return If the robot is running in the real world.
+ */
static constexpr bool IsReal() {
#ifdef __FRC_ROBORIO__
return true;
@@ -174,9 +198,13 @@
#endif
}
+ /**
+ * Get if the robot is a simulation.
+ *
+ * @return If the robot is running in simulation.
+ */
static constexpr bool IsSimulation() { return !IsReal(); }
- protected:
/**
* Constructor for a generic robot program.
*
@@ -192,6 +220,7 @@
virtual ~RobotBase();
+ protected:
// m_ds isn't moved in these because DriverStation is a singleton; every
// instance of RobotBase has a reference to the same object.
RobotBase(RobotBase&&) noexcept;
diff --git a/wpilibc/src/main/native/include/frc/RobotDrive.h b/wpilibc/src/main/native/include/frc/RobotDrive.h
index 3580003..a8b63e6 100644
--- a/wpilibc/src/main/native/include/frc/RobotDrive.h
+++ b/wpilibc/src/main/native/include/frc/RobotDrive.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 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. */
@@ -30,6 +30,9 @@
* supplied on creation of the class. Those are used for either the Drive
* function (intended for hand created drive code, such as autonomous) or with
* the Tank/Arcade functions intended to be used for Operator Control driving.
+ *
+ * @deprecated Use DifferentialDrive or MecanumDrive classes instead.
+ *
*/
class RobotDrive : public MotorSafety {
public:
@@ -346,7 +349,7 @@
/**
* Holonomic Drive method for Mecanum wheeled robots.
*
- * This is an alias to MecanumDrive_Polar() for backward compatability
+ * This is an alias to MecanumDrive_Polar() for backward compatibility
*
* @param magnitude The speed that the robot should drive in a given
* direction. [-1.0..1.0]
diff --git a/wpilibc/src/main/native/include/frc/RobotState.h b/wpilibc/src/main/native/include/frc/RobotState.h
index 60e608a..5f1c136 100644
--- a/wpilibc/src/main/native/include/frc/RobotState.h
+++ b/wpilibc/src/main/native/include/frc/RobotState.h
@@ -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. */
@@ -7,8 +7,6 @@
#pragma once
-#include <memory>
-
namespace frc {
class RobotState {
diff --git a/wpilibc/src/main/native/include/frc/SPI.h b/wpilibc/src/main/native/include/frc/SPI.h
index 9bc9564..3592775 100644
--- a/wpilibc/src/main/native/include/frc/SPI.h
+++ b/wpilibc/src/main/native/include/frc/SPI.h
@@ -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. */
@@ -12,7 +12,7 @@
#include <memory>
#include <hal/SPITypes.h>
-#include <units/units.h>
+#include <units/time.h>
#include <wpi/ArrayRef.h>
#include <wpi/deprecated.h>
@@ -82,15 +82,21 @@
/**
* Configure that the data is stable on the falling edge and the data
* changes on the rising edge.
+ *
+ * @deprecated Use SetSampleDataOnTrailingEdge() instead.
+ *
*/
- WPI_DEPRECATED("Use SetSampleDataOnTrailingEdge in most cases.")
+ WPI_DEPRECATED("Use SetSampleDataOnTrailingEdge instead.")
void SetSampleDataOnFalling();
/**
* Configure that the data is stable on the rising edge and the data
* changes on the falling edge.
+ *
+ * @deprecated Use SetSampleDataOnLeadingEdge() instead.
+ *
*/
- WPI_DEPRECATED("Use SetSampleDataOnLeadingEdge in most cases")
+ WPI_DEPRECATED("Use SetSampleDataOnLeadingEdge instead")
void SetSampleDataOnRising();
/**
@@ -116,11 +122,11 @@
void SetChipSelectActiveLow();
/**
- * Write data to the slave device. Blocks until there is space in the
+ * Write data to the peripheral device. Blocks until there is space in the
* output FIFO.
*
* If not running in output only mode, also saves the data received
- * on the MISO input during the transfer into the receive FIFO.
+ * on the CIPO input during the transfer into the receive FIFO.
*/
virtual int Write(uint8_t* data, int size);
@@ -166,10 +172,10 @@
/**
* Set the data to be transmitted by the engine.
*
- * Up to 23 bytes are configurable, and may be followed by up to 127 zero
+ * Up to 16 bytes are configurable, and may be followed by up to 127 zero
* bytes.
*
- * @param dataToSend data to send (maximum 23 bytes)
+ * @param dataToSend data to send (maximum 16 bytes)
* @param zeroSize number of zeros to send after the data
*/
void SetAutoTransmitData(wpi::ArrayRef<uint8_t> dataToSend, int zeroSize);
@@ -190,6 +196,8 @@
* InitAuto() and SetAutoTransmitData() must be called before calling this
* function.
*
+ * @deprecated use unit-safe StartAutoRate(units::second_t period) instead.
+ *
* @param period period between transfers, in seconds (us resolution)
*/
WPI_DEPRECATED("Use StartAutoRate with unit-safety instead")
@@ -253,6 +261,10 @@
* Blocks until numToRead words have been read or timeout expires.
* May be called with numToRead=0 to retrieve how many words are available.
*
+ * @deprecated Use unit safe version instead.
+ * ReadAutoReceivedData(uint32_t* buffer, int numToRead, <!--
+ * --> units::second_t timeout)
+ *
* @param buffer buffer where read words are stored
* @param numToRead number of words to read
* @param timeout timeout in seconds (ms resolution)
@@ -304,6 +316,11 @@
/**
* Initialize the accumulator.
*
+ * @deprecated Use unit-safe version instead.
+ * InitAccumulator(units::second_t period, int cmd, int <!--
+ * --> xferSize, int validMask, int validValue, int dataShift, <!--
+ * --> int dataSize, bool isSigned, bool bigEndian)
+ *
* @param period Time between reads
* @param cmd SPI command to send to request data
* @param xferSize SPI transfer size, in bytes
diff --git a/wpilibc/src/main/native/include/frc/ScopedTracer.h b/wpilibc/src/main/native/include/frc/ScopedTracer.h
new file mode 100644
index 0000000..8634c1e
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/ScopedTracer.h
@@ -0,0 +1,48 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <string>
+
+#include <wpi/StringRef.h>
+#include <wpi/Twine.h>
+
+#include "frc/Tracer.h"
+
+namespace wpi {
+class raw_ostream;
+} // namespace wpi
+
+namespace frc {
+/**
+ * A class for keeping track of how much time it takes for different
+ * parts of code to execute. This class uses RAII, meaning you simply
+ * need to create an instance at the top of the block you are timing. After the
+ * block finishes execution (i.e. when the ScopedTracer instance gets
+ * destroyed), the epoch is printed to the provided raw_ostream.
+ */
+class ScopedTracer {
+ public:
+ /**
+ * Constructs a ScopedTracer instance.
+ *
+ * @param name The name of the epoch.
+ * @param os A reference to the raw_ostream to print data to.
+ */
+ ScopedTracer(wpi::Twine name, wpi::raw_ostream& os);
+ ~ScopedTracer();
+
+ ScopedTracer(const ScopedTracer&) = delete;
+ ScopedTracer& operator=(const ScopedTracer&) = delete;
+
+ private:
+ Tracer m_tracer;
+ std::string m_name;
+ wpi::raw_ostream& m_os;
+};
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/SerialPort.h b/wpilibc/src/main/native/include/frc/SerialPort.h
index f9edb84..7c44c75 100644
--- a/wpilibc/src/main/native/include/frc/SerialPort.h
+++ b/wpilibc/src/main/native/include/frc/SerialPort.h
@@ -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. */
@@ -106,7 +106,7 @@
* Enable termination and specify the termination character.
*
* Termination is currently only implemented for receive.
- * When the the terminator is recieved, the Read() or Scanf() will return
+ * When the the terminator is received, the Read() or Scanf() will return
* fewer bytes than requested, stopping after the terminator.
*
* @param terminator The character to use for termination.
@@ -169,7 +169,7 @@
*
* Specify the amount of data that can be stored before data
* from the device is returned to Read or Scanf. If you want
- * data that is recieved to be returned immediately, set this to 1.
+ * data that is received to be returned immediately, set this to 1.
*
* It the buffer is not filled before the read timeout expires, all
* data that has been received so far will be returned.
diff --git a/wpilibc/src/main/native/include/frc/SlewRateLimiter.h b/wpilibc/src/main/native/include/frc/SlewRateLimiter.h
index 7236a30..d18fb09 100644
--- a/wpilibc/src/main/native/include/frc/SlewRateLimiter.h
+++ b/wpilibc/src/main/native/include/frc/SlewRateLimiter.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -11,7 +11,7 @@
#include <algorithm>
-#include <units/units.h>
+#include <units/time.h>
namespace frc {
/**
@@ -25,11 +25,11 @@
*/
template <class Unit>
class SlewRateLimiter {
+ public:
using Unit_t = units::unit_t<Unit>;
using Rate = units::compound_unit<Unit, units::inverse<units::seconds>>;
using Rate_t = units::unit_t<Rate>;
- public:
/**
* Creates a new SlewRateLimiter with the given rate limit and initial value.
*
@@ -37,9 +37,9 @@
* @param initialValue The initial value of the input.
*/
explicit SlewRateLimiter(Rate_t rateLimit, Unit_t initialValue = Unit_t{0})
- : m_rateLimit{rateLimit}, m_prevVal{initialValue} {
- m_timer.Start();
- }
+ : m_rateLimit{rateLimit},
+ m_prevVal{initialValue},
+ m_prevTime{frc2::Timer::GetFPGATimestamp()} {}
/**
* Filters the input to limit its slew rate.
@@ -49,9 +49,11 @@
* rate.
*/
Unit_t Calculate(Unit_t input) {
- m_prevVal += std::clamp(input - m_prevVal, -m_rateLimit * m_timer.Get(),
- m_rateLimit * m_timer.Get());
- m_timer.Reset();
+ units::second_t currentTime = frc2::Timer::GetFPGATimestamp();
+ units::second_t elapsedTime = currentTime - m_prevTime;
+ m_prevVal += std::clamp(input - m_prevVal, -m_rateLimit * elapsedTime,
+ m_rateLimit * elapsedTime);
+ m_prevTime = currentTime;
return m_prevVal;
}
@@ -62,13 +64,13 @@
* @param value The value to reset to.
*/
void Reset(Unit_t value) {
- m_timer.Reset();
m_prevVal = value;
+ m_prevTime = frc2::Timer::GetFPGATimestamp();
}
private:
- frc2::Timer m_timer;
Rate_t m_rateLimit;
Unit_t m_prevVal;
+ units::second_t m_prevTime;
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/Solenoid.h b/wpilibc/src/main/native/include/frc/Solenoid.h
index 86a2839..9939b41 100644
--- a/wpilibc/src/main/native/include/frc/Solenoid.h
+++ b/wpilibc/src/main/native/include/frc/Solenoid.h
@@ -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. */
@@ -62,6 +62,14 @@
virtual bool Get() const;
/**
+ * Toggle the value of the solenoid.
+ *
+ * If the solenoid is set to on, it'll be turned off. If the solenoid is set
+ * to off, it'll be turned on.
+ */
+ void Toggle();
+
+ /**
* Check if solenoid is blacklisted.
*
* If a solenoid is shorted, it is added to the blacklist and
diff --git a/wpilibc/src/main/native/include/frc/SpeedController.h b/wpilibc/src/main/native/include/frc/SpeedController.h
index 2b11aee..3053c3b 100644
--- a/wpilibc/src/main/native/include/frc/SpeedController.h
+++ b/wpilibc/src/main/native/include/frc/SpeedController.h
@@ -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. */
@@ -7,7 +7,7 @@
#pragma once
-#include <units/units.h>
+#include <units/voltage.h>
#include "frc/PIDOutput.h"
diff --git a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h
index 80adf1c..e62563c 100644
--- a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h
+++ b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.h
@@ -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. */
@@ -23,7 +23,8 @@
template <class... SpeedControllers>
explicit SpeedControllerGroup(SpeedController& speedController,
SpeedControllers&... speedControllers);
- ~SpeedControllerGroup() override = default;
+ explicit SpeedControllerGroup(
+ std::vector<std::reference_wrapper<SpeedController>>&& speedControllers);
SpeedControllerGroup(SpeedControllerGroup&&) = default;
SpeedControllerGroup& operator=(SpeedControllerGroup&&) = default;
@@ -41,6 +42,8 @@
private:
bool m_isInverted = false;
std::vector<std::reference_wrapper<SpeedController>> m_speedControllers;
+
+ void Initialize();
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.inc b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.inc
index 5848746..d9e773d 100644
--- a/wpilibc/src/main/native/include/frc/SpeedControllerGroup.inc
+++ b/wpilibc/src/main/native/include/frc/SpeedControllerGroup.inc
@@ -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. */
@@ -7,19 +7,17 @@
#pragma once
-#include "frc/smartdashboard/SendableRegistry.h"
+#include <functional>
+#include <vector>
namespace frc {
template <class... SpeedControllers>
SpeedControllerGroup::SpeedControllerGroup(
SpeedController& speedController, SpeedControllers&... speedControllers)
- : m_speedControllers{speedController, speedControllers...} {
- for (auto& speedController : m_speedControllers)
- SendableRegistry::GetInstance().AddChild(this, &speedController.get());
- static int instances = 0;
- ++instances;
- SendableRegistry::GetInstance().Add(this, "SpeedControllerGroup", instances);
+ : m_speedControllers(std::vector<std::reference_wrapper<SpeedController>>{
+ speedController, speedControllers...}) {
+ Initialize();
}
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/TimedRobot.h b/wpilibc/src/main/native/include/frc/TimedRobot.h
index 112e2c9..9dbc3f2 100644
--- a/wpilibc/src/main/native/include/frc/TimedRobot.h
+++ b/wpilibc/src/main/native/include/frc/TimedRobot.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -7,12 +7,18 @@
#pragma once
+#include <functional>
+#include <vector>
+
#include <hal/Types.h>
-#include <units/units.h>
+#include <units/math.h>
+#include <units/time.h>
#include <wpi/deprecated.h>
+#include <wpi/priority_queue.h>
#include "frc/ErrorBase.h"
#include "frc/IterativeRobotBase.h"
+#include "frc2/Timer.h"
namespace frc {
@@ -47,6 +53,9 @@
/**
* Constructor for TimedRobot.
*
+ * @deprecated use unit safe constructor instead.
+ * TimedRobot(units::second_t period = kDefaultPeriod)
+ *
* @param period Period in seconds.
*/
WPI_DEPRECATED("Use constructor with unit-safety instead.")
@@ -64,16 +73,57 @@
TimedRobot(TimedRobot&&) = default;
TimedRobot& operator=(TimedRobot&&) = default;
- private:
- hal::Handle<HAL_NotifierHandle> m_notifier;
-
- // The absolute expiration time
- units::second_t m_expirationTime{0};
-
/**
- * Update the HAL alarm time.
+ * Add a callback to run at a specific period with a starting time offset.
+ *
+ * This is scheduled on TimedRobot's Notifier, so TimedRobot and the callback
+ * run synchronously. Interactions between them are thread-safe.
+ *
+ * @param callback The callback to run.
+ * @param period The period at which to run the callback.
+ * @param offset The offset from the common starting time. This is useful
+ * for scheduling a callback in a different timeslot relative
+ * to TimedRobot.
*/
- void UpdateAlarm();
+ void AddPeriodic(std::function<void()> callback, units::second_t period,
+ units::second_t offset = 0_s);
+
+ private:
+ class Callback {
+ public:
+ std::function<void()> func;
+ units::second_t period;
+ units::second_t expirationTime;
+
+ /**
+ * Construct a callback container.
+ *
+ * @param func The callback to run.
+ * @param startTime The common starting point for all callback scheduling.
+ * @param period The period at which to run the callback.
+ * @param offset The offset from the common starting time.
+ */
+ Callback(std::function<void()> func, units::second_t startTime,
+ units::second_t period, units::second_t offset)
+ : func{func},
+ period{period},
+ expirationTime{
+ startTime + offset +
+ units::math::floor((frc2::Timer::GetFPGATimestamp() - startTime) /
+ period) *
+ period +
+ period} {}
+
+ bool operator>(const Callback& rhs) const {
+ return expirationTime > rhs.expirationTime;
+ }
+ };
+
+ hal::Handle<HAL_NotifierHandle> m_notifier;
+ units::second_t m_startTime;
+
+ wpi::priority_queue<Callback, std::vector<Callback>, std::greater<Callback>>
+ m_callbacks;
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/Timer.h b/wpilibc/src/main/native/include/frc/Timer.h
index 99caa47..ac166c5 100644
--- a/wpilibc/src/main/native/include/frc/Timer.h
+++ b/wpilibc/src/main/native/include/frc/Timer.h
@@ -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. */
@@ -7,11 +7,6 @@
#pragma once
-#include <units/units.h>
-#include <wpi/deprecated.h>
-#include <wpi/mutex.h>
-
-#include "frc/Base.h"
#include "frc2/Timer.h"
namespace frc {
@@ -132,9 +127,6 @@
*/
static double GetMatchTime();
- // The time, in seconds, at which the 32-bit FPGA timestamp rolls over to 0
- static const double kRolloverTime;
-
private:
frc2::Timer m_timer;
};
diff --git a/wpilibc/src/main/native/include/frc/Tracer.h b/wpilibc/src/main/native/include/frc/Tracer.h
new file mode 100644
index 0000000..627b07b
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/Tracer.h
@@ -0,0 +1,76 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <chrono>
+
+#include <hal/cpp/fpga_clock.h>
+#include <wpi/StringMap.h>
+#include <wpi/StringRef.h>
+
+namespace wpi {
+class raw_ostream;
+} // namespace wpi
+
+namespace frc {
+/**
+ * A class for keeping track of how much time it takes for different parts of
+ * code to execute. This is done with epochs, that are added to calls to
+ * AddEpoch() and can be printed with a call to PrintEpochs().
+ *
+ * Epochs are a way to partition the time elapsed so that when overruns occur,
+ * one can determine which parts of an operation consumed the most time.
+ */
+class Tracer {
+ public:
+ /**
+ * Constructs a Tracer instance.
+ */
+ Tracer();
+
+ /**
+ * Restarts the epoch timer.
+ */
+ void ResetTimer();
+
+ /**
+ * Clears all epochs.
+ */
+ void ClearEpochs();
+
+ /**
+ * Adds time since last epoch to the list printed by PrintEpochs().
+ *
+ * Epochs are a way to partition the time elapsed so that when overruns occur,
+ * one can determine which parts of an operation consumed the most time.
+ *
+ * @param epochName The name to associate with the epoch.
+ */
+ void AddEpoch(wpi::StringRef epochName);
+
+ /**
+ * Prints list of epochs added so far and their times to the DriverStation.
+ */
+ void PrintEpochs();
+
+ /**
+ * Prints list of epochs added so far and their times to a stream.
+ *
+ * @param os output stream
+ */
+ void PrintEpochs(wpi::raw_ostream& os);
+
+ private:
+ static constexpr std::chrono::milliseconds kMinPrintPeriod{1000};
+
+ hal::fpga_clock::time_point m_startTime;
+ hal::fpga_clock::time_point m_lastEpochsPrintTime = hal::fpga_clock::epoch();
+
+ wpi::StringMap<std::chrono::nanoseconds> m_epochs;
+};
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/Ultrasonic.h b/wpilibc/src/main/native/include/frc/Ultrasonic.h
index 637c6fc..f6d301b 100644
--- a/wpilibc/src/main/native/include/frc/Ultrasonic.h
+++ b/wpilibc/src/main/native/include/frc/Ultrasonic.h
@@ -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. */
@@ -132,7 +132,7 @@
* the ultrasonic sensors. This scheduling method assures that
* the sensors are non-interfering because no two sensors fire
* at the same time. If another scheduling algorithm is
- * prefered, it can be implemented by pinging the sensors
+ * preferred, it can be implemented by pinging the sensors
* manually and waiting for the results to come back.
*/
static void SetAutomaticMode(bool enabling);
diff --git a/wpilibc/src/main/native/include/frc/Utility.h b/wpilibc/src/main/native/include/frc/Utility.h
index 3caaf84..a02e583 100644
--- a/wpilibc/src/main/native/include/frc/Utility.h
+++ b/wpilibc/src/main/native/include/frc/Utility.h
@@ -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. */
@@ -11,13 +11,8 @@
* @file Contains global utility functions
*/
-#include <stdint.h>
-
-#include <string>
-
#include <wpi/StringRef.h>
#include <wpi/Twine.h>
-#include <wpi/deprecated.h>
#define wpi_assert(condition) \
wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
diff --git a/wpilibc/src/main/native/include/frc/WPILib.h b/wpilibc/src/main/native/include/frc/WPILib.h
index 9d62514..634d0f5 100644
--- a/wpilibc/src/main/native/include/frc/WPILib.h
+++ b/wpilibc/src/main/native/include/frc/WPILib.h
@@ -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. */
@@ -9,7 +9,7 @@
// clang-format off
#ifdef _MSC_VER
-#pragma message "warning: Including this header drastically increases compilation times and is bad style. Include only what you use instead."
+#pragma message("warning: Including this header drastically increases compilation times and is bad style. Include only what you use instead.")
#else
#warning "Including this header drastically increases compilation times and is bad style. Include only what you use instead."
#endif
diff --git a/wpilibc/src/main/native/include/frc/Watchdog.h b/wpilibc/src/main/native/include/frc/Watchdog.h
index b36cf23..6fc3793 100644
--- a/wpilibc/src/main/native/include/frc/Watchdog.h
+++ b/wpilibc/src/main/native/include/frc/Watchdog.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -7,17 +7,15 @@
#pragma once
-#include <chrono>
#include <functional>
#include <utility>
-#include <hal/cpp/fpga_clock.h>
-#include <units/units.h>
-#include <wpi/SafeThread.h>
-#include <wpi/StringMap.h>
+#include <units/time.h>
#include <wpi/StringRef.h>
#include <wpi/deprecated.h>
+#include "frc/Tracer.h"
+
namespace frc {
/**
@@ -34,6 +32,9 @@
/**
* Watchdog constructor.
*
+ * @deprecated use unit-safe version instead.
+ * Watchdog(units::second_t timeout, std::function<void()> callback)
+ *
* @param timeout The watchdog's timeout in seconds with microsecond
* resolution.
* @param callback This function is called when the timeout expires.
@@ -63,8 +64,8 @@
~Watchdog();
- Watchdog(Watchdog&&) = default;
- Watchdog& operator=(Watchdog&&) = default;
+ Watchdog(Watchdog&& rhs);
+ Watchdog& operator=(Watchdog&& rhs);
/**
* Returns the time in seconds since the watchdog was last fed.
@@ -74,6 +75,9 @@
/**
* Sets the watchdog's timeout.
*
+ * @deprecated use the unit safe version instead.
+ * SetTimeout(units::second_t timeout)
+ *
* @param timeout The watchdog's timeout in seconds with microsecond
* resolution.
*/
@@ -142,26 +146,25 @@
private:
// Used for timeout print rate-limiting
- static constexpr std::chrono::milliseconds kMinPrintPeriod{1000};
+ static constexpr units::second_t kMinPrintPeriod = 1_s;
- hal::fpga_clock::time_point m_startTime;
- std::chrono::nanoseconds m_timeout;
- hal::fpga_clock::time_point m_expirationTime;
+ units::second_t m_startTime = 0_s;
+ units::second_t m_timeout;
+ units::second_t m_expirationTime = 0_s;
std::function<void()> m_callback;
- hal::fpga_clock::time_point m_lastTimeoutPrintTime = hal::fpga_clock::epoch();
- hal::fpga_clock::time_point m_lastEpochsPrintTime = hal::fpga_clock::epoch();
+ units::second_t m_lastTimeoutPrintTime = 0_s;
- wpi::StringMap<std::chrono::nanoseconds> m_epochs;
+ Tracer m_tracer;
bool m_isExpired = false;
bool m_suppressTimeoutMessage = false;
- class Thread;
- wpi::SafeThreadOwner<Thread>* m_owner;
+ class Impl;
+ Impl* m_impl;
- bool operator>(const Watchdog& rhs);
+ bool operator>(const Watchdog& rhs) const;
- static wpi::SafeThreadOwner<Thread>& GetThreadOwner();
+ static Impl* GetImpl();
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/XboxController.h b/wpilibc/src/main/native/include/frc/XboxController.h
index 3ca2f4b..ddf4dc2 100644
--- a/wpilibc/src/main/native/include/frc/XboxController.h
+++ b/wpilibc/src/main/native/include/frc/XboxController.h
@@ -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. */
@@ -244,6 +244,15 @@
kBack = 7,
kStart = 8
};
+
+ enum class Axis {
+ kLeftX = 0,
+ kRightX = 4,
+ kLeftY = 1,
+ kRightY = 5,
+ kLeftTrigger = 2,
+ kRightTrigger = 3
+ };
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/controller/ArmFeedforward.h b/wpilibc/src/main/native/include/frc/controller/ArmFeedforward.h
deleted file mode 100644
index 6f6e086..0000000
--- a/wpilibc/src/main/native/include/frc/controller/ArmFeedforward.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-#include <wpi/MathExtras.h>
-
-namespace frc {
-/**
- * A helper class that computes feedforward outputs for a simple arm (modeled as
- * a motor acting against the force of gravity on a beam suspended at an angle).
- */
-class ArmFeedforward {
- using Angle = units::radians;
- using Velocity = units::radians_per_second;
- using Acceleration = units::compound_unit<units::radians_per_second,
- units::inverse<units::second>>;
- using kv_unit =
- units::compound_unit<units::volts,
- units::inverse<units::radians_per_second>>;
- using ka_unit =
- units::compound_unit<units::volts, units::inverse<Acceleration>>;
-
- public:
- constexpr ArmFeedforward() = default;
-
- /**
- * Creates a new ArmFeedforward with the specified gains.
- *
- * @param kS The static gain, in volts.
- * @param kCos The gravity gain, in volts.
- * @param kV The velocity gain, in volt seconds per radian.
- * @param kA The acceleration gain, in volt seconds^2 per radian.
- */
- constexpr ArmFeedforward(
- units::volt_t kS, units::volt_t kCos, units::unit_t<kv_unit> kV,
- units::unit_t<ka_unit> kA = units::unit_t<ka_unit>(0))
- : kS(kS), kCos(kCos), kV(kV), kA(kA) {}
-
- /**
- * Calculates the feedforward from the gains and setpoints.
- *
- * @param angle The angle setpoint, in radians.
- * @param velocity The velocity setpoint, in radians per second.
- * @param acceleration The acceleration setpoint, in radians per second^2.
- * @return The computed feedforward, in volts.
- */
- units::volt_t Calculate(units::unit_t<Angle> angle,
- units::unit_t<Velocity> velocity,
- units::unit_t<Acceleration> acceleration =
- units::unit_t<Acceleration>(0)) const {
- return kS * wpi::sgn(velocity) + kCos * units::math::cos(angle) +
- kV * velocity + kA * acceleration;
- }
-
- // Rearranging the main equation from the calculate() method yields the
- // formulas for the methods below:
-
- /**
- * Calculates the maximum achievable velocity given a maximum voltage supply,
- * a position, and an acceleration. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the acceleration constraint, and this will give you
- * a simultaneously-achievable velocity constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the arm.
- * @param angle The angle of the arm
- * @param acceleration The acceleration of the arm.
- * @return The maximum possible velocity at the given acceleration and angle.
- */
- units::unit_t<Velocity> MaxAchievableVelocity(
- units::volt_t maxVoltage, units::unit_t<Angle> angle,
- units::unit_t<Acceleration> acceleration) {
- // Assume max velocity is positive
- return (maxVoltage - kS - kCos * units::math::cos(angle) -
- kA * acceleration) /
- kV;
- }
-
- /**
- * Calculates the minimum achievable velocity given a maximum voltage supply,
- * a position, and an acceleration. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the acceleration constraint, and this will give you
- * a simultaneously-achievable velocity constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the arm.
- * @param angle The angle of the arm
- * @param acceleration The acceleration of the arm.
- * @return The minimum possible velocity at the given acceleration and angle.
- */
- units::unit_t<Velocity> MinAchievableVelocity(
- units::volt_t maxVoltage, units::unit_t<Angle> angle,
- units::unit_t<Acceleration> acceleration) {
- // Assume min velocity is negative, ks flips sign
- return (-maxVoltage + kS - kCos * units::math::cos(angle) -
- kA * acceleration) /
- kV;
- }
-
- /**
- * Calculates the maximum achievable acceleration given a maximum voltage
- * supply, a position, and a velocity. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the velocity constraint, and this will give you
- * a simultaneously-achievable acceleration constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the arm.
- * @param angle The angle of the arm
- * @param velocity The velocity of the arm.
- * @return The maximum possible acceleration at the given velocity and angle.
- */
- units::unit_t<Acceleration> MaxAchievableAcceleration(
- units::volt_t maxVoltage, units::unit_t<Angle> angle,
- units::unit_t<Velocity> velocity) {
- return (maxVoltage - kS * wpi::sgn(velocity) -
- kCos * units::math::cos(angle) - kV * velocity) /
- kA;
- }
-
- /**
- * Calculates the minimum achievable acceleration given a maximum voltage
- * supply, a position, and a velocity. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the velocity constraint, and this will give you
- * a simultaneously-achievable acceleration constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the arm.
- * @param angle The angle of the arm
- * @param velocity The velocity of the arm.
- * @return The minimum possible acceleration at the given velocity and angle.
- */
- units::unit_t<Acceleration> MinAchievableAcceleration(
- units::volt_t maxVoltage, units::unit_t<Angle> angle,
- units::unit_t<Velocity> velocity) {
- return MaxAchievableAcceleration(-maxVoltage, angle, velocity);
- }
-
- units::volt_t kS{0};
- units::volt_t kCos{0};
- units::unit_t<kv_unit> kV{0};
- units::unit_t<ka_unit> kA{0};
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/controller/ControllerUtil.h b/wpilibc/src/main/native/include/frc/controller/ControllerUtil.h
new file mode 100644
index 0000000..7603fde
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/controller/ControllerUtil.h
@@ -0,0 +1,42 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <cmath>
+#include <type_traits>
+
+#include <units/math.h>
+
+namespace frc {
+
+/**
+ * Returns modulus of error where error is the difference between the reference
+ * and a measurement.
+ *
+ * @param reference Reference input of a controller.
+ * @param measurement The current measurement.
+ * @param minimumInput The minimum value expected from the input.
+ * @param maximumInput The maximum value expected from the input.
+ */
+template <typename T>
+T GetModulusError(T reference, T measurement, T minimumInput, T maximumInput) {
+ T error = reference - measurement;
+ T modulus = maximumInput - minimumInput;
+
+ // Wrap error above maximum input
+ int numMax = (error + maximumInput) / modulus;
+ error -= numMax * modulus;
+
+ // Wrap error below minimum input
+ int numMin = (error + minimumInput) / modulus;
+ error -= numMin * modulus;
+
+ return error;
+}
+
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/controller/ElevatorFeedforward.h b/wpilibc/src/main/native/include/frc/controller/ElevatorFeedforward.h
deleted file mode 100644
index c664fc4..0000000
--- a/wpilibc/src/main/native/include/frc/controller/ElevatorFeedforward.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-#include <wpi/MathExtras.h>
-
-namespace frc {
-/**
- * A helper class that computes feedforward outputs for a simple elevator
- * (modeled as a motor acting against the force of gravity).
- */
-template <class Distance>
-class ElevatorFeedforward {
- using Velocity =
- units::compound_unit<Distance, units::inverse<units::seconds>>;
- using Acceleration =
- units::compound_unit<Velocity, units::inverse<units::seconds>>;
- using kv_unit = units::compound_unit<units::volts, units::inverse<Velocity>>;
- using ka_unit =
- units::compound_unit<units::volts, units::inverse<Acceleration>>;
-
- public:
- ElevatorFeedforward() = default;
-
- /**
- * Creates a new ElevatorFeedforward with the specified gains.
- *
- * @param kS The static gain, in volts.
- * @param kG The gravity gain, in volts.
- * @param kV The velocity gain, in volt seconds per distance.
- * @param kA The acceleration gain, in volt seconds^2 per distance.
- */
- constexpr ElevatorFeedforward(
- units::volt_t kS, units::volt_t kG, units::unit_t<kv_unit> kV,
- units::unit_t<ka_unit> kA = units::unit_t<ka_unit>(0))
- : kS(kS), kG(kG), kV(kV), kA(kA) {}
-
- /**
- * Calculates the feedforward from the gains and setpoints.
- *
- * @param velocity The velocity setpoint, in distance per second.
- * @param acceleration The acceleration setpoint, in distance per second^2.
- * @return The computed feedforward, in volts.
- */
- constexpr units::volt_t Calculate(units::unit_t<Velocity> velocity,
- units::unit_t<Acceleration> acceleration =
- units::unit_t<Acceleration>(0)) {
- return kS * wpi::sgn(velocity) + kG + kV * velocity + kA * acceleration;
- }
-
- // Rearranging the main equation from the calculate() method yields the
- // formulas for the methods below:
-
- /**
- * Calculates the maximum achievable velocity given a maximum voltage supply
- * and an acceleration. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the acceleration constraint, and this will give you
- * a simultaneously-achievable velocity constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the elevator.
- * @param acceleration The acceleration of the elevator.
- * @return The maximum possible velocity at the given acceleration.
- */
- constexpr units::unit_t<Velocity> MaxAchievableVelocity(
- units::volt_t maxVoltage, units::unit_t<Acceleration> acceleration) {
- // Assume max velocity is positive
- return (maxVoltage - kS - kG - kA * acceleration) / kV;
- }
-
- /**
- * Calculates the minimum achievable velocity given a maximum voltage supply
- * and an acceleration. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the acceleration constraint, and this will give you
- * a simultaneously-achievable velocity constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the elevator.
- * @param acceleration The acceleration of the elevator.
- * @return The minimum possible velocity at the given acceleration.
- */
- constexpr units::unit_t<Velocity> MinAchievableVelocity(
- units::volt_t maxVoltage, units::unit_t<Acceleration> acceleration) {
- // Assume min velocity is negative, ks flips sign
- return (-maxVoltage + kS - kG - kA * acceleration) / kV;
- }
-
- /**
- * Calculates the maximum achievable acceleration given a maximum voltage
- * supply and a velocity. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the velocity constraint, and this will give you
- * a simultaneously-achievable acceleration constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the elevator.
- * @param velocity The velocity of the elevator.
- * @return The maximum possible acceleration at the given velocity.
- */
- constexpr units::unit_t<Acceleration> MaxAchievableAcceleration(
- units::volt_t maxVoltage, units::unit_t<Velocity> velocity) {
- return (maxVoltage - kS * wpi::sgn(velocity) - kG - kV * velocity) / kA;
- }
-
- /**
- * Calculates the minimum achievable acceleration given a maximum voltage
- * supply and a velocity. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the velocity constraint, and this will give you
- * a simultaneously-achievable acceleration constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the elevator.
- * @param velocity The velocity of the elevator.
- * @return The minimum possible acceleration at the given velocity.
- */
- constexpr units::unit_t<Acceleration> MinAchievableAcceleration(
- units::volt_t maxVoltage, units::unit_t<Velocity> velocity) {
- return MaxAchievableAcceleration(-maxVoltage, velocity);
- }
-
- units::volt_t kS{0};
- units::volt_t kG{0};
- units::unit_t<kv_unit> kV{0};
- units::unit_t<ka_unit> kA{0};
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/controller/HolonomicDriveController.h b/wpilibc/src/main/native/include/frc/controller/HolonomicDriveController.h
new file mode 100644
index 0000000..916e1a9
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/controller/HolonomicDriveController.h
@@ -0,0 +1,112 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <units/angle.h>
+#include <units/velocity.h>
+
+#include "frc/controller/PIDController.h"
+#include "frc/controller/ProfiledPIDController.h"
+#include "frc/geometry/Pose2d.h"
+#include "frc/geometry/Rotation2d.h"
+#include "frc/kinematics/ChassisSpeeds.h"
+#include "frc/trajectory/Trajectory.h"
+
+namespace frc {
+/**
+ * This holonomic drive controller can be used to follow trajectories using a
+ * holonomic drive train (i.e. swerve or mecanum). Holonomic trajectory
+ * following is a much simpler problem to solve compared to skid-steer style
+ * drivetrains because it is possible to individually control forward, sideways,
+ * and angular velocity.
+ *
+ * The holonomic drive controller takes in one PID controller for each
+ * direction, forward and sideways, and one profiled PID controller for the
+ * angular direction. Because the heading dynamics are decoupled from
+ * translations, users can specify a custom heading that the drivetrain should
+ * point toward. This heading reference is profiled for smoothness.
+ */
+class HolonomicDriveController {
+ public:
+ /**
+ * Constructs a holonomic drive controller.
+ *
+ * @param xController A PID Controller to respond to error in the
+ * field-relative x direction.
+ * @param yController A PID Controller to respond to error in the
+ * field-relative y direction.
+ * @param thetaController A profiled PID controller to respond to error in
+ * angle.
+ */
+ HolonomicDriveController(
+ const frc2::PIDController& xController,
+ const frc2::PIDController& yController,
+ const ProfiledPIDController<units::radian>& thetaController);
+
+ /**
+ * Returns true if the pose error is within tolerance of the reference.
+ */
+ bool AtReference() const;
+
+ /**
+ * Sets the pose error which is considered tolerable for use with
+ * AtReference().
+ *
+ * @param poseTolerance Pose error which is tolerable.
+ */
+ void SetTolerance(const Pose2d& tolerance);
+
+ /**
+ * Returns the next output of the holonomic drive controller.
+ *
+ * The reference pose, linear velocity, and angular velocity should come from
+ * a drivetrain trajectory.
+ *
+ * @param currentPose The current pose.
+ * @param poseRef The desired pose.
+ * @param linearVelocityRef The desired linear velocity.
+ * @param angleRef The desired ending angle.
+ */
+ ChassisSpeeds Calculate(const Pose2d& currentPose, const Pose2d& poseRef,
+ units::meters_per_second_t linearVelocityRef,
+ const Rotation2d& angleRef);
+
+ /**
+ * Returns the next output of the holonomic drive controller.
+ *
+ * The reference pose, linear velocity, and angular velocity should come from
+ * a drivetrain trajectory.
+ *
+ * @param currentPose The current pose.
+ * @param desiredState The desired pose, linear velocity, and angular velocity
+ * from a trajectory.
+ * @param angleRef The desired ending angle.
+ */
+ ChassisSpeeds Calculate(const Pose2d& currentPose,
+ const Trajectory::State& desiredState,
+ const Rotation2d& angleRef);
+
+ /**
+ * Enables and disables the controller for troubleshooting purposes. When
+ * Calculate() is called on a disabled controller, only feedforward values
+ * are returned.
+ *
+ * @param enabled If the controller is enabled or not.
+ */
+ void SetEnabled(bool enabled);
+
+ private:
+ Pose2d m_poseError;
+ Pose2d m_poseTolerance;
+ bool m_enabled = true;
+
+ frc2::PIDController m_xController;
+ frc2::PIDController m_yController;
+ ProfiledPIDController<units::radian> m_thetaController;
+};
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/controller/PIDController.h b/wpilibc/src/main/native/include/frc/controller/PIDController.h
index 66a36fb..5f97c1e 100644
--- a/wpilibc/src/main/native/include/frc/controller/PIDController.h
+++ b/wpilibc/src/main/native/include/frc/controller/PIDController.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -10,7 +10,7 @@
#include <functional>
#include <limits>
-#include <units/units.h>
+#include <units/time.h>
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableHelper.h"
@@ -117,7 +117,7 @@
double GetSetpoint() const;
/**
- * Returns true if the error is within the tolerance of the error.
+ * Returns true if the error is within the tolerance of the setpoint.
*
* This will return false until at least one input value has been computed.
*/
@@ -141,6 +141,11 @@
void DisableContinuousInput();
/**
+ * Returns true if continuous input is enabled.
+ */
+ bool IsContinuousInputEnabled() const;
+
+ /**
* Sets the minimum and maximum values for the integrator.
*
* When the cap is reached, the integrator value is added to the controller
@@ -193,16 +198,6 @@
void InitSendable(frc::SendableBuilder& builder) override;
- protected:
- /**
- * Wraps error around for continuous inputs. The original error is returned if
- * continuous mode is disabled.
- *
- * @param error The current error of the PID controller.
- * @return Error for continuous inputs.
- */
- double GetContinuousError(double error) const;
-
private:
// Factor for "proportional" control
double m_Kp;
@@ -220,15 +215,10 @@
double m_minimumIntegral = -1.0;
- // Maximum input - limit setpoint to this
double m_maximumInput = 0;
- // Minimum input - limit setpoint to this
double m_minimumInput = 0;
- // Input range - difference between maximum and minimum
- double m_inputRange = 0;
-
// Do the endpoints wrap around? eg. Absolute encoder
bool m_continuous = false;
@@ -248,14 +238,6 @@
double m_velocityTolerance = std::numeric_limits<double>::infinity();
double m_setpoint = 0;
-
- /**
- * Sets the minimum and maximum values expected from the input.
- *
- * @param minimumInput The minimum value expected from the input.
- * @param maximumInput The maximum value expected from the input.
- */
- void SetInputRange(double minimumInput, double maximumInput);
};
} // namespace frc2
diff --git a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h
index 079d96e..fd246cd 100644
--- a/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h
+++ b/wpilibc/src/main/native/include/frc/controller/ProfiledPIDController.h
@@ -12,8 +12,9 @@
#include <functional>
#include <limits>
-#include <units/units.h>
+#include <units/time.h>
+#include "frc/controller/ControllerUtil.h"
#include "frc/controller/PIDController.h"
#include "frc/smartdashboard/Sendable.h"
#include "frc/smartdashboard/SendableBuilder.h"
@@ -33,6 +34,7 @@
class ProfiledPIDController
: public Sendable,
public SendableHelper<ProfiledPIDController<Distance>> {
+ public:
using Distance_t = units::unit_t<Distance>;
using Velocity =
units::compound_unit<Distance, units::inverse<units::seconds>>;
@@ -43,7 +45,6 @@
using State = typename TrapezoidProfile<Distance>::State;
using Constraints = typename TrapezoidProfile<Distance>::Constraints;
- public:
/**
* Allocates a ProfiledPIDController with the given constants for Kp, Ki, and
* Kd. Users should call reset() when they first start running the controller
@@ -195,6 +196,8 @@
void EnableContinuousInput(Distance_t minimumInput, Distance_t maximumInput) {
m_controller.EnableContinuousInput(minimumInput.template to<double>(),
maximumInput.template to<double>());
+ m_minimumInput = minimumInput;
+ m_maximumInput = maximumInput;
}
/**
@@ -251,6 +254,23 @@
* @param measurement The current measurement of the process variable.
*/
double Calculate(Distance_t measurement) {
+ if (m_controller.IsContinuousInputEnabled()) {
+ // Get error which is smallest distance between goal and measurement
+ auto goalMinDistance = frc::GetModulusError<Distance_t>(
+ m_goal.position, measurement, m_minimumInput, m_maximumInput);
+ auto setpointMinDistance = frc::GetModulusError<Distance_t>(
+ m_setpoint.position, measurement, m_minimumInput, m_maximumInput);
+
+ // Recompute the profile goal with the smallest error, thus giving the
+ // shortest path. The goal may be outside the input range after this
+ // operation, but that's OK because the controller will still go there and
+ // report an error of zero. In other words, the setpoint only needs to be
+ // offset from the measurement by the input range modulus; they don't need
+ // to be equal.
+ m_goal.position = goalMinDistance + measurement;
+ m_setpoint.position = setpointMinDistance + measurement;
+ }
+
frc::TrapezoidProfile<Distance> profile{m_constraints, m_goal, m_setpoint};
m_setpoint = profile.Calculate(GetPeriod());
return m_controller.Calculate(measurement.template to<double>(),
@@ -324,12 +344,12 @@
void InitSendable(frc::SendableBuilder& builder) override {
builder.SetSmartDashboardType("ProfiledPIDController");
- builder.AddDoubleProperty("p", [this] { return GetP(); },
- [this](double value) { SetP(value); });
- builder.AddDoubleProperty("i", [this] { return GetI(); },
- [this](double value) { SetI(value); });
- builder.AddDoubleProperty("d", [this] { return GetD(); },
- [this](double value) { SetD(value); });
+ builder.AddDoubleProperty(
+ "p", [this] { return GetP(); }, [this](double value) { SetP(value); });
+ builder.AddDoubleProperty(
+ "i", [this] { return GetI(); }, [this](double value) { SetI(value); });
+ builder.AddDoubleProperty(
+ "d", [this] { return GetD(); }, [this](double value) { SetD(value); });
builder.AddDoubleProperty(
"goal", [this] { return GetGoal().position.template to<double>(); },
[this](double value) { SetGoal(Distance_t{value}); });
@@ -337,6 +357,8 @@
private:
frc2::PIDController m_controller;
+ Distance_t m_minimumInput{0};
+ Distance_t m_maximumInput{0};
typename frc::TrapezoidProfile<Distance>::State m_goal;
typename frc::TrapezoidProfile<Distance>::State m_setpoint;
typename frc::TrapezoidProfile<Distance>::Constraints m_constraints;
diff --git a/wpilibc/src/main/native/include/frc/controller/RamseteController.h b/wpilibc/src/main/native/include/frc/controller/RamseteController.h
index 6ec6edc..e746bb3 100644
--- a/wpilibc/src/main/native/include/frc/controller/RamseteController.h
+++ b/wpilibc/src/main/native/include/frc/controller/RamseteController.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -7,7 +7,8 @@
#pragma once
-#include <units/units.h>
+#include <units/angular_velocity.h>
+#include <units/velocity.h>
#include "frc/geometry/Pose2d.h"
#include "frc/kinematics/ChassisSpeeds.h"
@@ -56,7 +57,7 @@
/**
* Construct a Ramsete unicycle controller. The default arguments for
- * b and zeta of 2.0 and 0.7 have been well-tested to produce desireable
+ * b and zeta of 2.0 and 0.7 have been well-tested to produce desirable
* results.
*/
RamseteController() : RamseteController(2.0, 0.7) {}
@@ -102,12 +103,20 @@
ChassisSpeeds Calculate(const Pose2d& currentPose,
const Trajectory::State& desiredState);
+ /**
+ * Enables and disables the controller for troubleshooting purposes.
+ *
+ * @param enabled If the controller is enabled or not.
+ */
+ void SetEnabled(bool enabled);
+
private:
double m_b;
double m_zeta;
Pose2d m_poseError;
Pose2d m_poseTolerance;
+ bool m_enabled = true;
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/controller/SimpleMotorFeedforward.h b/wpilibc/src/main/native/include/frc/controller/SimpleMotorFeedforward.h
deleted file mode 100644
index 8f82cb9..0000000
--- a/wpilibc/src/main/native/include/frc/controller/SimpleMotorFeedforward.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-#include <wpi/MathExtras.h>
-
-namespace frc {
-/**
- * A helper class that computes feedforward voltages for a simple
- * permanent-magnet DC motor.
- */
-template <class Distance>
-class SimpleMotorFeedforward {
- using Velocity =
- units::compound_unit<Distance, units::inverse<units::seconds>>;
- using Acceleration =
- units::compound_unit<Velocity, units::inverse<units::seconds>>;
- using kv_unit = units::compound_unit<units::volts, units::inverse<Velocity>>;
- using ka_unit =
- units::compound_unit<units::volts, units::inverse<Acceleration>>;
-
- public:
- constexpr SimpleMotorFeedforward() = default;
-
- /**
- * Creates a new SimpleMotorFeedforward with the specified gains.
- *
- * @param kS The static gain, in volts.
- * @param kV The velocity gain, in volt seconds per distance.
- * @param kA The acceleration gain, in volt seconds^2 per distance.
- */
- constexpr SimpleMotorFeedforward(
- units::volt_t kS, units::unit_t<kv_unit> kV,
- units::unit_t<ka_unit> kA = units::unit_t<ka_unit>(0))
- : kS(kS), kV(kV), kA(kA) {}
-
- /**
- * Calculates the feedforward from the gains and setpoints.
- *
- * @param velocity The velocity setpoint, in distance per second.
- * @param acceleration The acceleration setpoint, in distance per second^2.
- * @return The computed feedforward, in volts.
- */
- constexpr units::volt_t Calculate(units::unit_t<Velocity> velocity,
- units::unit_t<Acceleration> acceleration =
- units::unit_t<Acceleration>(0)) const {
- return kS * wpi::sgn(velocity) + kV * velocity + kA * acceleration;
- }
-
- // Rearranging the main equation from the calculate() method yields the
- // formulas for the methods below:
-
- /**
- * Calculates the maximum achievable velocity given a maximum voltage supply
- * and an acceleration. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the acceleration constraint, and this will give you
- * a simultaneously-achievable velocity constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the motor.
- * @param acceleration The acceleration of the motor.
- * @return The maximum possible velocity at the given acceleration.
- */
- constexpr units::unit_t<Velocity> MaxAchievableVelocity(
- units::volt_t maxVoltage, units::unit_t<Acceleration> acceleration) {
- // Assume max velocity is positive
- return (maxVoltage - kS - kA * acceleration) / kV;
- }
-
- /**
- * Calculates the minimum achievable velocity given a maximum voltage supply
- * and an acceleration. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the acceleration constraint, and this will give you
- * a simultaneously-achievable velocity constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the motor.
- * @param acceleration The acceleration of the motor.
- * @return The minimum possible velocity at the given acceleration.
- */
- constexpr units::unit_t<Velocity> MinAchievableVelocity(
- units::volt_t maxVoltage, units::unit_t<Acceleration> acceleration) {
- // Assume min velocity is positive, ks flips sign
- return (-maxVoltage + kS - kA * acceleration) / kV;
- }
-
- /**
- * Calculates the maximum achievable acceleration given a maximum voltage
- * supply and a velocity. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the velocity constraint, and this will give you
- * a simultaneously-achievable acceleration constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the motor.
- * @param velocity The velocity of the motor.
- * @return The maximum possible acceleration at the given velocity.
- */
- constexpr units::unit_t<Acceleration> MaxAchievableAcceleration(
- units::volt_t maxVoltage, units::unit_t<Velocity> velocity) {
- return (maxVoltage - kS * wpi::sgn(velocity) - kV * velocity) / kA;
- }
-
- /**
- * Calculates the minimum achievable acceleration given a maximum voltage
- * supply and a velocity. Useful for ensuring that velocity and
- * acceleration constraints for a trapezoidal profile are simultaneously
- * achievable - enter the velocity constraint, and this will give you
- * a simultaneously-achievable acceleration constraint.
- *
- * @param maxVoltage The maximum voltage that can be supplied to the motor.
- * @param velocity The velocity of the motor.
- * @return The minimum possible acceleration at the given velocity.
- */
- constexpr units::unit_t<Acceleration> MinAchievableAcceleration(
- units::volt_t maxVoltage, units::unit_t<Velocity> velocity) {
- return MaxAchievableAcceleration(-maxVoltage, velocity);
- }
-
- units::volt_t kS{0};
- units::unit_t<kv_unit> kV{0};
- units::unit_t<ka_unit> kA{0};
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h
index c6b705a..86103de 100644
--- a/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h
+++ b/wpilibc/src/main/native/include/frc/drive/DifferentialDrive.h
@@ -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. */
@@ -191,7 +191,7 @@
void SetQuickStopAlpha(double alpha);
/**
- * Gets if the power sent to the right side of the drivetrain is multipled by
+ * Gets if the power sent to the right side of the drivetrain is multiplied by
* -1.
*
* @return true if the right side is inverted
@@ -200,9 +200,10 @@
/**
* Sets if the power sent to the right side of the drivetrain should be
- * multipled by -1.
+ * multiplied by -1.
*
- * @param rightSideInverted true if right side power should be multipled by -1
+ * @param rightSideInverted true if right side power should be multiplied by
+ * -1
*/
void SetRightSideInverted(bool rightSideInverted);
diff --git a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h
index 9ddb57e..8435b4d 100644
--- a/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h
+++ b/wpilibc/src/main/native/include/frc/drive/MecanumDrive.h
@@ -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. */
@@ -116,7 +116,7 @@
void DrivePolar(double magnitude, double angle, double zRotation);
/**
- * Gets if the power sent to the right side of the drivetrain is multipled by
+ * Gets if the power sent to the right side of the drivetrain is multiplied by
* -1.
*
* @return true if the right side is inverted
@@ -125,9 +125,10 @@
/**
* Sets if the power sent to the right side of the drivetrain should be
- * multipled by -1.
+ * multiplied by -1.
*
- * @param rightSideInverted true if right side power should be multipled by -1
+ * @param rightSideInverted true if right side power should be multiplied by
+ * -1
*/
void SetRightSideInverted(bool rightSideInverted);
diff --git a/wpilibc/src/main/native/include/frc/filters/Filter.h b/wpilibc/src/main/native/include/frc/filters/Filter.h
index b200407..fb14d28 100644
--- a/wpilibc/src/main/native/include/frc/filters/Filter.h
+++ b/wpilibc/src/main/native/include/frc/filters/Filter.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2015-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. */
@@ -17,6 +17,8 @@
/**
* Interface for filters
+ *
+ * @deprecated only used by the deprecated LinearDigitalFilter
*/
class Filter : public PIDSource {
public:
diff --git a/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h b/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h
index 0a2afd2..c4fc3ef 100644
--- a/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h
+++ b/wpilibc/src/main/native/include/frc/filters/LinearDigitalFilter.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2015-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2015-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. */
@@ -68,6 +68,8 @@
* definitely need to adjust the gains if you then want to run it at 200Hz!
* Combining this with Note 1 - the impetus is on YOU as a developer to make
* sure PIDGet() gets called at the desired, constant frequency!
+ *
+ * @deprecated Use LinearFilter class instead
*/
class LinearDigitalFilter : public Filter {
public:
diff --git a/wpilibc/src/main/native/include/frc/geometry/Pose2d.h b/wpilibc/src/main/native/include/frc/geometry/Pose2d.h
deleted file mode 100644
index 46328a0..0000000
--- a/wpilibc/src/main/native/include/frc/geometry/Pose2d.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "Transform2d.h"
-#include "Translation2d.h"
-#include "Twist2d.h"
-
-namespace wpi {
-class json;
-} // namespace wpi
-
-namespace frc {
-
-/**
- * Represents a 2d pose containing translational and rotational elements.
- */
-class Pose2d {
- public:
- /**
- * Constructs a pose at the origin facing toward the positive X axis.
- * (Translation2d{0, 0} and Rotation{0})
- */
- constexpr Pose2d() = default;
-
- /**
- * Constructs a pose with the specified translation and rotation.
- *
- * @param translation The translational component of the pose.
- * @param rotation The rotational component of the pose.
- */
- Pose2d(Translation2d translation, Rotation2d rotation);
-
- /**
- * Convenience constructors that takes in x and y values directly instead of
- * having to construct a Translation2d.
- *
- * @param x The x component of the translational component of the pose.
- * @param y The y component of the translational component of the pose.
- * @param rotation The rotational component of the pose.
- */
- Pose2d(units::meter_t x, units::meter_t y, Rotation2d rotation);
-
- /**
- * Transforms the pose by the given transformation and returns the new
- * transformed pose.
- *
- * [x_new] [cos, -sin, 0][transform.x]
- * [y_new] += [sin, cos, 0][transform.y]
- * [t_new] [0, 0, 1][transform.t]
- *
- * @param other The transform to transform the pose by.
- *
- * @return The transformed pose.
- */
- Pose2d operator+(const Transform2d& other) const;
-
- /**
- * Transforms the current pose by the transformation.
- *
- * This is similar to the + operator, except that it mutates the current
- * object.
- *
- * @param other The transform to transform the pose by.
- *
- * @return Reference to the new mutated object.
- */
- Pose2d& operator+=(const Transform2d& other);
-
- /**
- * Returns the Transform2d that maps the one pose to another.
- *
- * @param other The initial pose of the transformation.
- * @return The transform that maps the other pose to the current pose.
- */
- Transform2d operator-(const Pose2d& other) const;
-
- /**
- * Checks equality between this Pose2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are equal.
- */
- bool operator==(const Pose2d& other) const;
-
- /**
- * Checks inequality between this Pose2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are not equal.
- */
- bool operator!=(const Pose2d& other) const;
-
- /**
- * Returns the underlying translation.
- *
- * @return Reference to the translational component of the pose.
- */
- const Translation2d& Translation() const { return m_translation; }
-
- /**
- * Returns the underlying rotation.
- *
- * @return Reference to the rotational component of the pose.
- */
- const Rotation2d& Rotation() const { return m_rotation; }
-
- /**
- * Transforms the pose by the given transformation and returns the new pose.
- * See + operator for the matrix multiplication performed.
- *
- * @param other The transform to transform the pose by.
- *
- * @return The transformed pose.
- */
- Pose2d TransformBy(const Transform2d& other) const;
-
- /**
- * Returns the other pose relative to the current pose.
- *
- * This function can often be used for trajectory tracking or pose
- * stabilization algorithms to get the error between the reference and the
- * current pose.
- *
- * @param other The pose that is the origin of the new coordinate frame that
- * the current pose will be converted into.
- *
- * @return The current pose relative to the new origin pose.
- */
- Pose2d RelativeTo(const Pose2d& other) const;
-
- /**
- * Obtain a new Pose2d from a (constant curvature) velocity.
- *
- * See <https://file.tavsys.net/control/state-space-guide.pdf> section on
- * nonlinear pose estimation for derivation.
- *
- * The twist is a change in pose in the robot's coordinate frame since the
- * previous pose update. When the user runs exp() on the previous known
- * field-relative pose with the argument being the twist, the user will
- * receive the new field-relative pose.
- *
- * "Exp" represents the pose exponential, which is solving a differential
- * equation moving the pose forward in time.
- *
- * @param twist The change in pose in the robot's coordinate frame since the
- * previous pose update. For example, if a non-holonomic robot moves forward
- * 0.01 meters and changes angle by 0.5 degrees since the previous pose
- * update, the twist would be Twist2d{0.01, 0.0, toRadians(0.5)}
- *
- * @return The new pose of the robot.
- */
- Pose2d Exp(const Twist2d& twist) const;
-
- /**
- * Returns a Twist2d that maps this pose to the end pose. If c is the output
- * of a.Log(b), then a.Exp(c) would yield b.
- *
- * @param end The end pose for the transformation.
- *
- * @return The twist that maps this to end.
- */
- Twist2d Log(const Pose2d& end) const;
-
- private:
- Translation2d m_translation;
- Rotation2d m_rotation;
-};
-
-void to_json(wpi::json& json, const Pose2d& pose);
-
-void from_json(const wpi::json& json, Pose2d& pose);
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h b/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h
deleted file mode 100644
index b636513..0000000
--- a/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-namespace wpi {
-class json;
-} // namespace wpi
-
-namespace frc {
-
-/**
- * A rotation in a 2d coordinate frame represented a point on the unit circle
- * (cosine and sine).
- */
-class Rotation2d {
- public:
- /**
- * Constructs a Rotation2d with a default angle of 0 degrees.
- */
- constexpr Rotation2d() = default;
-
- /**
- * Constructs a Rotation2d with the given radian value.
- *
- * @param value The value of the angle in radians.
- */
- Rotation2d(units::radian_t value); // NOLINT(runtime/explicit)
-
- /**
- * Constructs a Rotation2d with the given x and y (cosine and sine)
- * components. The x and y don't have to be normalized.
- *
- * @param x The x component or cosine of the rotation.
- * @param y The y component or sine of the rotation.
- */
- Rotation2d(double x, double y);
-
- /**
- * Adds two rotations together, with the result being bounded between -pi and
- * pi.
- *
- * For example, Rotation2d.FromDegrees(30) + Rotation2d.FromDegrees(60) =
- * Rotation2d{-pi/2}
- *
- * @param other The rotation to add.
- *
- * @return The sum of the two rotations.
- */
- Rotation2d operator+(const Rotation2d& other) const;
-
- /**
- * Adds a rotation to the current rotation.
- *
- * This is similar to the + operator except that it mutates the current
- * object.
- *
- * @param other The rotation to add.
- *
- * @return The reference to the new mutated object.
- */
- Rotation2d& operator+=(const Rotation2d& other);
-
- /**
- * Subtracts the new rotation from the current rotation and returns the new
- * rotation.
- *
- * For example, Rotation2d.FromDegrees(10) - Rotation2d.FromDegrees(100) =
- * Rotation2d{-pi/2}
- *
- * @param other The rotation to subtract.
- *
- * @return The difference between the two rotations.
- */
- Rotation2d operator-(const Rotation2d& other) const;
-
- /**
- * Subtracts the new rotation from the current rotation.
- *
- * This is similar to the - operator except that it mutates the current
- * object.
- *
- * @param other The rotation to subtract.
- *
- * @return The reference to the new mutated object.
- */
- Rotation2d& operator-=(const Rotation2d& other);
-
- /**
- * Takes the inverse of the current rotation. This is simply the negative of
- * the current angular value.
- *
- * @return The inverse of the current rotation.
- */
- Rotation2d operator-() const;
-
- /**
- * Multiplies the current rotation by a scalar.
- * @param scalar The scalar.
- *
- * @return The new scaled Rotation2d.
- */
- Rotation2d operator*(double scalar) const;
-
- /**
- * Checks equality between this Rotation2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are equal.
- */
- bool operator==(const Rotation2d& other) const;
-
- /**
- * Checks inequality between this Rotation2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are not equal.
- */
- bool operator!=(const Rotation2d& other) const;
-
- /**
- * Adds the new rotation to the current rotation using a rotation matrix.
- *
- * [cos_new] [other.cos, -other.sin][cos]
- * [sin_new] = [other.sin, other.cos][sin]
- *
- * value_new = std::atan2(cos_new, sin_new)
- *
- * @param other The rotation to rotate by.
- *
- * @return The new rotated Rotation2d.
- */
- Rotation2d RotateBy(const Rotation2d& other) const;
-
- /**
- * Returns the radian value of the rotation.
- *
- * @return The radian value of the rotation.
- */
- units::radian_t Radians() const { return m_value; }
-
- /**
- * Returns the degree value of the rotation.
- *
- * @return The degree value of the rotation.
- */
- units::degree_t Degrees() const { return m_value; }
-
- /**
- * Returns the cosine of the rotation.
- *
- * @return The cosine of the rotation.
- */
- double Cos() const { return m_cos; }
-
- /**
- * Returns the sine of the rotation.
- *
- * @return The sine of the rotation.
- */
- double Sin() const { return m_sin; }
-
- /**
- * Returns the tangent of the rotation.
- *
- * @return The tangent of the rotation.
- */
- double Tan() const { return m_sin / m_cos; }
-
- private:
- units::radian_t m_value = 0_deg;
- double m_cos = 1;
- double m_sin = 0;
-};
-
-void to_json(wpi::json& json, const Rotation2d& rotation);
-
-void from_json(const wpi::json& json, Rotation2d& rotation);
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/geometry/Transform2d.h b/wpilibc/src/main/native/include/frc/geometry/Transform2d.h
deleted file mode 100644
index c75fbeb..0000000
--- a/wpilibc/src/main/native/include/frc/geometry/Transform2d.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "Translation2d.h"
-
-namespace frc {
-
-class Pose2d;
-
-/**
- * Represents a transformation for a Pose2d.
- */
-class Transform2d {
- public:
- /**
- * Constructs the transform that maps the initial pose to the final pose.
- *
- * @param initial The initial pose for the transformation.
- * @param final The final pose for the transformation.
- */
- Transform2d(Pose2d initial, Pose2d final);
-
- /**
- * Constructs a transform with the given translation and rotation components.
- *
- * @param translation Translational component of the transform.
- * @param rotation Rotational component of the transform.
- */
- Transform2d(Translation2d translation, Rotation2d rotation);
-
- /**
- * Constructs the identity transform -- maps an initial pose to itself.
- */
- constexpr Transform2d() = default;
-
- /**
- * Returns the translation component of the transformation.
- *
- * @return Reference to the translational component of the transform.
- */
- const Translation2d& Translation() const { return m_translation; }
-
- /**
- * Returns the rotational component of the transformation.
- *
- * @return Reference to the rotational component of the transform.
- */
- const Rotation2d& Rotation() const { return m_rotation; }
-
- /**
- * Scales the transform by the scalar.
- *
- * @param scalar The scalar.
- * @return The scaled Transform2d.
- */
- Transform2d operator*(double scalar) const {
- return Transform2d(m_translation * scalar, m_rotation * scalar);
- }
-
- /**
- * Checks equality between this Transform2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are equal.
- */
- bool operator==(const Transform2d& other) const;
-
- /**
- * Checks inequality between this Transform2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are not equal.
- */
- bool operator!=(const Transform2d& other) const;
-
- private:
- Translation2d m_translation;
- Rotation2d m_rotation;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/geometry/Translation2d.h b/wpilibc/src/main/native/include/frc/geometry/Translation2d.h
deleted file mode 100644
index 90c61e2..0000000
--- a/wpilibc/src/main/native/include/frc/geometry/Translation2d.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "Rotation2d.h"
-
-namespace wpi {
-class json;
-} // namespace wpi
-
-namespace frc {
-
-/**
- * Represents a translation in 2d space.
- * This object can be used to represent a point or a vector.
- *
- * This assumes that you are using conventional mathematical axes.
- * When the robot is placed on the origin, facing toward the X direction,
- * moving forward increases the X, whereas moving to the left increases the Y.
- */
-class Translation2d {
- public:
- /**
- * Constructs a Translation2d with X and Y components equal to zero.
- */
- constexpr Translation2d() = default;
-
- /**
- * Constructs a Translation2d with the X and Y components equal to the
- * provided values.
- *
- * @param x The x component of the translation.
- * @param y The y component of the translation.
- */
- Translation2d(units::meter_t x, units::meter_t y);
-
- /**
- * Calculates the distance between two translations in 2d space.
- *
- * This function uses the pythagorean theorem to calculate the distance.
- * distance = std::sqrt((x2 - x1)^2 + (y2 - y1)^2)
- *
- * @param other The translation to compute the distance to.
- *
- * @return The distance between the two translations.
- */
- units::meter_t Distance(const Translation2d& other) const;
-
- /**
- * Returns the X component of the translation.
- *
- * @return The x component of the translation.
- */
- units::meter_t X() const { return m_x; }
-
- /**
- * Returns the Y component of the translation.
- *
- * @return The y component of the translation.
- */
- units::meter_t Y() const { return m_y; }
-
- /**
- * Returns the norm, or distance from the origin to the translation.
- *
- * @return The norm of the translation.
- */
- units::meter_t Norm() const;
-
- /**
- * Applies a rotation to the translation in 2d space.
- *
- * This multiplies the translation vector by a counterclockwise rotation
- * matrix of the given angle.
- *
- * [x_new] [other.cos, -other.sin][x]
- * [y_new] = [other.sin, other.cos][y]
- *
- * For example, rotating a Translation2d of {2, 0} by 90 degrees will return a
- * Translation2d of {0, 2}.
- *
- * @param other The rotation to rotate the translation by.
- *
- * @return The new rotated translation.
- */
- Translation2d RotateBy(const Rotation2d& other) const;
-
- /**
- * Adds two translations in 2d space and returns the sum. This is similar to
- * vector addition.
- *
- * For example, Translation2d{1.0, 2.5} + Translation2d{2.0, 5.5} =
- * Translation2d{3.0, 8.0}
- *
- * @param other The translation to add.
- *
- * @return The sum of the translations.
- */
- Translation2d operator+(const Translation2d& other) const;
-
- /**
- * Adds the new translation to the current translation.
- *
- * This is similar to the + operator, except that the current object is
- * mutated.
- *
- * @param other The translation to add.
- *
- * @return The reference to the new mutated object.
- */
- Translation2d& operator+=(const Translation2d& other);
-
- /**
- * Subtracts the other translation from the other translation and returns the
- * difference.
- *
- * For example, Translation2d{5.0, 4.0} - Translation2d{1.0, 2.0} =
- * Translation2d{4.0, 2.0}
- *
- * @param other The translation to subtract.
- *
- * @return The difference between the two translations.
- */
- Translation2d operator-(const Translation2d& other) const;
-
- /**
- * Subtracts the new translation from the current translation.
- *
- * This is similar to the - operator, except that the current object is
- * mutated.
- *
- * @param other The translation to subtract.
- *
- * @return The reference to the new mutated object.
- */
- Translation2d& operator-=(const Translation2d& other);
-
- /**
- * Returns the inverse of the current translation. This is equivalent to
- * rotating by 180 degrees, flipping the point over both axes, or simply
- * negating both components of the translation.
- *
- * @return The inverse of the current translation.
- */
- Translation2d operator-() const;
-
- /**
- * Multiplies the translation by a scalar and returns the new translation.
- *
- * For example, Translation2d{2.0, 2.5} * 2 = Translation2d{4.0, 5.0}
- *
- * @param scalar The scalar to multiply by.
- *
- * @return The scaled translation.
- */
- Translation2d operator*(double scalar) const;
-
- /**
- * Multiplies the current translation by a scalar.
- *
- * This is similar to the * operator, except that current object is mutated.
- *
- * @param scalar The scalar to multiply by.
- *
- * @return The reference to the new mutated object.
- */
- Translation2d& operator*=(double scalar);
-
- /**
- * Divides the translation by a scalar and returns the new translation.
- *
- * For example, Translation2d{2.0, 2.5} / 2 = Translation2d{1.0, 1.25}
- *
- * @param scalar The scalar to divide by.
- *
- * @return The scaled translation.
- */
- Translation2d operator/(double scalar) const;
-
- /**
- * Checks equality between this Translation2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are equal.
- */
- bool operator==(const Translation2d& other) const;
-
- /**
- * Checks inequality between this Translation2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are not equal.
- */
- bool operator!=(const Translation2d& other) const;
-
- /*
- * Divides the current translation by a scalar.
- *
- * This is similar to the / operator, except that current object is mutated.
- *
- * @param scalar The scalar to divide by.
- *
- * @return The reference to the new mutated object.
- */
- Translation2d& operator/=(double scalar);
-
- private:
- units::meter_t m_x = 0_m;
- units::meter_t m_y = 0_m;
-};
-
-void to_json(wpi::json& json, const Translation2d& state);
-
-void from_json(const wpi::json& json, Translation2d& state);
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/geometry/Twist2d.h b/wpilibc/src/main/native/include/frc/geometry/Twist2d.h
deleted file mode 100644
index ab246a0..0000000
--- a/wpilibc/src/main/native/include/frc/geometry/Twist2d.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-namespace frc {
-/**
- * A change in distance along arc since the last pose update. We can use ideas
- * from differential calculus to create new Pose2ds from a Twist2d and vise
- * versa.
- *
- * A Twist can be used to represent a difference between two poses.
- */
-struct Twist2d {
- /**
- * Linear "dx" component
- */
- units::meter_t dx = 0_m;
-
- /**
- * Linear "dy" component
- */
- units::meter_t dy = 0_m;
-
- /**
- * Angular "dtheta" component (radians)
- */
- units::radian_t dtheta = 0_rad;
-
- /**
- * Checks equality between this Twist2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are equal.
- */
- bool operator==(const Twist2d& other) const {
- return units::math::abs(dx - other.dx) < 1E-9_m &&
- units::math::abs(dy - other.dy) < 1E-9_m &&
- units::math::abs(dtheta - other.dtheta) < 1E-9_rad;
- }
-
- /**
- * Checks inequality between this Twist2d and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are not equal.
- */
- bool operator!=(const Twist2d& other) const { return !operator==(other); }
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/interfaces/Gyro.h b/wpilibc/src/main/native/include/frc/interfaces/Gyro.h
index b5aa332..8c06993 100644
--- a/wpilibc/src/main/native/include/frc/interfaces/Gyro.h
+++ b/wpilibc/src/main/native/include/frc/interfaces/Gyro.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -7,6 +7,10 @@
#pragma once
+#include <units/angle.h>
+
+#include "frc/geometry/Rotation2d.h"
+
namespace frc {
/**
@@ -21,12 +25,10 @@
Gyro& operator=(Gyro&&) = default;
/**
- * Calibrate the gyro by running for a number of samples and computing the
- * center value. Then use the center value as the Accumulator center value for
- * subsequent measurements. It's important to make sure that the robot is not
- * moving while the centering calculations are in progress, this is typically
+ * Calibrate the gyro. It's important to make sure that the robot is not
+ * moving while the calibration is in progress, this is typically
* done when the robot is first turned on while it's sitting at rest before
- * the competition starts.
+ * the match starts.
*/
virtual void Calibrate() = 0;
@@ -38,17 +40,14 @@
virtual void Reset() = 0;
/**
- * Return the actual angle in degrees that the robot is currently facing.
+ * Return the heading of the robot in degrees.
*
- * The angle is based on the current accumulator value corrected by the
- * oversampling rate, the gyro type and the A/D calibration values. The angle
- * is continuous, that is it will continue from 360 to 361 degrees. This
- * allows algorithms that wouldn't want to see a discontinuity in the gyro
- * output as it sweeps past from 360 to 0 on the second time around.
+ * The angle is continuous, that is it will continue from 360 to 361 degrees.
+ * This allows algorithms that wouldn't want to see a discontinuity in the
+ * gyro output as it sweeps past from 360 to 0 on the second time around.
*
* The angle is expected to increase as the gyro turns clockwise when looked
- * at from the top. It needs to follow NED axis conventions in order to work
- * properly with dependent control loops.
+ * at from the top. It needs to follow the NED axis convention.
*
* @return the current heading of the robot in degrees. This heading is based
* on integration of the returned rate from the gyro.
@@ -61,12 +60,28 @@
* The rate is based on the most recent reading of the gyro analog value.
*
* The rate is expected to be positive as the gyro turns clockwise when looked
- * at from the top. It needs to follow NED axis conventions in order to work
- * properly with dependent control loops.
+ * at from the top. It needs to follow the NED axis convention.
*
* @return the current rate in degrees per second
*/
virtual double GetRate() const = 0;
+
+ /**
+ * Return the heading of the robot as a Rotation2d.
+ *
+ * The angle is continuous, that is it will continue from 360 to 361 degrees.
+ * This allows algorithms that wouldn't want to see a discontinuity in the
+ * gyro output as it sweeps past from 360 to 0 on the second time around.
+ *
+ * The angle is expected to increase as the gyro turns counterclockwise when
+ * looked at from the top. It needs to follow the NWU axis convention.
+ *
+ * @return the current heading of the robot as a Rotation2d. This heading is
+ * based on integration of the returned rate from the gyro.
+ */
+ virtual Rotation2d GetRotation2d() const {
+ return Rotation2d{units::degree_t{-GetAngle()}};
+ }
};
} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/ChassisSpeeds.h b/wpilibc/src/main/native/include/frc/kinematics/ChassisSpeeds.h
deleted file mode 100644
index 8c772c0..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/ChassisSpeeds.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "frc/geometry/Rotation2d.h"
-
-namespace frc {
-/**
- * Represents the speed of a robot chassis. Although this struct contains
- * similar members compared to a Twist2d, they do NOT represent the same thing.
- * Whereas a Twist2d represents a change in pose w.r.t to the robot frame of
- * reference, this ChassisSpeeds struct represents a velocity w.r.t to the robot
- * frame of reference.
- *
- * A strictly non-holonomic drivetrain, such as a differential drive, should
- * never have a dy component because it can never move sideways. Holonomic
- * drivetrains such as swerve and mecanum will often have all three components.
- */
-struct ChassisSpeeds {
- /**
- * Represents forward velocity w.r.t the robot frame of reference. (Fwd is +)
- */
- units::meters_per_second_t vx = 0_mps;
-
- /**
- * Represents strafe velocity w.r.t the robot frame of reference. (Left is +)
- */
- units::meters_per_second_t vy = 0_mps;
-
- /**
- * Represents the angular velocity of the robot frame. (CCW is +)
- */
- units::radians_per_second_t omega = 0_rad_per_s;
-
- /**
- * Converts a user provided field-relative set of speeds into a robot-relative
- * ChassisSpeeds object.
- *
- * @param vx The component of speed in the x direction relative to the field.
- * Positive x is away from your alliance wall.
- * @param vy The component of speed in the y direction relative to the field.
- * Positive y is to your left when standing behind the alliance wall.
- * @param omega The angular rate of the robot.
- * @param robotAngle The angle of the robot as measured by a gyroscope. The
- * robot's angle is considered to be zero when it is facing directly away from
- * your alliance station wall. Remember that this should be CCW positive.
- *
- * @return ChassisSpeeds object representing the speeds in the robot's frame
- * of reference.
- */
- static ChassisSpeeds FromFieldRelativeSpeeds(
- units::meters_per_second_t vx, units::meters_per_second_t vy,
- units::radians_per_second_t omega, const Rotation2d& robotAngle) {
- return {vx * robotAngle.Cos() + vy * robotAngle.Sin(),
- -vx * robotAngle.Sin() + vy * robotAngle.Cos(), omega};
- }
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h
deleted file mode 100644
index e986029..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveKinematics.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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/FRCUsageReporting.h>
-#include <units/units.h>
-
-#include "frc/kinematics/ChassisSpeeds.h"
-#include "frc/kinematics/DifferentialDriveWheelSpeeds.h"
-
-namespace frc {
-/**
- * Helper class that converts a chassis velocity (dx and dtheta components) to
- * left and right wheel velocities for a differential drive.
- *
- * Inverse kinematics converts a desired chassis speed into left and right
- * velocity components whereas forward kinematics converts left and right
- * component velocities into a linear and angular chassis speed.
- */
-class DifferentialDriveKinematics {
- public:
- /**
- * Constructs a differential drive kinematics object.
- *
- * @param trackWidth The track width of the drivetrain. Theoretically, this is
- * the distance between the left wheels and right wheels. However, the
- * empirical value may be larger than the physical measured value due to
- * scrubbing effects.
- */
- explicit DifferentialDriveKinematics(units::meter_t trackWidth)
- : trackWidth(trackWidth) {
- HAL_Report(HALUsageReporting::kResourceType_Kinematics,
- HALUsageReporting::kKinematics_DifferentialDrive);
- }
-
- /**
- * Returns a chassis speed from left and right component velocities using
- * forward kinematics.
- *
- * @param wheelSpeeds The left and right velocities.
- * @return The chassis speed.
- */
- constexpr ChassisSpeeds ToChassisSpeeds(
- const DifferentialDriveWheelSpeeds& wheelSpeeds) const {
- return {(wheelSpeeds.left + wheelSpeeds.right) / 2.0, 0_mps,
- (wheelSpeeds.right - wheelSpeeds.left) / trackWidth * 1_rad};
- }
-
- /**
- * Returns left and right component velocities from a chassis speed using
- * inverse kinematics.
- *
- * @param chassisSpeeds The linear and angular (dx and dtheta) components that
- * represent the chassis' speed.
- * @return The left and right velocities.
- */
- constexpr DifferentialDriveWheelSpeeds ToWheelSpeeds(
- const ChassisSpeeds& chassisSpeeds) const {
- return {chassisSpeeds.vx - trackWidth / 2 * chassisSpeeds.omega / 1_rad,
- chassisSpeeds.vx + trackWidth / 2 * chassisSpeeds.omega / 1_rad};
- }
-
- units::meter_t trackWidth;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveOdometry.h b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveOdometry.h
deleted file mode 100644
index 379839d..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveOdometry.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "DifferentialDriveKinematics.h"
-#include "frc/geometry/Pose2d.h"
-#include "frc2/Timer.h"
-
-namespace frc {
-/**
- * Class for differential drive odometry. Odometry allows you to track the
- * robot's position on the field over the course of a match using readings from
- * 2 encoders and a gyroscope.
- *
- * Teams can use odometry during the autonomous period for complex tasks like
- * path following. Furthermore, odometry can be used for latency compensation
- * when using computer-vision systems.
- *
- * It is important that you reset your encoders to zero before using this class.
- * Any subsequent pose resets also require the encoders to be reset to zero.
- */
-class DifferentialDriveOdometry {
- public:
- /**
- * Constructs a DifferentialDriveOdometry object.
- *
- * @param gyroAngle The angle reported by the gyroscope.
- * @param initialPose The starting position of the robot on the field.
- */
- explicit DifferentialDriveOdometry(const Rotation2d& gyroAngle,
- const Pose2d& initialPose = Pose2d());
-
- /**
- * Resets the robot's position on the field.
- *
- * You NEED to reset your encoders (to zero) when calling this method.
- *
- * The gyroscope angle does not need to be reset here on the user's robot
- * code. The library automatically takes care of offsetting the gyro angle.
- *
- * @param pose The position on the field that your robot is at.
- * @param gyroAngle The angle reported by the gyroscope.
- */
- void ResetPosition(const Pose2d& pose, const Rotation2d& gyroAngle) {
- m_pose = pose;
- m_previousAngle = pose.Rotation();
- m_gyroOffset = m_pose.Rotation() - gyroAngle;
-
- m_prevLeftDistance = 0_m;
- m_prevRightDistance = 0_m;
- }
-
- /**
- * Returns the position of the robot on the field.
- * @return The pose of the robot.
- */
- const Pose2d& GetPose() const { return m_pose; }
-
- /**
- * Updates the robot position on the field using distance measurements from
- * encoders. This method is more numerically accurate than using velocities to
- * integrate the pose and is also advantageous for teams that are using lower
- * CPR encoders.
- *
- * @param gyroAngle The angle reported by the gyroscope.
- * @param leftDistance The distance traveled by the left encoder.
- * @param rightDistance The distance traveled by the right encoder.
- * @return The new pose of the robot.
- */
- const Pose2d& Update(const Rotation2d& gyroAngle, units::meter_t leftDistance,
- units::meter_t rightDistance);
-
- private:
- Pose2d m_pose;
-
- Rotation2d m_gyroOffset;
- Rotation2d m_previousAngle;
-
- units::meter_t m_prevLeftDistance = 0_m;
- units::meter_t m_prevRightDistance = 0_m;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveWheelSpeeds.h b/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveWheelSpeeds.h
deleted file mode 100644
index 66bd84e..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/DifferentialDriveWheelSpeeds.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-namespace frc {
-/**
- * Represents the wheel speeds for a differential drive drivetrain.
- */
-struct DifferentialDriveWheelSpeeds {
- /**
- * Speed of the left side of the robot.
- */
- units::meters_per_second_t left = 0_mps;
-
- /**
- * Speed of the right side of the robot.
- */
- units::meters_per_second_t right = 0_mps;
-
- /**
- * Normalizes the wheel speeds using some max attainable speed. Sometimes,
- * after inverse kinematics, the requested speed from a/several modules may be
- * above the max attainable speed for the driving motor on that module. To fix
- * this issue, one can "normalize" all the wheel speeds to make sure that all
- * requested module speeds are below the absolute threshold, while maintaining
- * the ratio of speeds between modules.
- *
- * @param attainableMaxSpeed The absolute max speed that a wheel can reach.
- */
- void Normalize(units::meters_per_second_t attainableMaxSpeed);
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveKinematics.h b/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveKinematics.h
deleted file mode 100644
index 47b1b34..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveKinematics.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <Eigen/Core>
-#include <Eigen/QR>
-#include <hal/FRCUsageReporting.h>
-
-#include "frc/geometry/Translation2d.h"
-#include "frc/kinematics/ChassisSpeeds.h"
-#include "frc/kinematics/MecanumDriveWheelSpeeds.h"
-
-namespace frc {
-
-/**
- * Helper class that converts a chassis velocity (dx, dy, and dtheta components)
- * into individual wheel speeds.
- *
- * The inverse kinematics (converting from a desired chassis velocity to
- * individual wheel speeds) uses the relative locations of the wheels with
- * respect to the center of rotation. The center of rotation for inverse
- * kinematics is also variable. This means that you can set your set your center
- * of rotation in a corner of the robot to perform special evasion manuevers.
- *
- * Forward kinematics (converting an array of wheel speeds into the overall
- * chassis motion) is performs the exact opposite of what inverse kinematics
- * does. Since this is an overdetermined system (more equations than variables),
- * we use a least-squares approximation.
- *
- * The inverse kinematics: [wheelSpeeds] = [wheelLocations] * [chassisSpeeds]
- * We take the Moore-Penrose pseudoinverse of [wheelLocations] and then
- * multiply by [wheelSpeeds] to get our chassis speeds.
- *
- * Forward kinematics is also used for odometry -- determining the position of
- * the robot on the field using encoders and a gyro.
- */
-class MecanumDriveKinematics {
- public:
- /**
- * Constructs a mecanum drive kinematics object.
- *
- * @param frontLeftWheel The location of the front-left wheel relative to the
- * physical center of the robot.
- * @param frontRightWheel The location of the front-right wheel relative to
- * the physical center of the robot.
- * @param rearLeftWheel The location of the rear-left wheel relative to the
- * physical center of the robot.
- * @param rearRightWheel The location of the rear-right wheel relative to the
- * physical center of the robot.
- */
- explicit MecanumDriveKinematics(Translation2d frontLeftWheel,
- Translation2d frontRightWheel,
- Translation2d rearLeftWheel,
- Translation2d rearRightWheel)
- : m_frontLeftWheel{frontLeftWheel},
- m_frontRightWheel{frontRightWheel},
- m_rearLeftWheel{rearLeftWheel},
- m_rearRightWheel{rearRightWheel} {
- SetInverseKinematics(frontLeftWheel, frontRightWheel, rearLeftWheel,
- rearRightWheel);
- m_forwardKinematics = m_inverseKinematics.householderQr();
- HAL_Report(HALUsageReporting::kResourceType_Kinematics,
- HALUsageReporting::kKinematics_MecanumDrive);
- }
-
- MecanumDriveKinematics(const MecanumDriveKinematics&) = default;
-
- /**
- * Performs inverse kinematics to return the wheel speeds from a desired
- * chassis velocity. This method is often used to convert joystick values into
- * wheel speeds.
- *
- * This function also supports variable centers of rotation. During normal
- * operations, the center of rotation is usually the same as the physical
- * center of the robot; therefore, the argument is defaulted to that use case.
- * However, if you wish to change the center of rotation for evasive
- * manuevers, vision alignment, or for any other use case, you can do so.
- *
- * @param chassisSpeeds The desired chassis speed.
- * @param centerOfRotation The center of rotation. For example, if you set the
- * center of rotation at one corner of the robot and
- * provide a chassis speed that only has a dtheta
- * component, the robot will rotate around that
- * corner.
- *
- * @return The wheel speeds. Use caution because they are not normalized.
- * Sometimes, a user input may cause one of the wheel speeds to go
- * above the attainable max velocity. Use the
- * MecanumDriveWheelSpeeds::Normalize() function to rectify this
- * issue. In addition, you can leverage the power of C++17 to directly
- * assign the wheel speeds to variables:
- *
- * @code{.cpp}
- * auto [fl, fr, bl, br] = kinematics.ToWheelSpeeds(chassisSpeeds);
- * @endcode
- */
- MecanumDriveWheelSpeeds ToWheelSpeeds(
- const ChassisSpeeds& chassisSpeeds,
- const Translation2d& centerOfRotation = Translation2d());
-
- /**
- * Performs forward kinematics to return the resulting chassis state from the
- * given wheel speeds. This method is often used for odometry -- determining
- * the robot's position on the field using data from the real-world speed of
- * each wheel on the robot.
- *
- * @param wheelSpeeds The current mecanum drive wheel speeds.
- *
- * @return The resulting chassis speed.
- */
- ChassisSpeeds ToChassisSpeeds(const MecanumDriveWheelSpeeds& wheelSpeeds);
-
- private:
- Eigen::Matrix<double, 4, 3> m_inverseKinematics;
- Eigen::HouseholderQR<Eigen::Matrix<double, 4, 3>> m_forwardKinematics;
- Translation2d m_frontLeftWheel;
- Translation2d m_frontRightWheel;
- Translation2d m_rearLeftWheel;
- Translation2d m_rearRightWheel;
-
- Translation2d m_previousCoR;
-
- /**
- * Construct inverse kinematics matrix from wheel locations.
- *
- * @param fl The location of the front-left wheel relative to the physical
- * center of the robot.
- * @param fr The location of the front-right wheel relative to the physical
- * center of the robot.
- * @param rl The location of the rear-left wheel relative to the physical
- * center of the robot.
- * @param rr The location of the rear-right wheel relative to the physical
- * center of the robot.
- */
- void SetInverseKinematics(Translation2d fl, Translation2d fr,
- Translation2d rl, Translation2d rr);
-};
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveOdometry.h b/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveOdometry.h
deleted file mode 100644
index 697a6b0..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveOdometry.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "frc/geometry/Pose2d.h"
-#include "frc/kinematics/MecanumDriveKinematics.h"
-#include "frc/kinematics/MecanumDriveWheelSpeeds.h"
-#include "frc2/Timer.h"
-
-namespace frc {
-
-/**
- * Class for mecanum drive odometry. Odometry allows you to track the robot's
- * position on the field over a course of a match using readings from your
- * mecanum wheel encoders.
- *
- * Teams can use odometry during the autonomous period for complex tasks like
- * path following. Furthermore, odometry can be used for latency compensation
- * when using computer-vision systems.
- */
-class MecanumDriveOdometry {
- public:
- /**
- * Constructs a MecanumDriveOdometry object.
- *
- * @param kinematics The mecanum drive kinematics for your drivetrain.
- * @param gyroAngle The angle reported by the gyroscope.
- * @param initialPose The starting position of the robot on the field.
- */
- explicit MecanumDriveOdometry(MecanumDriveKinematics kinematics,
- const Rotation2d& gyroAngle,
- const Pose2d& initialPose = Pose2d());
-
- /**
- * Resets the robot's position on the field.
- *
- * The gyroscope angle does not need to be reset here on the user's robot
- * code. The library automatically takes care of offsetting the gyro angle.
- *
- * @param pose The position on the field that your robot is at.
- * @param gyroAngle The angle reported by the gyroscope.
- */
- void ResetPosition(const Pose2d& pose, const Rotation2d& gyroAngle) {
- m_pose = pose;
- m_previousAngle = pose.Rotation();
- m_gyroOffset = m_pose.Rotation() - gyroAngle;
- }
-
- /**
- * Returns the position of the robot on the field.
- * @return The pose of the robot.
- */
- const Pose2d& GetPose() const { return m_pose; }
-
- /**
- * Updates the robot's position on the field using forward kinematics and
- * integration of the pose over time. This method takes in the current time as
- * a parameter to calculate period (difference between two timestamps). The
- * period is used to calculate the change in distance from a velocity. This
- * also takes in an angle parameter which is used instead of the
- * angular rate that is calculated from forward kinematics.
- *
- * @param currentTime The current time.
- * @param gyroAngle The angle reported by the gyroscope.
- * @param wheelSpeeds The current wheel speeds.
- *
- * @return The new pose of the robot.
- */
- const Pose2d& UpdateWithTime(units::second_t currentTime,
- const Rotation2d& gyroAngle,
- MecanumDriveWheelSpeeds wheelSpeeds);
-
- /**
- * Updates the robot's position on the field using forward kinematics and
- * integration of the pose over time. This method automatically calculates
- * the current time to calculate period (difference between two timestamps).
- * The period is used to calculate the change in distance from a velocity.
- * This also takes in an angle parameter which is used instead of the
- * angular rate that is calculated from forward kinematics.
- *
- * @param gyroAngle The angle reported by the gyroscope.
- * @param wheelSpeeds The current wheel speeds.
- *
- * @return The new pose of the robot.
- */
- const Pose2d& Update(const Rotation2d& gyroAngle,
- MecanumDriveWheelSpeeds wheelSpeeds) {
- return UpdateWithTime(frc2::Timer::GetFPGATimestamp(), gyroAngle,
- wheelSpeeds);
- }
-
- private:
- MecanumDriveKinematics m_kinematics;
- Pose2d m_pose;
-
- units::second_t m_previousTime = -1_s;
- Rotation2d m_previousAngle;
- Rotation2d m_gyroOffset;
-};
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveWheelSpeeds.h b/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveWheelSpeeds.h
deleted file mode 100644
index 159f7f0..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/MecanumDriveWheelSpeeds.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-namespace frc {
-/**
- * Represents the wheel speeds for a mecanum drive drivetrain.
- */
-struct MecanumDriveWheelSpeeds {
- /**
- * Speed of the front-left wheel.
- */
- units::meters_per_second_t frontLeft = 0_mps;
-
- /**
- * Speed of the front-right wheel.
- */
- units::meters_per_second_t frontRight = 0_mps;
-
- /**
- * Speed of the rear-left wheel.
- */
- units::meters_per_second_t rearLeft = 0_mps;
-
- /**
- * Speed of the rear-right wheel.
- */
- units::meters_per_second_t rearRight = 0_mps;
-
- /**
- * Normalizes the wheel speeds using some max attainable speed. Sometimes,
- * after inverse kinematics, the requested speed from a/several modules may be
- * above the max attainable speed for the driving motor on that module. To fix
- * this issue, one can "normalize" all the wheel speeds to make sure that all
- * requested module speeds are below the absolute threshold, while maintaining
- * the ratio of speeds between modules.
- *
- * @param attainableMaxSpeed The absolute max speed that a wheel can reach.
- */
- void Normalize(units::meters_per_second_t attainableMaxSpeed);
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h
deleted file mode 100644
index f889363..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <array>
-#include <cstddef>
-
-#include <Eigen/Core>
-#include <Eigen/QR>
-#include <hal/FRCUsageReporting.h>
-#include <units/units.h>
-
-#include "frc/geometry/Rotation2d.h"
-#include "frc/geometry/Translation2d.h"
-#include "frc/kinematics/ChassisSpeeds.h"
-#include "frc/kinematics/SwerveModuleState.h"
-
-namespace frc {
-/**
- * Helper class that converts a chassis velocity (dx, dy, and dtheta components)
- * into individual module states (speed and angle).
- *
- * The inverse kinematics (converting from a desired chassis velocity to
- * individual module states) uses the relative locations of the modules with
- * respect to the center of rotation. The center of rotation for inverse
- * kinematics is also variable. This means that you can set your set your center
- * of rotation in a corner of the robot to perform special evasion manuevers.
- *
- * Forward kinematics (converting an array of module states into the overall
- * chassis motion) is performs the exact opposite of what inverse kinematics
- * does. Since this is an overdetermined system (more equations than variables),
- * we use a least-squares approximation.
- *
- * The inverse kinematics: [moduleStates] = [moduleLocations] * [chassisSpeeds]
- * We take the Moore-Penrose pseudoinverse of [moduleLocations] and then
- * multiply by [moduleStates] to get our chassis speeds.
- *
- * Forward kinematics is also used for odometry -- determining the position of
- * the robot on the field using encoders and a gyro.
- */
-template <size_t NumModules>
-class SwerveDriveKinematics {
- public:
- /**
- * Constructs a swerve drive kinematics object. This takes in a variable
- * number of wheel locations as Translation2ds. The order in which you pass in
- * the wheel locations is the same order that you will recieve the module
- * states when performing inverse kinematics. It is also expected that you
- * pass in the module states in the same order when calling the forward
- * kinematics methods.
- *
- * @param wheels The locations of the wheels relative to the physical center
- * of the robot.
- */
- template <typename... Wheels>
- explicit SwerveDriveKinematics(Translation2d wheel, Wheels&&... wheels)
- : m_modules{wheel, wheels...} {
- static_assert(sizeof...(wheels) >= 1,
- "A swerve drive requires at least two modules");
-
- for (size_t i = 0; i < NumModules; i++) {
- // clang-format off
- m_inverseKinematics.template block<2, 3>(i * 2, 0) <<
- 1, 0, (-m_modules[i].Y()).template to<double>(),
- 0, 1, (+m_modules[i].X()).template to<double>();
- // clang-format on
- }
-
- m_forwardKinematics = m_inverseKinematics.householderQr();
-
- HAL_Report(HALUsageReporting::kResourceType_Kinematics,
- HALUsageReporting::kKinematics_SwerveDrive);
- }
-
- SwerveDriveKinematics(const SwerveDriveKinematics&) = default;
-
- /**
- * Performs inverse kinematics to return the module states from a desired
- * chassis velocity. This method is often used to convert joystick values into
- * module speeds and angles.
- *
- * This function also supports variable centers of rotation. During normal
- * operations, the center of rotation is usually the same as the physical
- * center of the robot; therefore, the argument is defaulted to that use case.
- * However, if you wish to change the center of rotation for evasive
- * manuevers, vision alignment, or for any other use case, you can do so.
- *
- * @param chassisSpeeds The desired chassis speed.
- * @param centerOfRotation The center of rotation. For example, if you set the
- * center of rotation at one corner of the robot and provide a chassis speed
- * that only has a dtheta component, the robot will rotate around that corner.
- *
- * @return An array containing the module states. Use caution because these
- * module states are not normalized. Sometimes, a user input may cause one of
- * the module speeds to go above the attainable max velocity. Use the
- * <NormalizeWheelSpeeds> function to rectify this issue. In addition, you can
- * leverage the power of C++17 to directly assign the module states to
- * variables:
- *
- * @code{.cpp}
- * auto [fl, fr, bl, br] = kinematics.ToSwerveModuleStates(chassisSpeeds);
- * @endcode
- */
- std::array<SwerveModuleState, NumModules> ToSwerveModuleStates(
- const ChassisSpeeds& chassisSpeeds,
- const Translation2d& centerOfRotation = Translation2d());
-
- /**
- * Performs forward kinematics to return the resulting chassis state from the
- * given module states. This method is often used for odometry -- determining
- * the robot's position on the field using data from the real-world speed and
- * angle of each module on the robot.
- *
- * @param wheelStates The state of the modules (as a SwerveModuleState type)
- * as measured from respective encoders and gyros. The order of the swerve
- * module states should be same as passed into the constructor of this class.
- *
- * @return The resulting chassis speed.
- */
- template <typename... ModuleStates>
- ChassisSpeeds ToChassisSpeeds(ModuleStates&&... wheelStates);
-
- /**
- * Performs forward kinematics to return the resulting chassis state from the
- * given module states. This method is often used for odometry -- determining
- * the robot's position on the field using data from the real-world speed and
- * angle of each module on the robot.
- *
- * @param moduleStates The state of the modules as an std::array of type
- * SwerveModuleState, NumModules long as measured from respective encoders
- * and gyros. The order of the swerve module states should be same as passed
- * into the constructor of this class.
- *
- * @return The resulting chassis speed.
- */
- ChassisSpeeds ToChassisSpeeds(
- std::array<SwerveModuleState, NumModules> moduleStates);
-
- /**
- * Normalizes the wheel speeds using some max attainable speed. Sometimes,
- * after inverse kinematics, the requested speed from a/several modules may be
- * above the max attainable speed for the driving motor on that module. To fix
- * this issue, one can "normalize" all the wheel speeds to make sure that all
- * requested module speeds are below the absolute threshold, while maintaining
- * the ratio of speeds between modules.
- *
- * @param moduleStates Reference to array of module states. The array will be
- * mutated with the normalized speeds!
- * @param attainableMaxSpeed The absolute max speed that a module can reach.
- */
- static void NormalizeWheelSpeeds(
- std::array<SwerveModuleState, NumModules>* moduleStates,
- units::meters_per_second_t attainableMaxSpeed);
-
- private:
- Eigen::Matrix<double, NumModules * 2, 3> m_inverseKinematics;
- Eigen::HouseholderQR<Eigen::Matrix<double, NumModules * 2, 3>>
- m_forwardKinematics;
- std::array<Translation2d, NumModules> m_modules;
-
- Translation2d m_previousCoR;
-};
-} // namespace frc
-
-#include "SwerveDriveKinematics.inc"
diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc
deleted file mode 100644
index b362aa0..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveKinematics.inc
+++ /dev/null
@@ -1,110 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <algorithm>
-
-namespace frc {
-
-template <class... Wheels>
-SwerveDriveKinematics(Translation2d, Wheels...)
- ->SwerveDriveKinematics<1 + sizeof...(Wheels)>;
-
-template <size_t NumModules>
-std::array<SwerveModuleState, NumModules>
-SwerveDriveKinematics<NumModules>::ToSwerveModuleStates(
- const ChassisSpeeds& chassisSpeeds, const Translation2d& centerOfRotation) {
- // We have a new center of rotation. We need to compute the matrix again.
- if (centerOfRotation != m_previousCoR) {
- for (size_t i = 0; i < NumModules; i++) {
- // clang-format off
- m_inverseKinematics.template block<2, 3>(i * 2, 0) <<
- 1, 0, (-m_modules[i].Y() + centerOfRotation.Y()).template to<double>(),
- 0, 1, (+m_modules[i].X() - centerOfRotation.X()).template to<double>();
- // clang-format on
- }
- m_previousCoR = centerOfRotation;
- }
-
- Eigen::Vector3d chassisSpeedsVector;
- chassisSpeedsVector << chassisSpeeds.vx.to<double>(),
- chassisSpeeds.vy.to<double>(), chassisSpeeds.omega.to<double>();
-
- Eigen::Matrix<double, NumModules * 2, 1> moduleStatesMatrix =
- m_inverseKinematics * chassisSpeedsVector;
- std::array<SwerveModuleState, NumModules> moduleStates;
-
- for (size_t i = 0; i < NumModules; i++) {
- units::meters_per_second_t x =
- units::meters_per_second_t{moduleStatesMatrix(i * 2, 0)};
- units::meters_per_second_t y =
- units::meters_per_second_t{moduleStatesMatrix(i * 2 + 1, 0)};
-
- auto speed = units::math::hypot(x, y);
- Rotation2d rotation{x.to<double>(), y.to<double>()};
-
- moduleStates[i] = {speed, rotation};
- }
-
- return moduleStates;
-}
-
-template <size_t NumModules>
-template <typename... ModuleStates>
-ChassisSpeeds SwerveDriveKinematics<NumModules>::ToChassisSpeeds(
- ModuleStates&&... wheelStates) {
- static_assert(sizeof...(wheelStates) == NumModules,
- "Number of modules is not consistent with number of wheel "
- "locations provided in constructor.");
-
- std::array<SwerveModuleState, NumModules> moduleStates{wheelStates...};
-
- return this->ToChassisSpeeds(moduleStates);
-}
-
-template <size_t NumModules>
-ChassisSpeeds SwerveDriveKinematics<NumModules>::ToChassisSpeeds(
- std::array<SwerveModuleState, NumModules> moduleStates) {
- Eigen::Matrix<double, NumModules * 2, 1> moduleStatesMatrix;
-
- for (size_t i = 0; i < NumModules; i++) {
- SwerveModuleState module = moduleStates[i];
- moduleStatesMatrix.row(i * 2)
- << module.speed.to<double>() * module.angle.Cos();
- moduleStatesMatrix.row(i * 2 + 1)
- << module.speed.to<double>() * module.angle.Sin();
- }
-
- Eigen::Vector3d chassisSpeedsVector =
- m_forwardKinematics.solve(moduleStatesMatrix);
-
- return {units::meters_per_second_t{chassisSpeedsVector(0)},
- units::meters_per_second_t{chassisSpeedsVector(1)},
- units::radians_per_second_t{chassisSpeedsVector(2)}};
-}
-
-template <size_t NumModules>
-void SwerveDriveKinematics<NumModules>::NormalizeWheelSpeeds(
- std::array<SwerveModuleState, NumModules>* moduleStates,
- units::meters_per_second_t attainableMaxSpeed) {
- auto& states = *moduleStates;
- auto realMaxSpeed = std::max_element(states.begin(), states.end(),
- [](const auto& a, const auto& b) {
- return units::math::abs(a.speed) <
- units::math::abs(b.speed);
- })
- ->speed;
-
- if (realMaxSpeed > attainableMaxSpeed) {
- for (auto& module : states) {
- module.speed = module.speed / realMaxSpeed * attainableMaxSpeed;
- }
- }
-}
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.h b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.h
deleted file mode 100644
index 8093ca5..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <chrono>
-#include <cstddef>
-#include <ctime>
-
-#include <units/units.h>
-
-#include "SwerveDriveKinematics.h"
-#include "SwerveModuleState.h"
-#include "frc/geometry/Pose2d.h"
-#include "frc2/Timer.h"
-
-namespace frc {
-
-/**
- * Class for swerve drive odometry. Odometry allows you to track the robot's
- * position on the field over a course of a match using readings from your
- * swerve drive encoders and swerve azimuth encoders.
- *
- * Teams can use odometry during the autonomous period for complex tasks like
- * path following. Furthermore, odometry can be used for latency compensation
- * when using computer-vision systems.
- */
-template <size_t NumModules>
-class SwerveDriveOdometry {
- public:
- /**
- * Constructs a SwerveDriveOdometry object.
- *
- * @param kinematics The swerve drive kinematics for your drivetrain.
- * @param gyroAngle The angle reported by the gyroscope.
- * @param initialPose The starting position of the robot on the field.
- */
- SwerveDriveOdometry(SwerveDriveKinematics<NumModules> kinematics,
- const Rotation2d& gyroAngle,
- const Pose2d& initialPose = Pose2d());
-
- /**
- * Resets the robot's position on the field.
- *
- * The gyroscope angle does not need to be reset here on the user's robot
- * code. The library automatically takes care of offsetting the gyro angle.
- *
- * @param pose The position on the field that your robot is at.
- * @param gyroAngle The angle reported by the gyroscope.
- */
- void ResetPosition(const Pose2d& pose, const Rotation2d& gyroAngle) {
- m_pose = pose;
- m_previousAngle = pose.Rotation();
- m_gyroOffset = m_pose.Rotation() - gyroAngle;
- }
-
- /**
- * Returns the position of the robot on the field.
- * @return The pose of the robot.
- */
- const Pose2d& GetPose() const { return m_pose; }
-
- /**
- * Updates the robot's position on the field using forward kinematics and
- * integration of the pose over time. This method takes in the current time as
- * a parameter to calculate period (difference between two timestamps). The
- * period is used to calculate the change in distance from a velocity. This
- * also takes in an angle parameter which is used instead of the
- * angular rate that is calculated from forward kinematics.
- *
- * @param currentTime The current time.
- * @param gyroAngle The angle reported by the gyroscope.
- * @param moduleStates The current state of all swerve modules. Please provide
- * the states in the same order in which you instantiated
- * your SwerveDriveKinematics.
- *
- * @return The new pose of the robot.
- */
- template <typename... ModuleStates>
- const Pose2d& UpdateWithTime(units::second_t currentTime,
- const Rotation2d& gyroAngle,
- ModuleStates&&... moduleStates);
-
- /**
- * Updates the robot's position on the field using forward kinematics and
- * integration of the pose over time. This method automatically calculates
- * the current time to calculate period (difference between two timestamps).
- * The period is used to calculate the change in distance from a velocity.
- * This also takes in an angle parameter which is used instead of the
- * angular rate that is calculated from forward kinematics.
- *
- * @param gyroAngle The angle reported by the gyroscope.
- * @param moduleStates The current state of all swerve modules. Please provide
- * the states in the same order in which you instantiated
- * your SwerveDriveKinematics.
- *
- * @return The new pose of the robot.
- */
- template <typename... ModuleStates>
- const Pose2d& Update(const Rotation2d& gyroAngle,
- ModuleStates&&... moduleStates) {
- return UpdateWithTime(frc2::Timer::GetFPGATimestamp(), gyroAngle,
- moduleStates...);
- }
-
- private:
- SwerveDriveKinematics<NumModules> m_kinematics;
- Pose2d m_pose;
-
- units::second_t m_previousTime = -1_s;
- Rotation2d m_previousAngle;
- Rotation2d m_gyroOffset;
-};
-
-} // namespace frc
-
-#include "SwerveDriveOdometry.inc"
diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.inc b/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.inc
deleted file mode 100644
index e794388..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/SwerveDriveOdometry.inc
+++ /dev/null
@@ -1,46 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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/FRCUsageReporting.h>
-
-namespace frc {
-template <size_t NumModules>
-SwerveDriveOdometry<NumModules>::SwerveDriveOdometry(
- SwerveDriveKinematics<NumModules> kinematics, const Rotation2d& gyroAngle,
- const Pose2d& initialPose)
- : m_kinematics(kinematics), m_pose(initialPose) {
- m_previousAngle = m_pose.Rotation();
- m_gyroOffset = m_pose.Rotation() - gyroAngle;
- HAL_Report(HALUsageReporting::kResourceType_Odometry,
- HALUsageReporting::kOdometry_SwerveDrive);
-}
-
-template <size_t NumModules>
-template <typename... ModuleStates>
-const Pose2d& frc::SwerveDriveOdometry<NumModules>::UpdateWithTime(
- units::second_t currentTime, const Rotation2d& gyroAngle,
- ModuleStates&&... moduleStates) {
- units::second_t deltaTime =
- (m_previousTime >= 0_s) ? currentTime - m_previousTime : 0_s;
- m_previousTime = currentTime;
-
- auto angle = gyroAngle + m_gyroOffset;
-
- auto [dx, dy, dtheta] = m_kinematics.ToChassisSpeeds(moduleStates...);
- static_cast<void>(dtheta);
-
- auto newPose = m_pose.Exp(
- {dx * deltaTime, dy * deltaTime, (angle - m_previousAngle).Radians()});
-
- m_previousAngle = angle;
- m_pose = {newPose.Translation(), angle};
-
- return m_pose;
-}
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/kinematics/SwerveModuleState.h b/wpilibc/src/main/native/include/frc/kinematics/SwerveModuleState.h
deleted file mode 100644
index fbfe0d1..0000000
--- a/wpilibc/src/main/native/include/frc/kinematics/SwerveModuleState.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "frc/geometry/Rotation2d.h"
-
-namespace frc {
-/**
- * Represents the state of one swerve module.
- */
-struct SwerveModuleState {
- /**
- * Speed of the wheel of the module.
- */
- units::meters_per_second_t speed = 0_mps;
-
- /**
- * Angle of the module.
- */
- Rotation2d angle;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h b/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h
index c7e0ec2..b755f46 100644
--- a/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h
+++ b/wpilibc/src/main/native/include/frc/livewindow/LiveWindow.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2012-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2012-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. */
@@ -7,6 +7,7 @@
#pragma once
+#include <functional>
#include <memory>
namespace frc {
@@ -22,6 +23,9 @@
LiveWindow(const LiveWindow&) = delete;
LiveWindow& operator=(const LiveWindow&) = delete;
+ std::function<void()> enabled;
+ std::function<void()> disabled;
+
/**
* Get an instance of the LiveWindow main class.
*
diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h
index 8e666b7..df943b2 100644
--- a/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h
+++ b/wpilibc/src/main/native/include/frc/shuffleboard/BuiltInWidgets.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -144,7 +144,7 @@
* <br>Supported types:
* <ul>
* <li>Number</li>
- * <li>{@link edu.wpi.first.wpilibj.AnalogInput}</li>
+ * <li>AnalogInput</li>
* </ul>
* <br>Custom properties:
* <table>
@@ -163,9 +163,8 @@
*/
kVoltageView,
/**
- * Displays a {@link edu.wpi.first.wpilibj.PowerDistributionPanel
- * PowerDistributionPanel}. <br>Supported types: <ul> <li>{@link
- * edu.wpi.first.wpilibj.PowerDistributionPanel}</li>
+ * Displays a PowerDistributionPanel. <br>Supported types: <ul> <li>
+ * PowerDistributionPanel</li>
* </ul>
* <br>Custom properties:
* <table>
@@ -176,49 +175,49 @@
*/
kPowerDistributionPanel,
/**
- * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser
- * SendableChooser} with a dropdown combo box with a list of options.
+ * Displays a SendableChooser with a dropdown combo box with a list of
+ * options.
* <br>Supported types:
* <ul>
- * <li>{@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser}</li>
+ * <li>SendableChooser</li>
* </ul>
* <br>This widget has no custom properties.
*/
kComboBoxChooser,
/**
- * Displays a {@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser
- * SendableChooser} with a toggle button for each available option.
+ * Displays a SendableChooserwith a toggle button for each available option.
* <br>Supported types:
* <ul>
- * <li>{@link edu.wpi.first.wpilibj.smartdashboard.SendableChooser}</li>
+ * <li>SendableChooser</li>
* </ul>
* <br>This widget has no custom properties.
*/
kSplitButtonChooser,
/**
- * Displays an {@link edu.wpi.first.wpilibj.Encoder} displaying its speed,
- * total travelled distance, and its distance per tick. <br>Supported types:
+ * Displays an Encoder displaying its speed,
+ * total traveled distance, and its distance per tick. <br>Supported types:
* <ul>
- * <li>{@link edu.wpi.first.wpilibj.Encoder}</li>
+ * <li>Encoder</li>
* </ul>
* <br>This widget has no custom properties.
*/
kEncoder,
/**
- * Displays a {@link edu.wpi.first.wpilibj.SpeedController SpeedController}.
+ * Displays a SpeedController.
* The speed controller will be controllable from the dashboard when test mode
* is enabled, but will otherwise be view-only. <br>Supported types: <ul>
- * <li>{@link edu.wpi.first.wpilibj.PWMSpeedController}</li>
- * <li>{@link edu.wpi.first.wpilibj.DMC60}</li>
- * <li>{@link edu.wpi.first.wpilibj.Jaguar}</li>
- * <li>{@link edu.wpi.first.wpilibj.PWMTalonSRX}</li>
- * <li>{@link edu.wpi.first.wpilibj.PWMVictorSPX}</li>
- * <li>{@link edu.wpi.first.wpilibj.SD540}</li>
- * <li>{@link edu.wpi.first.wpilibj.Spark}</li>
- * <li>{@link edu.wpi.first.wpilibj.Talon}</li>
- * <li>{@link edu.wpi.first.wpilibj.Victor}</li>
- * <li>{@link edu.wpi.first.wpilibj.VictorSP}</li>
- * <li>{@link edu.wpi.first.wpilibj.SpeedControllerGroup}</li>
+ * <li>PWMSpeedController</li>
+ * <li>DMC60</li>
+ * <li>Jaguar</li>
+ * <li>PWMTalonSRX</li>
+ * <li>PWMVictorSPX</li>
+ * <li>SD540</li>
+ * <li>Spark</li>
+ * <li>Talon</li>
+ * <li>Victor</li>
+ * <li>VictorSP</li>
+ * <li>SpeedControllerGroup</li>
+ * <li>Any custom subclass of {@code SpeedContorller}</li>
* </ul>
* <br>Custom properties:
* <table>
@@ -231,10 +230,8 @@
/**
* Displays a command with a toggle button. Pressing the button will start the
* command, and the button will automatically release when the command
- * completes. <br>Supported types: <ul> <li>{@link
- * edu.wpi.first.wpilibj.command.Command}</li> <li>{@link
- * edu.wpi.first.wpilibj.command.CommandGroup}</li> <li>Any custom subclass of
- * {@code Command} or {@code CommandGroup}</li>
+ * completes. <br>Supported types: <ul> <li>Command</li> <li>CommandGroup</li>
+ * <li>Any custom subclass of {@code Command} or {@code CommandGroup}</li>
* </ul>
* <br>This widget has no custom properties.
*/
@@ -243,7 +240,7 @@
* Displays a PID command with a checkbox and an editor for the PIDF
* constants. Selecting the checkbox will start the command, and the checkbox
* will automatically deselect when the command completes. <br>Supported
- * types: <ul> <li>{@link edu.wpi.first.wpilibj.command.PIDCommand}</li>
+ * types: <ul> <li>PIDCommand</li>
* <li>Any custom subclass of {@code PIDCommand}</li>
* </ul>
* <br>This widget has no custom properties.
@@ -252,7 +249,7 @@
/**
* Displays a PID controller with an editor for the PIDF constants and a
* toggle switch for enabling and disabling the controller. <br>Supported
- * types: <ul> <li>{@link edu.wpi.first.wpilibj.PIDController}</li>
+ * types: <ul> <li>PIDController</li>
* </ul>
* <br>This widget has no custom properties.
*/
@@ -260,7 +257,7 @@
/**
* Displays an accelerometer with a number bar displaying the magnitude of the
* acceleration and text displaying the exact value. <br>Supported types: <ul>
- * <li>{@link edu.wpi.first.wpilibj.AnalogAccelerometer}</li>
+ * <li>AnalogAccelerometer</li>
* </ul>
* <br>Custom properties:
* <table>
@@ -280,10 +277,8 @@
kAccelerometer,
/**
* Displays a 3-axis accelerometer with a number bar for each axis'
- * accleration. <br>Supported types: <ul> <li>{@link
- * edu.wpi.first.wpilibj.ADXL345_I2C}</li> <li>{@link
- * edu.wpi.first.wpilibj.ADXL345_SPI}</li> <li>{@link
- * edu.wpi.first.wpilibj.ADXL362}</li>
+ * acceleration. <br>Supported types: <ul> <li>ADXL345_I2C</li> <li>
+ * ADXL345_SPI</li> <li>ADXL362</li>
* </ul>
* <br>Custom properties:
* <table>
@@ -302,8 +297,8 @@
* Displays a gyro with a dial from 0 to 360 degrees.
* <br>Supported types:
* <ul>
- * <li>{@link edu.wpi.first.wpilibj.ADXRS450_Gyro}</li>
- * <li>{@link edu.wpi.first.wpilibj.AnalogGyro}</li>
+ * <li>ADXRS450_Gyro</li>
+ * <li>AnalogGyro</li>
* <li>Any custom subclass of {@code GyroBase} (such as a MXP gyro)</li>
* </ul>
* <br>Custom properties:
@@ -319,8 +314,7 @@
kGyro,
/**
* Displays a relay with toggle buttons for each supported mode (off, on,
- * forward, reverse). <br>Supported types: <ul> <li>{@link
- * edu.wpi.first.wpilibj.Relay}</li>
+ * forward, reverse). <br>Supported types: <ul> <li>Relay</li>
* </ul>
* <br>This widget has no custom properties.
*/
@@ -331,7 +325,7 @@
* drivebase. The widget will be controllable if the robot is in test mode.
* <br>Supported types:
* <ul>
- * <li>{@link edu.wpi.first.wpilibj.drive.DifferentialDrive}</li>
+ * <li>DifferentialDrive</li>
* </ul>
* <br>Custom properties:
* <table>
@@ -348,7 +342,7 @@
* Displays a mecanum drive with a widget that displays the speed of each
* wheel, and vectors for the direction and rotation of the drivebase. The
* widget will be controllable if the robot is in test mode. <br>Supported
- * types: <ul> <li>{@link edu.wpi.first.wpilibj.drive.MecanumDrive}</li>
+ * types: <ul> <li>MecanumDrive</li>
* </ul>
* <br>Custom properties:
* <table>
@@ -361,8 +355,7 @@
* Displays a camera stream.
* <br>Supported types:
* <ul>
- * <li>{@link edu.wpi.cscore.VideoSource} (as long as it is streaming on an
- * MJPEG server)</li>
+ * <li>VideoSource (as long as it is streaming on an MJPEG server)</li>
* </ul>
* <br>Custom properties:
* <table>
diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h
index ccbc802..57e4743 100644
--- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h
+++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardEventImportance.h
@@ -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. */
@@ -7,6 +7,8 @@
#pragma once
+#include <wpi/StringRef.h>
+
namespace frc {
// Maintainer note: this enum is mirrored in WPILibJ and in Shuffleboard
diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardInstance.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardInstance.h
index b202160..2be9859 100644
--- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardInstance.h
+++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardInstance.h
@@ -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. */
@@ -20,6 +20,9 @@
explicit ShuffleboardInstance(nt::NetworkTableInstance ntInstance);
virtual ~ShuffleboardInstance();
+ ShuffleboardInstance(ShuffleboardInstance&&) = default;
+ ShuffleboardInstance& operator=(ShuffleboardInstance&&) = default;
+
frc::ShuffleboardTab& GetTab(wpi::StringRef title) override;
void Update() override;
diff --git a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h
index ea92b93..729da40 100644
--- a/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h
+++ b/wpilibc/src/main/native/include/frc/shuffleboard/ShuffleboardWidget.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -62,7 +62,7 @@
* Sets the type of widget used to display the data. If not set, the default
* widget type will be used. This method should only be used to use a widget
* that does not come built into Shuffleboard (i.e. one that comes with a
- * custom or thrid-party plugin). To use a widget that is built into
+ * custom or third-party plugin). To use a widget that is built into
* Shuffleboard, use {@link #withWidget(WidgetType)} and {@link
* BuiltInWidgets}.
*
diff --git a/wpilibc/src/main/native/include/frc/simulation/ADXRS450_GyroSim.h b/wpilibc/src/main/native/include/frc/simulation/ADXRS450_GyroSim.h
new file mode 100644
index 0000000..1d2d2c3
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/ADXRS450_GyroSim.h
@@ -0,0 +1,54 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <hal/SimDevice.h>
+#include <units/angle.h>
+#include <units/angular_velocity.h>
+
+#include "frc/geometry/Rotation2d.h"
+
+namespace frc {
+
+class ADXRS450_Gyro;
+
+namespace sim {
+
+/**
+ * Class to control a simulated ADXRS450 gyroscope.
+ */
+class ADXRS450_GyroSim {
+ public:
+ /**
+ * Constructs from a ADXRS450_Gyro object.
+ *
+ * @param gyro ADXRS450_Gyro to simulate
+ */
+ explicit ADXRS450_GyroSim(const ADXRS450_Gyro& gyro);
+
+ /**
+ * Sets the angle.
+ *
+ * @param angle The angle (clockwise positive).
+ */
+ void SetAngle(units::degree_t angle);
+
+ /**
+ * Sets the angular rate (clockwise positive).
+ *
+ * @param rate The angular rate.
+ */
+ void SetRate(units::degrees_per_second_t rate);
+
+ private:
+ hal::SimDouble m_simAngle;
+ hal::SimDouble m_simRate;
+};
+
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/AddressableLEDSim.h b/wpilibc/src/main/native/include/frc/simulation/AddressableLEDSim.h
new file mode 100644
index 0000000..0c578f4
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/AddressableLEDSim.h
@@ -0,0 +1,99 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+struct HAL_AddressableLEDData;
+
+namespace frc {
+
+class AddressableLED;
+
+namespace sim {
+
+/**
+ * Class to control a simulated addressable LED.
+ */
+class AddressableLEDSim {
+ public:
+ /**
+ * Constructs for the first addressable LED.
+ */
+ AddressableLEDSim();
+
+ /**
+ * Constructs from an AddressableLED object.
+ *
+ * @param addressableLED AddressableLED to simulate
+ */
+ explicit AddressableLEDSim(const AddressableLED& addressableLED);
+
+ /**
+ * Creates an AddressableLEDSim for a PWM channel.
+ *
+ * @param pwmChannel PWM channel
+ * @return Simulated object
+ * @throws std::out_of_range if no AddressableLED is configured for that
+ * channel
+ */
+ static AddressableLEDSim CreateForChannel(int pwmChannel);
+
+ /**
+ * Creates an AddressableLEDSim for a simulated index.
+ * The index is incremented for each simulated AddressableLED.
+ *
+ * @param index simulator index
+ * @return Simulated object
+ */
+ static AddressableLEDSim CreateForIndex(int index);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterOutputPortCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetOutputPort() const;
+
+ void SetOutputPort(int outputPort);
+
+ std::unique_ptr<CallbackStore> RegisterLengthCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ int GetLength() const;
+
+ void SetLength(int length);
+
+ std::unique_ptr<CallbackStore> RegisterRunningCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetRunning() const;
+
+ void SetRunning(bool running);
+
+ std::unique_ptr<CallbackStore> RegisterDataCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ int GetData(struct HAL_AddressableLEDData* data) const;
+
+ void SetData(struct HAL_AddressableLEDData* data, int length);
+
+ private:
+ explicit AddressableLEDSim(int index) : m_index{index} {}
+
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/AnalogEncoderSim.h b/wpilibc/src/main/native/include/frc/simulation/AnalogEncoderSim.h
new file mode 100644
index 0000000..aef979a
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/AnalogEncoderSim.h
@@ -0,0 +1,61 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <hal/SimDevice.h>
+#include <units/angle.h>
+
+#include "frc/geometry/Rotation2d.h"
+
+namespace frc {
+
+class AnalogEncoder;
+
+namespace sim {
+
+/**
+ * Class to control a simulated analog encoder.
+ */
+class AnalogEncoderSim {
+ public:
+ /**
+ * Constructs from an AnalogEncoder object.
+ *
+ * @param encoder AnalogEncoder to simulate
+ */
+ explicit AnalogEncoderSim(const AnalogEncoder& encoder);
+
+ /**
+ * Set the position using an {@link Rotation2d}.
+ *
+ * @param angle The angle.
+ */
+ void SetPosition(Rotation2d angle);
+
+ /**
+ * Set the position of the encoder.
+ *
+ * @param turns The position.
+ */
+ void SetTurns(units::turn_t turns);
+
+ /**
+ * Get the simulated position.
+ */
+ units::turn_t GetTurns();
+
+ /**
+ * Get the position as a {@link Rotation2d}.
+ */
+ Rotation2d GetPosition();
+
+ private:
+ hal::SimDouble m_positionSim;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/AnalogGyroSim.h b/wpilibc/src/main/native/include/frc/simulation/AnalogGyroSim.h
new file mode 100644
index 0000000..685e3ed
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/AnalogGyroSim.h
@@ -0,0 +1,66 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class AnalogGyro;
+
+namespace sim {
+
+/**
+ * Class to control a simulated analog gyro.
+ */
+class AnalogGyroSim {
+ public:
+ /**
+ * Constructs from an AnalogGyro object.
+ *
+ * @param gyro AnalogGyro to simulate
+ */
+ explicit AnalogGyroSim(const AnalogGyro& gyro);
+
+ /**
+ * Constructs from an analog input channel number.
+ *
+ * @param channel Channel number
+ */
+ explicit AnalogGyroSim(int channel);
+
+ std::unique_ptr<CallbackStore> RegisterAngleCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetAngle() const;
+
+ void SetAngle(double angle);
+
+ std::unique_ptr<CallbackStore> RegisterRateCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetRate() const;
+
+ void SetRate(double rate);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/AnalogInputSim.h b/wpilibc/src/main/native/include/frc/simulation/AnalogInputSim.h
new file mode 100644
index 0000000..a52cec4
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/AnalogInputSim.h
@@ -0,0 +1,108 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class AnalogInput;
+
+namespace sim {
+
+/**
+ * Class to control a simulated analog input.
+ */
+class AnalogInputSim {
+ public:
+ /**
+ * Constructs from an AnalogInput object.
+ *
+ * @param analogInput AnalogInput to simulate
+ */
+ explicit AnalogInputSim(const AnalogInput& analogInput);
+
+ /**
+ * Constructs from an analog input channel number.
+ *
+ * @param channel Channel number
+ */
+ explicit AnalogInputSim(int channel);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterAverageBitsCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetAverageBits() const;
+
+ void SetAverageBits(int averageBits);
+
+ std::unique_ptr<CallbackStore> RegisterOversampleBitsCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetOversampleBits() const;
+
+ void SetOversampleBits(int oversampleBits);
+
+ std::unique_ptr<CallbackStore> RegisterVoltageCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetVoltage() const;
+
+ void SetVoltage(double voltage);
+
+ std::unique_ptr<CallbackStore> RegisterAccumulatorInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetAccumulatorInitialized() const;
+
+ void SetAccumulatorInitialized(bool accumulatorInitialized);
+
+ std::unique_ptr<CallbackStore> RegisterAccumulatorValueCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int64_t GetAccumulatorValue() const;
+
+ void SetAccumulatorValue(int64_t accumulatorValue);
+
+ std::unique_ptr<CallbackStore> RegisterAccumulatorCountCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int64_t GetAccumulatorCount() const;
+
+ void SetAccumulatorCount(int64_t accumulatorCount);
+
+ std::unique_ptr<CallbackStore> RegisterAccumulatorCenterCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetAccumulatorCenter() const;
+
+ void SetAccumulatorCenter(int accumulatorCenter);
+
+ std::unique_ptr<CallbackStore> RegisterAccumulatorDeadbandCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetAccumulatorDeadband() const;
+
+ void SetAccumulatorDeadband(int accumulatorDeadband);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/AnalogOutputSim.h b/wpilibc/src/main/native/include/frc/simulation/AnalogOutputSim.h
new file mode 100644
index 0000000..e468fa5
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/AnalogOutputSim.h
@@ -0,0 +1,59 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class AnalogOutput;
+
+namespace sim {
+
+/**
+ * Class to control a simulated analog output.
+ */
+class AnalogOutputSim {
+ public:
+ /**
+ * Constructs from an AnalogOutput object.
+ *
+ * @param analogOutput AnalogOutput to simulate
+ */
+ explicit AnalogOutputSim(const AnalogOutput& analogOutput);
+
+ /**
+ * Constructs from an analog output channel number.
+ *
+ * @param channel Channel number
+ */
+ explicit AnalogOutputSim(int channel);
+
+ std::unique_ptr<CallbackStore> RegisterVoltageCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetVoltage() const;
+
+ void SetVoltage(double voltage);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/AnalogTriggerSim.h b/wpilibc/src/main/native/include/frc/simulation/AnalogTriggerSim.h
new file mode 100644
index 0000000..60d62e1
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/AnalogTriggerSim.h
@@ -0,0 +1,80 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class AnalogTrigger;
+
+namespace sim {
+
+/**
+ * Class to control a simulated analog trigger.
+ */
+class AnalogTriggerSim {
+ public:
+ /**
+ * Constructs from an AnalogTrigger object.
+ *
+ * @param analogTrigger AnalogTrigger to simulate
+ */
+ explicit AnalogTriggerSim(const AnalogTrigger& analogTrigger);
+
+ /**
+ * Creates an AnalogTriggerSim for an analog input channel.
+ *
+ * @param channel analog input channel
+ * @return Simulated object
+ * @throws std::out_of_range if no AnalogTrigger is configured for that
+ * channel
+ */
+ static AnalogTriggerSim CreateForChannel(int channel);
+
+ /**
+ * Creates an AnalogTriggerSim for a simulated index.
+ * The index is incremented for each simulated AnalogTrigger.
+ *
+ * @param index simulator index
+ * @return Simulated object
+ */
+ static AnalogTriggerSim CreateForIndex(int index);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterTriggerLowerBoundCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetTriggerLowerBound() const;
+
+ void SetTriggerLowerBound(double triggerLowerBound);
+
+ std::unique_ptr<CallbackStore> RegisterTriggerUpperBoundCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetTriggerUpperBound() const;
+
+ void SetTriggerUpperBound(double triggerUpperBound);
+
+ void ResetData();
+
+ private:
+ explicit AnalogTriggerSim(int index) : m_index{index} {}
+
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/BatterySim.h b/wpilibc/src/main/native/include/frc/simulation/BatterySim.h
new file mode 100644
index 0000000..ef8fb5d
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/BatterySim.h
@@ -0,0 +1,55 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <numeric>
+
+#include <units/current.h>
+#include <units/impedance.h>
+#include <units/voltage.h>
+
+namespace frc::sim {
+
+class BatterySim {
+ public:
+ /**
+ * Calculate the loaded battery voltage. Use this with
+ * {@link RoboRioSim#setVInVoltage(double)} to set the simulated battery
+ * voltage, which can then be retrieved with the {@link
+ * RobotController#getBatteryVoltage()} method.
+ *
+ * @param nominalVoltage The nominal battery voltage. Usually 12v.
+ * @param resistance The forward resistance of the battery. Most batteries
+ * are at or below 20 milliohms.
+ * @param currents The currents drawn from the battery.
+ * @return The battery's voltage under load.
+ */
+ static units::volt_t Calculate(
+ units::volt_t nominalVoltage, units::ohm_t resistance,
+ std::initializer_list<units::ampere_t> currents) {
+ return nominalVoltage -
+ std::accumulate(currents.begin(), currents.end(), 0_A) * resistance;
+ }
+
+ /**
+ * Calculate the loaded battery voltage. Use this with
+ * {@link RoboRioSim#setVInVoltage(double)} to set the simulated battery
+ * voltage, which can then be retrieved with the {@link
+ * RobotController#getBatteryVoltage()} method. This function assumes a
+ * nominal voltage of 12v and a resistance of 20 milliohms (0.020 ohms)
+ *
+ * @param currents The currents drawn from the battery.
+ * @return The battery's voltage under load.
+ */
+ static units::volt_t Calculate(
+ std::initializer_list<units::ampere_t> currents) {
+ return Calculate(12_V, 0.02_Ohm, currents);
+ }
+};
+
+} // namespace frc::sim
diff --git a/wpilibc/src/main/native/include/frc/simulation/BuiltInAccelerometerSim.h b/wpilibc/src/main/native/include/frc/simulation/BuiltInAccelerometerSim.h
new file mode 100644
index 0000000..49a581c
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/BuiltInAccelerometerSim.h
@@ -0,0 +1,80 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include <hal/Accelerometer.h>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class BuiltInAccelerometer;
+
+namespace sim {
+
+/**
+ * Class to control a simulated built-in accelerometer.
+ */
+class BuiltInAccelerometerSim {
+ public:
+ /**
+ * Constructs for the first built-in accelerometer.
+ */
+ BuiltInAccelerometerSim();
+
+ /**
+ * Constructs from a BuiltInAccelerometer object.
+ *
+ * @param accel BuiltInAccelerometer to simulate
+ */
+ explicit BuiltInAccelerometerSim(const BuiltInAccelerometer& accel);
+
+ std::unique_ptr<CallbackStore> RegisterActiveCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ bool GetActive() const;
+
+ void SetActive(bool active);
+
+ std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ HAL_AccelerometerRange GetRange() const;
+
+ void SetRange(HAL_AccelerometerRange range);
+
+ std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetX() const;
+
+ void SetX(double x);
+
+ std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetY() const;
+
+ void SetY(double y);
+
+ std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetZ() const;
+
+ void SetZ(double z);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/CallbackStore.h b/wpilibc/src/main/native/include/frc/simulation/CallbackStore.h
new file mode 100644
index 0000000..379296a
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/CallbackStore.h
@@ -0,0 +1,80 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <functional>
+
+#include <hal/Value.h>
+#include <wpi/StringRef.h>
+
+namespace frc {
+namespace sim {
+
+using NotifyCallback = std::function<void(wpi::StringRef, const HAL_Value*)>;
+using ConstBufferCallback = std::function<void(
+ wpi::StringRef, const unsigned char* buffer, unsigned int count)>;
+typedef void (*CancelCallbackFunc)(int32_t index, int32_t uid);
+typedef void (*CancelCallbackNoIndexFunc)(int32_t uid);
+typedef void (*CancelCallbackChannelFunc)(int32_t index, int32_t channel,
+ int32_t uid);
+
+void CallbackStoreThunk(const char* name, void* param, const HAL_Value* value);
+void ConstBufferCallbackStoreThunk(const char* name, void* param,
+ const unsigned char* buffer,
+ unsigned int count);
+
+class CallbackStore {
+ public:
+ CallbackStore(int32_t i, NotifyCallback cb, CancelCallbackNoIndexFunc ccf);
+
+ CallbackStore(int32_t i, int32_t u, NotifyCallback cb,
+ CancelCallbackFunc ccf);
+
+ CallbackStore(int32_t i, int32_t c, int32_t u, NotifyCallback cb,
+ CancelCallbackChannelFunc ccf);
+
+ CallbackStore(int32_t i, ConstBufferCallback cb,
+ CancelCallbackNoIndexFunc ccf);
+
+ CallbackStore(int32_t i, int32_t u, ConstBufferCallback cb,
+ CancelCallbackFunc ccf);
+
+ CallbackStore(int32_t i, int32_t c, int32_t u, ConstBufferCallback cb,
+ CancelCallbackChannelFunc ccf);
+
+ CallbackStore(const CallbackStore&) = delete;
+ CallbackStore& operator=(const CallbackStore&) = delete;
+
+ ~CallbackStore();
+
+ void SetUid(int32_t uid);
+
+ friend void CallbackStoreThunk(const char* name, void* param,
+ const HAL_Value* value);
+
+ friend void ConstBufferCallbackStoreThunk(const char* name, void* param,
+ const unsigned char* buffer,
+ unsigned int count);
+
+ private:
+ int32_t index;
+ int32_t channel;
+ int32_t uid;
+
+ NotifyCallback callback;
+ ConstBufferCallback constBufferCallback;
+ union {
+ CancelCallbackFunc ccf;
+ CancelCallbackChannelFunc cccf;
+ CancelCallbackNoIndexFunc ccnif;
+ };
+ enum CancelType { Normal, Channel, NoIndex };
+ CancelType cancelType;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/DIOSim.h b/wpilibc/src/main/native/include/frc/simulation/DIOSim.h
new file mode 100644
index 0000000..f6edb39
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/DIOSim.h
@@ -0,0 +1,88 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class DigitalInput;
+class DigitalOutput;
+
+namespace sim {
+
+/**
+ * Class to control a simulated digital input or output.
+ */
+class DIOSim {
+ public:
+ /**
+ * Constructs from a DigitalInput object.
+ *
+ * @param input DigitalInput to simulate
+ */
+ explicit DIOSim(const DigitalInput& input);
+
+ /**
+ * Constructs from a DigitalOutput object.
+ *
+ * @param output DigitalOutput to simulate
+ */
+ explicit DIOSim(const DigitalOutput& output);
+
+ /**
+ * Constructs from an digital I/O channel number.
+ *
+ * @param channel Channel number
+ */
+ explicit DIOSim(int channel);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterValueCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ bool GetValue() const;
+
+ void SetValue(bool value);
+
+ std::unique_ptr<CallbackStore> RegisterPulseLengthCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetPulseLength() const;
+
+ void SetPulseLength(double pulseLength);
+
+ std::unique_ptr<CallbackStore> RegisterIsInputCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetIsInput() const;
+
+ void SetIsInput(bool isInput);
+
+ std::unique_ptr<CallbackStore> RegisterFilterIndexCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetFilterIndex() const;
+
+ void SetFilterIndex(int filterIndex);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h
new file mode 100644
index 0000000..a75edb9
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/DifferentialDrivetrainSim.h
@@ -0,0 +1,235 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <frc/kinematics/DifferentialDriveKinematics.h>
+#include <frc/system/LinearSystem.h>
+#include <frc/system/plant/DCMotor.h>
+
+#include <Eigen/Core>
+#include <units/length.h>
+#include <units/moment_of_inertia.h>
+#include <units/time.h>
+#include <units/voltage.h>
+
+namespace frc::sim {
+
+class DifferentialDrivetrainSim {
+ public:
+ /**
+ * Create a SimDrivetrain.
+ *
+ * @param drivetrainPlant The LinearSystem representing the robot's
+ * drivetrain. This system can be created with
+ * LinearSystemId#createDrivetrainVelocitySystem or
+ * LinearSystemId#identifyDrivetrainSystem.
+ * @param trackWidth The robot's track width.
+ * @param driveMotor A {@link DCMotor} representing the left side of
+ * the drivetrain.
+ * @param gearingRatio The gearingRatio ratio of the left side, as output
+ * over input. This must be the same ratio as the ratio used to identify or
+ * create the drivetrainPlant.
+ * @param wheelRadiusMeters The radius of the wheels on the drivetrain, in
+ * meters.
+ */
+ DifferentialDrivetrainSim(const LinearSystem<2, 2, 2>& plant,
+ units::meter_t trackWidth, DCMotor driveMotor,
+ double gearingRatio, units::meter_t wheelRadius);
+
+ /**
+ * Create a SimDrivetrain.
+ *
+ * @param driveMotor A {@link DCMotor} representing the left side of the
+ * drivetrain.
+ * @param gearing The gearing on the drive between motor and wheel, as
+ * output over input. This must be the same ratio as the ratio used to
+ * identify or create the drivetrainPlant.
+ * @param J The moment of inertia of the drivetrain about its
+ * center.
+ * @param mass The mass of the drivebase.
+ * @param wheelRadius The radius of the wheels on the drivetrain.
+ * @param trackWidth The robot's track width, or distance between left and
+ * right wheels.
+ */
+ DifferentialDrivetrainSim(frc::DCMotor driveMotor, double gearing,
+ units::kilogram_square_meter_t J,
+ units::kilogram_t mass, units::meter_t wheelRadius,
+ units::meter_t trackWidth);
+
+ /**
+ * Sets the applied voltage to the drivetrain. Note that positive voltage must
+ * make that side of the drivetrain travel forward (+X).
+ *
+ * @param leftVoltage The left voltage.
+ * @param rightVoltage The right voltage.
+ */
+ void SetInputs(units::volt_t leftVoltage, units::volt_t rightVoltage);
+
+ /**
+ * Sets the gearing reduction on the drivetrain. This is commonly used for
+ * shifting drivetrains.
+ *
+ * @param newGearing The new gear ratio, as output over input.
+ */
+ void SetGearing(double newGearing);
+
+ /**
+ * Updates the simulation.
+ *
+ * @param dt The time that's passed since the last {@link #update(double)}
+ * call.
+ */
+ void Update(units::second_t dt);
+
+ /**
+ * Returns an element of the state vector.
+ *
+ * @param state The row of the state vector.
+ */
+ double GetState(int state) const;
+
+ /**
+ * Returns the current gearing reduction of the drivetrain, as output over
+ * input.
+ */
+ double GetGearing() const;
+
+ /**
+ * Returns the current state vector x.
+ */
+ Eigen::Matrix<double, 7, 1> GetState() const;
+
+ /**
+ * Returns the direction the robot is pointing.
+ *
+ * Note that this angle is counterclockwise-positive, while most gyros are
+ * clockwise positive.
+ */
+ Rotation2d GetHeading() const;
+
+ /**
+ * Returns the current pose.
+ */
+ Pose2d GetPose() const;
+
+ /**
+ * Returns the currently drawn current.
+ */
+ units::ampere_t GetCurrentDraw() const;
+
+ /**
+ * Sets the system state.
+ *
+ * @param state The state.
+ */
+ void SetState(const Eigen::Matrix<double, 7, 1>& state);
+
+ /**
+ * Sets the system pose.
+ *
+ * @param pose The pose.
+ */
+ void SetPose(const frc::Pose2d& pose);
+
+ Eigen::Matrix<double, 7, 1> Dynamics(const Eigen::Matrix<double, 7, 1>& x,
+ const Eigen::Matrix<double, 2, 1>& u);
+
+ class State {
+ public:
+ static constexpr int kX = 0;
+ static constexpr int kY = 1;
+ static constexpr int kHeading = 2;
+ static constexpr int kLeftVelocity = 3;
+ static constexpr int kRightVelocity = 4;
+ static constexpr int kLeftPosition = 5;
+ static constexpr int kRightPosition = 6;
+ };
+
+ /**
+ * Represents a gearing option of the Toughbox mini.
+ * 12.75:1 -- 14:50 and 14:50
+ * 10.71:1 -- 14:50 and 16:48
+ * 8.45:1 -- 14:50 and 19:45
+ * 7.31:1 -- 14:50 and 21:43
+ * 5.95:1 -- 14:50 and 24:40
+ */
+ class KitbotGearing {
+ public:
+ static constexpr double k12p75 = 12.75;
+ static constexpr double k10p71 = 10.71;
+ static constexpr double k8p45 = 8.45;
+ static constexpr double k7p31 = 7.31;
+ static constexpr double k5p95 = 5.95;
+ };
+
+ class KitbotMotor {
+ public:
+ static constexpr frc::DCMotor SingleCIMPerSide = frc::DCMotor::CIM(1);
+ static constexpr frc::DCMotor DualCIMPerSide = frc::DCMotor::CIM(2);
+ static constexpr frc::DCMotor SingleMiniCIMPerSide =
+ frc::DCMotor::MiniCIM(1);
+ static constexpr frc::DCMotor DualMiniCIMPerSide = frc::DCMotor::MiniCIM(2);
+ };
+
+ class KitbotWheelSize {
+ public:
+ static constexpr units::meter_t kSixInch = 6_in;
+ static constexpr units::meter_t kEightInch = 8_in;
+ static constexpr units::meter_t kTenInch = 10_in;
+ };
+
+ /**
+ * Create a sim for the standard FRC kitbot.
+ *
+ * @param motor The motors installed in the bot.
+ * @param gearing The gearing reduction used.
+ * @param wheelSize The wheel size.
+ */
+ static DifferentialDrivetrainSim CreateKitbotSim(frc::DCMotor motor,
+ double gearing,
+ units::meter_t wheelSize) {
+ // MOI estimation -- note that I = m r^2 for point masses
+ units::kilogram_square_meter_t batteryMoi = 12.5_lb * 10_in * 10_in;
+ units::kilogram_square_meter_t gearboxMoi = (2.8_lb + 2.0_lb) *
+ 2 // CIM plus toughbox per side
+ * (26_in / 2) * (26_in / 2);
+
+ return DifferentialDrivetrainSim{
+ motor, gearing, batteryMoi + gearboxMoi, 25_kg, wheelSize / 2.0, 26_in};
+ }
+
+ /**
+ * Create a sim for the standard FRC kitbot.
+ *
+ * @param motor The motors installed in the bot.
+ * @param gearing The gearing reduction used.
+ * @param wheelSize The wheel size.
+ * @param J The moment of inertia of the drivebase. This can be
+ * calculated using frc-characterization.
+ */
+ static DifferentialDrivetrainSim CreateKitbotSim(
+ frc::DCMotor motor, double gearing, units::meter_t wheelSize,
+ units::kilogram_square_meter_t J) {
+ return DifferentialDrivetrainSim{motor, gearing, J,
+ 25_kg, wheelSize / 2.0, 26_in};
+ }
+
+ private:
+ LinearSystem<2, 2, 2> m_plant;
+ units::meter_t m_rb;
+ units::meter_t m_wheelRadius;
+
+ DCMotor m_motor;
+
+ double m_originalGearing;
+ double m_currentGearing;
+
+ Eigen::Matrix<double, 7, 1> m_x;
+ Eigen::Matrix<double, 2, 1> m_u;
+};
+} // namespace frc::sim
diff --git a/wpilibc/src/main/native/include/frc/simulation/DigitalPWMSim.h b/wpilibc/src/main/native/include/frc/simulation/DigitalPWMSim.h
new file mode 100644
index 0000000..2ff8a12
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/DigitalPWMSim.h
@@ -0,0 +1,82 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class DigitalOutput;
+
+namespace sim {
+
+/**
+ * Class to control a simulated digital PWM output.
+ *
+ * This is for duty cycle PWM outputs on a DigitalOutput, not for the servo
+ * style PWM outputs on a PWM channel.
+ */
+class DigitalPWMSim {
+ public:
+ /**
+ * Constructs from a DigitalOutput object.
+ *
+ * @param digitalOutput DigitalOutput to simulate
+ */
+ explicit DigitalPWMSim(const DigitalOutput& digitalOutput);
+
+ /**
+ * Creates an DigitalPWMSim for a digital I/O channel.
+ *
+ * @param channel DIO channel
+ * @return Simulated object
+ * @throws std::out_of_range if no Digital PWM is configured for that channel
+ */
+ static DigitalPWMSim CreateForChannel(int channel);
+
+ /**
+ * Creates an DigitalPWMSim for a simulated index.
+ * The index is incremented for each simulated DigitalPWM.
+ *
+ * @param index simulator index
+ * @return Simulated object
+ */
+ static DigitalPWMSim CreateForIndex(int index);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterDutyCycleCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetDutyCycle() const;
+
+ void SetDutyCycle(double dutyCycle);
+
+ std::unique_ptr<CallbackStore> RegisterPinCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ int GetPin() const;
+
+ void SetPin(int pin);
+
+ void ResetData();
+
+ private:
+ explicit DigitalPWMSim(int index) : m_index{index} {}
+
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/DriverStationSim.h b/wpilibc/src/main/native/include/frc/simulation/DriverStationSim.h
new file mode 100644
index 0000000..80cf942
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/DriverStationSim.h
@@ -0,0 +1,248 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include <hal/DriverStationTypes.h>
+
+#include "frc/DriverStation.h"
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+namespace sim {
+
+/**
+ * Class to control a simulated driver station.
+ */
+class DriverStationSim {
+ public:
+ static std::unique_ptr<CallbackStore> RegisterEnabledCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetEnabled();
+
+ static void SetEnabled(bool enabled);
+
+ static std::unique_ptr<CallbackStore> RegisterAutonomousCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetAutonomous();
+
+ static void SetAutonomous(bool autonomous);
+
+ static std::unique_ptr<CallbackStore> RegisterTestCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetTest();
+
+ static void SetTest(bool test);
+
+ static std::unique_ptr<CallbackStore> RegisterEStopCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetEStop();
+
+ static void SetEStop(bool eStop);
+
+ static std::unique_ptr<CallbackStore> RegisterFmsAttachedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetFmsAttached();
+
+ static void SetFmsAttached(bool fmsAttached);
+
+ static std::unique_ptr<CallbackStore> RegisterDsAttachedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetDsAttached();
+
+ static void SetDsAttached(bool dsAttached);
+
+ static std::unique_ptr<CallbackStore> RegisterAllianceStationIdCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static HAL_AllianceStationID GetAllianceStationId();
+
+ static void SetAllianceStationId(HAL_AllianceStationID allianceStationId);
+
+ static std::unique_ptr<CallbackStore> RegisterMatchTimeCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static double GetMatchTime();
+
+ static void SetMatchTime(double matchTime);
+
+ /**
+ * Updates DriverStation data so that new values are visible to the user
+ * program.
+ */
+ static void NotifyNewData();
+
+ /**
+ * Sets suppression of DriverStation::ReportError and ReportWarning messages.
+ *
+ * @param shouldSend If false then messages will be suppressed.
+ */
+ static void SetSendError(bool shouldSend);
+
+ /**
+ * Sets suppression of DriverStation::SendConsoleLine messages.
+ *
+ * @param shouldSend If false then messages will be suppressed.
+ */
+ static void SetSendConsoleLine(bool shouldSend);
+
+ /**
+ * Gets the joystick outputs.
+ *
+ * @param stick The joystick number
+ * @return The joystick outputs
+ */
+ static int64_t GetJoystickOutputs(int stick);
+
+ /**
+ * Gets the joystick rumble.
+ *
+ * @param stick The joystick number
+ * @param rumbleNum Rumble to get (0=left, 1=right)
+ * @return The joystick rumble value
+ */
+ static int GetJoystickRumble(int stick, int rumbleNum);
+
+ /**
+ * Sets the state of one joystick button. Button indexes begin at 1.
+ *
+ * @param stick The joystick number
+ * @param button The button index, beginning at 1
+ * @param state The state of the joystick button
+ */
+ static void SetJoystickButton(int stick, int button, bool state);
+
+ /**
+ * Gets the value of the axis on a joystick.
+ *
+ * @param stick The joystick number
+ * @param axis The analog axis number
+ * @param value The value of the axis on the joystick
+ */
+ static void SetJoystickAxis(int stick, int axis, double value);
+
+ /**
+ * Gets the state of a POV on a joystick.
+ *
+ * @param stick The joystick number
+ * @param pov The POV number
+ * @param value the angle of the POV in degrees, or -1 for not pressed
+ */
+ static void SetJoystickPOV(int stick, int pov, int value);
+
+ /**
+ * Sets the state of all the buttons on a joystick.
+ *
+ * @param stick The joystick number
+ * @param buttons The bitmap state of the buttons on the joystick
+ */
+ static void SetJoystickButtons(int stick, uint32_t buttons);
+
+ /**
+ * Sets the number of axes for a joystick.
+ *
+ * @param stick The joystick number
+ * @param count The number of axes on the indicated joystick
+ */
+ static void SetJoystickAxisCount(int stick, int count);
+
+ /**
+ * Sets the number of POVs for a joystick.
+ *
+ * @param stick The joystick number
+ * @param count The number of POVs on the indicated joystick
+ */
+ static void SetJoystickPOVCount(int stick, int count);
+
+ /**
+ * Sets the number of buttons for a joystick.
+ *
+ * @param stick The joystick number
+ * @param count The number of buttons on the indicated joystick
+ */
+ static void SetJoystickButtonCount(int stick, int count);
+
+ /**
+ * Sets the value of isXbox for a joystick.
+ *
+ * @param stick The joystick number
+ * @param isXbox The value of isXbox
+ */
+ static void SetJoystickIsXbox(int stick, bool isXbox);
+
+ /**
+ * Sets the value of type for a joystick.
+ *
+ * @param stick The joystick number
+ * @param type The value of type
+ */
+ static void SetJoystickType(int stick, int type);
+
+ /**
+ * Sets the name of a joystick.
+ *
+ * @param stick The joystick number
+ * @param name The value of name
+ */
+ static void SetJoystickName(int stick, const char* name);
+
+ /**
+ * Sets the types of Axes for a joystick.
+ *
+ * @param stick The joystick number
+ * @param axis The target axis
+ * @param type The type of axis
+ */
+ static void SetJoystickAxisType(int stick, int axis, int type);
+
+ /**
+ * Sets the game specific message.
+ *
+ * @param message the game specific message
+ */
+ static void SetGameSpecificMessage(const char* message);
+
+ /**
+ * Sets the event name.
+ *
+ * @param name the event name
+ */
+ static void SetEventName(const char* name);
+
+ /**
+ * Sets the match type.
+ *
+ * @param type the match type
+ */
+ static void SetMatchType(DriverStation::MatchType type);
+
+ /**
+ * Sets the match number.
+ *
+ * @param matchNumber the match number
+ */
+ static void SetMatchNumber(int matchNumber);
+
+ /**
+ * Sets the replay number.
+ *
+ * @param replayNumber the replay number
+ */
+ static void SetReplayNumber(int replayNumber);
+
+ static void ResetData();
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/DutyCycleEncoderSim.h b/wpilibc/src/main/native/include/frc/simulation/DutyCycleEncoderSim.h
new file mode 100644
index 0000000..5d9a039
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/DutyCycleEncoderSim.h
@@ -0,0 +1,49 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <hal/SimDevice.h>
+#include <units/angle.h>
+
+namespace frc {
+
+class DutyCycleEncoder;
+
+namespace sim {
+
+/**
+ * Class to control a simulated duty cycle encoder.
+ */
+class DutyCycleEncoderSim {
+ public:
+ /**
+ * Constructs from a DutyCycleEncoder object.
+ *
+ * @param dutyCycleEncoder DutyCycleEncoder to simulate
+ */
+ explicit DutyCycleEncoderSim(const DutyCycleEncoder& encoder);
+
+ /**
+ * Set the position tin turns.
+ *
+ * @param turns The position.
+ */
+ void Set(units::turn_t turns);
+
+ /**
+ * Set the position.
+ */
+ void SetDistance(double distance);
+
+ private:
+ hal::SimDouble m_simPosition;
+ hal::SimDouble m_simDistancePerRotation;
+};
+
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/DutyCycleSim.h b/wpilibc/src/main/native/include/frc/simulation/DutyCycleSim.h
new file mode 100644
index 0000000..40dad13
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/DutyCycleSim.h
@@ -0,0 +1,79 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class DutyCycle;
+
+namespace sim {
+
+/**
+ * Class to control a simulated duty cycle digital input.
+ */
+class DutyCycleSim {
+ public:
+ /**
+ * Constructs from a DutyCycle object.
+ *
+ * @param dutyCycle DutyCycle to simulate
+ */
+ explicit DutyCycleSim(const DutyCycle& dutyCycle);
+
+ /**
+ * Creates a DutyCycleSim for a digital input channel.
+ *
+ * @param channel digital input channel
+ * @return Simulated object
+ * @throws std::out_of_range if no DutyCycle is configured for that channel
+ */
+ static DutyCycleSim CreateForChannel(int channel);
+
+ /**
+ * Creates a DutyCycleSim for a simulated index.
+ * The index is incremented for each simulated DutyCycle.
+ *
+ * @param index simulator index
+ * @return Simulated object
+ */
+ static DutyCycleSim CreateForIndex(int index);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterFrequencyCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetFrequency() const;
+
+ void SetFrequency(int count);
+
+ std::unique_ptr<CallbackStore> RegisterOutputCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetOutput() const;
+
+ void SetOutput(double period);
+
+ void ResetData();
+
+ private:
+ explicit DutyCycleSim(int index) : m_index{index} {}
+
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/ElevatorSim.h b/wpilibc/src/main/native/include/frc/simulation/ElevatorSim.h
new file mode 100644
index 0000000..9b7069f
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/ElevatorSim.h
@@ -0,0 +1,126 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <array>
+
+#include <units/length.h>
+#include <units/mass.h>
+#include <units/velocity.h>
+
+#include "frc/simulation/LinearSystemSim.h"
+#include "frc/system/plant/DCMotor.h"
+
+namespace frc::sim {
+/**
+ * Represents a simulated elevator mechanism.
+ */
+class ElevatorSim : public LinearSystemSim<2, 1, 1> {
+ public:
+ /**
+ * Constructs a simulated elevator mechanism.
+ *
+ * @param plant The linear system that represents the elevator.
+ * @param gearbox The type of and number of motors in your
+ * elevator gearbox.
+ * @param gearing The gearing of the elevator (numbers greater
+ * than 1 represent reductions).
+ * @param drumRadius The radius of the drum that your cable is
+ * wrapped around.
+ * @param minHeight The minimum allowed height of the elevator.
+ * @param maxHeight The maximum allowed height of the elevator.
+ * @param measurementStdDevs The standard deviation of the measurements.
+ */
+ ElevatorSim(const LinearSystem<2, 1, 1>& plant, const DCMotor& gearbox,
+ double gearing, units::meter_t drumRadius,
+ units::meter_t minHeight, units::meter_t maxHeight,
+ const std::array<double, 1>& measurementStdDevs = {0.0});
+
+ /**
+ * Constructs a simulated elevator mechanism.
+ *
+ * @param gearbox The type of and number of motors in your
+ * elevator gearbox.
+ * @param gearing The gearing of the elevator (numbers greater
+ * than 1 represent reductions).
+ * @param carriageMass The mass of the elevator carriage.
+ * @param drumRadius The radius of the drum that your cable is
+ * wrapped around.
+ * @param minHeight The minimum allowed height of the elevator.
+ * @param maxHeight The maximum allowed height of the elevator.
+ * @param measurementStdDevs The standard deviation of the measurements.
+ */
+ ElevatorSim(const DCMotor& gearbox, double gearing,
+ units::kilogram_t carriageMass, units::meter_t drumRadius,
+ units::meter_t minHeight, units::meter_t maxHeight,
+ const std::array<double, 1>& measurementStdDevs = {0.0});
+
+ /**
+ * Returns whether the elevator has hit the lower limit.
+ *
+ * @param x The current elevator state.
+ * @return Whether the elevator has hit the lower limit.
+ */
+ bool HasHitLowerLimit(const Eigen::Matrix<double, 2, 1>& x) const;
+
+ /**
+ * Returns whether the elevator has hit the upper limit.
+ *
+ * @param x The current elevator state.
+ * @return Whether the elevator has hit the upper limit.
+ */
+ bool HasHitUpperLimit(const Eigen::Matrix<double, 2, 1>& x) const;
+
+ /**
+ * Returns the position of the elevator.
+ *
+ * @return The position of the elevator.
+ */
+ units::meter_t GetPosition() const;
+
+ /**
+ * Returns the velocity of the elevator.
+ *
+ * @return The velocity of the elevator.
+ */
+ units::meters_per_second_t GetVelocity() const;
+
+ /**
+ * Returns the elevator current draw.
+ *
+ * @return The elevator current draw.
+ */
+ units::ampere_t GetCurrentDraw() const override;
+
+ /**
+ * Sets the input voltage for the elevator.
+ *
+ * @param voltage The input voltage.
+ */
+ void SetInputVoltage(units::volt_t voltage);
+
+ protected:
+ /**
+ * Updates the state estimate of the elevator.
+ *
+ * @param currentXhat The current state estimate.
+ * @param u The system inputs (voltage).
+ * @param dt The time difference between controller updates.
+ */
+ Eigen::Matrix<double, 2, 1> UpdateX(
+ const Eigen::Matrix<double, 2, 1>& currentXhat,
+ const Eigen::Matrix<double, 1, 1>& u, units::second_t dt) override;
+
+ private:
+ DCMotor m_gearbox;
+ units::meter_t m_drumRadius;
+ units::meter_t m_minHeight;
+ units::meter_t m_maxHeight;
+ double m_gearing;
+};
+} // namespace frc::sim
diff --git a/wpilibc/src/main/native/include/frc/simulation/EncoderSim.h b/wpilibc/src/main/native/include/frc/simulation/EncoderSim.h
new file mode 100644
index 0000000..4049ab8
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/EncoderSim.h
@@ -0,0 +1,130 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class Encoder;
+
+namespace sim {
+
+/**
+ * Class to control a simulated encoder.
+ */
+class EncoderSim {
+ public:
+ /**
+ * Constructs from an Encoder object.
+ *
+ * @param encoder Encoder to simulate
+ */
+ explicit EncoderSim(const Encoder& encoder);
+
+ /**
+ * Creates an EncoderSim for a digital input channel. Encoders take two
+ * channels, so either one may be specified.
+ *
+ * @param channel digital input channel
+ * @return Simulated object
+ * @throws NoSuchElementException if no Encoder is configured for that channel
+ */
+ static EncoderSim CreateForChannel(int channel);
+
+ /**
+ * Creates an EncoderSim for a simulated index.
+ * The index is incremented for each simulated Encoder.
+ *
+ * @param index simulator index
+ * @return Simulated object
+ */
+ static EncoderSim CreateForIndex(int index);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterCountCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ int GetCount() const;
+
+ void SetCount(int count);
+
+ std::unique_ptr<CallbackStore> RegisterPeriodCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetPeriod() const;
+
+ void SetPeriod(double period);
+
+ std::unique_ptr<CallbackStore> RegisterResetCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ bool GetReset() const;
+
+ void SetReset(bool reset);
+
+ std::unique_ptr<CallbackStore> RegisterMaxPeriodCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetMaxPeriod() const;
+
+ void SetMaxPeriod(double maxPeriod);
+
+ std::unique_ptr<CallbackStore> RegisterDirectionCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetDirection() const;
+
+ void SetDirection(bool direction);
+
+ std::unique_ptr<CallbackStore> RegisterReverseDirectionCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetReverseDirection() const;
+
+ void SetReverseDirection(bool reverseDirection);
+
+ std::unique_ptr<CallbackStore> RegisterSamplesToAverageCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetSamplesToAverage() const;
+
+ void SetSamplesToAverage(int samplesToAverage);
+
+ std::unique_ptr<CallbackStore> RegisterDistancePerPulseCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetDistancePerPulse() const;
+
+ void SetDistancePerPulse(double distancePerPulse);
+
+ void ResetData();
+
+ void SetDistance(double distance);
+
+ double GetDistance();
+
+ void SetRate(double rate);
+
+ double GetRate();
+
+ private:
+ explicit EncoderSim(int index) : m_index{index} {}
+
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/Field2d.h b/wpilibc/src/main/native/include/frc/simulation/Field2d.h
new file mode 100644
index 0000000..de30847
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/Field2d.h
@@ -0,0 +1,70 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <hal/SimDevice.h>
+#include <units/length.h>
+
+#include "frc/geometry/Pose2d.h"
+#include "frc/geometry/Rotation2d.h"
+
+namespace frc {
+
+/**
+ * 2D representation of game field (for simulation).
+ *
+ * In non-simulation mode this simply stores and returns the robot pose.
+ *
+ * The robot pose is the actual location shown on the simulation view.
+ * This may or may not match the robot's internal odometry. For example, if
+ * the robot is shown at a particular starting location, the pose in this
+ * class would represent the actual location on the field, but the robot's
+ * internal state might have a 0,0,0 pose (unless it's initialized to
+ * something different).
+ *
+ * As the user is able to edit the pose, code performing updates should get
+ * the robot pose, transform it as appropriate (e.g. based on simulated wheel
+ * velocity), and set the new pose.
+ */
+class Field2d {
+ public:
+ Field2d();
+
+ /**
+ * Set the robot pose from a Pose object.
+ *
+ * @param pose 2D pose
+ */
+ void SetRobotPose(const Pose2d& pose);
+
+ /**
+ * Set the robot pose from x, y, and rotation.
+ *
+ * @param x X location
+ * @param y Y location
+ * @param rotation rotation
+ */
+ void SetRobotPose(units::meter_t x, units::meter_t y, Rotation2d rotation);
+
+ /**
+ * Get the robot pose.
+ *
+ * @return 2D pose
+ */
+ Pose2d GetRobotPose();
+
+ private:
+ Pose2d m_pose;
+
+ hal::SimDevice m_device;
+ hal::SimDouble m_x;
+ hal::SimDouble m_y;
+ hal::SimDouble m_rot;
+};
+
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/FlywheelSim.h b/wpilibc/src/main/native/include/frc/simulation/FlywheelSim.h
new file mode 100644
index 0000000..1c47c45
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/FlywheelSim.h
@@ -0,0 +1,76 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <units/angular_velocity.h>
+#include <units/moment_of_inertia.h>
+
+#include "frc/simulation/LinearSystemSim.h"
+#include "frc/system/LinearSystem.h"
+#include "frc/system/plant/DCMotor.h"
+
+namespace frc::sim {
+/**
+ * Represents a simulated flywheel mechanism.
+ */
+class FlywheelSim : public LinearSystemSim<1, 1, 1> {
+ public:
+ /**
+ * Creates a simulated flywhel mechanism.
+ *
+ * @param plant The linear system representing the flywheel.
+ * @param gearbox The type of and number of motors in the flywheel
+ * gearbox.
+ * @param gearing The gearing of the flywheel (numbers greater than
+ * 1 represent reductions).
+ * @param measurementStdDevs The standard deviation of the measurement noise.
+ */
+ FlywheelSim(const LinearSystem<1, 1, 1>& plant, const DCMotor& gearbox,
+ double gearing,
+ const std::array<double, 1>& measurementStdDevs = {0.0});
+
+ /**
+ * Creates a simulated flywhel mechanism.
+ *
+ * @param gearbox The type of and number of motors in the flywheel
+ * gearbox.
+ * @param gearing The gearing of the flywheel (numbers greater than
+ * 1 represent reductions).
+ * @param moi The moment of inertia of the flywheel.
+ * @param measurementStdDevs The standard deviation of the measurement noise.
+ */
+ FlywheelSim(const DCMotor& gearbox, double gearing,
+ units::kilogram_square_meter_t moi,
+ const std::array<double, 1>& measurementStdDevs = {0.0});
+
+ /**
+ * Returns the flywheel velocity.
+ *
+ * @return The flywheel velocity.
+ */
+ units::radians_per_second_t GetAngularVelocity() const;
+
+ /**
+ * Returns the flywheel current draw.
+ *
+ * @return The flywheel current draw.
+ */
+ units::ampere_t GetCurrentDraw() const override;
+
+ /**
+ * Sets the input voltage for the flywheel.
+ *
+ * @param voltage The input voltage.
+ */
+ void SetInputVoltage(units::volt_t voltage);
+
+ private:
+ DCMotor m_gearbox;
+ double m_gearing;
+};
+} // namespace frc::sim
diff --git a/wpilibc/src/main/native/include/frc/simulation/GenericHIDSim.h b/wpilibc/src/main/native/include/frc/simulation/GenericHIDSim.h
new file mode 100644
index 0000000..1705200
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/GenericHIDSim.h
@@ -0,0 +1,75 @@
+/*----------------------------------------------------------------------------*/
+/* 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>
+
+#include "frc/GenericHID.h"
+
+namespace frc {
+
+class GenericHID;
+
+namespace sim {
+
+/**
+ * Class to control a simulated generic joystick.
+ */
+class GenericHIDSim {
+ public:
+ /**
+ * Constructs from a GenericHID object.
+ *
+ * @param joystick joystick to simulate
+ */
+ explicit GenericHIDSim(const GenericHID& joystick);
+
+ /**
+ * Constructs from a joystick port number.
+ *
+ * @param port port number
+ */
+ explicit GenericHIDSim(int port);
+
+ /**
+ * Updates joystick data so that new values are visible to the user program.
+ */
+ void NotifyNewData();
+
+ void SetRawButton(int button, bool value);
+
+ void SetRawAxis(int axis, double value);
+
+ void SetPOV(int pov, int value);
+
+ void SetPOV(int value);
+
+ void SetAxisCount(int count);
+
+ void SetPOVCount(int count);
+
+ void SetButtonCount(int count);
+
+ void SetType(GenericHID::HIDType type);
+
+ void SetName(const char* name);
+
+ void SetAxisType(int axis, int type);
+
+ bool GetOutput(int outputNumber);
+
+ int64_t GetOutputs();
+
+ double GetRumble(GenericHID::RumbleType type);
+
+ protected:
+ int m_port;
+};
+
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/JoystickSim.h b/wpilibc/src/main/native/include/frc/simulation/JoystickSim.h
new file mode 100644
index 0000000..5735728
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/JoystickSim.h
@@ -0,0 +1,56 @@
+/*----------------------------------------------------------------------------*/
+/* 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 "frc/simulation/GenericHIDSim.h"
+
+namespace frc {
+
+class Joystick;
+
+namespace sim {
+
+/**
+ * Class to control a simulated joystick.
+ */
+class JoystickSim : public GenericHIDSim {
+ public:
+ /**
+ * Constructs from a Joystick object.
+ *
+ * @param joystick joystick to simulate
+ */
+ explicit JoystickSim(const Joystick& joystick);
+
+ /**
+ * Constructs from a joystick port number.
+ *
+ * @param port port number
+ */
+ explicit JoystickSim(int port);
+
+ void SetX(double value);
+
+ void SetY(double value);
+
+ void SetZ(double value);
+
+ void SetTwist(double value);
+
+ void SetThrottle(double value);
+
+ void SetTrigger(bool state);
+
+ void SetTop(bool state);
+
+ private:
+ const Joystick* m_joystick = nullptr;
+};
+
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h b/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h
new file mode 100644
index 0000000..4f3c658
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/LinearSystemSim.h
@@ -0,0 +1,137 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <array>
+
+#include <Eigen/Core>
+#include <units/current.h>
+#include <units/time.h>
+
+#include "frc/StateSpaceUtil.h"
+#include "frc/system/LinearSystem.h"
+
+namespace frc::sim {
+/**
+ * This class helps simulate linear systems. To use this class, do the following
+ * in the simulationPeriodic() method.
+ *
+ * Call the SetInput() method with the inputs to your system (generally
+ * voltage). Call the Update() method to update the simulation. Set simulated
+ * sensor readings with the simulated positions in the GetOutput() method.
+ *
+ * @tparam States The number of states of the system.
+ * @tparam Inputs The number of inputs to the system.
+ * @tparam Outputs The number of outputs of the system.
+ */
+template <int States, int Inputs, int Outputs>
+class LinearSystemSim {
+ public:
+ /**
+ * Creates a simulated generic linear system.
+ *
+ * @param system The system to simulate.
+ * @param measurementStdDevs The standard deviations of the measurements.
+ */
+ LinearSystemSim(const LinearSystem<States, Inputs, Outputs>& system,
+ const std::array<double, Outputs>& measurementStdDevs =
+ std::array<double, Outputs>{})
+ : m_plant(system), m_measurementStdDevs(measurementStdDevs) {
+ m_x = Eigen::Matrix<double, States, 1>::Zero();
+ m_y = Eigen::Matrix<double, Outputs, 1>::Zero();
+ m_u = Eigen::Matrix<double, Inputs, 1>::Zero();
+ }
+
+ /**
+ * Updates the simulation.
+ *
+ * @param dt The time between updates.
+ */
+ void Update(units::second_t dt) {
+ // Update x. By default, this is the linear system dynamics x_k+1 = Ax_k +
+ // Bu_k
+ m_x = UpdateX(m_x, m_u, dt);
+
+ // y = Cx + Du
+ m_y = m_plant.CalculateY(m_x, m_u);
+
+ // Add noise. If the user did not pass a noise vector to the
+ // constructor, then this method will not do anything because
+ // the standard deviations default to zero.
+ m_y += frc::MakeWhiteNoiseVector<Outputs>(m_measurementStdDevs);
+ }
+
+ /**
+ * Returns the current output of the plant.
+ *
+ * @return The current output of the plant.
+ */
+ const Eigen::Matrix<double, Outputs, 1>& GetOutput() const { return m_y; }
+
+ /**
+ * Returns an element of the current output of the plant.
+ *
+ * @param row The row to return.
+ * @return An element of the current output of the plant.
+ */
+ double GetOutput(int row) const { return m_y(row); }
+
+ /**
+ * Sets the system inputs (usually voltages).
+ *
+ * @param u The system inputs.
+ */
+ void SetInput(const Eigen::Matrix<double, Inputs, 1>& u) { m_u = u; }
+
+ /*
+ * Sets the system inputs.
+ *
+ * @param row The row in the input matrix to set.
+ * @param value The value to set the row to.
+ */
+ void SetInput(int row, double value) { m_u(row, 0) = value; }
+
+ /**
+ * Sets the system state.
+ *
+ * @param state The new state.
+ */
+ void SetState(const Eigen::Matrix<double, States, 1>& state) { m_x = state; }
+
+ /**
+ * Returns the current drawn by this simulated system. Override this method to
+ * add a custom current calculation.
+ *
+ * @return The current drawn by this simulated mechanism.
+ */
+ virtual units::ampere_t GetCurrentDraw() const {
+ return units::ampere_t(0.0);
+ }
+
+ protected:
+ /**
+ * Updates the state estimate of the system.
+ *
+ * @param currentXhat The current state estimate.
+ * @param u The system inputs (usually voltage).
+ * @param dt The time difference between controller updates.
+ */
+ virtual Eigen::Matrix<double, States, 1> UpdateX(
+ const Eigen::Matrix<double, States, 1>& currentXhat,
+ const Eigen::Matrix<double, Inputs, 1>& u, units::second_t dt) {
+ return m_plant.CalculateX(currentXhat, u, dt);
+ }
+
+ LinearSystem<States, Inputs, Outputs> m_plant;
+
+ Eigen::Matrix<double, States, 1> m_x;
+ Eigen::Matrix<double, Outputs, 1> m_y;
+ Eigen::Matrix<double, Inputs, 1> m_u;
+ std::array<double, Outputs> m_measurementStdDevs;
+};
+} // namespace frc::sim
diff --git a/wpilibc/src/main/native/include/frc/simulation/Mechanism2D.h b/wpilibc/src/main/native/include/frc/simulation/Mechanism2D.h
new file mode 100644
index 0000000..3d61cf5
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/Mechanism2D.h
@@ -0,0 +1,45 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <map>
+#include <string>
+
+#include <hal/SimDevice.h>
+#include <wpi/StringMap.h>
+
+#include "frc/geometry/Pose2d.h"
+#include "frc/geometry/Rotation2d.h"
+
+namespace frc {
+class Mechanism2D {
+ public:
+ Mechanism2D();
+
+ /**
+ * Set/Create the angle of a ligament
+ *
+ * @param ligamentPath json path to the ligament
+ * @param angle to set the ligament
+ */
+ void SetLigamentAngle(const wpi::Twine& ligamentPath, float angle);
+
+ /**
+ * Set/Create the length of a ligament
+ *
+ * @param ligamentPath json path to the ligament
+ * @param length to set the ligament
+ */
+ void SetLigamentLength(const wpi::Twine& ligamentPath, float length);
+
+ private:
+ wpi::StringMap<hal::SimDouble> createdItems;
+ hal::SimDevice m_device;
+};
+
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/PCMSim.h b/wpilibc/src/main/native/include/frc/simulation/PCMSim.h
new file mode 100644
index 0000000..2e3ed5e
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/PCMSim.h
@@ -0,0 +1,103 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class Compressor;
+
+namespace sim {
+
+/**
+ * Class to control a simulated Pneumatic Control Module (PCM).
+ */
+class PCMSim {
+ public:
+ /**
+ * Constructs with the default PCM module number (CAN ID).
+ */
+ PCMSim();
+
+ /**
+ * Constructs from a PCM module number (CAN ID).
+ *
+ * @param module module number
+ */
+ explicit PCMSim(int module);
+
+ /**
+ * Constructs from a Compressor object.
+ *
+ * @param compressor Compressor connected to PCM to simulate
+ */
+ explicit PCMSim(const Compressor& compressor);
+
+ std::unique_ptr<CallbackStore> RegisterSolenoidInitializedCallback(
+ int channel, NotifyCallback callback, bool initialNotify);
+
+ bool GetSolenoidInitialized(int channel) const;
+
+ void SetSolenoidInitialized(int channel, bool solenoidInitialized);
+
+ std::unique_ptr<CallbackStore> RegisterSolenoidOutputCallback(
+ int channel, NotifyCallback callback, bool initialNotify);
+
+ bool GetSolenoidOutput(int channel) const;
+
+ void SetSolenoidOutput(int channel, bool solenoidOutput);
+
+ std::unique_ptr<CallbackStore> RegisterCompressorInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetCompressorInitialized() const;
+
+ void SetCompressorInitialized(bool compressorInitialized);
+
+ std::unique_ptr<CallbackStore> RegisterCompressorOnCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetCompressorOn() const;
+
+ void SetCompressorOn(bool compressorOn);
+
+ std::unique_ptr<CallbackStore> RegisterClosedLoopEnabledCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetClosedLoopEnabled() const;
+
+ void SetClosedLoopEnabled(bool closedLoopEnabled);
+
+ std::unique_ptr<CallbackStore> RegisterPressureSwitchCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetPressureSwitch() const;
+
+ void SetPressureSwitch(bool pressureSwitch);
+
+ std::unique_ptr<CallbackStore> RegisterCompressorCurrentCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetCompressorCurrent() const;
+
+ void SetCompressorCurrent(double compressorCurrent);
+
+ uint8_t GetAllSolenoidOutputs() const;
+
+ void SetAllSolenoidOutputs(uint8_t outputs);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/PDPSim.h b/wpilibc/src/main/native/include/frc/simulation/PDPSim.h
new file mode 100644
index 0000000..c67815f
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/PDPSim.h
@@ -0,0 +1,77 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class PowerDistributionPanel;
+
+namespace sim {
+
+/**
+ * Class to control a simulated Power Distribution Panel (PDP).
+ */
+class PDPSim {
+ public:
+ /**
+ * Constructs from a PDP module number (CAN ID).
+ *
+ * @param module module number
+ */
+ explicit PDPSim(int module = 0);
+
+ /**
+ * Constructs from a PowerDistributionPanel object.
+ *
+ * @param pdp PowerDistributionPanel to simulate
+ */
+ explicit PDPSim(const PowerDistributionPanel& pdp);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterTemperatureCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetTemperature() const;
+
+ void SetTemperature(double temperature);
+
+ std::unique_ptr<CallbackStore> RegisterVoltageCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetVoltage() const;
+
+ void SetVoltage(double voltage);
+
+ std::unique_ptr<CallbackStore> RegisterCurrentCallback(
+ int channel, NotifyCallback callback, bool initialNotify);
+
+ double GetCurrent(int channel) const;
+
+ void SetCurrent(int channel, double current);
+
+ void GetAllCurrents(double* currents) const;
+
+ void SetAllCurrents(const double* currents);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/PWMSim.h b/wpilibc/src/main/native/include/frc/simulation/PWMSim.h
new file mode 100644
index 0000000..ca2dfca
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/PWMSim.h
@@ -0,0 +1,87 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class PWM;
+
+namespace sim {
+
+/**
+ * Class to control a simulated PWM output.
+ */
+class PWMSim {
+ public:
+ /**
+ * Constructs from a PWM object.
+ *
+ * @param pwm PWM to simulate
+ */
+ explicit PWMSim(const PWM& pwm);
+
+ /**
+ * Constructs from a PWM channel number.
+ *
+ * @param channel Channel number
+ */
+ explicit PWMSim(int channel);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitialized() const;
+
+ void SetInitialized(bool initialized);
+
+ std::unique_ptr<CallbackStore> RegisterRawValueCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetRawValue() const;
+
+ void SetRawValue(int rawValue);
+
+ std::unique_ptr<CallbackStore> RegisterSpeedCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetSpeed() const;
+
+ void SetSpeed(double speed);
+
+ std::unique_ptr<CallbackStore> RegisterPositionCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ double GetPosition() const;
+
+ void SetPosition(double position);
+
+ std::unique_ptr<CallbackStore> RegisterPeriodScaleCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ int GetPeriodScale() const;
+
+ void SetPeriodScale(int periodScale);
+
+ std::unique_ptr<CallbackStore> RegisterZeroLatchCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetZeroLatch() const;
+
+ void SetZeroLatch(bool zeroLatch);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/RelaySim.h b/wpilibc/src/main/native/include/frc/simulation/RelaySim.h
new file mode 100644
index 0000000..99a8eef
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/RelaySim.h
@@ -0,0 +1,73 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+
+class Relay;
+
+namespace sim {
+
+/**
+ * Class to control a simulated relay.
+ */
+class RelaySim {
+ public:
+ /**
+ * Constructs from a Relay object.
+ *
+ * @param relay Relay to simulate
+ */
+ explicit RelaySim(const Relay& relay);
+
+ /**
+ * Constructs from a relay channel number.
+ *
+ * @param channel Channel number
+ */
+ explicit RelaySim(int channel);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedForwardCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitializedForward() const;
+
+ void SetInitializedForward(bool initializedForward);
+
+ std::unique_ptr<CallbackStore> RegisterInitializedReverseCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetInitializedReverse() const;
+
+ void SetInitializedReverse(bool initializedReverse);
+
+ std::unique_ptr<CallbackStore> RegisterForwardCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetForward() const;
+
+ void SetForward(bool forward);
+
+ std::unique_ptr<CallbackStore> RegisterReverseCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ bool GetReverse() const;
+
+ void SetReverse(bool reverse);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h b/wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h
new file mode 100644
index 0000000..32eb462
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/RoboRioSim.h
@@ -0,0 +1,133 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include <units/current.h>
+#include <units/voltage.h>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+namespace sim {
+
+/**
+ * Class to control a simulated RoboRIO.
+ */
+class RoboRioSim {
+ public:
+ static std::unique_ptr<CallbackStore> RegisterFPGAButtonCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetFPGAButton();
+
+ static void SetFPGAButton(bool fPGAButton);
+
+ static std::unique_ptr<CallbackStore> RegisterVInVoltageCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::volt_t GetVInVoltage();
+
+ static void SetVInVoltage(units::volt_t vInVoltage);
+
+ static std::unique_ptr<CallbackStore> RegisterVInCurrentCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::ampere_t GetVInCurrent();
+
+ static void SetVInCurrent(units::ampere_t vInCurrent);
+
+ static std::unique_ptr<CallbackStore> RegisterUserVoltage6VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::volt_t GetUserVoltage6V();
+
+ static void SetUserVoltage6V(units::volt_t userVoltage6V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserCurrent6VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::ampere_t GetUserCurrent6V();
+
+ static void SetUserCurrent6V(units::ampere_t userCurrent6V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserActive6VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetUserActive6V();
+
+ static void SetUserActive6V(bool userActive6V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserVoltage5VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::volt_t GetUserVoltage5V();
+
+ static void SetUserVoltage5V(units::volt_t userVoltage5V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserCurrent5VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::ampere_t GetUserCurrent5V();
+
+ static void SetUserCurrent5V(units::ampere_t userCurrent5V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserActive5VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetUserActive5V();
+
+ static void SetUserActive5V(bool userActive5V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserVoltage3V3Callback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::volt_t GetUserVoltage3V3();
+
+ static void SetUserVoltage3V3(units::volt_t userVoltage3V3);
+
+ static std::unique_ptr<CallbackStore> RegisterUserCurrent3V3Callback(
+ NotifyCallback callback, bool initialNotify);
+
+ static units::ampere_t GetUserCurrent3V3();
+
+ static void SetUserCurrent3V3(units::ampere_t userCurrent3V3);
+
+ static std::unique_ptr<CallbackStore> RegisterUserActive3V3Callback(
+ NotifyCallback callback, bool initialNotify);
+
+ static bool GetUserActive3V3();
+
+ static void SetUserActive3V3(bool userActive3V3);
+
+ static std::unique_ptr<CallbackStore> RegisterUserFaults6VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static int GetUserFaults6V();
+
+ static void SetUserFaults6V(int userFaults6V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserFaults5VCallback(
+ NotifyCallback callback, bool initialNotify);
+
+ static int GetUserFaults5V();
+
+ static void SetUserFaults5V(int userFaults5V);
+
+ static std::unique_ptr<CallbackStore> RegisterUserFaults3V3Callback(
+ NotifyCallback callback, bool initialNotify);
+
+ static int GetUserFaults3V3();
+
+ static void SetUserFaults3V3(int userFaults3V3);
+
+ static void ResetData();
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/SPIAccelerometerSim.h b/wpilibc/src/main/native/include/frc/simulation/SPIAccelerometerSim.h
new file mode 100644
index 0000000..f2e3249
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/SPIAccelerometerSim.h
@@ -0,0 +1,61 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <memory>
+
+#include "frc/simulation/CallbackStore.h"
+
+namespace frc {
+namespace sim {
+class SPIAccelerometerSim {
+ public:
+ explicit SPIAccelerometerSim(int index);
+
+ std::unique_ptr<CallbackStore> RegisterActiveCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ bool GetActive() const;
+
+ void SetActive(bool active);
+
+ std::unique_ptr<CallbackStore> RegisterRangeCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ int GetRange() const;
+
+ void SetRange(int range);
+
+ std::unique_ptr<CallbackStore> RegisterXCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetX() const;
+
+ void SetX(double x);
+
+ std::unique_ptr<CallbackStore> RegisterYCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetY() const;
+
+ void SetY(double y);
+
+ std::unique_ptr<CallbackStore> RegisterZCallback(NotifyCallback callback,
+ bool initialNotify);
+
+ double GetZ() const;
+
+ void SetZ(double z);
+
+ void ResetData();
+
+ private:
+ int m_index;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/SimDeviceSim.h b/wpilibc/src/main/native/include/frc/simulation/SimDeviceSim.h
new file mode 100644
index 0000000..640cc0e
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/SimDeviceSim.h
@@ -0,0 +1,69 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <functional>
+#include <string>
+#include <vector>
+
+#include <hal/SimDevice.h>
+#include <hal/simulation/SimDeviceData.h>
+
+namespace frc {
+namespace sim {
+
+/**
+ * Class to control the simulation side of a SimDevice.
+ */
+class SimDeviceSim {
+ public:
+ /**
+ * Constructs a SimDeviceSim.
+ *
+ * @param name name of the SimDevice
+ */
+ explicit SimDeviceSim(const char* name);
+
+ hal::SimValue GetValue(const char* name) const;
+
+ hal::SimDouble GetDouble(const char* name) const;
+
+ hal::SimEnum GetEnum(const char* name) const;
+
+ hal::SimBoolean GetBoolean(const char* name) const;
+
+ static std::vector<std::string> GetEnumOptions(hal::SimEnum val);
+
+ template <typename F>
+ void EnumerateValues(F callback) const {
+ return HALSIM_EnumerateSimValues(
+ m_handle, &callback,
+ [](const char* name, void* param, HAL_SimValueHandle handle,
+ HAL_Bool readonly, const struct HAL_Value* value) {
+ std::invoke(*static_cast<F*>(param), name, handle, readonly, value);
+ });
+ }
+
+ operator HAL_SimDeviceHandle() const { return m_handle; }
+
+ template <typename F>
+ static void EnumerateDevices(const char* prefix, F callback) {
+ return HALSIM_EnumerateSimDevices(
+ prefix, &callback,
+ [](const char* name, void* param, HAL_SimDeviceHandle handle) {
+ std::invoke(*static_cast<F*>(param), name, handle);
+ });
+ }
+
+ static void ResetData();
+
+ private:
+ HAL_SimDeviceHandle m_handle;
+};
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/SimHooks.h b/wpilibc/src/main/native/include/frc/simulation/SimHooks.h
new file mode 100644
index 0000000..7690a4f
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/SimHooks.h
@@ -0,0 +1,39 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#pragma once
+
+#include <stdint.h>
+
+#include <hal/HALBase.h>
+#include <units/time.h>
+
+namespace frc {
+namespace sim {
+
+void SetRuntimeType(HAL_RuntimeType type);
+
+void WaitForProgramStart();
+
+void SetProgramStarted();
+
+bool GetProgramStarted();
+
+void RestartTiming();
+
+void PauseTiming();
+
+void ResumeTiming();
+
+bool IsTimingPaused();
+
+void StepTiming(units::second_t delta);
+
+void StepTimingAsync(units::second_t delta);
+
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/simulation/SingleJointedArmSim.h b/wpilibc/src/main/native/include/frc/simulation/SingleJointedArmSim.h
new file mode 100644
index 0000000..f8de822
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/SingleJointedArmSim.h
@@ -0,0 +1,147 @@
+/*----------------------------------------------------------------------------*/
+/* 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 <array>
+
+#include <units/angle.h>
+#include <units/length.h>
+#include <units/mass.h>
+#include <units/moment_of_inertia.h>
+
+#include "frc/simulation/LinearSystemSim.h"
+#include "frc/system/plant/DCMotor.h"
+
+namespace frc::sim {
+/**
+ * Represents a simulated arm mechanism.
+ */
+class SingleJointedArmSim : public LinearSystemSim<2, 1, 1> {
+ public:
+ /**
+ * Creates a simulated arm mechanism.
+ *
+ * @param system The system representing this arm.
+ * @param gearbox The type and number of motors on the arm gearbox.
+ * @param gearing The gear ratio of the arm (numbers greater than 1
+ * represent reductions).
+ * @param armLength The length of the arm.
+ * @param minAngle The minimum angle that the arm is capable of.
+ * @param maxAngle The maximum angle that the arm is capable of.
+ * @param mass The mass of the arm.
+ * @param measurementStdDevs The standard deviations of the measurements.
+ * @param simulateGravity Whether gravity should be simulated or not.
+ */
+ SingleJointedArmSim(const LinearSystem<2, 1, 1>& system,
+ const DCMotor& gearbox, double gearing,
+ units::meter_t armLength, units::radian_t minAngle,
+ units::radian_t maxAngle, units::kilogram_t mass,
+ bool simulateGravity,
+ const std::array<double, 1>& measurementStdDevs = {0.0});
+ /**
+ * Creates a simulated arm mechanism.
+ *
+ * @param gearbox The type and number of motors on the arm gearbox.
+ * @param gearing The gear ratio of the arm (numbers greater than 1
+ * represent reductions).
+ * @param moi The moment of inertia of the arm. This can be
+ * calculated from CAD software.
+ * @param armLength The length of the arm.
+ * @param minAngle The minimum angle that the arm is capable of.
+ * @param maxAngle The maximum angle that the arm is capable of.
+ * @param mass The mass of the arm.
+ * @param measurementStdDevs The standard deviation of the measurement noise.
+ * @param simulateGravity Whether gravity should be simulated or not.
+ */
+ SingleJointedArmSim(const DCMotor& gearbox, double gearing,
+ units::kilogram_square_meter_t moi,
+ units::meter_t armLength, units::radian_t minAngle,
+ units::radian_t maxAngle, units::kilogram_t mass,
+ bool simulateGravity,
+ const std::array<double, 1>& measurementStdDevs = {0.0});
+
+ /**
+ * Returns whether the arm has hit the lower limit.
+ *
+ * @param x The current arm state.
+ * @return Whether the arm has hit the lower limit.
+ */
+ bool HasHitLowerLimit(const Eigen::Matrix<double, 2, 1>& x) const;
+
+ /**
+ * Returns whether the arm has hit the upper limit.
+ *
+ * @param x The current arm state.
+ * @return Whether the arm has hit the upper limit.
+ */
+ bool HasHitUpperLimit(const Eigen::Matrix<double, 2, 1>& x) const;
+
+ /**
+ * Returns the current arm angle.
+ *
+ * @return The current arm angle.
+ */
+ units::radian_t GetAngle() const;
+
+ /**
+ * Returns the current arm velocity.
+ *
+ * @return The current arm velocity.
+ */
+ units::radians_per_second_t GetVelocity() const;
+
+ /**
+ * Returns the arm current draw.
+ *
+ * @return The arm current draw.
+ */
+ units::ampere_t GetCurrentDraw() const override;
+
+ /**
+ * Sets the input voltage for the elevator.
+ *
+ * @param voltage The input voltage.
+ */
+ void SetInputVoltage(units::volt_t voltage);
+
+ /**
+ * Calculates a rough estimate of the moment of inertia of an arm given its
+ * length and mass.
+ *
+ * @param length The length of the arm.
+ * @param mass The mass of the arm.
+ *
+ * @return The calculated moment of inertia.
+ */
+ static constexpr units::kilogram_square_meter_t EstimateMOI(
+ units::meter_t length, units::kilogram_t mass) {
+ return 1.0 / 3.0 * mass * length * length;
+ }
+
+ protected:
+ /**
+ * Updates the state estimate of the arm.
+ *
+ * @param currentXhat The current state estimate.
+ * @param u The system inputs (voltage).
+ * @param dt The time difference between controller updates.
+ */
+ Eigen::Matrix<double, 2, 1> UpdateX(
+ const Eigen::Matrix<double, 2, 1>& currentXhat,
+ const Eigen::Matrix<double, 1, 1>& u, units::second_t dt) override;
+
+ private:
+ units::meter_t m_r;
+ units::radian_t m_minAngle;
+ units::radian_t m_maxAngle;
+ units::kilogram_t m_mass;
+ const DCMotor m_gearbox;
+ double m_gearing;
+ bool m_simulateGravity;
+};
+} // namespace frc::sim
diff --git a/wpilibc/src/main/native/include/frc/simulation/XboxControllerSim.h b/wpilibc/src/main/native/include/frc/simulation/XboxControllerSim.h
new file mode 100644
index 0000000..d981111
--- /dev/null
+++ b/wpilibc/src/main/native/include/frc/simulation/XboxControllerSim.h
@@ -0,0 +1,61 @@
+/*----------------------------------------------------------------------------*/
+/* 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 "frc/simulation/GenericHIDSim.h"
+
+namespace frc {
+
+class XboxController;
+
+namespace sim {
+
+/**
+ * Class to control a simulated Xbox 360 or Xbox One controller.
+ */
+class XboxControllerSim : public GenericHIDSim {
+ public:
+ /**
+ * Constructs from a XboxController object.
+ *
+ * @param joystick controller to simulate
+ */
+ explicit XboxControllerSim(const XboxController& joystick);
+
+ /**
+ * Constructs from a joystick port number.
+ *
+ * @param port port number
+ */
+ explicit XboxControllerSim(int port);
+
+ void SetX(GenericHID::JoystickHand hand, double value);
+
+ void SetY(GenericHID::JoystickHand hand, double value);
+
+ void SetTriggerAxis(GenericHID::JoystickHand hand, double value);
+
+ void SetBumper(GenericHID::JoystickHand hand, bool state);
+
+ void SetStickButton(GenericHID::JoystickHand hand, bool state);
+
+ void SetAButton(bool state);
+
+ void SetBButton(bool state);
+
+ void SetXButton(bool state);
+
+ void SetYButton(bool state);
+
+ void SetBackButton(bool state);
+
+ void SetStartButton(bool state);
+};
+
+} // namespace sim
+} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h
index a0ea0f9..98419b9 100644
--- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h
+++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBase.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -17,7 +17,9 @@
class SendableBase : public Sendable, public SendableHelper<SendableBase> {
public:
/**
- * Creates an instance of the sensor base.
+ * Creates an instance of the sensor base
+ *
+ * @deprecated use Sendable and SendableHelper
*
* @param addLiveWindow if true, add this Sendable to LiveWindow
*/
diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h
index eb69dcd..e5dea44 100644
--- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h
+++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableBuilderImpl.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2017-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. */
@@ -202,7 +202,7 @@
std::vector<Property> m_properties;
std::function<void()> m_safeState;
- std::function<void()> m_updateTable;
+ std::vector<std::function<void()>> m_updateTables;
std::shared_ptr<nt::NetworkTable> m_table;
nt::NetworkTableEntry m_controllableEntry;
bool m_actuator = false;
diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h
index 6cf3c47..b370fc0 100644
--- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h
+++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2011-2018 FIRST. All Rights Reserved. */
+/* Copyright (c) 2011-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. */
@@ -46,13 +46,38 @@
public:
~SendableChooser() override = default;
+ SendableChooser() = default;
+ SendableChooser(SendableChooser&& rhs) = default;
+ SendableChooser& operator=(SendableChooser&& rhs) = default;
void AddOption(wpi::StringRef name, T object);
void SetDefaultOption(wpi::StringRef name, T object);
+ /**
+ * Adds the given object to the list of options.
+ *
+ * On the SmartDashboard on the desktop, the object will appear as the given
+ * name.
+ *
+ * @deprecated use AddOption(wpi::StringRef name, T object) instead.
+ *
+ * @param name the name of the option
+ * @param object the option
+ */
WPI_DEPRECATED("use AddOption() instead")
void AddObject(wpi::StringRef name, T object) { AddOption(name, object); }
+ /**
+ * Add the given object to the list of options and marks it as the default.
+ *
+ * Functionally, this is very close to AddOption() except that it will use
+ * this as the default option if none other is explicitly selected.
+ *
+ * @deprecated use SetDefaultOption(wpi::StringRef name, T object) instead.
+ *
+ * @param name the name of the option
+ * @param object the option
+ */
WPI_DEPRECATED("use SetDefaultOption() instead")
void AddDefault(wpi::StringRef name, T object) {
SetDefaultOption(name, object);
diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc
index 295d263..57e2828 100644
--- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc
+++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableChooser.inc
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2011-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2011-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. */
@@ -76,20 +76,21 @@
void SendableChooser<T>::InitSendable(SendableBuilder& builder) {
builder.SetSmartDashboardType("String Chooser");
builder.GetEntry(kInstance).SetDouble(m_instance);
- builder.AddStringArrayProperty(kOptions,
- [=]() {
- std::vector<std::string> keys;
- for (const auto& choice : m_choices) {
- keys.push_back(choice.first());
- }
+ builder.AddStringArrayProperty(
+ kOptions,
+ [=]() {
+ std::vector<std::string> keys;
+ for (const auto& choice : m_choices) {
+ keys.push_back(choice.first());
+ }
- // Unlike std::map, wpi::StringMap elements
- // are not sorted
- std::sort(keys.begin(), keys.end());
+ // Unlike std::map, wpi::StringMap elements
+ // are not sorted
+ std::sort(keys.begin(), keys.end());
- return keys;
- },
- nullptr);
+ return keys;
+ },
+ nullptr);
builder.AddSmallStringProperty(
kDefault,
[=](wpi::SmallVectorImpl<char>&) -> wpi::StringRef {
diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h b/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h
index 6b0b28b..1f39216 100644
--- a/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h
+++ b/wpilibc/src/main/native/include/frc/smartdashboard/SendableHelper.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -46,6 +46,8 @@
/**
* Gets the name of this Sendable object.
*
+ * @deprecated use SendableRegistry::GetName()
+ *
* @return Name
*/
WPI_DEPRECATED("use SendableRegistry::GetName()")
@@ -57,6 +59,8 @@
/**
* Sets the name of this Sendable object.
*
+ * @deprecated use SendableRegistry::SetName()
+ *
* @param name name
*/
WPI_DEPRECATED("use SendableRegistry::SetName()")
@@ -67,6 +71,8 @@
/**
* Sets both the subsystem name and device name of this Sendable object.
*
+ * @deprecated use SendableRegistry::SetName()
+ *
* @param subsystem subsystem name
* @param name device name
*/
@@ -79,6 +85,8 @@
/**
* Gets the subsystem name of this Sendable object.
*
+ * @deprecated use SendableRegistry::GetSubsystem().
+ *
* @return Subsystem name
*/
WPI_DEPRECATED("use SendableRegistry::GetSubsystem()")
@@ -90,6 +98,8 @@
/**
* Sets the subsystem name of this Sendable object.
*
+ * @deprecated use SendableRegistry::SetSubsystem()
+ *
* @param subsystem subsystem name
*/
WPI_DEPRECATED("use SendableRegistry::SetSubsystem()")
@@ -102,6 +112,8 @@
/**
* Add a child component.
*
+ * @deprecated use SendableRegistry::AddChild()
+ *
* @param child child component
*/
WPI_DEPRECATED("use SendableRegistry::AddChild()")
@@ -113,6 +125,8 @@
/**
* Add a child component.
*
+ * @deprecated use SendableRegistry::AddChild()
+ *
* @param child child component
*/
WPI_DEPRECATED("use SendableRegistry::AddChild()")
@@ -124,6 +138,8 @@
/**
* Sets the name of the sensor with a channel number.
*
+ * @deprecated use SendableRegistry::SetName()
+ *
* @param moduleType A string that defines the module name in the label for
* the value
* @param channel The channel number the device is plugged into
@@ -137,6 +153,8 @@
/**
* Sets the name of the sensor with a module and channel number.
*
+ * @deprecated use SendableRegistry::SetName()
+ *
* @param moduleType A string that defines the module name in the label for
* the value
* @param moduleNumber The number of the particular module type
diff --git a/wpilibc/src/main/native/include/frc/spline/CubicHermiteSpline.h b/wpilibc/src/main/native/include/frc/spline/CubicHermiteSpline.h
deleted file mode 100644
index 1e08a94..0000000
--- a/wpilibc/src/main/native/include/frc/spline/CubicHermiteSpline.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <array>
-
-#include <Eigen/Core>
-
-#include "frc/spline/Spline.h"
-
-namespace frc {
-/**
- * Represents a hermite spline of degree 3.
- */
-class CubicHermiteSpline : public Spline<3> {
- public:
- /**
- * Constructs a cubic hermite spline with the specified control vectors. Each
- * control vector contains info about the location of the point and its first
- * derivative.
- *
- * @param xInitialControlVector The control vector for the initial point in
- * the x dimension.
- * @param xFinalControlVector The control vector for the final point in
- * the x dimension.
- * @param yInitialControlVector The control vector for the initial point in
- * the y dimension.
- * @param yFinalControlVector The control vector for the final point in
- * the y dimension.
- */
- CubicHermiteSpline(std::array<double, 2> xInitialControlVector,
- std::array<double, 2> xFinalControlVector,
- std::array<double, 2> yInitialControlVector,
- std::array<double, 2> yFinalControlVector);
-
- protected:
- /**
- * Returns the coefficients matrix.
- * @return The coefficients matrix.
- */
- Eigen::Matrix<double, 6, 3 + 1> Coefficients() const override {
- return m_coefficients;
- }
-
- private:
- Eigen::Matrix<double, 6, 4> m_coefficients =
- Eigen::Matrix<double, 6, 4>::Zero();
-
- /**
- * Returns the hermite basis matrix for cubic hermite spline interpolation.
- * @return The hermite basis matrix for cubic hermite spline interpolation.
- */
- static Eigen::Matrix<double, 4, 4> MakeHermiteBasis() {
- // clang-format off
- static auto basis = (Eigen::Matrix<double, 4, 4>() <<
- +2.0, +1.0, -2.0, +1.0,
- -3.0, -2.0, +3.0, -1.0,
- +0.0, +1.0, +0.0, +0.0,
- +1.0, +0.0, +0.0, +0.0).finished();
- // clang-format on
- return basis;
- }
-
- /**
- * Returns the control vector for each dimension as a matrix from the
- * user-provided arrays in the constructor.
- *
- * @param initialVector The control vector for the initial point.
- * @param finalVector The control vector for the final point.
- *
- * @return The control vector matrix for a dimension.
- */
- static Eigen::Vector4d ControlVectorFromArrays(
- std::array<double, 2> initialVector, std::array<double, 2> finalVector) {
- return (Eigen::Vector4d() << initialVector[0], initialVector[1],
- finalVector[0], finalVector[1])
- .finished();
- }
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/spline/QuinticHermiteSpline.h b/wpilibc/src/main/native/include/frc/spline/QuinticHermiteSpline.h
deleted file mode 100644
index 632d3ad..0000000
--- a/wpilibc/src/main/native/include/frc/spline/QuinticHermiteSpline.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <array>
-
-#include <Eigen/Core>
-
-#include "frc/spline/Spline.h"
-
-namespace frc {
-/**
- * Represents a hermite spline of degree 5.
- */
-class QuinticHermiteSpline : public Spline<5> {
- public:
- /**
- * Constructs a quintic hermite spline with the specified control vectors.
- * Each control vector contains into about the location of the point, its
- * first derivative, and its second derivative.
- *
- * @param xInitialControlVector The control vector for the initial point in
- * the x dimension.
- * @param xFinalControlVector The control vector for the final point in
- * the x dimension.
- * @param yInitialControlVector The control vector for the initial point in
- * the y dimension.
- * @param yFinalControlVector The control vector for the final point in
- * the y dimension.
- */
- QuinticHermiteSpline(std::array<double, 3> xInitialControlVector,
- std::array<double, 3> xFinalControlVector,
- std::array<double, 3> yInitialControlVector,
- std::array<double, 3> yFinalControlVector);
-
- protected:
- /**
- * Returns the coefficients matrix.
- * @return The coefficients matrix.
- */
- Eigen::Matrix<double, 6, 6> Coefficients() const override {
- return m_coefficients;
- }
-
- private:
- Eigen::Matrix<double, 6, 6> m_coefficients =
- Eigen::Matrix<double, 6, 6>::Zero();
-
- /**
- * Returns the hermite basis matrix for quintic hermite spline interpolation.
- * @return The hermite basis matrix for quintic hermite spline interpolation.
- */
- static Eigen::Matrix<double, 6, 6> MakeHermiteBasis() {
- // clang-format off
- static const auto basis = (Eigen::Matrix<double, 6, 6>() <<
- -06.0, -03.0, -00.5, +06.0, -03.0, +00.5,
- +15.0, +08.0, +01.5, -15.0, +07.0, +01.0,
- -10.0, -06.0, -01.5, +10.0, -04.0, +00.5,
- +00.0, +00.0, +00.5, +00.0, +00.0, +00.0,
- +00.0, +01.0, +00.0, +00.0, +00.0, +00.0,
- +01.0, +00.0, +00.0, +00.0, +00.0, +00.0).finished();
- // clang-format on
- return basis;
- }
-
- /**
- * Returns the control vector for each dimension as a matrix from the
- * user-provided arrays in the constructor.
- *
- * @param initialVector The control vector for the initial point.
- * @param finalVector The control vector for the final point.
- *
- * @return The control vector matrix for a dimension.
- */
- static Eigen::Matrix<double, 6, 1> ControlVectorFromArrays(
- std::array<double, 3> initialVector, std::array<double, 3> finalVector) {
- return (Eigen::Matrix<double, 6, 1>() << initialVector[0], initialVector[1],
- initialVector[2], finalVector[0], finalVector[1], finalVector[2])
- .finished();
- }
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/spline/Spline.h b/wpilibc/src/main/native/include/frc/spline/Spline.h
deleted file mode 100644
index e8f2372..0000000
--- a/wpilibc/src/main/native/include/frc/spline/Spline.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <array>
-#include <utility>
-#include <vector>
-
-#include <Eigen/Core>
-
-#include "frc/geometry/Pose2d.h"
-
-namespace frc {
-
-/**
- * Define a unit for curvature.
- */
-using curvature_t = units::unit_t<
- units::compound_unit<units::radian, units::inverse<units::meter>>>;
-
-/**
- * Represents a two-dimensional parametric spline that interpolates between two
- * points.
- *
- * @tparam Degree The degree of the spline.
- */
-template <int Degree>
-class Spline {
- public:
- using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
-
- Spline() = default;
-
- Spline(const Spline&) = default;
- Spline& operator=(const Spline&) = default;
-
- Spline(Spline&&) = default;
- Spline& operator=(Spline&&) = default;
-
- virtual ~Spline() = default;
-
- /**
- * Represents a control vector for a spline.
- *
- * Each element in each array represents the value of the derivative at the
- * index. For example, the value of x[2] is the second derivative in the x
- * dimension.
- */
- struct ControlVector {
- std::array<double, (Degree + 1) / 2> x;
- std::array<double, (Degree + 1) / 2> y;
- };
-
- /**
- * Gets the pose and curvature at some point t on the spline.
- *
- * @param t The point t
- * @return The pose and curvature at that point.
- */
- PoseWithCurvature GetPoint(double t) const {
- Eigen::Matrix<double, Degree + 1, 1> polynomialBases;
-
- // Populate the polynomial bases
- for (int i = 0; i <= Degree; i++) {
- polynomialBases(i) = std::pow(t, Degree - i);
- }
-
- // This simply multiplies by the coefficients. We need to divide out t some
- // n number of times where n is the derivative we want to take.
- Eigen::Matrix<double, 6, 1> combined = Coefficients() * polynomialBases;
-
- double dx, dy, ddx, ddy;
-
- // If t = 0, all other terms in the equation cancel out to zero. We can use
- // the last x^0 term in the equation.
- if (t == 0.0) {
- dx = Coefficients()(2, Degree - 1);
- dy = Coefficients()(3, Degree - 1);
- ddx = Coefficients()(4, Degree - 2);
- ddy = Coefficients()(5, Degree - 2);
- } else {
- // Divide out t for first derivative.
- dx = combined(2) / t;
- dy = combined(3) / t;
-
- // Divide out t for second derivative.
- ddx = combined(4) / t / t;
- ddy = combined(5) / t / t;
- }
-
- // Find the curvature.
- const auto curvature =
- (dx * ddy - ddx * dy) / ((dx * dx + dy * dy) * std::hypot(dx, dy));
-
- return {
- {FromVector(combined.template block<2, 1>(0, 0)), Rotation2d(dx, dy)},
- curvature_t(curvature)};
- }
-
- protected:
- /**
- * Returns the coefficients of the spline.
- *
- * @return The coefficients of the spline.
- */
- virtual Eigen::Matrix<double, 6, Degree + 1> Coefficients() const = 0;
-
- /**
- * Converts a Translation2d into a vector that is compatible with Eigen.
- *
- * @param translation The Translation2d to convert.
- * @return The vector.
- */
- static Eigen::Vector2d ToVector(const Translation2d& translation) {
- return (Eigen::Vector2d() << translation.X().to<double>(),
- translation.Y().to<double>())
- .finished();
- }
-
- /**
- * Converts an Eigen vector into a Translation2d.
- *
- * @param vector The vector to convert.
- * @return The Translation2d.
- */
- static Translation2d FromVector(const Eigen::Vector2d& vector) {
- return Translation2d(units::meter_t(vector(0)), units::meter_t(vector(1)));
- }
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/spline/SplineHelper.h b/wpilibc/src/main/native/include/frc/spline/SplineHelper.h
deleted file mode 100644
index 4ed1cf5..0000000
--- a/wpilibc/src/main/native/include/frc/spline/SplineHelper.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <array>
-#include <utility>
-#include <vector>
-
-#include "frc/spline/CubicHermiteSpline.h"
-#include "frc/spline/QuinticHermiteSpline.h"
-
-namespace frc {
-/**
- * Helper class that is used to generate cubic and quintic splines from user
- * provided waypoints.
- */
-class SplineHelper {
- public:
- /**
- * Returns 2 cubic control vectors from a set of exterior waypoints and
- * interior translations.
- *
- * @param start The starting pose.
- * @param interiorWaypoints The interior waypoints.
- * @param end The ending pose.
- * @return 2 cubic control vectors.
- */
- static std::array<Spline<3>::ControlVector, 2>
- CubicControlVectorsFromWaypoints(
- const Pose2d& start, const std::vector<Translation2d>& interiorWaypoints,
- const Pose2d& end);
-
- /**
- * Returns quintic control vectors from a set of waypoints.
- *
- * @param waypoints The waypoints
- * @return List of control vectors
- */
- static std::vector<Spline<5>::ControlVector>
- QuinticControlVectorsFromWaypoints(const std::vector<Pose2d>& waypoints);
-
- /**
- * Returns a set of cubic splines corresponding to the provided control
- * vectors. The user is free to set the direction of the start and end
- * point. The directions for the middle waypoints are determined
- * automatically to ensure continuous curvature throughout the path.
- *
- * The derivation for the algorithm used can be found here:
- * <https://www.uio.no/studier/emner/matnat/ifi/nedlagte-emner/INF-MAT4350/h08/undervisningsmateriale/chap7alecture.pdf>
- *
- * @param start The starting control vector.
- * @param waypoints The middle waypoints. This can be left blank if you
- * only wish to create a path with two waypoints.
- * @param end The ending control vector.
- *
- * @return A vector of cubic hermite splines that interpolate through the
- * provided waypoints.
- */
- static std::vector<CubicHermiteSpline> CubicSplinesFromControlVectors(
- const Spline<3>::ControlVector& start,
- std::vector<Translation2d> waypoints,
- const Spline<3>::ControlVector& end);
-
- /**
- * Returns a set of quintic splines corresponding to the provided control
- * vectors. The user is free to set the direction of all waypoints. Continuous
- * curvature is guaranteed throughout the path.
- *
- * @param controlVectors The control vectors.
- * @return A vector of quintic hermite splines that interpolate through the
- * provided waypoints.
- */
- static std::vector<QuinticHermiteSpline> QuinticSplinesFromControlVectors(
- const std::vector<Spline<5>::ControlVector>& controlVectors);
-
- private:
- static Spline<3>::ControlVector CubicControlVector(double scalar,
- const Pose2d& point) {
- return {
- {point.Translation().X().to<double>(), scalar * point.Rotation().Cos()},
- {point.Translation().Y().to<double>(),
- scalar * point.Rotation().Sin()}};
- }
-
- static Spline<5>::ControlVector QuinticControlVector(double scalar,
- const Pose2d& point) {
- return {{point.Translation().X().to<double>(),
- scalar * point.Rotation().Cos(), 0.0},
- {point.Translation().Y().to<double>(),
- scalar * point.Rotation().Sin(), 0.0}};
- }
-
- /**
- * Thomas algorithm for solving tridiagonal systems Af = d.
- *
- * @param a the values of A above the diagonal
- * @param b the values of A on the diagonal
- * @param c the values of A below the diagonal
- * @param d the vector on the rhs
- * @param solutionVector the unknown (solution) vector, modified in-place
- */
- static void ThomasAlgorithm(const std::vector<double>& a,
- const std::vector<double>& b,
- const std::vector<double>& c,
- const std::vector<double>& d,
- std::vector<double>* solutionVector);
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/spline/SplineParameterizer.h b/wpilibc/src/main/native/include/frc/spline/SplineParameterizer.h
deleted file mode 100644
index d3a5e6e..0000000
--- a/wpilibc/src/main/native/include/frc/spline/SplineParameterizer.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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. */
-/*----------------------------------------------------------------------------*/
-
-/*
- * MIT License
- *
- * Copyright (c) 2018 Team 254
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#pragma once
-
-#include <frc/spline/Spline.h>
-
-#include <stack>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <units/units.h>
-#include <wpi/Twine.h>
-
-namespace frc {
-
-/**
- * Class used to parameterize a spline by its arc length.
- */
-class SplineParameterizer {
- public:
- using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
-
- struct MalformedSplineException : public std::runtime_error {
- explicit MalformedSplineException(const char* what_arg)
- : runtime_error(what_arg) {}
- };
-
- /**
- * Parameterizes the spline. This method breaks up the spline into various
- * arcs until their dx, dy, and dtheta are within specific tolerances.
- *
- * @param spline The spline to parameterize.
- * @param t0 Starting internal spline parameter. It is recommended to leave
- * this as default.
- * @param t1 Ending internal spline parameter. It is recommended to leave this
- * as default.
- *
- * @return A vector of poses and curvatures that represents various points on
- * the spline.
- */
- template <int Dim>
- static std::vector<PoseWithCurvature> Parameterize(const Spline<Dim>& spline,
- double t0 = 0.0,
- double t1 = 1.0) {
- std::vector<PoseWithCurvature> splinePoints;
-
- // The parameterization does not add the initial point. Let's add that.
- splinePoints.push_back(spline.GetPoint(t0));
-
- // We use an "explicit stack" to simulate recursion, instead of a recursive
- // function call This give us greater control, instead of a stack overflow
- std::stack<StackContents> stack;
- stack.emplace(StackContents{t0, t1});
-
- StackContents current;
- PoseWithCurvature start;
- PoseWithCurvature end;
- int iterations = 0;
-
- while (!stack.empty()) {
- current = stack.top();
- stack.pop();
- start = spline.GetPoint(current.t0);
- end = spline.GetPoint(current.t1);
-
- const auto twist = start.first.Log(end.first);
-
- if (units::math::abs(twist.dy) > kMaxDy ||
- units::math::abs(twist.dx) > kMaxDx ||
- units::math::abs(twist.dtheta) > kMaxDtheta) {
- stack.emplace(StackContents{(current.t0 + current.t1) / 2, current.t1});
- stack.emplace(StackContents{current.t0, (current.t0 + current.t1) / 2});
- } else {
- splinePoints.push_back(spline.GetPoint(current.t1));
- }
-
- if (iterations++ >= kMaxIterations) {
- throw MalformedSplineException(
- "Could not parameterize a malformed spline. "
- "This means that you probably had two or more adjacent "
- "waypoints that were very close together with headings "
- "in opposing directions.");
- }
- }
-
- return splinePoints;
- }
-
- private:
- // Constraints for spline parameterization.
- static constexpr units::meter_t kMaxDx = 5_in;
- static constexpr units::meter_t kMaxDy = 0.05_in;
- static constexpr units::radian_t kMaxDtheta = 0.0872_rad;
-
- struct StackContents {
- double t0;
- double t1;
- };
-
- /**
- * A malformed spline does not actually explode the LIFO stack size. Instead,
- * the stack size stays at a relatively small number (e.g. 30) and never
- * decreases. Because of this, we must count iterations. Even long, complex
- * paths don't usually go over 300 iterations, so hitting this maximum should
- * definitely indicate something has gone wrong.
- */
- static constexpr int kMaxIterations = 5000;
-
- friend class CubicHermiteSplineTest;
- friend class QuinticHermiteSplineTest;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/Trajectory.h b/wpilibc/src/main/native/include/frc/trajectory/Trajectory.h
deleted file mode 100644
index 13e32d6..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/Trajectory.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <vector>
-
-#include <units/units.h>
-
-#include "frc/geometry/Pose2d.h"
-#include "frc/geometry/Transform2d.h"
-
-namespace wpi {
-class json;
-} // namespace wpi
-
-namespace frc {
-
-/**
- * Define a unit for curvature.
- */
-using curvature_t = units::unit_t<
- units::compound_unit<units::radian, units::inverse<units::meter>>>;
-
-/**
- * Represents a time-parameterized trajectory. The trajectory contains of
- * various States that represent the pose, curvature, time elapsed, velocity,
- * and acceleration at that point.
- */
-class Trajectory {
- public:
- /**
- * Represents one point on the trajectory.
- */
- struct State {
- // The time elapsed since the beginning of the trajectory.
- units::second_t t = 0_s;
-
- // The speed at that point of the trajectory.
- units::meters_per_second_t velocity = 0_mps;
-
- // The acceleration at that point of the trajectory.
- units::meters_per_second_squared_t acceleration = 0_mps_sq;
-
- // The pose at that point of the trajectory.
- Pose2d pose;
-
- // The curvature at that point of the trajectory.
- curvature_t curvature{0.0};
-
- /**
- * Checks equality between this State and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are equal.
- */
- bool operator==(const State& other) const;
-
- /**
- * Checks inequality between this State and another object.
- *
- * @param other The other object.
- * @return Whether the two objects are not equal.
- */
- bool operator!=(const State& other) const;
-
- /**
- * Interpolates between two States.
- *
- * @param endValue The end value for the interpolation.
- * @param i The interpolant (fraction).
- *
- * @return The interpolated state.
- */
- State Interpolate(State endValue, double i) const;
- };
-
- Trajectory() = default;
-
- /**
- * Constructs a trajectory from a vector of states.
- */
- explicit Trajectory(const std::vector<State>& states);
-
- /**
- * Returns the overall duration of the trajectory.
- * @return The duration of the trajectory.
- */
- units::second_t TotalTime() const { return m_totalTime; }
-
- /**
- * Return the states of the trajectory.
- * @return The states of the trajectory.
- */
- const std::vector<State>& States() const { return m_states; }
-
- /**
- * Sample the trajectory at a point in time.
- *
- * @param t The point in time since the beginning of the trajectory to sample.
- * @return The state at that point in time.
- */
- State Sample(units::second_t t) const;
-
- /**
- * Transforms all poses in the trajectory by the given transform. This is
- * useful for converting a robot-relative trajectory into a field-relative
- * trajectory. This works with respect to the first pose in the trajectory.
- *
- * @param transform The transform to transform the trajectory by.
- * @return The transformed trajectory.
- */
- Trajectory TransformBy(const Transform2d& transform);
-
- /**
- * Transforms all poses in the trajectory so that they are relative to the
- * given pose. This is useful for converting a field-relative trajectory
- * into a robot-relative trajectory.
- *
- * @param pose The pose that is the origin of the coordinate frame that
- * the current trajectory will be transformed into.
- * @return The transformed trajectory.
- */
- Trajectory RelativeTo(const Pose2d& pose);
-
- /**
- * Returns the initial pose of the trajectory.
- *
- * @return The initial pose of the trajectory.
- */
- Pose2d InitialPose() const { return Sample(0_s).pose; }
-
- private:
- std::vector<State> m_states;
- units::second_t m_totalTime;
-
- /**
- * Linearly interpolates between two values.
- *
- * @param startValue The start value.
- * @param endValue The end value.
- * @param t The fraction for interpolation.
- *
- * @return The interpolated value.
- */
- template <typename T>
- static T Lerp(const T& startValue, const T& endValue, const double t) {
- return startValue + (endValue - startValue) * t;
- }
-};
-
-void to_json(wpi::json& json, const Trajectory::State& state);
-
-void from_json(const wpi::json& json, Trajectory::State& state);
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryConfig.h b/wpilibc/src/main/native/include/frc/trajectory/TrajectoryConfig.h
deleted file mode 100644
index 36118a0..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryConfig.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <utility>
-#include <vector>
-
-#include <units/units.h>
-
-#include "frc/kinematics/DifferentialDriveKinematics.h"
-#include "frc/kinematics/MecanumDriveKinematics.h"
-#include "frc/kinematics/SwerveDriveKinematics.h"
-#include "frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h"
-#include "frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h"
-#include "frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-namespace frc {
-/**
- * Represents the configuration for generating a trajectory. This class stores
- * the start velocity, end velocity, max velocity, max acceleration, custom
- * constraints, and the reversed flag.
- *
- * The class must be constructed with a max velocity and max acceleration.
- * The other parameters (start velocity, end velocity, constraints, reversed)
- * have been defaulted to reasonable values (0, 0, {}, false). These values can
- * be changed via the SetXXX methods.
- */
-class TrajectoryConfig {
- public:
- /**
- * Constructs a config object.
- * @param maxVelocity The max velocity of the trajectory.
- * @param maxAcceleration The max acceleration of the trajectory.
- */
- TrajectoryConfig(units::meters_per_second_t maxVelocity,
- units::meters_per_second_squared_t maxAcceleration)
- : m_maxVelocity(maxVelocity), m_maxAcceleration(maxAcceleration) {}
-
- TrajectoryConfig(const TrajectoryConfig&) = delete;
- TrajectoryConfig& operator=(const TrajectoryConfig&) = delete;
-
- TrajectoryConfig(TrajectoryConfig&&) = default;
- TrajectoryConfig& operator=(TrajectoryConfig&&) = default;
-
- /**
- * Sets the start velocity of the trajectory.
- * @param startVelocity The start velocity of the trajectory.
- */
- void SetStartVelocity(units::meters_per_second_t startVelocity) {
- m_startVelocity = startVelocity;
- }
-
- /**
- * Sets the end velocity of the trajectory.
- * @param endVelocity The end velocity of the trajectory.
- */
- void SetEndVelocity(units::meters_per_second_t endVelocity) {
- m_endVelocity = endVelocity;
- }
-
- /**
- * Sets the reversed flag of the trajectory.
- * @param reversed Whether the trajectory should be reversed or not.
- */
- void SetReversed(bool reversed) { m_reversed = reversed; }
-
- /**
- * Adds a user-defined constraint to the trajectory.
- * @param constraint The user-defined constraint.
- */
- template <typename Constraint, typename = std::enable_if_t<std::is_base_of_v<
- TrajectoryConstraint, Constraint>>>
- void AddConstraint(Constraint constraint) {
- m_constraints.emplace_back(std::make_unique<Constraint>(constraint));
- }
-
- /**
- * Adds a differential drive kinematics constraint to ensure that
- * no wheel velocity of a differential drive goes above the max velocity.
- *
- * @param kinematics The differential drive kinematics.
- */
- void SetKinematics(const DifferentialDriveKinematics& kinematics) {
- AddConstraint(
- DifferentialDriveKinematicsConstraint(kinematics, m_maxVelocity));
- }
-
- /**
- * Adds a mecanum drive kinematics constraint to ensure that
- * no wheel velocity of a mecanum drive goes above the max velocity.
- *
- * @param kinematics The mecanum drive kinematics.
- */
- void SetKinematics(MecanumDriveKinematics kinematics) {
- AddConstraint(MecanumDriveKinematicsConstraint(kinematics, m_maxVelocity));
- }
-
- /**
- * Adds a swerve drive kinematics constraint to ensure that
- * no wheel velocity of a swerve drive goes above the max velocity.
- *
- * @param kinematics The swerve drive kinematics.
- */
- template <size_t NumModules>
- void SetKinematics(SwerveDriveKinematics<NumModules>& kinematics) {
- AddConstraint(SwerveDriveKinematicsConstraint(kinematics, m_maxVelocity));
- }
-
- /**
- * Returns the starting velocity of the trajectory.
- * @return The starting velocity of the trajectory.
- */
- units::meters_per_second_t StartVelocity() const { return m_startVelocity; }
-
- /**
- * Returns the ending velocity of the trajectory.
- * @return The ending velocity of the trajectory.
- */
- units::meters_per_second_t EndVelocity() const { return m_endVelocity; }
-
- /**
- * Returns the maximum velocity of the trajectory.
- * @return The maximum velocity of the trajectory.
- */
- units::meters_per_second_t MaxVelocity() const { return m_maxVelocity; }
-
- /**
- * Returns the maximum acceleration of the trajectory.
- * @return The maximum acceleration of the trajectory.
- */
- units::meters_per_second_squared_t MaxAcceleration() const {
- return m_maxAcceleration;
- }
-
- /**
- * Returns the user-defined constraints of the trajectory.
- * @return The user-defined constraints of the trajectory.
- */
- const std::vector<std::unique_ptr<TrajectoryConstraint>>& Constraints()
- const {
- return m_constraints;
- }
-
- /**
- * Returns whether the trajectory is reversed or not.
- * @return whether the trajectory is reversed or not.
- */
- bool IsReversed() const { return m_reversed; }
-
- private:
- units::meters_per_second_t m_startVelocity = 0_mps;
- units::meters_per_second_t m_endVelocity = 0_mps;
- units::meters_per_second_t m_maxVelocity;
- units::meters_per_second_squared_t m_maxAcceleration;
- std::vector<std::unique_ptr<TrajectoryConstraint>> m_constraints;
- bool m_reversed = false;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryGenerator.h b/wpilibc/src/main/native/include/frc/trajectory/TrajectoryGenerator.h
deleted file mode 100644
index 40e7e7b..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryGenerator.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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. */
-/*----------------------------------------------------------------------------*/
-
-#pragma once
-
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "frc/spline/SplineParameterizer.h"
-#include "frc/trajectory/Trajectory.h"
-#include "frc/trajectory/TrajectoryConfig.h"
-#include "frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-namespace frc {
-/**
- * Helper class used to generate trajectories with various constraints.
- */
-class TrajectoryGenerator {
- public:
- using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
-
- /**
- * Generates a trajectory from the given control vectors and config. This
- * method uses clamped cubic splines -- a method in which the exterior control
- * vectors and interior waypoints are provided. The headings are automatically
- * determined at the interior points to ensure continuous curvature.
- *
- * @param initial The initial control vector.
- * @param interiorWaypoints The interior waypoints.
- * @param end The ending control vector.
- * @param config The configuration for the trajectory.
- * @return The generated trajectory.
- */
- static Trajectory GenerateTrajectory(
- Spline<3>::ControlVector initial,
- const std::vector<Translation2d>& interiorWaypoints,
- Spline<3>::ControlVector end, const TrajectoryConfig& config);
-
- /**
- * Generates a trajectory from the given waypoints and config. This method
- * uses clamped cubic splines -- a method in which the initial pose, final
- * pose, and interior waypoints are provided. The headings are automatically
- * determined at the interior points to ensure continuous curvature.
- *
- * @param start The starting pose.
- * @param interiorWaypoints The interior waypoints.
- * @param end The ending pose.
- * @param config The configuration for the trajectory.
- * @return The generated trajectory.
- */
- static Trajectory GenerateTrajectory(
- const Pose2d& start, const std::vector<Translation2d>& interiorWaypoints,
- const Pose2d& end, const TrajectoryConfig& config);
-
- /**
- * Generates a trajectory from the given quintic control vectors and config.
- * This method uses quintic hermite splines -- therefore, all points must be
- * represented by control vectors. Continuous curvature is guaranteed in this
- * method.
- *
- * @param controlVectors List of quintic control vectors.
- * @param config The configuration for the trajectory.
- * @return The generated trajectory.
- */
- static Trajectory GenerateTrajectory(
- std::vector<Spline<5>::ControlVector> controlVectors,
- const TrajectoryConfig& config);
-
- /**
- * Generates a trajectory from the given waypoints and config. This method
- * uses quintic hermite splines -- therefore, all points must be represented
- * by Pose2d objects. Continuous curvature is guaranteed in this method.
- *
- * @param waypoints List of waypoints..
- * @param config The configuration for the trajectory.
- * @return The generated trajectory.
- */
- static Trajectory GenerateTrajectory(const std::vector<Pose2d>& waypoints,
- const TrajectoryConfig& config);
-
- /**
- * Generate spline points from a vector of splines by parameterizing the
- * splines.
- *
- * @param splines The splines to parameterize.
- *
- * @return The spline points for use in time parameterization of a trajectory.
- */
- template <typename Spline>
- static std::vector<PoseWithCurvature> SplinePointsFromSplines(
- const std::vector<Spline>& splines) {
- // Create the vector of spline points.
- std::vector<PoseWithCurvature> splinePoints;
-
- // Add the first point to the vector.
- splinePoints.push_back(splines.front().GetPoint(0.0));
-
- // Iterate through the vector and parameterize each spline, adding the
- // parameterized points to the final vector.
- for (auto&& spline : splines) {
- auto points = SplineParameterizer::Parameterize(spline);
- // Append the array of poses to the vector. We are removing the first
- // point because it's a duplicate of the last point from the previous
- // spline.
- splinePoints.insert(std::end(splinePoints), std::begin(points) + 1,
- std::end(points));
- }
- return splinePoints;
- }
-
- private:
- static const Trajectory kDoNothingTrajectory;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryParameterizer.h b/wpilibc/src/main/native/include/frc/trajectory/TrajectoryParameterizer.h
deleted file mode 100644
index b8ea8da..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryParameterizer.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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. */
-/*----------------------------------------------------------------------------*/
-
-/*
- * MIT License
- *
- * Copyright (c) 2018 Team 254
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#pragma once
-
-#include <memory>
-#include <utility>
-#include <vector>
-
-#include "frc/trajectory/Trajectory.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-namespace frc {
-/**
- * Class used to parameterize a trajectory by time.
- */
-class TrajectoryParameterizer {
- public:
- using PoseWithCurvature = std::pair<Pose2d, curvature_t>;
-
- /**
- * Parameterize the trajectory by time. This is where the velocity profile is
- * generated.
- *
- * The derivation of the algorithm used can be found here:
- * <http://www2.informatik.uni-freiburg.de/~lau/students/Sprunk2008.pdf>
- *
- * @param points Reference to the spline points.
- * @param constraints A vector of various velocity and acceleration
- * constraints.
- * @param startVelocity The start velocity for the trajectory.
- * @param endVelocity The end velocity for the trajectory.
- * @param maxVelocity The max velocity for the trajectory.
- * @param maxAcceleration The max acceleration for the trajectory.
- * @param reversed Whether the robot should move backwards. Note that the
- * robot will still move from a -> b -> ... -> z as defined in the waypoints.
- *
- * @return The trajectory.
- */
- static Trajectory TimeParameterizeTrajectory(
- const std::vector<PoseWithCurvature>& points,
- const std::vector<std::unique_ptr<TrajectoryConstraint>>& constraints,
- units::meters_per_second_t startVelocity,
- units::meters_per_second_t endVelocity,
- units::meters_per_second_t maxVelocity,
- units::meters_per_second_squared_t maxAcceleration, bool reversed);
-
- private:
- constexpr static double kEpsilon = 1E-6;
-
- /**
- * Represents a constrained state that is used when time parameterizing a
- * trajectory. Each state has the pose, curvature, distance from the start of
- * the trajectory, max velocity, min acceleration and max acceleration.
- */
- struct ConstrainedState {
- PoseWithCurvature pose = {Pose2d(), curvature_t(0.0)};
- units::meter_t distance = 0_m;
- units::meters_per_second_t maxVelocity = 0_mps;
- units::meters_per_second_squared_t minAcceleration = 0_mps_sq;
- units::meters_per_second_squared_t maxAcceleration = 0_mps_sq;
- };
-
- /**
- * Enforces acceleration limits as defined by the constraints. This function
- * is used when time parameterizing a trajectory.
- *
- * @param reverse Whether the robot is traveling backwards.
- * @param constraints A vector of the user-defined velocity and acceleration
- * constraints.
- * @param state Pointer to the constrained state that we are operating on.
- * This is mutated in place.
- */
- static void EnforceAccelerationLimits(
- bool reverse,
- const std::vector<std::unique_ptr<TrajectoryConstraint>>& constraints,
- ConstrainedState* state);
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryUtil.h b/wpilibc/src/main/native/include/frc/trajectory/TrajectoryUtil.h
deleted file mode 100644
index 700ed9c..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/TrajectoryUtil.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <string>
-
-#include <wpi/StringRef.h>
-#include <wpi/Twine.h>
-
-#include "frc/trajectory/Trajectory.h"
-
-namespace frc {
-class TrajectoryUtil {
- public:
- TrajectoryUtil() = delete;
-
- /**
- * Exports a Trajectory to a PathWeaver-style JSON file.
- *
- * @param trajectory the trajectory to export
- * @param path the path of the file to export to
- *
- * @return The interpolated state.
- */
- static void ToPathweaverJson(const Trajectory& trajectory,
- const wpi::Twine& path);
- /**
- * Imports a Trajectory from a PathWeaver-style JSON file.
- *
- * @param path The path of the json file to import from.
- *
- * @return The trajectory represented by the file.
- */
- static Trajectory FromPathweaverJson(const wpi::Twine& path);
-
- /**
- * Deserializes a Trajectory from PathWeaver-style JSON.
-
- * @param json the string containing the serialized JSON
-
- * @return the trajectory represented by the JSON
- */
- static std::string SerializeTrajectory(const Trajectory& trajectory);
-
- /**
- * Serializes a Trajectory to PathWeaver-style JSON.
-
- * @param trajectory the trajectory to export
-
- * @return the string containing the serialized JSON
- */
- static Trajectory DeserializeTrajectory(wpi::StringRef json_str);
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.h b/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.h
deleted file mode 100644
index 575088e..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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/FRCUsageReporting.h>
-#include <units/units.h>
-
-namespace frc {
-
-/**
- * A trapezoid-shaped velocity profile.
- *
- * While this class can be used for a profiled movement from start to finish,
- * the intended usage is to filter a reference's dynamics based on trapezoidal
- * velocity constraints. To compute the reference obeying this constraint, do
- * the following.
- *
- * Initialization:
- * @code{.cpp}
- * TrapezoidalMotionProfile::Constraints constraints{kMaxV, kMaxA};
- * double previousProfiledReference = initialReference;
- * @endcode
- *
- * Run on update:
- * @code{.cpp}
- * TrapezoidalMotionProfile profile{constraints, unprofiledReference,
- * previousProfiledReference};
- * previousProfiledReference = profile.Calculate(timeSincePreviousUpdate);
- * @endcode
- *
- * where `unprofiledReference` is free to change between calls. Note that when
- * the unprofiled reference is within the constraints, `Calculate()` returns the
- * unprofiled reference unchanged.
- *
- * Otherwise, a timer can be started to provide monotonic values for
- * `Calculate()` and to determine when the profile has completed via
- * `IsFinished()`.
- */
-template <class Distance>
-class TrapezoidProfile {
- using Distance_t = units::unit_t<Distance>;
- using Velocity =
- units::compound_unit<Distance, units::inverse<units::seconds>>;
- using Velocity_t = units::unit_t<Velocity>;
- using Acceleration =
- units::compound_unit<Velocity, units::inverse<units::seconds>>;
- using Acceleration_t = units::unit_t<Acceleration>;
-
- public:
- class Constraints {
- public:
- Constraints() {
- HAL_Report(HALUsageReporting::kResourceType_TrapezoidProfile, 1);
- }
- Constraints(Velocity_t maxVelocity_, Acceleration_t maxAcceleration_)
- : maxVelocity{maxVelocity_}, maxAcceleration{maxAcceleration_} {
- HAL_Report(HALUsageReporting::kResourceType_TrapezoidProfile, 1);
- }
- Velocity_t maxVelocity{0};
- Acceleration_t maxAcceleration{0};
- };
-
- class State {
- public:
- Distance_t position{0};
- Velocity_t velocity{0};
- bool operator==(const State& rhs) const {
- return position == rhs.position && velocity == rhs.velocity;
- }
- bool operator!=(const State& rhs) const { return !(*this == rhs); }
- };
-
- /**
- * Construct a TrapezoidProfile.
- *
- * @param constraints The constraints on the profile, like maximum velocity.
- * @param goal The desired state when the profile is complete.
- * @param initial The initial state (usually the current state).
- */
- TrapezoidProfile(Constraints constraints, State goal,
- State initial = State{Distance_t(0), Velocity_t(0)});
-
- TrapezoidProfile(const TrapezoidProfile&) = default;
- TrapezoidProfile& operator=(const TrapezoidProfile&) = default;
- TrapezoidProfile(TrapezoidProfile&&) = default;
- TrapezoidProfile& operator=(TrapezoidProfile&&) = default;
-
- /**
- * Calculate the correct position and velocity for the profile at a time t
- * where the beginning of the profile was at time t = 0.
- *
- * @param t The time since the beginning of the profile.
- */
- State Calculate(units::second_t t) const;
-
- /**
- * Returns the time left until a target distance in the profile is reached.
- *
- * @param target The target distance.
- */
- units::second_t TimeLeftUntil(Distance_t target) const;
-
- /**
- * Returns the total time the profile takes to reach the goal.
- */
- units::second_t TotalTime() const { return m_endDeccel; }
-
- /**
- * Returns true if the profile has reached the goal.
- *
- * The profile has reached the goal if the time since the profile started
- * has exceeded the profile's total time.
- *
- * @param t The time since the beginning of the profile.
- */
- bool IsFinished(units::second_t t) const { return t >= TotalTime(); }
-
- private:
- /**
- * Returns true if the profile inverted.
- *
- * The profile is inverted if goal position is less than the initial position.
- *
- * @param initial The initial state (usually the current state).
- * @param goal The desired state when the profile is complete.
- */
- static bool ShouldFlipAcceleration(const State& initial, const State& goal) {
- return initial.position > goal.position;
- }
-
- // Flip the sign of the velocity and position if the profile is inverted
- State Direct(const State& in) const {
- State result = in;
- result.position *= m_direction;
- result.velocity *= m_direction;
- return result;
- }
-
- // The direction of the profile, either 1 for forwards or -1 for inverted
- int m_direction;
-
- Constraints m_constraints;
- State m_initial;
- State m_goal;
-
- units::second_t m_endAccel;
- units::second_t m_endFullSpeed;
- units::second_t m_endDeccel;
-};
-} // namespace frc
-
-#include "TrapezoidProfile.inc"
diff --git a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.inc b/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.inc
deleted file mode 100644
index 50f232d..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/TrapezoidProfile.inc
+++ /dev/null
@@ -1,163 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <algorithm>
-
-namespace frc {
-template <class Distance>
-TrapezoidProfile<Distance>::TrapezoidProfile(Constraints constraints,
- State goal, State initial)
- : m_direction{ShouldFlipAcceleration(initial, goal) ? -1 : 1},
- m_constraints(constraints),
- m_initial(Direct(initial)),
- m_goal(Direct(goal)) {
- if (m_initial.velocity > m_constraints.maxVelocity) {
- m_initial.velocity = m_constraints.maxVelocity;
- }
-
- // Deal with a possibly truncated motion profile (with nonzero initial or
- // final velocity) by calculating the parameters as if the profile began and
- // ended at zero velocity
- units::second_t cutoffBegin =
- m_initial.velocity / m_constraints.maxAcceleration;
- Distance_t cutoffDistBegin =
- cutoffBegin * cutoffBegin * m_constraints.maxAcceleration / 2.0;
-
- units::second_t cutoffEnd = m_goal.velocity / m_constraints.maxAcceleration;
- Distance_t cutoffDistEnd =
- cutoffEnd * cutoffEnd * m_constraints.maxAcceleration / 2.0;
-
- // Now we can calculate the parameters as if it was a full trapezoid instead
- // of a truncated one
-
- Distance_t fullTrapezoidDist =
- cutoffDistBegin + (m_goal.position - m_initial.position) + cutoffDistEnd;
- units::second_t accelerationTime =
- m_constraints.maxVelocity / m_constraints.maxAcceleration;
-
- Distance_t fullSpeedDist =
- fullTrapezoidDist -
- accelerationTime * accelerationTime * m_constraints.maxAcceleration;
-
- // Handle the case where the profile never reaches full speed
- if (fullSpeedDist < Distance_t(0)) {
- accelerationTime =
- units::math::sqrt(fullTrapezoidDist / m_constraints.maxAcceleration);
- fullSpeedDist = Distance_t(0);
- }
-
- m_endAccel = accelerationTime - cutoffBegin;
- m_endFullSpeed = m_endAccel + fullSpeedDist / m_constraints.maxVelocity;
- m_endDeccel = m_endFullSpeed + accelerationTime - cutoffEnd;
-}
-
-template <class Distance>
-typename TrapezoidProfile<Distance>::State
-TrapezoidProfile<Distance>::Calculate(units::second_t t) const {
- State result = m_initial;
-
- if (t < m_endAccel) {
- result.velocity += t * m_constraints.maxAcceleration;
- result.position +=
- (m_initial.velocity + t * m_constraints.maxAcceleration / 2.0) * t;
- } else if (t < m_endFullSpeed) {
- result.velocity = m_constraints.maxVelocity;
- result.position += (m_initial.velocity +
- m_endAccel * m_constraints.maxAcceleration / 2.0) *
- m_endAccel +
- m_constraints.maxVelocity * (t - m_endAccel);
- } else if (t <= m_endDeccel) {
- result.velocity =
- m_goal.velocity + (m_endDeccel - t) * m_constraints.maxAcceleration;
- units::second_t timeLeft = m_endDeccel - t;
- result.position =
- m_goal.position -
- (m_goal.velocity + timeLeft * m_constraints.maxAcceleration / 2.0) *
- timeLeft;
- } else {
- result = m_goal;
- }
-
- return Direct(result);
-}
-
-template <class Distance>
-units::second_t TrapezoidProfile<Distance>::TimeLeftUntil(
- Distance_t target) const {
- Distance_t position = m_initial.position * m_direction;
- Velocity_t velocity = m_initial.velocity * m_direction;
-
- units::second_t endAccel = m_endAccel * m_direction;
- units::second_t endFullSpeed = m_endFullSpeed * m_direction - endAccel;
-
- if (target < position) {
- endAccel *= -1.0;
- endFullSpeed *= -1.0;
- velocity *= -1.0;
- }
-
- endAccel = units::math::max(endAccel, 0_s);
- endFullSpeed = units::math::max(endFullSpeed, 0_s);
- units::second_t endDeccel = m_endDeccel - endAccel - endFullSpeed;
- endDeccel = units::math::max(endDeccel, 0_s);
-
- const Acceleration_t acceleration = m_constraints.maxAcceleration;
- const Acceleration_t decceleration = -m_constraints.maxAcceleration;
-
- Distance_t distToTarget = units::math::abs(target - position);
-
- if (distToTarget < Distance_t(1e-6)) {
- return 0_s;
- }
-
- Distance_t accelDist =
- velocity * endAccel + 0.5 * acceleration * endAccel * endAccel;
-
- Velocity_t deccelVelocity;
- if (endAccel > 0_s) {
- deccelVelocity = units::math::sqrt(
- units::math::abs(velocity * velocity + 2 * acceleration * accelDist));
- } else {
- deccelVelocity = velocity;
- }
-
- Distance_t deccelDist =
- deccelVelocity * endDeccel + 0.5 * decceleration * endDeccel * endDeccel;
-
- deccelDist = units::math::max(deccelDist, Distance_t(0));
-
- Distance_t fullSpeedDist = m_constraints.maxVelocity * endFullSpeed;
-
- if (accelDist > distToTarget) {
- accelDist = distToTarget;
- fullSpeedDist = Distance_t(0);
- deccelDist = Distance_t(0);
- } else if (accelDist + fullSpeedDist > distToTarget) {
- fullSpeedDist = distToTarget - accelDist;
- deccelDist = Distance_t(0);
- } else {
- deccelDist = distToTarget - fullSpeedDist - accelDist;
- }
-
- units::second_t accelTime =
- (-velocity + units::math::sqrt(units::math::abs(
- velocity * velocity + 2 * acceleration * accelDist))) /
- acceleration;
-
- units::second_t deccelTime =
- (-deccelVelocity +
- units::math::sqrt(units::math::abs(deccelVelocity * deccelVelocity +
- 2 * decceleration * deccelDist))) /
- decceleration;
-
- units::second_t fullSpeedTime = fullSpeedDist / m_constraints.maxVelocity;
-
- return accelTime + fullSpeedTime + deccelTime;
-}
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/CentripetalAccelerationConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/CentripetalAccelerationConstraint.h
deleted file mode 100644
index de25738..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/constraint/CentripetalAccelerationConstraint.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-namespace frc {
-
-/**
- * A constraint on the maximum absolute centripetal acceleration allowed when
- * traversing a trajectory. The centripetal acceleration of a robot is defined
- * as the velocity squared divided by the radius of curvature.
- *
- * Effectively, limiting the maximum centripetal acceleration will cause the
- * robot to slow down around tight turns, making it easier to track trajectories
- * with sharp turns.
- */
-class CentripetalAccelerationConstraint : public TrajectoryConstraint {
- public:
- explicit CentripetalAccelerationConstraint(
- units::meters_per_second_squared_t maxCentripetalAcceleration);
-
- units::meters_per_second_t MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) override;
-
- MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) override;
-
- private:
- units::meters_per_second_squared_t m_maxCentripetalAcceleration;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h
deleted file mode 100644
index 6259c96..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "frc/kinematics/DifferentialDriveKinematics.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-/**
- * A class that enforces constraints on the differential drive kinematics.
- * This can be used to ensure that the trajectory is constructed so that the
- * commanded velocities for both sides of the drivetrain stay below a certain
- * limit.
- */
-namespace frc {
-class DifferentialDriveKinematicsConstraint : public TrajectoryConstraint {
- public:
- DifferentialDriveKinematicsConstraint(DifferentialDriveKinematics kinematics,
- units::meters_per_second_t maxSpeed);
-
- units::meters_per_second_t MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) override;
-
- MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) override;
-
- private:
- DifferentialDriveKinematics m_kinematics;
- units::meters_per_second_t m_maxSpeed;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h
deleted file mode 100644
index 50ace85..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-
-#include "frc/controller/SimpleMotorFeedforward.h"
-#include "frc/kinematics/DifferentialDriveKinematics.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-namespace frc {
-/**
- * A class that enforces constraints on differential drive voltage expenditure
- * based on the motor dynamics and the drive kinematics. Ensures that the
- * acceleration of any wheel of the robot while following the trajectory is
- * never higher than what can be achieved with the given maximum voltage.
- */
-class DifferentialDriveVoltageConstraint : public TrajectoryConstraint {
- public:
- /**
- * Creates a new DifferentialDriveVoltageConstraint.
- *
- * @param feedforward A feedforward component describing the behavior of the
- * drive.
- * @param kinematics A kinematics component describing the drive geometry.
- * @param maxVoltage The maximum voltage available to the motors while
- * following the path. Should be somewhat less than the nominal battery
- * voltage (12V) to account for "voltage sag" due to current draw.
- */
- DifferentialDriveVoltageConstraint(
- SimpleMotorFeedforward<units::meter> feedforward,
- DifferentialDriveKinematics kinematics, units::volt_t maxVoltage);
-
- units::meters_per_second_t MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) override;
-
- MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) override;
-
- private:
- SimpleMotorFeedforward<units::meter> m_feedforward;
- DifferentialDriveKinematics m_kinematics;
- units::volt_t m_maxVoltage;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h
deleted file mode 100644
index 53e3953..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/constraint/MecanumDriveKinematicsConstraint.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <cmath>
-
-#include <units/units.h>
-
-#include "frc/kinematics/MecanumDriveKinematics.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-/**
- * A class that enforces constraints on the differential drive kinematics.
- * This can be used to ensure that the trajectory is constructed so that the
- * commanded velocities for both sides of the drivetrain stay below a certain
- * limit.
- */
-namespace frc {
-class MecanumDriveKinematicsConstraint : public TrajectoryConstraint {
- public:
- MecanumDriveKinematicsConstraint(MecanumDriveKinematics kinematics,
- units::meters_per_second_t maxSpeed);
-
- units::meters_per_second_t MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) override;
-
- MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) override;
-
- private:
- MecanumDriveKinematics m_kinematics;
- units::meters_per_second_t m_maxSpeed;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h
deleted file mode 100644
index a8ad870..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <cmath>
-
-#include <units/units.h>
-
-#include "frc/kinematics/SwerveDriveKinematics.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-/**
- * A class that enforces constraints on the differential drive kinematics.
- * This can be used to ensure that the trajectory is constructed so that the
- * commanded velocities for both sides of the drivetrain stay below a certain
- * limit.
- */
-namespace frc {
-
-template <size_t NumModules>
-class SwerveDriveKinematicsConstraint : public TrajectoryConstraint {
- public:
- SwerveDriveKinematicsConstraint(
- frc::SwerveDriveKinematics<NumModules> kinematics,
- units::meters_per_second_t maxSpeed);
-
- units::meters_per_second_t MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) override;
-
- MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) override;
-
- private:
- frc::SwerveDriveKinematics<NumModules> m_kinematics;
- units::meters_per_second_t m_maxSpeed;
-};
-} // namespace frc
-
-#include "SwerveDriveKinematicsConstraint.inc"
diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.inc b/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.inc
deleted file mode 100644
index c3437d5..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/constraint/SwerveDriveKinematicsConstraint.inc
+++ /dev/null
@@ -1,49 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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
-
-/**
- * A class that enforces constraints on the differential drive kinematics.
- * This can be used to ensure that the trajectory is constructed so that the
- * commanded velocities for both sides of the drivetrain stay below a certain
- * limit.
- */
-
-namespace frc {
-
-template <size_t NumModules>
-SwerveDriveKinematicsConstraint<NumModules>::SwerveDriveKinematicsConstraint(
- frc::SwerveDriveKinematics<NumModules> kinematics,
- units::meters_per_second_t maxSpeed)
- : m_kinematics(kinematics), m_maxSpeed(maxSpeed) {}
-
-template <size_t NumModules>
-units::meters_per_second_t
-SwerveDriveKinematicsConstraint<NumModules>::MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) {
- auto xVelocity = velocity * pose.Rotation().Cos();
- auto yVelocity = velocity * pose.Rotation().Sin();
- auto wheelSpeeds = m_kinematics.ToSwerveModuleStates(
- {xVelocity, yVelocity, velocity * curvature});
- m_kinematics.NormalizeWheelSpeeds(&wheelSpeeds, m_maxSpeed);
-
- auto normSpeeds = m_kinematics.ToChassisSpeeds(wheelSpeeds);
-
- return units::math::hypot(normSpeeds.vx, normSpeeds.vy);
-}
-
-template <size_t NumModules>
-TrajectoryConstraint::MinMax
-SwerveDriveKinematicsConstraint<NumModules>::MinMaxAcceleration(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) {
- return {};
-}
-
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/trajectory/constraint/TrajectoryConstraint.h b/wpilibc/src/main/native/include/frc/trajectory/constraint/TrajectoryConstraint.h
deleted file mode 100644
index dcde8c4..0000000
--- a/wpilibc/src/main/native/include/frc/trajectory/constraint/TrajectoryConstraint.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <limits>
-
-#include <units/units.h>
-
-#include "frc/geometry/Pose2d.h"
-#include "frc/spline/Spline.h"
-
-namespace frc {
-/**
- * An interface for defining user-defined velocity and acceleration constraints
- * while generating trajectories.
- */
-class TrajectoryConstraint {
- public:
- TrajectoryConstraint() = default;
-
- TrajectoryConstraint(const TrajectoryConstraint&) = default;
- TrajectoryConstraint& operator=(const TrajectoryConstraint&) = default;
-
- TrajectoryConstraint(TrajectoryConstraint&&) = default;
- TrajectoryConstraint& operator=(TrajectoryConstraint&&) = default;
-
- virtual ~TrajectoryConstraint() = default;
-
- /**
- * Represents a minimum and maximum acceleration.
- */
- struct MinMax {
- /**
- * The minimum acceleration.
- */
- units::meters_per_second_squared_t minAcceleration{
- -std::numeric_limits<double>::max()};
-
- /**
- * The maximum acceleration.
- */
- units::meters_per_second_squared_t maxAcceleration{
- std::numeric_limits<double>::max()};
- };
-
- /**
- * Returns the max velocity given the current pose and curvature.
- *
- * @param pose The pose at the current point in the trajectory.
- * @param curvature The curvature at the current point in the trajectory.
- * @param velocity The velocity at the current point in the trajectory before
- * constraints are applied.
- *
- * @return The absolute maximum velocity.
- */
- virtual units::meters_per_second_t MaxVelocity(
- const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t velocity) = 0;
-
- /**
- * Returns the minimum and maximum allowable acceleration for the trajectory
- * given pose, curvature, and speed.
- *
- * @param pose The pose at the current point in the trajectory.
- * @param curvature The curvature at the current point in the trajectory.
- * @param speed The speed at the current point in the trajectory.
- *
- * @return The min and max acceleration bounds.
- */
- virtual MinMax MinMaxAcceleration(const Pose2d& pose, curvature_t curvature,
- units::meters_per_second_t speed) = 0;
-};
-} // namespace frc
diff --git a/wpilibc/src/main/native/include/frc/util/Color.h b/wpilibc/src/main/native/include/frc/util/Color.h
index 2538d60..1321380 100644
--- a/wpilibc/src/main/native/include/frc/util/Color.h
+++ b/wpilibc/src/main/native/include/frc/util/Color.h
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -399,7 +399,7 @@
/**
* #20B2AA.
*/
- static const Color kLightSeagGeen;
+ static const Color kLightSeaGreen;
/**
* #87CEFA.
@@ -414,7 +414,7 @@
/**
* #B0C4DE.
*/
- static const Color kLightSteellue;
+ static const Color kLightSteelBlue;
/**
* #FFFFE0.
@@ -755,6 +755,42 @@
green(roundAndClamp(g)),
blue(roundAndClamp(b)) {}
+ /**
+ * Creates a Color from HSV values.
+ *
+ * @param h The h value [0-180]
+ * @param s The s value [0-255]
+ * @param v The v value [0-255]
+ * @return The color
+ */
+ static constexpr Color FromHSV(int h, int s, int v) {
+ if (s == 0) {
+ return {v / 255.0, v / 255.0, v / 255.0};
+ }
+
+ int region = h / 30;
+ int remainder = (h - (region * 30)) * 6;
+
+ int p = (v * (255 - s)) >> 8;
+ int q = (v * (255 - ((s * remainder) >> 8))) >> 8;
+ int t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
+
+ switch (region) {
+ case 0:
+ return Color(v / 255.0, t / 255.0, p / 255.0);
+ case 1:
+ return Color(q / 255.0, v / 255.0, p / 255.0);
+ case 2:
+ return Color(p / 255.0, v / 255.0, t / 255.0);
+ case 3:
+ return Color(p / 255.0, q / 255.0, v / 255.0);
+ case 4:
+ return Color(t / 255.0, p / 255.0, v / 255.0);
+ default:
+ return Color(v / 255.0, p / 255.0, q / 255.0);
+ }
+ }
+
double red = 0.0;
double green = 0.0;
double blue = 0.0;
@@ -864,13 +900,13 @@
inline constexpr Color Color::kLightGreen{0.5647059f, 0.93333334f, 0.5647059f};
inline constexpr Color Color::kLightPink{1.0f, 0.7137255f, 0.75686276f};
inline constexpr Color Color::kLightSalmon{1.0f, 0.627451f, 0.47843137f};
-inline constexpr Color Color::kLightSeagGeen{0.1254902f, 0.69803923f,
+inline constexpr Color Color::kLightSeaGreen{0.1254902f, 0.69803923f,
0.6666667f};
inline constexpr Color Color::kLightSkyBlue{0.5294118f, 0.80784315f,
0.98039216f};
inline constexpr Color Color::kLightSlateGray{0.46666667f, 0.53333336f, 0.6f};
-inline constexpr Color Color::kLightSteellue{0.6901961f, 0.76862746f,
- 0.87058824f};
+inline constexpr Color Color::kLightSteelBlue{0.6901961f, 0.76862746f,
+ 0.87058824f};
inline constexpr Color Color::kLightYellow{1.0f, 1.0f, 0.8784314f};
inline constexpr Color Color::kLime{0.0f, 1.0f, 0.0f};
inline constexpr Color Color::kLimeGreen{0.19607843f, 0.8039216f, 0.19607843f};
diff --git a/wpilibc/src/main/native/include/frc2/Timer.h b/wpilibc/src/main/native/include/frc2/Timer.h
index c1eeb16..8f943a6 100644
--- a/wpilibc/src/main/native/include/frc2/Timer.h
+++ b/wpilibc/src/main/native/include/frc2/Timer.h
@@ -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. */
@@ -7,12 +7,9 @@
#pragma once
-#include <units/units.h>
-#include <wpi/deprecated.h>
+#include <units/time.h>
#include <wpi/mutex.h>
-#include "frc/Base.h"
-
namespace frc2 {
/**
@@ -75,7 +72,8 @@
* Start the timer running.
*
* Just set the running flag to true indicating that all time requests should
- * be relative to the system clock.
+ * be relative to the system clock. Note that this method is a no-op if the
+ * timer is already running.
*/
void Start();
@@ -89,6 +87,14 @@
void Stop();
/**
+ * Check if the period specified has passed.
+ *
+ * @param seconds The period to check.
+ * @return True if the period has passed.
+ */
+ bool HasElapsed(units::second_t period) const;
+
+ /**
* Check if the period specified has passed and if it has, advance the start
* time by that period. This is useful to decide if it's time to do periodic
* work without drifting later by the time it took to get around to checking.
@@ -99,6 +105,16 @@
bool HasPeriodPassed(units::second_t period);
/**
+ * Check if the period specified has passed and if it has, advance the start
+ * time by that period. This is useful to decide if it's time to do periodic
+ * work without drifting later by the time it took to get around to checking.
+ *
+ * @param period The period to check for.
+ * @return True if the period has passed.
+ */
+ bool AdvanceIfElapsed(units::second_t period);
+
+ /**
* Return the FPGA system clock time in seconds.
*
* Return the time from the FPGA hardware clock in seconds since the FPGA
@@ -125,9 +141,6 @@
*/
static units::second_t GetMatchTime();
- // The time, in seconds, at which the 32-bit FPGA timestamp rolls over to 0
- static const units::second_t kRolloverTime;
-
private:
units::second_t m_startTime = 0_s;
units::second_t m_accumulatedTime = 0_s;
diff --git a/wpilibc/src/test/native/cpp/DriverStationTest.cpp b/wpilibc/src/test/native/cpp/DriverStationTest.cpp
new file mode 100644
index 0000000..3b8272f
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/DriverStationTest.cpp
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <string>
+#include <tuple>
+
+#include "frc/DriverStation.h"
+#include "frc/Joystick.h"
+#include "frc/simulation/DriverStationSim.h"
+#include "frc/simulation/SimHooks.h"
+#include "gtest/gtest.h"
+
+class IsJoystickConnectedParametersTests
+ : public ::testing::TestWithParam<std::tuple<int, int, int, bool>> {};
+
+TEST_P(IsJoystickConnectedParametersTests, IsJoystickConnected) {
+ frc::sim::DriverStationSim::SetJoystickAxisCount(1, std::get<0>(GetParam()));
+ frc::sim::DriverStationSim::SetJoystickButtonCount(1,
+ std::get<1>(GetParam()));
+ frc::sim::DriverStationSim::SetJoystickPOVCount(1, std::get<2>(GetParam()));
+ frc::sim::DriverStationSim::NotifyNewData();
+
+ ASSERT_EQ(std::get<3>(GetParam()),
+ frc::DriverStation::GetInstance().IsJoystickConnected(1));
+}
+
+INSTANTIATE_TEST_SUITE_P(IsConnectedTests, IsJoystickConnectedParametersTests,
+ ::testing::Values(std::make_tuple(0, 0, 0, false),
+ std::make_tuple(1, 0, 0, true),
+ std::make_tuple(0, 1, 0, true),
+ std::make_tuple(0, 0, 1, true),
+ std::make_tuple(1, 1, 1, true),
+ std::make_tuple(4, 10, 1, true)));
+class JoystickConnectionWarningTests
+ : public ::testing::TestWithParam<
+ std::tuple<bool, bool, bool, std::string>> {};
+
+TEST_P(JoystickConnectionWarningTests, JoystickConnectionWarnings) {
+ // Capture all output to stderr.
+ ::testing::internal::CaptureStderr();
+
+ // Set FMS and Silence settings
+ frc::sim::DriverStationSim::SetFmsAttached(std::get<0>(GetParam()));
+ frc::sim::DriverStationSim::NotifyNewData();
+ frc::DriverStation::GetInstance().SilenceJoystickConnectionWarning(
+ std::get<1>(GetParam()));
+
+ // Create joystick and attempt to retrieve button.
+ frc::Joystick joystick(0);
+ joystick.GetRawButton(1);
+
+ frc::sim::StepTiming(1_s);
+ EXPECT_EQ(
+ frc::DriverStation::GetInstance().IsJoystickConnectionWarningSilenced(),
+ std::get<2>(GetParam()));
+ EXPECT_EQ(::testing::internal::GetCapturedStderr(), std::get<3>(GetParam()));
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ DriverStation, JoystickConnectionWarningTests,
+ ::testing::Values(std::make_tuple(false, true, true, ""),
+ std::make_tuple(false, false, false,
+ "Joystick Button missing, check if all "
+ "controllers are plugged in\n"),
+ std::make_tuple(true, true, false,
+ "Joystick Button missing, check if all "
+ "controllers are plugged in\n"),
+ std::make_tuple(true, false, false,
+ "Joystick Button missing, check if all "
+ "controllers are plugged in\n")));
diff --git a/wpilibc/src/test/native/cpp/JoystickTest.cpp b/wpilibc/src/test/native/cpp/JoystickTest.cpp
new file mode 100644
index 0000000..0480b76
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/JoystickTest.cpp
@@ -0,0 +1,39 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/Joystick.h" // NOLINT(build/include_order)
+
+#include "frc/simulation/JoystickSim.h"
+#include "gtest/gtest.h"
+
+using namespace frc;
+
+TEST(JoystickTests, GetX) {
+ Joystick joy{1};
+ sim::JoystickSim joysim{joy};
+
+ joysim.SetX(0.25);
+ joysim.NotifyNewData();
+ ASSERT_NEAR(joy.GetX(), 0.25, 0.001);
+
+ joysim.SetX(0);
+ joysim.NotifyNewData();
+ ASSERT_NEAR(joy.GetX(), 0, 0.001);
+}
+
+TEST(JoystickTests, GetY) {
+ Joystick joy{1};
+ sim::JoystickSim joysim{joy};
+
+ joysim.SetY(0.25);
+ joysim.NotifyNewData();
+ ASSERT_NEAR(joy.GetY(), 0.25, 0.001);
+
+ joysim.SetY(0);
+ joysim.NotifyNewData();
+ ASSERT_NEAR(joy.GetY(), 0, 0.001);
+}
diff --git a/wpilibc/src/test/native/cpp/LinearFilterNoiseTest.cpp b/wpilibc/src/test/native/cpp/LinearFilterNoiseTest.cpp
deleted file mode 100644
index 0bb1002..0000000
--- a/wpilibc/src/test/native/cpp/LinearFilterNoiseTest.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2015-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 "frc/LinearFilter.h" // NOLINT(build/include_order)
-
-#include <cmath>
-#include <memory>
-#include <random>
-
-#include <units/units.h>
-#include <wpi/math>
-
-#include "gtest/gtest.h"
-
-// Filter constants
-static constexpr units::second_t kFilterStep = 0.005_s;
-static constexpr units::second_t kFilterTime = 2.0_s;
-static constexpr double kSinglePoleIIRTimeConstant = 0.015915;
-static constexpr int32_t kMovAvgTaps = 6;
-
-enum LinearFilterNoiseTestType { TEST_SINGLE_POLE_IIR, TEST_MOVAVG };
-
-std::ostream& operator<<(std::ostream& os,
- const LinearFilterNoiseTestType& type) {
- switch (type) {
- case TEST_SINGLE_POLE_IIR:
- os << "LinearFilter SinglePoleIIR";
- break;
- case TEST_MOVAVG:
- os << "LinearFilter MovingAverage";
- break;
- }
-
- return os;
-}
-
-static double GetData(double t) {
- return 100.0 * std::sin(2.0 * wpi::math::pi * t);
-}
-
-class LinearFilterNoiseTest
- : public testing::TestWithParam<LinearFilterNoiseTestType> {
- protected:
- std::unique_ptr<frc::LinearFilter<double>> m_filter;
-
- void SetUp() override {
- switch (GetParam()) {
- case TEST_SINGLE_POLE_IIR: {
- m_filter = std::make_unique<frc::LinearFilter<double>>(
- frc::LinearFilter<double>::SinglePoleIIR(kSinglePoleIIRTimeConstant,
- kFilterStep));
- break;
- }
-
- case TEST_MOVAVG: {
- m_filter = std::make_unique<frc::LinearFilter<double>>(
- frc::LinearFilter<double>::MovingAverage(kMovAvgTaps));
- break;
- }
- }
- }
-};
-
-/**
- * Test if the filter reduces the noise produced by a signal generator
- */
-TEST_P(LinearFilterNoiseTest, NoiseReduce) {
- double noiseGenError = 0.0;
- double filterError = 0.0;
-
- std::random_device rd;
- std::mt19937 gen{rd()};
- std::normal_distribution<double> distr{0.0, 10.0};
-
- for (auto t = 0_s; t < kFilterTime; t += kFilterStep) {
- double theory = GetData(t.to<double>());
- double noise = distr(gen);
- filterError += std::abs(m_filter->Calculate(theory + noise) - theory);
- noiseGenError += std::abs(noise - theory);
- }
-
- RecordProperty("FilterError", filterError);
-
- // The filter should have produced values closer to the theory
- EXPECT_GT(noiseGenError, filterError)
- << "Filter should have reduced noise accumulation but failed";
-}
-
-INSTANTIATE_TEST_SUITE_P(Test, LinearFilterNoiseTest,
- testing::Values(TEST_SINGLE_POLE_IIR, TEST_MOVAVG));
diff --git a/wpilibc/src/test/native/cpp/LinearFilterOutputTest.cpp b/wpilibc/src/test/native/cpp/LinearFilterOutputTest.cpp
deleted file mode 100644
index 8db91b3..0000000
--- a/wpilibc/src/test/native/cpp/LinearFilterOutputTest.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2015-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 "frc/LinearFilter.h" // NOLINT(build/include_order)
-
-#include <cmath>
-#include <functional>
-#include <memory>
-#include <random>
-
-#include <units/units.h>
-#include <wpi/math>
-
-#include "gtest/gtest.h"
-
-// Filter constants
-static constexpr units::second_t kFilterStep = 0.005_s;
-static constexpr units::second_t kFilterTime = 2.0_s;
-static constexpr double kSinglePoleIIRTimeConstant = 0.015915;
-static constexpr double kSinglePoleIIRExpectedOutput = -3.2172003;
-static constexpr double kHighPassTimeConstant = 0.006631;
-static constexpr double kHighPassExpectedOutput = 10.074717;
-static constexpr int32_t kMovAvgTaps = 6;
-static constexpr double kMovAvgExpectedOutput = -10.191644;
-
-enum LinearFilterOutputTestType {
- TEST_SINGLE_POLE_IIR,
- TEST_HIGH_PASS,
- TEST_MOVAVG,
- TEST_PULSE
-};
-
-std::ostream& operator<<(std::ostream& os,
- const LinearFilterOutputTestType& type) {
- switch (type) {
- case TEST_SINGLE_POLE_IIR:
- os << "LinearFilter SinglePoleIIR";
- break;
- case TEST_HIGH_PASS:
- os << "LinearFilter HighPass";
- break;
- case TEST_MOVAVG:
- os << "LinearFilter MovingAverage";
- break;
- case TEST_PULSE:
- os << "LinearFilter Pulse";
- break;
- }
-
- return os;
-}
-
-static double GetData(double t) {
- return 100.0 * std::sin(2.0 * wpi::math::pi * t) +
- 20.0 * std::cos(50.0 * wpi::math::pi * t);
-}
-
-static double GetPulseData(double t) {
- if (std::abs(t - 1.0) < 0.001) {
- return 1.0;
- } else {
- return 0.0;
- }
-}
-
-/**
- * A fixture that includes a consistent data source wrapped in a filter
- */
-class LinearFilterOutputTest
- : public testing::TestWithParam<LinearFilterOutputTestType> {
- protected:
- std::unique_ptr<frc::LinearFilter<double>> m_filter;
- std::function<double(double)> m_data;
- double m_expectedOutput = 0.0;
-
- void SetUp() override {
- switch (GetParam()) {
- case TEST_SINGLE_POLE_IIR: {
- m_filter = std::make_unique<frc::LinearFilter<double>>(
- frc::LinearFilter<double>::SinglePoleIIR(kSinglePoleIIRTimeConstant,
- kFilterStep));
- m_data = GetData;
- m_expectedOutput = kSinglePoleIIRExpectedOutput;
- break;
- }
-
- case TEST_HIGH_PASS: {
- m_filter = std::make_unique<frc::LinearFilter<double>>(
- frc::LinearFilter<double>::HighPass(kHighPassTimeConstant,
- kFilterStep));
- m_data = GetData;
- m_expectedOutput = kHighPassExpectedOutput;
- break;
- }
-
- case TEST_MOVAVG: {
- m_filter = std::make_unique<frc::LinearFilter<double>>(
- frc::LinearFilter<double>::MovingAverage(kMovAvgTaps));
- m_data = GetData;
- m_expectedOutput = kMovAvgExpectedOutput;
- break;
- }
-
- case TEST_PULSE: {
- m_filter = std::make_unique<frc::LinearFilter<double>>(
- frc::LinearFilter<double>::MovingAverage(kMovAvgTaps));
- m_data = GetPulseData;
- m_expectedOutput = 0.0;
- break;
- }
- }
- }
-};
-
-/**
- * Test if the linear filters produce consistent output for a given data set.
- */
-TEST_P(LinearFilterOutputTest, Output) {
- double filterOutput = 0.0;
- for (auto t = 0_s; t < kFilterTime; t += kFilterStep) {
- filterOutput = m_filter->Calculate(m_data(t.to<double>()));
- }
-
- RecordProperty("LinearFilterOutput", filterOutput);
-
- EXPECT_FLOAT_EQ(m_expectedOutput, filterOutput)
- << "Filter output didn't match expected value";
-}
-
-INSTANTIATE_TEST_SUITE_P(Test, LinearFilterOutputTest,
- testing::Values(TEST_SINGLE_POLE_IIR, TEST_HIGH_PASS,
- TEST_MOVAVG, TEST_PULSE));
diff --git a/wpilibc/src/test/native/cpp/MedianFilterTest.cpp b/wpilibc/src/test/native/cpp/MedianFilterTest.cpp
deleted file mode 100644
index 7fe7d2e..0000000
--- a/wpilibc/src/test/native/cpp/MedianFilterTest.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/MedianFilter.h"
-#include "gtest/gtest.h"
-
-TEST(MedianFilterTest, MedianFilterNotFullTestEven) {
- frc::MedianFilter<double> filter{10};
-
- filter.Calculate(3);
- filter.Calculate(0);
- filter.Calculate(4);
-
- EXPECT_EQ(filter.Calculate(1000), 3.5);
-}
-
-TEST(MedianFilterTest, MedianFilterNotFullTestOdd) {
- frc::MedianFilter<double> filter{10};
-
- filter.Calculate(3);
- filter.Calculate(0);
- filter.Calculate(4);
- filter.Calculate(7);
-
- EXPECT_EQ(filter.Calculate(1000), 4);
-}
-
-TEST(MedianFilterTest, MedianFilterFullTestEven) {
- frc::MedianFilter<double> filter{6};
-
- filter.Calculate(3);
- filter.Calculate(0);
- filter.Calculate(0);
- filter.Calculate(5);
- filter.Calculate(4);
- filter.Calculate(1000);
-
- EXPECT_EQ(filter.Calculate(99), 4.5);
-}
-
-TEST(MedianFilterTest, MedianFilterFullTestOdd) {
- frc::MedianFilter<double> filter{5};
-
- filter.Calculate(3);
- filter.Calculate(0);
- filter.Calculate(5);
- filter.Calculate(4);
- filter.Calculate(1000);
-
- EXPECT_EQ(filter.Calculate(99), 5);
-}
diff --git a/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp b/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp
new file mode 100644
index 0000000..da222de
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/ScopedTracerTest.cpp
@@ -0,0 +1,33 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <string>
+#include <thread>
+
+#include <wpi/SmallString.h>
+#include <wpi/StringRef.h>
+#include <wpi/raw_ostream.h>
+
+#include "frc/ScopedTracer.h"
+#include "gtest/gtest.h"
+
+wpi::SmallString<128> buf;
+wpi::raw_svector_ostream os(buf);
+
+#ifdef __APPLE__
+TEST(ScopedTracerTest, DISABLED_Timing) {
+#else
+TEST(ScopedTracerTest, Timing) {
+#endif
+ {
+ frc::ScopedTracer tracer("timing_test", os);
+ std::this_thread::sleep_for(std::chrono::milliseconds(1500));
+ }
+
+ wpi::StringRef out = os.str();
+ EXPECT_TRUE(out.startswith(" timing_test: 1.5"));
+}
diff --git a/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp b/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp
index ae253a7..dea56bb 100644
--- a/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp
+++ b/wpilibc/src/test/native/cpp/SlewRateLimiterTest.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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. */
@@ -7,13 +7,18 @@
#include <thread>
+#include <units/length.h>
+#include <units/time.h>
+#include <units/velocity.h>
+
#include "frc/SlewRateLimiter.h"
+#include "frc/simulation/SimHooks.h"
#include "gtest/gtest.h"
TEST(SlewRateLimiterTest, SlewRateLimitTest) {
frc::SlewRateLimiter<units::meters> limiter(1_mps);
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+ frc::sim::StepTiming(1.0_s);
EXPECT_TRUE(limiter.Calculate(2_m) < 2_m);
}
@@ -21,7 +26,7 @@
TEST(SlewRateLimiterTest, SlewRateNoLimitTest) {
frc::SlewRateLimiter<units::meters> limiter(1_mps);
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+ frc::sim::StepTiming(1.0_s);
EXPECT_EQ(limiter.Calculate(0.5_m), 0.5_m);
}
diff --git a/wpilibc/src/test/native/cpp/TimedRobotTest.cpp b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp
new file mode 100644
index 0000000..f91efb8
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/TimedRobotTest.cpp
@@ -0,0 +1,394 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/TimedRobot.h" // NOLINT(build/include_order)
+
+#include <stdint.h>
+
+#include <atomic>
+#include <thread>
+
+#include "frc/simulation/DriverStationSim.h"
+#include "frc/simulation/SimHooks.h"
+#include "gtest/gtest.h"
+
+using namespace frc;
+
+namespace {
+class TimedRobotTest : public ::testing::Test {
+ protected:
+ void SetUp() override { frc::sim::PauseTiming(); }
+
+ void TearDown() override { frc::sim::ResumeTiming(); }
+};
+
+class MockRobot : public TimedRobot {
+ public:
+ std::atomic<uint32_t> m_robotInitCount{0};
+ std::atomic<uint32_t> m_simulationInitCount{0};
+ std::atomic<uint32_t> m_disabledInitCount{0};
+ std::atomic<uint32_t> m_autonomousInitCount{0};
+ std::atomic<uint32_t> m_teleopInitCount{0};
+ std::atomic<uint32_t> m_testInitCount{0};
+
+ std::atomic<uint32_t> m_robotPeriodicCount{0};
+ std::atomic<uint32_t> m_simulationPeriodicCount{0};
+ std::atomic<uint32_t> m_disabledPeriodicCount{0};
+ std::atomic<uint32_t> m_autonomousPeriodicCount{0};
+ std::atomic<uint32_t> m_teleopPeriodicCount{0};
+ std::atomic<uint32_t> m_testPeriodicCount{0};
+
+ void RobotInit() override { m_robotInitCount++; }
+
+ void SimulationInit() override { m_simulationInitCount++; }
+
+ void DisabledInit() override { m_disabledInitCount++; }
+
+ void AutonomousInit() override { m_autonomousInitCount++; }
+
+ void TeleopInit() override { m_teleopInitCount++; }
+
+ void TestInit() override { m_testInitCount++; }
+
+ void RobotPeriodic() override { m_robotPeriodicCount++; }
+
+ void SimulationPeriodic() override { m_simulationPeriodicCount++; }
+
+ void DisabledPeriodic() override { m_disabledPeriodicCount++; }
+
+ void AutonomousPeriodic() override { m_autonomousPeriodicCount++; }
+
+ void TeleopPeriodic() override { m_teleopPeriodicCount++; }
+
+ void TestPeriodic() override { m_testPeriodicCount++; }
+};
+} // namespace
+
+TEST_F(TimedRobotTest, Disabled) {
+ MockRobot robot;
+
+ std::thread robotThread{[&] { robot.StartCompetition(); }};
+
+ frc::sim::DriverStationSim::SetEnabled(false);
+ frc::sim::DriverStationSim::NotifyNewData();
+ frc::sim::StepTiming(0_ms); // Wait for Notifiers
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(0u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(1u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(1u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(1u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(2u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(2u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ robot.EndCompetition();
+ robotThread.join();
+}
+
+TEST_F(TimedRobotTest, Autonomous) {
+ MockRobot robot;
+
+ std::thread robotThread{[&] { robot.StartCompetition(); }};
+
+ frc::sim::DriverStationSim::SetEnabled(true);
+ frc::sim::DriverStationSim::SetAutonomous(true);
+ frc::sim::DriverStationSim::SetTest(false);
+ frc::sim::DriverStationSim::NotifyNewData();
+ frc::sim::StepTiming(0_ms); // Wait for Notifiers
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(0u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(1u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(1u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(1u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(1u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(2u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(2u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ robot.EndCompetition();
+ robotThread.join();
+}
+
+TEST_F(TimedRobotTest, Teleop) {
+ MockRobot robot;
+
+ std::thread robotThread{[&] { robot.StartCompetition(); }};
+
+ frc::sim::DriverStationSim::SetEnabled(true);
+ frc::sim::DriverStationSim::SetAutonomous(false);
+ frc::sim::DriverStationSim::SetTest(false);
+ frc::sim::DriverStationSim::NotifyNewData();
+ frc::sim::StepTiming(0_ms); // Wait for Notifiers
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(0u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(1u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(1u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(1u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(1u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(2u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(2u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ robot.EndCompetition();
+ robotThread.join();
+}
+
+TEST_F(TimedRobotTest, Test) {
+ MockRobot robot;
+
+ std::thread robotThread{[&] { robot.StartCompetition(); }};
+
+ frc::sim::DriverStationSim::SetEnabled(true);
+ frc::sim::DriverStationSim::SetAutonomous(false);
+ frc::sim::DriverStationSim::SetTest(true);
+ frc::sim::DriverStationSim::NotifyNewData();
+ frc::sim::StepTiming(0_ms); // Wait for Notifiers
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(0u, robot.m_testInitCount);
+
+ EXPECT_EQ(0u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(0u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(0u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(1u, robot.m_testInitCount);
+
+ EXPECT_EQ(1u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(1u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(1u, robot.m_testPeriodicCount);
+
+ frc::sim::StepTiming(20_ms);
+
+ EXPECT_EQ(1u, robot.m_robotInitCount);
+ EXPECT_EQ(1u, robot.m_simulationInitCount);
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_autonomousInitCount);
+ EXPECT_EQ(0u, robot.m_teleopInitCount);
+ EXPECT_EQ(1u, robot.m_testInitCount);
+
+ EXPECT_EQ(2u, robot.m_robotPeriodicCount);
+ EXPECT_EQ(2u, robot.m_simulationPeriodicCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, robot.m_autonomousPeriodicCount);
+ EXPECT_EQ(0u, robot.m_teleopPeriodicCount);
+ EXPECT_EQ(2u, robot.m_testPeriodicCount);
+
+ robot.EndCompetition();
+ robotThread.join();
+}
+
+TEST_F(TimedRobotTest, AddPeriodic) {
+ MockRobot robot;
+
+ std::atomic<uint32_t> callbackCount{0};
+ robot.AddPeriodic([&] { callbackCount++; }, 10_ms);
+
+ std::thread robotThread{[&] { robot.StartCompetition(); }};
+
+ frc::sim::DriverStationSim::SetEnabled(false);
+ frc::sim::DriverStationSim::NotifyNewData();
+ frc::sim::StepTiming(0_ms); // Wait for Notifiers
+
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, callbackCount);
+
+ frc::sim::StepTiming(10_ms);
+
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(1u, callbackCount);
+
+ frc::sim::StepTiming(10_ms);
+
+ EXPECT_EQ(1u, robot.m_disabledInitCount);
+ EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(2u, callbackCount);
+
+ robot.EndCompetition();
+ robotThread.join();
+}
+
+TEST_F(TimedRobotTest, AddPeriodicWithOffset) {
+ MockRobot robot;
+
+ std::atomic<uint32_t> callbackCount{0};
+ robot.AddPeriodic([&] { callbackCount++; }, 10_ms, 5_ms);
+
+ // Expirations in this test (ms)
+ //
+ // Robot | Callback
+ // ================
+ // 20 | 15
+ // 40 | 25
+
+ std::thread robotThread{[&] { robot.StartCompetition(); }};
+
+ frc::sim::DriverStationSim::SetEnabled(false);
+ frc::sim::DriverStationSim::NotifyNewData();
+ frc::sim::StepTiming(0_ms); // Wait for Notifiers
+
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, callbackCount);
+
+ frc::sim::StepTiming(7.5_ms);
+
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(0u, callbackCount);
+
+ frc::sim::StepTiming(7.5_ms);
+
+ EXPECT_EQ(0u, robot.m_disabledInitCount);
+ EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(1u, callbackCount);
+
+ frc::sim::StepTiming(5_ms);
+
+ EXPECT_EQ(1u, robot.m_disabledInitCount);
+ EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(1u, callbackCount);
+
+ frc::sim::StepTiming(5_ms);
+
+ EXPECT_EQ(1u, robot.m_disabledInitCount);
+ EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
+ EXPECT_EQ(2u, callbackCount);
+
+ robot.EndCompetition();
+ robotThread.join();
+}
diff --git a/wpilibc/src/test/native/cpp/WatchdogTest.cpp b/wpilibc/src/test/native/cpp/WatchdogTest.cpp
index 10ff996..0e33511 100644
--- a/wpilibc/src/test/native/cpp/WatchdogTest.cpp
+++ b/wpilibc/src/test/native/cpp/WatchdogTest.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2018-2019 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. */
@@ -9,101 +9,92 @@
#include <stdint.h>
-#include <thread>
-
-#include <wpi/raw_ostream.h>
-
+#include "frc/simulation/SimHooks.h"
#include "gtest/gtest.h"
using namespace frc;
-#ifdef __APPLE__
-TEST(WatchdogTest, DISABLED_EnableDisable) {
-#else
-TEST(WatchdogTest, EnableDisable) {
-#endif
+namespace {
+class WatchdogTest : public ::testing::Test {
+ protected:
+ void SetUp() override { frc::sim::PauseTiming(); }
+
+ void TearDown() override { frc::sim::ResumeTiming(); }
+};
+
+} // namespace
+
+TEST_F(WatchdogTest, EnableDisable) {
uint32_t watchdogCounter = 0;
Watchdog watchdog(0.4_s, [&] { watchdogCounter++; });
- wpi::outs() << "Run 1\n";
+ // Run 1
watchdog.Enable();
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ frc::sim::StepTiming(0.2_s);
watchdog.Disable();
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
- wpi::outs() << "Run 2\n";
+ // Run 2
watchdogCounter = 0;
watchdog.Enable();
- std::this_thread::sleep_for(std::chrono::milliseconds(600));
+ frc::sim::StepTiming(0.4_s);
watchdog.Disable();
EXPECT_EQ(1u, watchdogCounter)
<< "Watchdog either didn't trigger or triggered more than once";
- wpi::outs() << "Run 3\n";
+ // Run 3
watchdogCounter = 0;
watchdog.Enable();
- std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+ frc::sim::StepTiming(1_s);
watchdog.Disable();
EXPECT_EQ(1u, watchdogCounter)
<< "Watchdog either didn't trigger or triggered more than once";
}
-#ifdef __APPLE__
-TEST(WatchdogTest, DISABLED_Reset) {
-#else
-TEST(WatchdogTest, Reset) {
-#endif
+TEST_F(WatchdogTest, Reset) {
uint32_t watchdogCounter = 0;
Watchdog watchdog(0.4_s, [&] { watchdogCounter++; });
watchdog.Enable();
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ frc::sim::StepTiming(0.2_s);
watchdog.Reset();
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ frc::sim::StepTiming(0.2_s);
watchdog.Disable();
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
}
-#ifdef __APPLE__
-TEST(WatchdogTest, DISABLED_SetTimeout) {
-#else
-TEST(WatchdogTest, SetTimeout) {
-#endif
+TEST_F(WatchdogTest, SetTimeout) {
uint32_t watchdogCounter = 0;
- Watchdog watchdog(1.0_s, [&] { watchdogCounter++; });
+ Watchdog watchdog(1_s, [&] { watchdogCounter++; });
watchdog.Enable();
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ frc::sim::StepTiming(0.2_s);
watchdog.SetTimeout(0.2_s);
EXPECT_EQ(0.2, watchdog.GetTimeout());
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
- std::this_thread::sleep_for(std::chrono::milliseconds(300));
+ frc::sim::StepTiming(0.3_s);
watchdog.Disable();
EXPECT_EQ(1u, watchdogCounter)
<< "Watchdog either didn't trigger or triggered more than once";
}
-#ifdef __APPLE__
-TEST(WatchdogTest, DISABLED_IsExpired) {
-#else
-TEST(WatchdogTest, IsExpired) {
-#endif
+TEST_F(WatchdogTest, IsExpired) {
Watchdog watchdog(0.2_s, [] {});
EXPECT_FALSE(watchdog.IsExpired());
watchdog.Enable();
EXPECT_FALSE(watchdog.IsExpired());
- std::this_thread::sleep_for(std::chrono::milliseconds(300));
+ frc::sim::StepTiming(0.3_s);
EXPECT_TRUE(watchdog.IsExpired());
watchdog.Disable();
@@ -113,43 +104,35 @@
EXPECT_FALSE(watchdog.IsExpired());
}
-#ifdef __APPLE__
-TEST(WatchdogTest, DISABLED_Epochs) {
-#else
-TEST(WatchdogTest, Epochs) {
-#endif
+TEST_F(WatchdogTest, Epochs) {
uint32_t watchdogCounter = 0;
Watchdog watchdog(0.4_s, [&] { watchdogCounter++; });
- wpi::outs() << "Run 1\n";
+ // Run 1
watchdog.Enable();
watchdog.AddEpoch("Epoch 1");
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ frc::sim::StepTiming(0.1_s);
watchdog.AddEpoch("Epoch 2");
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ frc::sim::StepTiming(0.1_s);
watchdog.AddEpoch("Epoch 3");
watchdog.Disable();
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
- wpi::outs() << "Run 2\n";
+ // Run 2
watchdog.Enable();
watchdog.AddEpoch("Epoch 1");
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ frc::sim::StepTiming(0.2_s);
watchdog.Reset();
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ frc::sim::StepTiming(0.2_s);
watchdog.AddEpoch("Epoch 2");
watchdog.Disable();
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
}
-#ifdef __APPLE__
-TEST(WatchdogTest, DISABLED_MultiWatchdog) {
-#else
-TEST(WatchdogTest, MultiWatchdog) {
-#endif
+TEST_F(WatchdogTest, MultiWatchdog) {
uint32_t watchdogCounter1 = 0;
uint32_t watchdogCounter2 = 0;
@@ -157,13 +140,13 @@
Watchdog watchdog2(0.6_s, [&] { watchdogCounter2++; });
watchdog2.Enable();
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
+ frc::sim::StepTiming(0.25_s);
EXPECT_EQ(0u, watchdogCounter1) << "Watchdog triggered early";
EXPECT_EQ(0u, watchdogCounter2) << "Watchdog triggered early";
// Sleep enough such that only the watchdog enabled later times out first
watchdog1.Enable();
- std::this_thread::sleep_for(std::chrono::milliseconds(300));
+ frc::sim::StepTiming(0.25_s);
watchdog1.Disable();
watchdog2.Disable();
diff --git a/wpilibc/src/test/native/cpp/XboxControllerTest.cpp b/wpilibc/src/test/native/cpp/XboxControllerTest.cpp
new file mode 100644
index 0000000..66ccfcd
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/XboxControllerTest.cpp
@@ -0,0 +1,74 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/XboxController.h" // NOLINT(build/include_order)
+
+#include "frc/simulation/XboxControllerSim.h"
+#include "gtest/gtest.h"
+
+using namespace frc;
+
+TEST(XboxControllerTests, GetX) {
+ XboxController joy{2};
+ sim::XboxControllerSim joysim{joy};
+
+ joysim.SetX(XboxController::kLeftHand, 0.35);
+ joysim.SetX(XboxController::kRightHand, 0.45);
+ joysim.NotifyNewData();
+ ASSERT_NEAR(joy.GetX(XboxController::kLeftHand), 0.35, 0.001);
+ ASSERT_NEAR(joy.GetX(XboxController::kRightHand), 0.45, 0.001);
+}
+
+TEST(XboxControllerTests, GetBumper) {
+ XboxController joy{1};
+ sim::XboxControllerSim joysim{joy};
+
+ joysim.SetBumper(XboxController::kLeftHand, false);
+ joysim.SetBumper(XboxController::kRightHand, true);
+ joysim.NotifyNewData();
+ ASSERT_FALSE(joy.GetBumper(XboxController::kLeftHand));
+ ASSERT_TRUE(joy.GetBumper(XboxController::kRightHand));
+ // need to call pressed and released to clear flags
+ joy.GetBumperPressed(XboxController::kLeftHand);
+ joy.GetBumperReleased(XboxController::kLeftHand);
+ joy.GetBumperPressed(XboxController::kRightHand);
+ joy.GetBumperReleased(XboxController::kRightHand);
+
+ joysim.SetBumper(XboxController::kLeftHand, true);
+ joysim.SetBumper(XboxController::kRightHand, false);
+ joysim.NotifyNewData();
+ ASSERT_TRUE(joy.GetBumper(XboxController::kLeftHand));
+ ASSERT_TRUE(joy.GetBumperPressed(XboxController::kLeftHand));
+ ASSERT_FALSE(joy.GetBumperReleased(XboxController::kLeftHand));
+ ASSERT_FALSE(joy.GetBumper(XboxController::kRightHand));
+ ASSERT_FALSE(joy.GetBumperPressed(XboxController::kRightHand));
+ ASSERT_TRUE(joy.GetBumperReleased(XboxController::kRightHand));
+}
+
+TEST(XboxControllerTests, GetAButton) {
+ XboxController joy{1};
+ sim::XboxControllerSim joysim{joy};
+
+ joysim.SetAButton(false);
+ joysim.NotifyNewData();
+ ASSERT_FALSE(joy.GetAButton());
+ // need to call pressed and released to clear flags
+ joy.GetAButtonPressed();
+ joy.GetAButtonReleased();
+
+ joysim.SetAButton(true);
+ joysim.NotifyNewData();
+ ASSERT_TRUE(joy.GetAButton());
+ ASSERT_TRUE(joy.GetAButtonPressed());
+ ASSERT_FALSE(joy.GetAButtonReleased());
+
+ joysim.SetAButton(false);
+ joysim.NotifyNewData();
+ ASSERT_FALSE(joy.GetAButton());
+ ASSERT_FALSE(joy.GetAButtonPressed());
+ ASSERT_TRUE(joy.GetAButtonReleased());
+}
diff --git a/wpilibc/src/test/native/cpp/controller/ControllerUtilTest.cpp b/wpilibc/src/test/native/cpp/controller/ControllerUtilTest.cpp
new file mode 100644
index 0000000..00259d1
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/controller/ControllerUtilTest.cpp
@@ -0,0 +1,42 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <units/angle.h>
+
+#include "frc/controller/ControllerUtil.h"
+#include "gtest/gtest.h"
+
+TEST(ControllerUtilTest, GetModulusError) {
+ // Test symmetric range
+ EXPECT_FLOAT_EQ(-20.0, frc::GetModulusError(170.0, -170.0, -180.0, 180.0));
+ EXPECT_FLOAT_EQ(-20.0,
+ frc::GetModulusError(170.0 + 360.0, -170.0, -180.0, 180.0));
+ EXPECT_FLOAT_EQ(-20.0,
+ frc::GetModulusError(170.0, -170.0 + 360.0, -180.0, 180.0));
+ EXPECT_FLOAT_EQ(20.0, frc::GetModulusError(-170.0, 170.0, -180.0, 180.0));
+ EXPECT_FLOAT_EQ(20.0,
+ frc::GetModulusError(-170.0 + 360.0, 170.0, -180.0, 180.0));
+ EXPECT_FLOAT_EQ(20.0,
+ frc::GetModulusError(-170.0, 170.0 + 360.0, -180.0, 180.0));
+
+ // Test range starting at zero
+ EXPECT_FLOAT_EQ(-20.0, frc::GetModulusError(170.0, 190.0, 0.0, 360.0));
+ EXPECT_FLOAT_EQ(-20.0,
+ frc::GetModulusError(170.0 + 360.0, 190.0, 0.0, 360.0));
+ EXPECT_FLOAT_EQ(-20.0,
+ frc::GetModulusError(170.0, 190.0 + 360.0, 0.0, 360.0));
+
+ // Test asymmetric range that doesn't start at zero
+ EXPECT_FLOAT_EQ(-20.0, frc::GetModulusError(170.0, -170.0, -170.0, 190.0));
+
+ // Test all supported types
+ EXPECT_FLOAT_EQ(-20.0,
+ frc::GetModulusError<double>(170.0, -170.0, -170.0, 190.0));
+ EXPECT_EQ(-20, frc::GetModulusError<int>(170, -170, -170, 190));
+ EXPECT_EQ(-20_deg, frc::GetModulusError<units::degree_t>(170_deg, -170_deg,
+ -170_deg, 190_deg));
+}
diff --git a/wpilibc/src/test/native/cpp/controller/HolonomicDriveControllerTest.cpp b/wpilibc/src/test/native/cpp/controller/HolonomicDriveControllerTest.cpp
new file mode 100644
index 0000000..fb72a4a
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/controller/HolonomicDriveControllerTest.cpp
@@ -0,0 +1,51 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <units/math.h>
+#include <units/time.h>
+#include <wpi/math>
+
+#include "frc/controller/HolonomicDriveController.h"
+#include "frc/trajectory/TrajectoryGenerator.h"
+#include "gtest/gtest.h"
+
+#define EXPECT_NEAR_UNITS(val1, val2, eps) \
+ EXPECT_LE(units::math::abs(val1 - val2), eps)
+
+static constexpr units::meter_t kTolerance{1 / 12.0};
+static constexpr units::radian_t kAngularTolerance{2.0 * wpi::math::pi / 180.0};
+
+TEST(HolonomicDriveControllerTest, ReachesReference) {
+ frc::HolonomicDriveController controller{
+ frc2::PIDController{1.0, 0.0, 0.0}, frc2::PIDController{1.0, 0.0, 0.0},
+ frc::ProfiledPIDController<units::radian>{
+ 1.0, 0.0, 0.0,
+ frc::TrapezoidProfile<units::radian>::Constraints{
+ 6.28_rad_per_s, 3.14_rad_per_s / 1_s}}};
+
+ frc::Pose2d robotPose{2.7_m, 23_m, frc::Rotation2d{0_deg}};
+
+ auto waypoints = std::vector{frc::Pose2d{2.75_m, 22.521_m, 0_rad},
+ frc::Pose2d{24.73_m, 19.68_m, 5.846_rad}};
+ auto trajectory = frc::TrajectoryGenerator::GenerateTrajectory(
+ waypoints, {8.0_mps, 4.0_mps_sq});
+
+ constexpr auto kDt = 0.02_s;
+ auto totalTime = trajectory.TotalTime();
+ for (size_t i = 0; i < (totalTime / kDt).to<double>(); ++i) {
+ auto state = trajectory.Sample(kDt * i);
+ auto [vx, vy, omega] = controller.Calculate(robotPose, state, 0_rad);
+
+ robotPose = robotPose.Exp(frc::Twist2d{vx * kDt, vy * kDt, omega * kDt});
+ }
+
+ auto& endPose = trajectory.States().back().pose;
+ EXPECT_NEAR_UNITS(endPose.X(), robotPose.X(), kTolerance);
+ EXPECT_NEAR_UNITS(endPose.Y(), robotPose.Y(), kTolerance);
+ EXPECT_NEAR_UNITS(units::math::NormalizeAngle(robotPose.Rotation().Radians()),
+ 0_rad, kAngularTolerance);
+}
diff --git a/wpilibc/src/test/native/cpp/controller/PIDInputOutputTest.cpp b/wpilibc/src/test/native/cpp/controller/PIDInputOutputTest.cpp
index c68cb37..3580308 100644
--- a/wpilibc/src/test/native/cpp/controller/PIDInputOutputTest.cpp
+++ b/wpilibc/src/test/native/cpp/controller/PIDInputOutputTest.cpp
@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. All Rights Reserved. */
+/* Copyright (c) 2014-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. */
@@ -21,7 +21,7 @@
controller->SetP(1);
controller->EnableContinuousInput(-180, 180);
- EXPECT_TRUE(controller->Calculate(-179, 179) < 0);
+ EXPECT_LT(controller->Calculate(-179, 179), 0);
}
TEST_F(PIDInputOutputTest, ProportionalGainOutputTest) {
diff --git a/wpilibc/src/test/native/cpp/controller/ProfiledPIDInputOutputTest.cpp b/wpilibc/src/test/native/cpp/controller/ProfiledPIDInputOutputTest.cpp
new file mode 100644
index 0000000..6f9c36d
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/controller/ProfiledPIDInputOutputTest.cpp
@@ -0,0 +1,111 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <units/angle.h>
+#include <units/angular_acceleration.h>
+#include <units/angular_velocity.h>
+#include <wpi/math>
+
+#include "frc/controller/ProfiledPIDController.h"
+#include "gtest/gtest.h"
+
+class ProfiledPIDInputOutputTest : public testing::Test {
+ protected:
+ frc::ProfiledPIDController<units::degrees>* controller;
+
+ void SetUp() override {
+ controller = new frc::ProfiledPIDController<units::degrees>(
+ 0, 0, 0, {360_deg_per_s, 180_deg_per_s_sq});
+ }
+
+ void TearDown() override { delete controller; }
+};
+
+TEST_F(ProfiledPIDInputOutputTest, ContinuousInputTest) {
+ controller->SetP(1);
+ controller->EnableContinuousInput(-180_deg, 180_deg);
+
+ controller->Reset(-179_deg);
+ EXPECT_LT(controller->Calculate(-179_deg, 179_deg), 0);
+}
+
+TEST_F(ProfiledPIDInputOutputTest, ContinuousInputTest1) {
+ controller->SetP(1);
+ controller->EnableContinuousInput(-180_deg, 180_deg);
+
+ static constexpr units::degree_t kSetpoint{-179.0};
+ static constexpr units::degree_t kMeasurement{-179.0};
+ static constexpr units::degree_t kGoal{179.0};
+
+ controller->Reset(kSetpoint);
+ EXPECT_LT(controller->Calculate(kMeasurement, kGoal), 0.0);
+
+ // Error must be less than half the input range at all times
+ EXPECT_LT(units::math::abs(controller->GetSetpoint().position - kMeasurement),
+ 180_deg);
+}
+
+TEST_F(ProfiledPIDInputOutputTest, ContinuousInputTest2) {
+ controller->SetP(1);
+ controller->EnableContinuousInput(-units::radian_t{wpi::math::pi},
+ units::radian_t{wpi::math::pi});
+
+ static constexpr units::radian_t kSetpoint{-3.4826633343199735};
+ static constexpr units::radian_t kMeasurement{-3.1352207333939606};
+ static constexpr units::radian_t kGoal{-3.534162788601621};
+
+ controller->Reset(kSetpoint);
+ EXPECT_LT(controller->Calculate(kMeasurement, kGoal), 0.0);
+
+ // Error must be less than half the input range at all times
+ EXPECT_LT(units::math::abs(controller->GetSetpoint().position - kMeasurement),
+ units::radian_t{wpi::math::pi});
+}
+
+TEST_F(ProfiledPIDInputOutputTest, ContinuousInputTest3) {
+ controller->SetP(1);
+ controller->EnableContinuousInput(-units::radian_t{wpi::math::pi},
+ units::radian_t{wpi::math::pi});
+
+ static constexpr units::radian_t kSetpoint{-3.5176604690006377};
+ static constexpr units::radian_t kMeasurement{3.1191729343822456};
+ static constexpr units::radian_t kGoal{2.709680418117445};
+
+ controller->Reset(kSetpoint);
+ EXPECT_LT(controller->Calculate(kMeasurement, kGoal), 0.0);
+
+ // Error must be less than half the input range at all times
+ EXPECT_LT(units::math::abs(controller->GetSetpoint().position - kMeasurement),
+ units::radian_t{wpi::math::pi});
+}
+
+TEST_F(ProfiledPIDInputOutputTest, ProportionalGainOutputTest) {
+ controller->SetP(4);
+
+ EXPECT_DOUBLE_EQ(-0.1, controller->Calculate(0.025_deg, 0_deg));
+}
+
+TEST_F(ProfiledPIDInputOutputTest, IntegralGainOutputTest) {
+ controller->SetI(4);
+
+ double out = 0;
+
+ for (int i = 0; i < 5; i++) {
+ out = controller->Calculate(0.025_deg, 0_deg);
+ }
+
+ EXPECT_DOUBLE_EQ(-0.5 * controller->GetPeriod().to<double>(), out);
+}
+
+TEST_F(ProfiledPIDInputOutputTest, DerivativeGainOutputTest) {
+ controller->SetD(4);
+
+ controller->Calculate(0_deg, 0_deg);
+
+ EXPECT_DOUBLE_EQ(-10_ms / controller->GetPeriod(),
+ controller->Calculate(0.0025_deg, 0_deg));
+}
diff --git a/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp b/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp
index a600054..fb34385 100644
--- a/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp
+++ b/wpilibc/src/test/native/cpp/controller/RamseteControllerTest.cpp
@@ -1,11 +1,11 @@
/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2019 FIRST. All Rights Reserved. */
+/* 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 <wpi/math>
+#include <units/math.h>
#include "frc/controller/RamseteController.h"
#include "frc/trajectory/TrajectoryGenerator.h"
@@ -17,16 +17,6 @@
static constexpr units::meter_t kTolerance{1 / 12.0};
static constexpr units::radian_t kAngularTolerance{2.0 * wpi::math::pi / 180.0};
-units::radian_t boundRadians(units::radian_t value) {
- while (value > units::radian_t{wpi::math::pi}) {
- value -= units::radian_t{wpi::math::pi * 2};
- }
- while (value <= units::radian_t{-wpi::math::pi}) {
- value += units::radian_t{wpi::math::pi * 2};
- }
- return value;
-}
-
TEST(RamseteControllerTest, ReachesReference) {
frc::RamseteController controller{2.0, 0.7};
frc::Pose2d robotPose{2.7_m, 23_m, frc::Rotation2d{0_deg}};
@@ -47,11 +37,9 @@
}
auto& endPose = trajectory.States().back().pose;
- EXPECT_NEAR_UNITS(endPose.Translation().X(), robotPose.Translation().X(),
- kTolerance);
- EXPECT_NEAR_UNITS(endPose.Translation().Y(), robotPose.Translation().Y(),
- kTolerance);
- EXPECT_NEAR_UNITS(boundRadians(endPose.Rotation().Radians() -
- robotPose.Rotation().Radians()),
+ EXPECT_NEAR_UNITS(endPose.X(), robotPose.X(), kTolerance);
+ EXPECT_NEAR_UNITS(endPose.Y(), robotPose.Y(), kTolerance);
+ EXPECT_NEAR_UNITS(units::math::NormalizeAngle(endPose.Rotation().Radians() -
+ robotPose.Rotation().Radians()),
0_rad, kAngularTolerance);
}
diff --git a/wpilibc/src/test/native/cpp/geometry/Pose2dTest.cpp b/wpilibc/src/test/native/cpp/geometry/Pose2dTest.cpp
deleted file mode 100644
index 8b5f674..0000000
--- a/wpilibc/src/test/native/cpp/geometry/Pose2dTest.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <cmath>
-
-#include "frc/geometry/Pose2d.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-static constexpr double kEpsilon = 1E-9;
-
-TEST(Pose2dTest, TransformBy) {
- const Pose2d initial{1_m, 2_m, Rotation2d(45.0_deg)};
- const Transform2d transform{Translation2d{5.0_m, 0.0_m}, Rotation2d(5.0_deg)};
-
- const auto transformed = initial + transform;
-
- EXPECT_NEAR(transformed.Translation().X().to<double>(),
- 1 + 5 / std::sqrt(2.0), kEpsilon);
- EXPECT_NEAR(transformed.Translation().Y().to<double>(),
- 2 + 5 / std::sqrt(2.0), kEpsilon);
- EXPECT_NEAR(transformed.Rotation().Degrees().to<double>(), 50.0, kEpsilon);
-}
-
-TEST(Pose2dTest, RelativeTo) {
- const Pose2d initial{0_m, 0_m, Rotation2d(45.0_deg)};
- const Pose2d final{5_m, 5_m, Rotation2d(45.0_deg)};
-
- const auto finalRelativeToInitial = final.RelativeTo(initial);
-
- EXPECT_NEAR(finalRelativeToInitial.Translation().X().to<double>(),
- 5.0 * std::sqrt(2.0), kEpsilon);
- EXPECT_NEAR(finalRelativeToInitial.Translation().Y().to<double>(), 0.0,
- kEpsilon);
- EXPECT_NEAR(finalRelativeToInitial.Rotation().Degrees().to<double>(), 0.0,
- kEpsilon);
-}
-
-TEST(Pose2dTest, Equality) {
- const Pose2d a{0_m, 5_m, Rotation2d(43_deg)};
- const Pose2d b{0_m, 5_m, Rotation2d(43_deg)};
- EXPECT_TRUE(a == b);
-}
-
-TEST(Pose2dTest, Inequality) {
- const Pose2d a{0_m, 5_m, Rotation2d(43_deg)};
- const Pose2d b{0_m, 5_ft, Rotation2d(43_deg)};
- EXPECT_TRUE(a != b);
-}
-
-TEST(Pose2dTest, Minus) {
- const Pose2d initial{0_m, 0_m, Rotation2d(45.0_deg)};
- const Pose2d final{5_m, 5_m, Rotation2d(45.0_deg)};
-
- const auto transform = final - initial;
-
- EXPECT_NEAR(transform.Translation().X().to<double>(), 5.0 * std::sqrt(2.0),
- kEpsilon);
- EXPECT_NEAR(transform.Translation().Y().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(transform.Rotation().Degrees().to<double>(), 0.0, kEpsilon);
-}
diff --git a/wpilibc/src/test/native/cpp/geometry/Rotation2dTest.cpp b/wpilibc/src/test/native/cpp/geometry/Rotation2dTest.cpp
deleted file mode 100644
index ba80787..0000000
--- a/wpilibc/src/test/native/cpp/geometry/Rotation2dTest.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <cmath>
-
-#include <wpi/math>
-
-#include "frc/geometry/Rotation2d.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-static constexpr double kEpsilon = 1E-9;
-
-TEST(Rotation2dTest, RadiansToDegrees) {
- const Rotation2d one{units::radian_t(wpi::math::pi / 3)};
- const Rotation2d two{units::radian_t(wpi::math::pi / 4)};
-
- EXPECT_NEAR(one.Degrees().to<double>(), 60.0, kEpsilon);
- EXPECT_NEAR(two.Degrees().to<double>(), 45.0, kEpsilon);
-}
-
-TEST(Rotation2dTest, DegreesToRadians) {
- const auto one = Rotation2d(45.0_deg);
- const auto two = Rotation2d(30.0_deg);
-
- EXPECT_NEAR(one.Radians().to<double>(), wpi::math::pi / 4.0, kEpsilon);
- EXPECT_NEAR(two.Radians().to<double>(), wpi::math::pi / 6.0, kEpsilon);
-}
-
-TEST(Rotation2dTest, RotateByFromZero) {
- const Rotation2d zero;
- auto sum = zero + Rotation2d(90.0_deg);
-
- EXPECT_NEAR(sum.Radians().to<double>(), wpi::math::pi / 2.0, kEpsilon);
- EXPECT_NEAR(sum.Degrees().to<double>(), 90.0, kEpsilon);
-}
-
-TEST(Rotation2dTest, RotateByNonZero) {
- auto rot = Rotation2d(90.0_deg);
- rot += Rotation2d(30.0_deg);
-
- EXPECT_NEAR(rot.Degrees().to<double>(), 120.0, kEpsilon);
-}
-
-TEST(Rotation2dTest, Minus) {
- const auto one = Rotation2d(70.0_deg);
- const auto two = Rotation2d(30.0_deg);
-
- EXPECT_NEAR((one - two).Degrees().to<double>(), 40.0, kEpsilon);
-}
-
-TEST(Rotation2dTest, Equality) {
- const auto one = Rotation2d(43_deg);
- const auto two = Rotation2d(43_deg);
- EXPECT_TRUE(one == two);
-}
-
-TEST(Rotation2dTest, Inequality) {
- const auto one = Rotation2d(43_deg);
- const auto two = Rotation2d(43.5_deg);
- EXPECT_TRUE(one != two);
-}
diff --git a/wpilibc/src/test/native/cpp/geometry/Translation2dTest.cpp b/wpilibc/src/test/native/cpp/geometry/Translation2dTest.cpp
deleted file mode 100644
index 99fced7..0000000
--- a/wpilibc/src/test/native/cpp/geometry/Translation2dTest.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <cmath>
-
-#include "frc/geometry/Translation2d.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-static constexpr double kEpsilon = 1E-9;
-
-TEST(Translation2dTest, Sum) {
- const Translation2d one{1.0_m, 3.0_m};
- const Translation2d two{2.0_m, 5.0_m};
-
- const auto sum = one + two;
-
- EXPECT_NEAR(sum.X().to<double>(), 3.0, kEpsilon);
- EXPECT_NEAR(sum.Y().to<double>(), 8.0, kEpsilon);
-}
-
-TEST(Translation2dTest, Difference) {
- const Translation2d one{1.0_m, 3.0_m};
- const Translation2d two{2.0_m, 5.0_m};
-
- const auto difference = one - two;
-
- EXPECT_NEAR(difference.X().to<double>(), -1.0, kEpsilon);
- EXPECT_NEAR(difference.Y().to<double>(), -2.0, kEpsilon);
-}
-
-TEST(Translation2dTest, RotateBy) {
- const Translation2d another{3.0_m, 0.0_m};
- const auto rotated = another.RotateBy(Rotation2d(90.0_deg));
-
- EXPECT_NEAR(rotated.X().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(rotated.Y().to<double>(), 3.0, kEpsilon);
-}
-
-TEST(Translation2dTest, Multiplication) {
- const Translation2d original{3.0_m, 5.0_m};
- const auto mult = original * 3;
-
- EXPECT_NEAR(mult.X().to<double>(), 9.0, kEpsilon);
- EXPECT_NEAR(mult.Y().to<double>(), 15.0, kEpsilon);
-}
-
-TEST(Translation2d, Division) {
- const Translation2d original{3.0_m, 5.0_m};
- const auto div = original / 2;
-
- EXPECT_NEAR(div.X().to<double>(), 1.5, kEpsilon);
- EXPECT_NEAR(div.Y().to<double>(), 2.5, kEpsilon);
-}
-
-TEST(Translation2dTest, Norm) {
- const Translation2d one{3.0_m, 5.0_m};
- EXPECT_NEAR(one.Norm().to<double>(), std::hypot(3, 5), kEpsilon);
-}
-
-TEST(Translation2dTest, Distance) {
- const Translation2d one{1_m, 1_m};
- const Translation2d two{6_m, 6_m};
- EXPECT_NEAR(one.Distance(two).to<double>(), 5 * std::sqrt(2), kEpsilon);
-}
-
-TEST(Translation2dTest, UnaryMinus) {
- const Translation2d original{-4.5_m, 7_m};
- const auto inverted = -original;
-
- EXPECT_NEAR(inverted.X().to<double>(), 4.5, kEpsilon);
- EXPECT_NEAR(inverted.Y().to<double>(), -7, kEpsilon);
-}
-
-TEST(Translation2dTest, Equality) {
- const Translation2d one{9_m, 5.5_m};
- const Translation2d two{9_m, 5.5_m};
- EXPECT_TRUE(one == two);
-}
-
-TEST(Translation2dTest, Inequality) {
- const Translation2d one{9_m, 5.5_m};
- const Translation2d two{9_m, 5.7_m};
- EXPECT_TRUE(one != two);
-}
diff --git a/wpilibc/src/test/native/cpp/geometry/Twist2dTest.cpp b/wpilibc/src/test/native/cpp/geometry/Twist2dTest.cpp
deleted file mode 100644
index faf36d9..0000000
--- a/wpilibc/src/test/native/cpp/geometry/Twist2dTest.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <cmath>
-
-#include <wpi/math>
-
-#include "frc/geometry/Pose2d.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-static constexpr double kEpsilon = 1E-9;
-
-TEST(Twist2dTest, Straight) {
- const Twist2d straight{5.0_m, 0.0_m, 0.0_rad};
- const auto straightPose = Pose2d().Exp(straight);
-
- EXPECT_NEAR(straightPose.Translation().X().to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(straightPose.Translation().Y().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(straightPose.Rotation().Radians().to<double>(), 0.0, kEpsilon);
-}
-
-TEST(Twist2dTest, QuarterCircle) {
- const Twist2d quarterCircle{5.0_m / 2.0 * wpi::math::pi, 0_m,
- units::radian_t(wpi::math::pi / 2.0)};
- const auto quarterCirclePose = Pose2d().Exp(quarterCircle);
-
- EXPECT_NEAR(quarterCirclePose.Translation().X().to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(quarterCirclePose.Translation().Y().to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(quarterCirclePose.Rotation().Degrees().to<double>(), 90.0,
- kEpsilon);
-}
-
-TEST(Twist2dTest, DiagonalNoDtheta) {
- const Twist2d diagonal{2.0_m, 2.0_m, 0.0_deg};
- const auto diagonalPose = Pose2d().Exp(diagonal);
-
- EXPECT_NEAR(diagonalPose.Translation().X().to<double>(), 2.0, kEpsilon);
- EXPECT_NEAR(diagonalPose.Translation().Y().to<double>(), 2.0, kEpsilon);
- EXPECT_NEAR(diagonalPose.Rotation().Degrees().to<double>(), 0.0, kEpsilon);
-}
-
-TEST(Twist2dTest, Equality) {
- const Twist2d one{5.0_m, 1.0_m, 3.0_rad};
- const Twist2d two{5.0_m, 1.0_m, 3.0_rad};
- EXPECT_TRUE(one == two);
-}
-
-TEST(Twist2dTest, Inequality) {
- const Twist2d one{5.0_m, 1.0_m, 3.0_rad};
- const Twist2d two{5.0_m, 1.2_m, 3.0_rad};
- EXPECT_TRUE(one != two);
-}
-
-TEST(Twist2dTest, Pose2dLog) {
- const Pose2d end{5_m, 5_m, Rotation2d(90_deg)};
- const Pose2d start{};
-
- const auto twist = start.Log(end);
-
- EXPECT_NEAR(twist.dx.to<double>(), 5 / 2.0 * wpi::math::pi, kEpsilon);
- EXPECT_NEAR(twist.dy.to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(twist.dtheta.to<double>(), wpi::math::pi / 2.0, kEpsilon);
-}
diff --git a/wpilibc/src/test/native/cpp/kinematics/ChassisSpeedsTest.cpp b/wpilibc/src/test/native/cpp/kinematics/ChassisSpeedsTest.cpp
deleted file mode 100644
index 3fb63fb..0000000
--- a/wpilibc/src/test/native/cpp/kinematics/ChassisSpeedsTest.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/ChassisSpeeds.h"
-#include "gtest/gtest.h"
-
-static constexpr double kEpsilon = 1E-9;
-
-TEST(ChassisSpeeds, FieldRelativeConstruction) {
- const auto chassisSpeeds = frc::ChassisSpeeds::FromFieldRelativeSpeeds(
- 1.0_mps, 0.0_mps, 0.5_rad_per_s, frc::Rotation2d(-90.0_deg));
-
- EXPECT_NEAR(0.0, chassisSpeeds.vx.to<double>(), kEpsilon);
- EXPECT_NEAR(1.0, chassisSpeeds.vy.to<double>(), kEpsilon);
- EXPECT_NEAR(0.5, chassisSpeeds.omega.to<double>(), kEpsilon);
-}
diff --git a/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveKinematicsTest.cpp
deleted file mode 100644
index ad0d3c7..0000000
--- a/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveKinematicsTest.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-#include <wpi/math>
-
-#include "frc/kinematics/ChassisSpeeds.h"
-#include "frc/kinematics/DifferentialDriveKinematics.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-static constexpr double kEpsilon = 1E-9;
-
-TEST(DifferentialDriveKinematics, InverseKinematicsFromZero) {
- const DifferentialDriveKinematics kinematics{0.381_m * 2};
- const ChassisSpeeds chassisSpeeds;
- const auto wheelSpeeds = kinematics.ToWheelSpeeds(chassisSpeeds);
-
- EXPECT_NEAR(wheelSpeeds.left.to<double>(), 0, kEpsilon);
- EXPECT_NEAR(wheelSpeeds.right.to<double>(), 0, kEpsilon);
-}
-
-TEST(DifferentialDriveKinematics, ForwardKinematicsFromZero) {
- const DifferentialDriveKinematics kinematics{0.381_m * 2};
- const DifferentialDriveWheelSpeeds wheelSpeeds;
- const auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), 0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), 0, kEpsilon);
-}
-
-TEST(DifferentialDriveKinematics, InverseKinematicsForStraightLine) {
- const DifferentialDriveKinematics kinematics{0.381_m * 2};
- const ChassisSpeeds chassisSpeeds{3.0_mps, 0_mps, 0_rad_per_s};
- const auto wheelSpeeds = kinematics.ToWheelSpeeds(chassisSpeeds);
-
- EXPECT_NEAR(wheelSpeeds.left.to<double>(), 3, kEpsilon);
- EXPECT_NEAR(wheelSpeeds.right.to<double>(), 3, kEpsilon);
-}
-
-TEST(DifferentialDriveKinematics, ForwardKinematicsForStraightLine) {
- const DifferentialDriveKinematics kinematics{0.381_m * 2};
- const DifferentialDriveWheelSpeeds wheelSpeeds{3.0_mps, 3.0_mps};
- const auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 3, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), 0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), 0, kEpsilon);
-}
-
-TEST(DifferentialDriveKinematics, InverseKinematicsForRotateInPlace) {
- const DifferentialDriveKinematics kinematics{0.381_m * 2};
- const ChassisSpeeds chassisSpeeds{0.0_mps, 0.0_mps,
- units::radians_per_second_t{wpi::math::pi}};
- const auto wheelSpeeds = kinematics.ToWheelSpeeds(chassisSpeeds);
-
- EXPECT_NEAR(wheelSpeeds.left.to<double>(), -0.381 * wpi::math::pi, kEpsilon);
- EXPECT_NEAR(wheelSpeeds.right.to<double>(), +0.381 * wpi::math::pi, kEpsilon);
-}
-
-TEST(DifferentialDriveKinematics, ForwardKinematicsForRotateInPlace) {
- const DifferentialDriveKinematics kinematics{0.381_m * 2};
- const DifferentialDriveWheelSpeeds wheelSpeeds{
- units::meters_per_second_t(+0.381 * wpi::math::pi),
- units::meters_per_second_t(-0.381 * wpi::math::pi)};
- const auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), 0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), -wpi::math::pi, kEpsilon);
-}
diff --git a/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveOdometryTest.cpp b/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveOdometryTest.cpp
deleted file mode 100644
index 8acaf92..0000000
--- a/wpilibc/src/test/native/cpp/kinematics/DifferentialDriveOdometryTest.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <wpi/math>
-
-#include "frc/kinematics/DifferentialDriveKinematics.h"
-#include "frc/kinematics/DifferentialDriveOdometry.h"
-#include "gtest/gtest.h"
-
-static constexpr double kEpsilon = 1E-9;
-
-using namespace frc;
-
-TEST(DifferentialDriveOdometry, EncoderDistances) {
- DifferentialDriveOdometry odometry{Rotation2d(45_deg)};
-
- const auto& pose = odometry.Update(Rotation2d(135_deg), 0_m,
- units::meter_t(5 * wpi::math::pi));
-
- EXPECT_NEAR(pose.Translation().X().to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(pose.Translation().Y().to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(pose.Rotation().Degrees().to<double>(), 90.0, kEpsilon);
-}
diff --git a/wpilibc/src/test/native/cpp/kinematics/MecanumDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/kinematics/MecanumDriveKinematicsTest.cpp
deleted file mode 100644
index 75f395d..0000000
--- a/wpilibc/src/test/native/cpp/kinematics/MecanumDriveKinematicsTest.cpp
+++ /dev/null
@@ -1,230 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-#include <wpi/math>
-
-#include "frc/geometry/Translation2d.h"
-#include "frc/kinematics/MecanumDriveKinematics.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-class MecanumDriveKinematicsTest : public ::testing::Test {
- protected:
- Translation2d m_fl{12_m, 12_m};
- Translation2d m_fr{12_m, -12_m};
- Translation2d m_bl{-12_m, 12_m};
- Translation2d m_br{-12_m, -12_m};
-
- MecanumDriveKinematics kinematics{m_fl, m_fr, m_bl, m_br};
-};
-
-TEST_F(MecanumDriveKinematicsTest, StraightLineInverseKinematics) {
- ChassisSpeeds speeds{5_mps, 0_mps, 0_rad_per_s};
- auto moduleStates = kinematics.ToWheelSpeeds(speeds);
-
- /*
- By equation (13.12) of the state-space-guide, the wheel speeds should
- be as follows:
- velocities: fl 3.535534 fr 3.535534 rl 3.535534 rr 3.535534
- */
-
- EXPECT_NEAR(3.536, moduleStates.frontLeft.to<double>(), 0.1);
- EXPECT_NEAR(3.536, moduleStates.frontRight.to<double>(), 0.1);
- EXPECT_NEAR(3.536, moduleStates.rearLeft.to<double>(), 0.1);
- EXPECT_NEAR(3.536, moduleStates.rearRight.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, StraightLineForwardKinematics) {
- MecanumDriveWheelSpeeds wheelSpeeds{3.536_mps, 3.536_mps, 3.536_mps,
- 3.536_mps};
- auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- /*
- By equation (13.13) of the state-space-guide, the chassis motion from wheel
- velocities: fl 3.535534 fr 3.535534 rl 3.535534 rr 3.535534 will be
- [[5][0][0]]
- */
-
- EXPECT_NEAR(5.0, chassisSpeeds.vx.to<double>(), 0.1);
- EXPECT_NEAR(0.0, chassisSpeeds.vy.to<double>(), 0.1);
- EXPECT_NEAR(0.0, chassisSpeeds.omega.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, StrafeInverseKinematics) {
- ChassisSpeeds speeds{0_mps, 4_mps, 0_rad_per_s};
- auto moduleStates = kinematics.ToWheelSpeeds(speeds);
-
- /*
- By equation (13.12) of the state-space-guide, the wheel speeds should
- be as follows:
- velocities: fl -2.828427 fr 2.828427 rl 2.828427 rr -2.828427
- */
-
- EXPECT_NEAR(-2.828427, moduleStates.frontLeft.to<double>(), 0.1);
- EXPECT_NEAR(2.828427, moduleStates.frontRight.to<double>(), 0.1);
- EXPECT_NEAR(2.828427, moduleStates.rearLeft.to<double>(), 0.1);
- EXPECT_NEAR(-2.828427, moduleStates.rearRight.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, StrafeForwardKinematics) {
- MecanumDriveWheelSpeeds wheelSpeeds{-2.828427_mps, 2.828427_mps, 2.828427_mps,
- -2.828427_mps};
- auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- /*
- By equation (13.13) of the state-space-guide, the chassis motion from wheel
- velocities: fl 3.535534 fr 3.535534 rl 3.535534 rr 3.535534 will be
- [[5][0][0]]
- */
-
- EXPECT_NEAR(0.0, chassisSpeeds.vx.to<double>(), 0.1);
- EXPECT_NEAR(4.0, chassisSpeeds.vy.to<double>(), 0.1);
- EXPECT_NEAR(0.0, chassisSpeeds.omega.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, RotationInverseKinematics) {
- ChassisSpeeds speeds{0_mps, 0_mps,
- units::radians_per_second_t(2 * wpi::math::pi)};
- auto moduleStates = kinematics.ToWheelSpeeds(speeds);
-
- /*
- By equation (13.12) of the state-space-guide, the wheel speeds should
- be as follows:
- velocities: fl -106.629191 fr 106.629191 rl -106.629191 rr 106.629191
- */
-
- EXPECT_NEAR(-106.62919, moduleStates.frontLeft.to<double>(), 0.1);
- EXPECT_NEAR(106.62919, moduleStates.frontRight.to<double>(), 0.1);
- EXPECT_NEAR(-106.62919, moduleStates.rearLeft.to<double>(), 0.1);
- EXPECT_NEAR(106.62919, moduleStates.rearRight.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, RotationForwardKinematics) {
- MecanumDriveWheelSpeeds wheelSpeeds{-106.62919_mps, 106.62919_mps,
- -106.62919_mps, 106.62919_mps};
- auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- /*
- By equation (13.13) of the state-space-guide, the chassis motion from wheel
- velocities: fl -106.629191 fr 106.629191 rl -106.629191 rr 106.629191 should
- be [[0][0][2pi]]
- */
-
- EXPECT_NEAR(0.0, chassisSpeeds.vx.to<double>(), 0.1);
- EXPECT_NEAR(0.0, chassisSpeeds.vy.to<double>(), 0.1);
- EXPECT_NEAR(2 * wpi::math::pi, chassisSpeeds.omega.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, MixedRotationTranslationInverseKinematics) {
- ChassisSpeeds speeds{2_mps, 3_mps, 1_rad_per_s};
- auto moduleStates = kinematics.ToWheelSpeeds(speeds);
-
- /*
- By equation (13.12) of the state-space-guide, the wheel speeds should
- be as follows:
- velocities: fl -17.677670 fr 20.506097 rl -13.435029 rr 16.263456
- */
-
- EXPECT_NEAR(-17.677670, moduleStates.frontLeft.to<double>(), 0.1);
- EXPECT_NEAR(20.506097, moduleStates.frontRight.to<double>(), 0.1);
- EXPECT_NEAR(-13.435, moduleStates.rearLeft.to<double>(), 0.1);
- EXPECT_NEAR(16.26, moduleStates.rearRight.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, MixedRotationTranslationForwardKinematics) {
- MecanumDriveWheelSpeeds wheelSpeeds{-17.677670_mps, 20.506097_mps,
- -13.435_mps, 16.26_mps};
-
- auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- /*
- By equation (13.13) of the state-space-guide, the chassis motion from wheel
- velocities: fl -17.677670 fr 20.506097 rl -13.435029 rr 16.263456 should be
- [[2][3][1]]
- */
-
- EXPECT_NEAR(2.0, chassisSpeeds.vx.to<double>(), 0.1);
- EXPECT_NEAR(3.0, chassisSpeeds.vy.to<double>(), 0.1);
- EXPECT_NEAR(1.0, chassisSpeeds.omega.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, OffCenterRotationInverseKinematics) {
- ChassisSpeeds speeds{0_mps, 0_mps, 1_rad_per_s};
- auto moduleStates = kinematics.ToWheelSpeeds(speeds, m_fl);
-
- /*
- By equation (13.12) of the state-space-guide, the wheel speeds should
- be as follows:
- velocities: fl 0.000000 fr 16.970563 rl -16.970563 rr 33.941125
- */
-
- EXPECT_NEAR(0, moduleStates.frontLeft.to<double>(), 0.1);
- EXPECT_NEAR(16.971, moduleStates.frontRight.to<double>(), 0.1);
- EXPECT_NEAR(-16.971, moduleStates.rearLeft.to<double>(), 0.1);
- EXPECT_NEAR(33.941, moduleStates.rearRight.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, OffCenterRotationForwardKinematics) {
- MecanumDriveWheelSpeeds wheelSpeeds{0_mps, 16.971_mps, -16.971_mps,
- 33.941_mps};
- auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- /*
- By equation (13.13) of the state-space-guide, the chassis motion from the
- wheel velocities should be [[12][-12][1]]
- */
-
- EXPECT_NEAR(12.0, chassisSpeeds.vx.to<double>(), 0.1);
- EXPECT_NEAR(-12, chassisSpeeds.vy.to<double>(), 0.1);
- EXPECT_NEAR(1.0, chassisSpeeds.omega.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest,
- OffCenterTranslationRotationInverseKinematics) {
- ChassisSpeeds speeds{5_mps, 2_mps, 1_rad_per_s};
- auto moduleStates = kinematics.ToWheelSpeeds(speeds, m_fl);
-
- /*
- By equation (13.12) of the state-space-guide, the wheel speeds should
- be as follows:
- velocities: fl 2.121320 fr 21.920310 rl -12.020815 rr 36.062446
- */
- EXPECT_NEAR(2.12, moduleStates.frontLeft.to<double>(), 0.1);
- EXPECT_NEAR(21.92, moduleStates.frontRight.to<double>(), 0.1);
- EXPECT_NEAR(-12.02, moduleStates.rearLeft.to<double>(), 0.1);
- EXPECT_NEAR(36.06, moduleStates.rearRight.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest,
- OffCenterTranslationRotationForwardKinematics) {
- MecanumDriveWheelSpeeds wheelSpeeds{2.12_mps, 21.92_mps, -12.02_mps,
- 36.06_mps};
- auto chassisSpeeds = kinematics.ToChassisSpeeds(wheelSpeeds);
-
- /*
- By equation (13.13) of the state-space-guide, the chassis motion from the
- wheel velocities should be [[17][-10][1]]
- */
-
- EXPECT_NEAR(17.0, chassisSpeeds.vx.to<double>(), 0.1);
- EXPECT_NEAR(-10, chassisSpeeds.vy.to<double>(), 0.1);
- EXPECT_NEAR(1.0, chassisSpeeds.omega.to<double>(), 0.1);
-}
-
-TEST_F(MecanumDriveKinematicsTest, NormalizeTest) {
- MecanumDriveWheelSpeeds wheelSpeeds{5_mps, 6_mps, 4_mps, 7_mps};
- wheelSpeeds.Normalize(5.5_mps);
-
- double kFactor = 5.5 / 7.0;
-
- EXPECT_NEAR(wheelSpeeds.frontLeft.to<double>(), 5.0 * kFactor, 1E-9);
- EXPECT_NEAR(wheelSpeeds.frontRight.to<double>(), 6.0 * kFactor, 1E-9);
- EXPECT_NEAR(wheelSpeeds.rearLeft.to<double>(), 4.0 * kFactor, 1E-9);
- EXPECT_NEAR(wheelSpeeds.rearRight.to<double>(), 7.0 * kFactor, 1E-9);
-}
diff --git a/wpilibc/src/test/native/cpp/kinematics/MecanumDriveOdometryTest.cpp b/wpilibc/src/test/native/cpp/kinematics/MecanumDriveOdometryTest.cpp
deleted file mode 100644
index 5d990bf..0000000
--- a/wpilibc/src/test/native/cpp/kinematics/MecanumDriveOdometryTest.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/MecanumDriveOdometry.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-class MecanumDriveOdometryTest : public ::testing::Test {
- protected:
- Translation2d m_fl{12_m, 12_m};
- Translation2d m_fr{12_m, -12_m};
- Translation2d m_bl{-12_m, 12_m};
- Translation2d m_br{-12_m, -12_m};
-
- MecanumDriveKinematics kinematics{m_fl, m_fr, m_bl, m_br};
- MecanumDriveOdometry odometry{kinematics, 0_rad};
-};
-
-TEST_F(MecanumDriveOdometryTest, MultipleConsecutiveUpdates) {
- odometry.ResetPosition(Pose2d(), 0_rad);
- MecanumDriveWheelSpeeds wheelSpeeds{3.536_mps, 3.536_mps, 3.536_mps,
- 3.536_mps};
-
- odometry.UpdateWithTime(0_s, Rotation2d(), wheelSpeeds);
- auto secondPose = odometry.UpdateWithTime(0.0_s, Rotation2d(), wheelSpeeds);
-
- EXPECT_NEAR(secondPose.Translation().X().to<double>(), 0.0, 0.01);
- EXPECT_NEAR(secondPose.Translation().Y().to<double>(), 0.0, 0.01);
- EXPECT_NEAR(secondPose.Rotation().Radians().to<double>(), 0.0, 0.01);
-}
-
-TEST_F(MecanumDriveOdometryTest, TwoIterations) {
- odometry.ResetPosition(Pose2d(), 0_rad);
- MecanumDriveWheelSpeeds speeds{3.536_mps, 3.536_mps, 3.536_mps, 3.536_mps};
-
- odometry.UpdateWithTime(0_s, Rotation2d(), MecanumDriveWheelSpeeds{});
- auto pose = odometry.UpdateWithTime(0.10_s, Rotation2d(), speeds);
-
- EXPECT_NEAR(pose.Translation().X().to<double>(), 0.5, 0.01);
- EXPECT_NEAR(pose.Translation().Y().to<double>(), 0.0, 0.01);
- EXPECT_NEAR(pose.Rotation().Radians().to<double>(), 0.0, 0.01);
-}
-
-TEST_F(MecanumDriveOdometryTest, Test90DegreeTurn) {
- odometry.ResetPosition(Pose2d(), 0_rad);
- MecanumDriveWheelSpeeds speeds{-13.328_mps, 39.986_mps, -13.329_mps,
- 39.986_mps};
- odometry.UpdateWithTime(0_s, Rotation2d(), MecanumDriveWheelSpeeds{});
- auto pose = odometry.UpdateWithTime(1_s, Rotation2d(90_deg), speeds);
-
- EXPECT_NEAR(pose.Translation().X().to<double>(), 12, 0.01);
- EXPECT_NEAR(pose.Translation().Y().to<double>(), 12, 0.01);
- EXPECT_NEAR(pose.Rotation().Degrees().to<double>(), 90.0, 0.01);
-}
-
-TEST_F(MecanumDriveOdometryTest, GyroAngleReset) {
- odometry.ResetPosition(Pose2d(), Rotation2d(90_deg));
-
- MecanumDriveWheelSpeeds speeds{3.536_mps, 3.536_mps, 3.536_mps, 3.536_mps};
-
- odometry.UpdateWithTime(0_s, Rotation2d(90_deg), MecanumDriveWheelSpeeds{});
- auto pose = odometry.UpdateWithTime(0.10_s, Rotation2d(90_deg), speeds);
-
- EXPECT_NEAR(pose.Translation().X().to<double>(), 0.5, 0.01);
- EXPECT_NEAR(pose.Translation().Y().to<double>(), 0.0, 0.01);
- EXPECT_NEAR(pose.Rotation().Radians().to<double>(), 0.0, 0.01);
-}
diff --git a/wpilibc/src/test/native/cpp/kinematics/SwerveDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/kinematics/SwerveDriveKinematicsTest.cpp
deleted file mode 100644
index 8fd67ea..0000000
--- a/wpilibc/src/test/native/cpp/kinematics/SwerveDriveKinematicsTest.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <units/units.h>
-#include <wpi/math>
-
-#include "frc/geometry/Translation2d.h"
-#include "frc/kinematics/SwerveDriveKinematics.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-static constexpr double kEpsilon = 0.1;
-
-class SwerveDriveKinematicsTest : public ::testing::Test {
- protected:
- Translation2d m_fl{12_m, 12_m};
- Translation2d m_fr{12_m, -12_m};
- Translation2d m_bl{-12_m, 12_m};
- Translation2d m_br{-12_m, -12_m};
-
- SwerveDriveKinematics<4> m_kinematics{m_fl, m_fr, m_bl, m_br};
-};
-
-TEST_F(SwerveDriveKinematicsTest, StraightLineInverseKinematics) {
- ChassisSpeeds speeds{5.0_mps, 0.0_mps, 0.0_rad_per_s};
-
- auto [fl, fr, bl, br] = m_kinematics.ToSwerveModuleStates(speeds);
-
- EXPECT_NEAR(fl.speed.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(fr.speed.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(bl.speed.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(br.speed.to<double>(), 5.0, kEpsilon);
-
- EXPECT_NEAR(fl.angle.Radians().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(fr.angle.Radians().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(bl.angle.Radians().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(br.angle.Radians().to<double>(), 0.0, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, StraightLineForwardKinematics) {
- SwerveModuleState state{5.0_mps, Rotation2d()};
-
- auto chassisSpeeds = m_kinematics.ToChassisSpeeds(state, state, state, state);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), 0.0, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, StraightStrafeInverseKinematics) {
- ChassisSpeeds speeds{0_mps, 5_mps, 0_rad_per_s};
- auto [fl, fr, bl, br] = m_kinematics.ToSwerveModuleStates(speeds);
-
- EXPECT_NEAR(fl.speed.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(fr.speed.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(bl.speed.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(br.speed.to<double>(), 5.0, kEpsilon);
-
- EXPECT_NEAR(fl.angle.Degrees().to<double>(), 90.0, kEpsilon);
- EXPECT_NEAR(fr.angle.Degrees().to<double>(), 90.0, kEpsilon);
- EXPECT_NEAR(bl.angle.Degrees().to<double>(), 90.0, kEpsilon);
- EXPECT_NEAR(br.angle.Degrees().to<double>(), 90.0, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, StraightStrafeForwardKinematics) {
- SwerveModuleState state{5_mps, Rotation2d(90_deg)};
- auto chassisSpeeds = m_kinematics.ToChassisSpeeds(state, state, state, state);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), 5.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), 0.0, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, TurnInPlaceInverseKinematics) {
- ChassisSpeeds speeds{0_mps, 0_mps,
- units::radians_per_second_t(2 * wpi::math::pi)};
- auto [fl, fr, bl, br] = m_kinematics.ToSwerveModuleStates(speeds);
-
- EXPECT_NEAR(fl.speed.to<double>(), 106.63, kEpsilon);
- EXPECT_NEAR(fr.speed.to<double>(), 106.63, kEpsilon);
- EXPECT_NEAR(bl.speed.to<double>(), 106.63, kEpsilon);
- EXPECT_NEAR(br.speed.to<double>(), 106.63, kEpsilon);
-
- EXPECT_NEAR(fl.angle.Degrees().to<double>(), 135.0, kEpsilon);
- EXPECT_NEAR(fr.angle.Degrees().to<double>(), 45.0, kEpsilon);
- EXPECT_NEAR(bl.angle.Degrees().to<double>(), -135.0, kEpsilon);
- EXPECT_NEAR(br.angle.Degrees().to<double>(), -45.0, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, TurnInPlaceForwardKinematics) {
- SwerveModuleState fl{106.629_mps, Rotation2d(135_deg)};
- SwerveModuleState fr{106.629_mps, Rotation2d(45_deg)};
- SwerveModuleState bl{106.629_mps, Rotation2d(-135_deg)};
- SwerveModuleState br{106.629_mps, Rotation2d(-45_deg)};
-
- auto chassisSpeeds = m_kinematics.ToChassisSpeeds(fl, fr, bl, br);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), 2 * wpi::math::pi, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, OffCenterCORRotationInverseKinematics) {
- ChassisSpeeds speeds{0_mps, 0_mps,
- units::radians_per_second_t(2 * wpi::math::pi)};
- auto [fl, fr, bl, br] = m_kinematics.ToSwerveModuleStates(speeds, m_fl);
-
- EXPECT_NEAR(fl.speed.to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(fr.speed.to<double>(), 150.796, kEpsilon);
- EXPECT_NEAR(bl.speed.to<double>(), 150.796, kEpsilon);
- EXPECT_NEAR(br.speed.to<double>(), 213.258, kEpsilon);
-
- EXPECT_NEAR(fl.angle.Degrees().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(fr.angle.Degrees().to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(bl.angle.Degrees().to<double>(), -90.0, kEpsilon);
- EXPECT_NEAR(br.angle.Degrees().to<double>(), -45.0, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, OffCenterCORRotationForwardKinematics) {
- SwerveModuleState fl{0.0_mps, Rotation2d(0_deg)};
- SwerveModuleState fr{150.796_mps, Rotation2d(0_deg)};
- SwerveModuleState bl{150.796_mps, Rotation2d(-90_deg)};
- SwerveModuleState br{213.258_mps, Rotation2d(-45_deg)};
-
- auto chassisSpeeds = m_kinematics.ToChassisSpeeds(fl, fr, bl, br);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 75.398, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), -75.398, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), 2 * wpi::math::pi, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest,
- OffCenterCORRotationAndTranslationInverseKinematics) {
- ChassisSpeeds speeds{0_mps, 3.0_mps, 1.5_rad_per_s};
- auto [fl, fr, bl, br] =
- m_kinematics.ToSwerveModuleStates(speeds, Translation2d(24_m, 0_m));
-
- EXPECT_NEAR(fl.speed.to<double>(), 23.43, kEpsilon);
- EXPECT_NEAR(fr.speed.to<double>(), 23.43, kEpsilon);
- EXPECT_NEAR(bl.speed.to<double>(), 54.08, kEpsilon);
- EXPECT_NEAR(br.speed.to<double>(), 54.08, kEpsilon);
-
- EXPECT_NEAR(fl.angle.Degrees().to<double>(), -140.19, kEpsilon);
- EXPECT_NEAR(fr.angle.Degrees().to<double>(), -39.81, kEpsilon);
- EXPECT_NEAR(bl.angle.Degrees().to<double>(), -109.44, kEpsilon);
- EXPECT_NEAR(br.angle.Degrees().to<double>(), -70.56, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest,
- OffCenterCORRotationAndTranslationForwardKinematics) {
- SwerveModuleState fl{23.43_mps, Rotation2d(-140.19_deg)};
- SwerveModuleState fr{23.43_mps, Rotation2d(-39.81_deg)};
- SwerveModuleState bl{54.08_mps, Rotation2d(-109.44_deg)};
- SwerveModuleState br{54.08_mps, Rotation2d(-70.56_deg)};
-
- auto chassisSpeeds = m_kinematics.ToChassisSpeeds(fl, fr, bl, br);
-
- EXPECT_NEAR(chassisSpeeds.vx.to<double>(), 0.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.vy.to<double>(), -33.0, kEpsilon);
- EXPECT_NEAR(chassisSpeeds.omega.to<double>(), 1.5, kEpsilon);
-}
-
-TEST_F(SwerveDriveKinematicsTest, NormalizeTest) {
- SwerveModuleState state1{5.0_mps, Rotation2d()};
- SwerveModuleState state2{6.0_mps, Rotation2d()};
- SwerveModuleState state3{4.0_mps, Rotation2d()};
- SwerveModuleState state4{7.0_mps, Rotation2d()};
-
- std::array<SwerveModuleState, 4> arr{state1, state2, state3, state4};
- SwerveDriveKinematics<4>::NormalizeWheelSpeeds(&arr, 5.5_mps);
-
- double kFactor = 5.5 / 7.0;
-
- EXPECT_NEAR(arr[0].speed.to<double>(), 5.0 * kFactor, kEpsilon);
- EXPECT_NEAR(arr[1].speed.to<double>(), 6.0 * kFactor, kEpsilon);
- EXPECT_NEAR(arr[2].speed.to<double>(), 4.0 * kFactor, kEpsilon);
- EXPECT_NEAR(arr[3].speed.to<double>(), 7.0 * kFactor, kEpsilon);
-}
diff --git a/wpilibc/src/test/native/cpp/kinematics/SwerveDriveOdometryTest.cpp b/wpilibc/src/test/native/cpp/kinematics/SwerveDriveOdometryTest.cpp
deleted file mode 100644
index d0399dc..0000000
--- a/wpilibc/src/test/native/cpp/kinematics/SwerveDriveOdometryTest.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/kinematics/SwerveDriveKinematics.h"
-#include "frc/kinematics/SwerveDriveOdometry.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-static constexpr double kEpsilon = 0.01;
-
-class SwerveDriveOdometryTest : public ::testing::Test {
- protected:
- Translation2d m_fl{12_m, 12_m};
- Translation2d m_fr{12_m, -12_m};
- Translation2d m_bl{-12_m, 12_m};
- Translation2d m_br{-12_m, -12_m};
-
- SwerveDriveKinematics<4> m_kinematics{m_fl, m_fr, m_bl, m_br};
- SwerveDriveOdometry<4> m_odometry{m_kinematics, 0_rad};
-};
-
-TEST_F(SwerveDriveOdometryTest, TwoIterations) {
- SwerveModuleState state{5_mps, Rotation2d()};
-
- m_odometry.ResetPosition(Pose2d(), 0_rad);
- m_odometry.UpdateWithTime(0_s, Rotation2d(), SwerveModuleState(),
- SwerveModuleState(), SwerveModuleState(),
- SwerveModuleState());
- auto pose = m_odometry.UpdateWithTime(0.1_s, Rotation2d(), state, state,
- state, state);
-
- EXPECT_NEAR(0.5, pose.Translation().X().to<double>(), kEpsilon);
- EXPECT_NEAR(0.0, pose.Translation().Y().to<double>(), kEpsilon);
- EXPECT_NEAR(0.0, pose.Rotation().Degrees().to<double>(), kEpsilon);
-}
-
-TEST_F(SwerveDriveOdometryTest, 90DegreeTurn) {
- SwerveModuleState fl{18.85_mps, Rotation2d(90_deg)};
- SwerveModuleState fr{42.15_mps, Rotation2d(26.565_deg)};
- SwerveModuleState bl{18.85_mps, Rotation2d(-90_deg)};
- SwerveModuleState br{42.15_mps, Rotation2d(-26.565_deg)};
-
- SwerveModuleState zero{0_mps, Rotation2d()};
-
- m_odometry.ResetPosition(Pose2d(), 0_rad);
- m_odometry.UpdateWithTime(0_s, Rotation2d(), zero, zero, zero, zero);
- auto pose =
- m_odometry.UpdateWithTime(1_s, Rotation2d(90_deg), fl, fr, bl, br);
-
- EXPECT_NEAR(12.0, pose.Translation().X().to<double>(), kEpsilon);
- EXPECT_NEAR(12.0, pose.Translation().Y().to<double>(), kEpsilon);
- EXPECT_NEAR(90.0, pose.Rotation().Degrees().to<double>(), kEpsilon);
-}
-
-TEST_F(SwerveDriveOdometryTest, GyroAngleReset) {
- m_odometry.ResetPosition(Pose2d(), Rotation2d(90_deg));
-
- SwerveModuleState state{5_mps, Rotation2d()};
-
- m_odometry.UpdateWithTime(0_s, Rotation2d(90_deg), SwerveModuleState(),
- SwerveModuleState(), SwerveModuleState(),
- SwerveModuleState());
- auto pose = m_odometry.UpdateWithTime(0.1_s, Rotation2d(90_deg), state, state,
- state, state);
-
- EXPECT_NEAR(0.5, pose.Translation().X().to<double>(), kEpsilon);
- EXPECT_NEAR(0.0, pose.Translation().Y().to<double>(), kEpsilon);
- EXPECT_NEAR(0.0, pose.Rotation().Degrees().to<double>(), kEpsilon);
-}
diff --git a/wpilibc/src/test/native/cpp/simulation/AccelerometerSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/AccelerometerSimTest.cpp
new file mode 100644
index 0000000..d2c7ea8
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/AccelerometerSimTest.cpp
@@ -0,0 +1,40 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include "frc/simulation/BuiltInAccelerometerSim.h" // NOLINT(build/include_order)
+
+#include <hal/Accelerometer.h>
+#include <hal/HAL.h>
+
+#include "gtest/gtest.h"
+
+using namespace frc::sim;
+
+TEST(AcclerometerSimTests, TestActiveCallback) {
+ HAL_Initialize(500, 0);
+
+ BuiltInAccelerometerSim sim;
+
+ sim.ResetData();
+
+ bool wasTriggered = false;
+ bool lastValue = false;
+
+ auto cb = sim.RegisterActiveCallback(
+ [&](wpi::StringRef name, const HAL_Value* value) {
+ wasTriggered = true;
+ lastValue = value->data.v_boolean;
+ },
+ false);
+
+ EXPECT_FALSE(wasTriggered);
+
+ HAL_SetAccelerometerActive(true);
+
+ EXPECT_TRUE(wasTriggered);
+ EXPECT_TRUE(lastValue);
+}
diff --git a/wpilibc/src/test/native/cpp/simulation/AnalogEncoderSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/AnalogEncoderSimTest.cpp
new file mode 100644
index 0000000..f32be7e
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/AnalogEncoderSimTest.cpp
@@ -0,0 +1,30 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <hal/HAL.h>
+#include <units/math.h>
+#include <wpi/math>
+
+#include "frc/AnalogEncoder.h"
+#include "frc/AnalogInput.h"
+#include "frc/simulation/AnalogEncoderSim.h"
+#include "gtest/gtest.h"
+
+#define EXPECT_NEAR_UNITS(val1, val2, eps) \
+ EXPECT_LE(units::math::abs(val1 - val2), eps)
+
+TEST(AnalogEncoderSimTest, TestBasic) {
+ frc::AnalogInput ai(0);
+ frc::AnalogEncoder encoder{ai};
+ frc::sim::AnalogEncoderSim encoderSim{encoder};
+
+ encoderSim.SetPosition(180_deg);
+ EXPECT_NEAR(encoder.Get().to<double>(), 0.5, 1E-8);
+ EXPECT_NEAR(encoderSim.GetTurns().to<double>(), 0.5, 1E-8);
+ EXPECT_NEAR(encoderSim.GetPosition().Radians().to<double>(), wpi::math::pi,
+ 1E-8);
+}
diff --git a/wpilibc/src/test/native/cpp/simulation/DifferentialDriveSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/DifferentialDriveSimTest.cpp
new file mode 100644
index 0000000..f09344e
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/DifferentialDriveSimTest.cpp
@@ -0,0 +1,115 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <units/current.h>
+#include <units/math.h>
+#include <units/moment_of_inertia.h>
+
+#include "frc/controller/LinearPlantInversionFeedforward.h"
+#include "frc/controller/RamseteController.h"
+#include "frc/kinematics/DifferentialDriveKinematics.h"
+#include "frc/simulation/DifferentialDrivetrainSim.h"
+#include "frc/system/RungeKutta.h"
+#include "frc/system/plant/DCMotor.h"
+#include "frc/system/plant/LinearSystemId.h"
+#include "frc/trajectory/TrajectoryGenerator.h"
+#include "frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h"
+#include "gtest/gtest.h"
+
+TEST(DifferentialDriveSim, Convergence) {
+ auto motor = frc::DCMotor::NEO(2);
+ auto plant = frc::LinearSystemId::DrivetrainVelocitySystem(
+ motor, 50_kg, 2_in, 12_in, 0.5_kg_sq_m, 1.0);
+
+ frc::DifferentialDriveKinematics kinematics{24_in};
+ frc::sim::DifferentialDrivetrainSim sim{plant, 24_in, motor, 1.0, 2_in};
+
+ frc::LinearPlantInversionFeedforward feedforward{plant, 20_ms};
+ frc::RamseteController ramsete;
+
+ feedforward.Reset(frc::MakeMatrix<2, 1>(0.0, 0.0));
+
+ // Ground truth.
+ Eigen::Matrix<double, 7, 1> groundTruthX =
+ Eigen::Matrix<double, 7, 1>::Zero();
+
+ frc::TrajectoryConfig config{1_mps, 1_mps_sq};
+ config.AddConstraint(
+ frc::DifferentialDriveKinematicsConstraint(kinematics, 1_mps));
+
+ auto trajectory = frc::TrajectoryGenerator::GenerateTrajectory(
+ frc::Pose2d(), {}, frc::Pose2d(2_m, 2_m, 0_rad), config);
+
+ for (double t = 0; t < trajectory.TotalTime().to<double>(); t += 0.02) {
+ auto state = trajectory.Sample(20_ms);
+ auto ramseteOut = ramsete.Calculate(sim.GetPose(), state);
+
+ auto [l, r] = kinematics.ToWheelSpeeds(ramseteOut);
+ auto voltages = feedforward.Calculate(
+ frc::MakeMatrix<2, 1>(l.to<double>(), r.to<double>()));
+
+ // Sim periodic code.
+ sim.SetInputs(units::volt_t(voltages(0, 0)), units::volt_t(voltages(1, 0)));
+ sim.Update(20_ms);
+
+ // Update ground truth.
+ groundTruthX = frc::RungeKutta(
+ [&sim](const auto& x, const auto& u) -> Eigen::Matrix<double, 7, 1> {
+ return sim.Dynamics(x, u);
+ },
+ groundTruthX, voltages, 20_ms);
+ }
+
+ EXPECT_NEAR(groundTruthX(0, 0), sim.GetState(0), 1E-6);
+ EXPECT_NEAR(groundTruthX(1, 0), sim.GetState(1), 1E-6);
+ EXPECT_NEAR(groundTruthX(2, 0), sim.GetState(2), 1E-6);
+}
+
+TEST(DifferentialDriveSim, Current) {
+ auto motor = frc::DCMotor::NEO(2);
+ auto plant = frc::LinearSystemId::DrivetrainVelocitySystem(
+ motor, 50_kg, 2_in, 12_in, 0.5_kg_sq_m, 1.0);
+
+ frc::DifferentialDriveKinematics kinematics{24_in};
+ frc::sim::DifferentialDrivetrainSim sim{plant, 24_in, motor, 1.0, 2_in};
+
+ sim.SetInputs(-12_V, 12_V);
+ for (int i = 0; i < 10; ++i) {
+ sim.Update(20_ms);
+ }
+ EXPECT_TRUE(sim.GetCurrentDraw() > 0_A);
+
+ sim.SetInputs(12_V, 12_V);
+ for (int i = 0; i < 20; ++i) {
+ sim.Update(20_ms);
+ }
+ EXPECT_TRUE(sim.GetCurrentDraw() > 0_A);
+
+ sim.SetInputs(-12_V, 12_V);
+ for (int i = 0; i < 30; ++i) {
+ sim.Update(20_ms);
+ }
+ EXPECT_TRUE(sim.GetCurrentDraw() > 0_A);
+}
+
+TEST(DifferentialDriveSim, ModelStability) {
+ auto motor = frc::DCMotor::NEO(2);
+ auto plant = frc::LinearSystemId::DrivetrainVelocitySystem(
+ motor, 50_kg, 2_in, 12_in, 2_kg_sq_m, 5.0);
+
+ frc::DifferentialDriveKinematics kinematics{24_in};
+ frc::sim::DifferentialDrivetrainSim sim{plant, 24_in, motor, 1.0, 2_in};
+
+ sim.SetInputs(2_V, 4_V);
+
+ // 10 seconds should be enough time to verify stability
+ for (int i = 0; i < 500; ++i) {
+ sim.Update(20_ms);
+ }
+
+ EXPECT_LT(units::math::abs(sim.GetPose().Translation().Norm()), 100_m);
+}
diff --git a/wpilibc/src/test/native/cpp/simulation/ElevatorSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/ElevatorSimTest.cpp
new file mode 100644
index 0000000..05b0dc9
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/ElevatorSimTest.cpp
@@ -0,0 +1,69 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <iostream>
+
+#include <units/time.h>
+
+#include "frc/Encoder.h"
+#include "frc/PWMVictorSPX.h"
+#include "frc/RobotController.h"
+#include "frc/StateSpaceUtil.h"
+#include "frc/controller/PIDController.h"
+#include "frc/simulation/ElevatorSim.h"
+#include "frc/simulation/EncoderSim.h"
+#include "frc/system/plant/DCMotor.h"
+#include "frc/system/plant/LinearSystemId.h"
+#include "gtest/gtest.h"
+
+TEST(ElevatorSim, StateSpaceSim) {
+ frc::sim::ElevatorSim sim(frc::DCMotor::Vex775Pro(4), 14.67, 8_kg,
+ units::meter_t(0.75 * 25.4 / 1000.0), 0_m, 3_m,
+ {0.01});
+ frc2::PIDController controller(10, 0.0, 0.0);
+
+ frc::PWMVictorSPX motor(0);
+ frc::Encoder encoder(0, 1);
+ frc::sim::EncoderSim encoderSim(encoder);
+
+ for (size_t i = 0; i < 100; ++i) {
+ controller.SetSetpoint(2.0);
+ auto nextVoltage = controller.Calculate(encoderSim.GetDistance());
+ motor.Set(nextVoltage / frc::RobotController::GetInputVoltage());
+
+ auto u = frc::MakeMatrix<1, 1>(motor.Get() *
+ frc::RobotController::GetInputVoltage());
+ sim.SetInput(u);
+ sim.Update(20_ms);
+
+ const auto& y = sim.GetOutput();
+ encoderSim.SetDistance(y(0));
+ }
+
+ EXPECT_NEAR(controller.GetSetpoint(), sim.GetPosition().to<double>(), 0.2);
+}
+
+TEST(ElevatorSim, MinMax) {
+ frc::sim::ElevatorSim sim(frc::DCMotor::Vex775Pro(4), 14.67, 8_kg,
+ units::meter_t(0.75 * 25.4 / 1000.0), 0_m, 1_m,
+ {0.01});
+ for (size_t i = 0; i < 100; ++i) {
+ sim.SetInput(frc::MakeMatrix<1, 1>(0.0));
+ sim.Update(20_ms);
+
+ auto height = sim.GetPosition();
+ EXPECT_TRUE(height > -0.05_m);
+ }
+
+ for (size_t i = 0; i < 100; ++i) {
+ sim.SetInput(frc::MakeMatrix<1, 1>(12.0));
+ sim.Update(20_ms);
+
+ auto height = sim.GetPosition();
+ EXPECT_TRUE(height < 1.05_m);
+ }
+}
diff --git a/wpilibc/src/test/native/cpp/simulation/SimDeviceSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/SimDeviceSimTest.cpp
new file mode 100644
index 0000000..ea7b809
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/SimDeviceSimTest.cpp
@@ -0,0 +1,36 @@
+/*----------------------------------------------------------------------------*/
+/* 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/SimDevice.h>
+#include <wpi/StringRef.h>
+
+#include "frc/simulation/SimDeviceSim.h"
+#include "gtest/gtest.h"
+
+using namespace frc::sim;
+
+TEST(SimDeviceSimTests, TestBasic) {
+ hal::SimDevice dev{"test"};
+ hal::SimBoolean devBool = dev.CreateBoolean("bool", false, false);
+
+ SimDeviceSim sim{"test"};
+ hal::SimBoolean simBool = sim.GetBoolean("bool");
+ EXPECT_FALSE(simBool.Get());
+ simBool.Set(true);
+ EXPECT_TRUE(devBool.Get());
+}
+
+TEST(SimDeviceSimTests, TestEnumerateDevices) {
+ hal::SimDevice dev{"test"};
+
+ bool foundit = false;
+ SimDeviceSim::EnumerateDevices(
+ "te", [&](const char* name, HAL_SimDeviceHandle handle) {
+ if (wpi::StringRef(name) == "test") foundit = true;
+ });
+ EXPECT_TRUE(foundit);
+}
diff --git a/wpilibc/src/test/native/cpp/simulation/SimInitializationTest.cpp b/wpilibc/src/test/native/cpp/simulation/SimInitializationTest.cpp
new file mode 100644
index 0000000..1b86e05
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/SimInitializationTest.cpp
@@ -0,0 +1,56 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <exception>
+
+#include <hal/HAL.h>
+
+#include "frc/simulation/AddressableLEDSim.h"
+#include "frc/simulation/AnalogGyroSim.h"
+#include "frc/simulation/AnalogInputSim.h"
+#include "frc/simulation/AnalogOutputSim.h"
+#include "frc/simulation/AnalogTriggerSim.h"
+#include "frc/simulation/BuiltInAccelerometerSim.h"
+#include "frc/simulation/DIOSim.h"
+#include "frc/simulation/DigitalPWMSim.h"
+#include "frc/simulation/DriverStationSim.h"
+#include "frc/simulation/DutyCycleSim.h"
+#include "frc/simulation/EncoderSim.h"
+#include "frc/simulation/PCMSim.h"
+#include "frc/simulation/PDPSim.h"
+#include "frc/simulation/PWMSim.h"
+#include "frc/simulation/RelaySim.h"
+#include "frc/simulation/RoboRioSim.h"
+#include "frc/simulation/SPIAccelerometerSim.h"
+#include "gtest/gtest.h"
+
+using namespace frc::sim;
+
+TEST(SimInitializationTests, TestAllInitialize) {
+ HAL_Initialize(500, 0);
+ BuiltInAccelerometerSim biacsim;
+ AnalogGyroSim agsim{0};
+ AnalogInputSim aisim{0};
+ AnalogOutputSim aosim{0};
+ EXPECT_THROW(AnalogTriggerSim::CreateForChannel(0), std::out_of_range);
+ EXPECT_THROW(DigitalPWMSim::CreateForChannel(0), std::out_of_range);
+ DIOSim diosim{0};
+ DriverStationSim dssim;
+ (void)dssim;
+ EncoderSim esim = EncoderSim::CreateForIndex(0);
+ (void)esim;
+ PCMSim pcmsim{0};
+ PDPSim pdpsim{0};
+ PWMSim pwmsim{0};
+ RelaySim rsim{0};
+ RoboRioSim rrsim;
+ (void)rrsim;
+ SPIAccelerometerSim sasim{0};
+ DutyCycleSim dcsim = DutyCycleSim::CreateForIndex(0);
+ (void)dcsim;
+ AddressableLEDSim adLED;
+}
diff --git a/wpilibc/src/test/native/cpp/simulation/SingleJointedArmSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/SingleJointedArmSimTest.cpp
new file mode 100644
index 0000000..a553985
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/SingleJointedArmSimTest.cpp
@@ -0,0 +1,25 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <wpi/math>
+
+#include "frc/simulation/SingleJointedArmSim.h"
+#include "gtest/gtest.h"
+
+TEST(SingleJointedArmTest, Disabled) {
+ frc::sim::SingleJointedArmSim sim(frc::DCMotor::Vex775Pro(2), 100, 3_kg_sq_m,
+ 9.5_in, -180_deg, 0_deg, 10_lb, true);
+ sim.SetState(frc::MakeMatrix<2, 1>(0.0, 0.0));
+
+ for (size_t i = 0; i < 12 / 0.02; ++i) {
+ sim.SetInput(frc::MakeMatrix<1, 1>(0.0));
+ sim.Update(20_ms);
+ }
+
+ // The arm should swing down.
+ EXPECT_NEAR(sim.GetAngle().to<double>(), -wpi::math::pi / 2, 0.01);
+}
diff --git a/wpilibc/src/test/native/cpp/simulation/StateSpaceSimTest.cpp b/wpilibc/src/test/native/cpp/simulation/StateSpaceSimTest.cpp
new file mode 100644
index 0000000..5766751
--- /dev/null
+++ b/wpilibc/src/test/native/cpp/simulation/StateSpaceSimTest.cpp
@@ -0,0 +1,58 @@
+/*----------------------------------------------------------------------------*/
+/* 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. */
+/*----------------------------------------------------------------------------*/
+
+#include <iostream>
+
+#include <units/angular_acceleration.h>
+#include <units/angular_velocity.h>
+
+#include "frc/Encoder.h"
+#include "frc/PWMVictorSPX.h"
+#include "frc/RobotController.h"
+#include "frc/controller/PIDController.h"
+#include "frc/controller/SimpleMotorFeedforward.h"
+#include "frc/simulation/BatterySim.h"
+#include "frc/simulation/DifferentialDrivetrainSim.h"
+#include "frc/simulation/ElevatorSim.h"
+#include "frc/simulation/EncoderSim.h"
+#include "frc/simulation/FlywheelSim.h"
+#include "frc/simulation/LinearSystemSim.h"
+#include "frc/simulation/PWMSim.h"
+#include "frc/simulation/RoboRioSim.h"
+#include "frc/simulation/SingleJointedArmSim.h"
+#include "frc/system/plant/LinearSystemId.h"
+#include "gtest/gtest.h"
+
+TEST(StateSpaceSimTest, TestFlywheelSim) {
+ const frc::LinearSystem<1, 1, 1> plant =
+ frc::LinearSystemId::IdentifyVelocitySystem<units::radian>(
+ 0.02_V / 1_rad_per_s, 0.01_V / 1_rad_per_s_sq);
+ frc::sim::FlywheelSim sim{plant, frc::DCMotor::NEO(2), 1.0};
+ frc2::PIDController controller{0.2, 0.0, 0.0};
+ frc::SimpleMotorFeedforward<units::radian> feedforward{
+ 0_V, 0.02_V / 1_rad_per_s, 0.01_V / 1_rad_per_s_sq};
+ frc::Encoder encoder{0, 1};
+ frc::sim::EncoderSim encoderSim{encoder};
+ frc::PWMVictorSPX motor{0};
+
+ for (int i = 0; i < 100; i++) {
+ // RobotPeriodic runs first
+ auto voltageOut = controller.Calculate(encoder.GetRate(), 200.0);
+ motor.SetVoltage(units::volt_t(voltageOut) +
+ feedforward.Calculate(200_rad_per_s));
+
+ // Then, SimulationPeriodic runs
+ frc::sim::RoboRioSim::SetVInVoltage(
+ frc::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
+ sim.SetInput(frc::MakeMatrix<1, 1>(
+ motor.Get() * frc::RobotController::GetInputVoltage()));
+ sim.Update(20_ms);
+ encoderSim.SetRate(sim.GetAngularVelocity().to<double>());
+ }
+
+ ASSERT_TRUE(std::abs(200 - encoder.GetRate()) < 0.1);
+}
diff --git a/wpilibc/src/test/native/cpp/spline/CubicHermiteSplineTest.cpp b/wpilibc/src/test/native/cpp/spline/CubicHermiteSplineTest.cpp
deleted file mode 100644
index f2f0a38..0000000
--- a/wpilibc/src/test/native/cpp/spline/CubicHermiteSplineTest.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <chrono>
-#include <iostream>
-#include <vector>
-
-#include <units/units.h>
-
-#include "frc/geometry/Pose2d.h"
-#include "frc/geometry/Rotation2d.h"
-#include "frc/spline/QuinticHermiteSpline.h"
-#include "frc/spline/SplineHelper.h"
-#include "frc/spline/SplineParameterizer.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-namespace frc {
-class CubicHermiteSplineTest : public ::testing::Test {
- protected:
- static void Run(const Pose2d& a, const std::vector<Translation2d>& waypoints,
- const Pose2d& b) {
- // Start the timer.
- const auto start = std::chrono::high_resolution_clock::now();
-
- // Generate and parameterize the spline.
-
- const auto [startCV, endCV] =
- SplineHelper::CubicControlVectorsFromWaypoints(a, waypoints, b);
-
- const auto splines =
- SplineHelper::CubicSplinesFromControlVectors(startCV, waypoints, endCV);
- std::vector<Spline<3>::PoseWithCurvature> poses;
-
- poses.push_back(splines[0].GetPoint(0.0));
-
- for (auto&& spline : splines) {
- auto x = SplineParameterizer::Parameterize(spline);
- poses.insert(std::end(poses), std::begin(x) + 1, std::end(x));
- }
-
- // End timer.
- const auto finish = std::chrono::high_resolution_clock::now();
-
- // Calculate the duration (used when benchmarking)
- const auto duration =
- std::chrono::duration_cast<std::chrono::microseconds>(finish - start);
-
- for (unsigned int i = 0; i < poses.size() - 1; i++) {
- auto& p0 = poses[i];
- auto& p1 = poses[i + 1];
-
- // Make sure the twist is under the tolerance defined by the Spline class.
- auto twist = p0.first.Log(p1.first);
- EXPECT_LT(std::abs(twist.dx.to<double>()),
- SplineParameterizer::kMaxDx.to<double>());
- EXPECT_LT(std::abs(twist.dy.to<double>()),
- SplineParameterizer::kMaxDy.to<double>());
- EXPECT_LT(std::abs(twist.dtheta.to<double>()),
- SplineParameterizer::kMaxDtheta.to<double>());
- }
-
- // Check first point.
- EXPECT_NEAR(poses.front().first.Translation().X().to<double>(),
- a.Translation().X().to<double>(), 1E-9);
- EXPECT_NEAR(poses.front().first.Translation().Y().to<double>(),
- a.Translation().Y().to<double>(), 1E-9);
- EXPECT_NEAR(poses.front().first.Rotation().Radians().to<double>(),
- a.Rotation().Radians().to<double>(), 1E-9);
-
- // Check interior waypoints
- bool interiorsGood = true;
- for (auto& waypoint : waypoints) {
- bool found = false;
- for (auto& state : poses) {
- if (std::abs(
- waypoint.Distance(state.first.Translation()).to<double>()) <
- 1E-9) {
- found = true;
- }
- }
- interiorsGood &= found;
- }
-
- EXPECT_TRUE(interiorsGood);
-
- // Check last point.
- EXPECT_NEAR(poses.back().first.Translation().X().to<double>(),
- b.Translation().X().to<double>(), 1E-9);
- EXPECT_NEAR(poses.back().first.Translation().Y().to<double>(),
- b.Translation().Y().to<double>(), 1E-9);
- EXPECT_NEAR(poses.back().first.Rotation().Radians().to<double>(),
- b.Rotation().Radians().to<double>(), 1E-9);
-
- static_cast<void>(duration);
- }
-};
-} // namespace frc
-
-TEST_F(CubicHermiteSplineTest, StraightLine) {
- Run(Pose2d(), std::vector<Translation2d>(), Pose2d(3_m, 0_m, Rotation2d()));
-}
-
-TEST_F(CubicHermiteSplineTest, SCurve) {
- Pose2d start{0_m, 0_m, Rotation2d(90_deg)};
- std::vector<Translation2d> waypoints{Translation2d(1_m, 1_m),
- Translation2d(2_m, -1_m)};
- Pose2d end{3_m, 0_m, Rotation2d{90_deg}};
- Run(start, waypoints, end);
-}
-
-TEST_F(CubicHermiteSplineTest, OneInterior) {
- Pose2d start{0_m, 0_m, 0_rad};
- std::vector<Translation2d> waypoints{Translation2d(2_m, 0_m)};
- Pose2d end{4_m, 0_m, 0_rad};
- Run(start, waypoints, end);
-}
-
-TEST_F(CubicHermiteSplineTest, ThrowsOnMalformed) {
- EXPECT_THROW(
- Run(Pose2d{0_m, 0_m, Rotation2d(0_deg)}, std::vector<Translation2d>{},
- Pose2d{1_m, 0_m, Rotation2d(180_deg)}),
- SplineParameterizer::MalformedSplineException);
- EXPECT_THROW(
- Run(Pose2d{10_m, 10_m, Rotation2d(90_deg)}, std::vector<Translation2d>{},
- Pose2d{10_m, 11_m, Rotation2d(-90_deg)}),
- SplineParameterizer::MalformedSplineException);
-}
diff --git a/wpilibc/src/test/native/cpp/spline/QuinticHermiteSplineTest.cpp b/wpilibc/src/test/native/cpp/spline/QuinticHermiteSplineTest.cpp
deleted file mode 100644
index 8a87053..0000000
--- a/wpilibc/src/test/native/cpp/spline/QuinticHermiteSplineTest.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <chrono>
-#include <iostream>
-
-#include <units/units.h>
-
-#include "frc/geometry/Pose2d.h"
-#include "frc/geometry/Rotation2d.h"
-#include "frc/spline/QuinticHermiteSpline.h"
-#include "frc/spline/SplineHelper.h"
-#include "frc/spline/SplineParameterizer.h"
-#include "gtest/gtest.h"
-
-using namespace frc;
-
-namespace frc {
-class QuinticHermiteSplineTest : public ::testing::Test {
- protected:
- static void Run(const Pose2d& a, const Pose2d& b) {
- // Start the timer.
- const auto start = std::chrono::high_resolution_clock::now();
-
- // Generate and parameterize the spline.
- const auto spline = SplineHelper::QuinticSplinesFromControlVectors(
- SplineHelper::QuinticControlVectorsFromWaypoints({a, b}))[0];
- const auto poses = SplineParameterizer::Parameterize(spline);
-
- // End timer.
- const auto finish = std::chrono::high_resolution_clock::now();
-
- // Calculate the duration (used when benchmarking)
- const auto duration =
- std::chrono::duration_cast<std::chrono::microseconds>(finish - start);
-
- for (unsigned int i = 0; i < poses.size() - 1; i++) {
- auto& p0 = poses[i];
- auto& p1 = poses[i + 1];
-
- // Make sure the twist is under the tolerance defined by the Spline class.
- auto twist = p0.first.Log(p1.first);
- EXPECT_LT(std::abs(twist.dx.to<double>()),
- SplineParameterizer::kMaxDx.to<double>());
- EXPECT_LT(std::abs(twist.dy.to<double>()),
- SplineParameterizer::kMaxDy.to<double>());
- EXPECT_LT(std::abs(twist.dtheta.to<double>()),
- SplineParameterizer::kMaxDtheta.to<double>());
- }
-
- // Check first point.
- EXPECT_NEAR(poses.front().first.Translation().X().to<double>(),
- a.Translation().X().to<double>(), 1E-9);
- EXPECT_NEAR(poses.front().first.Translation().Y().to<double>(),
- a.Translation().Y().to<double>(), 1E-9);
- EXPECT_NEAR(poses.front().first.Rotation().Radians().to<double>(),
- a.Rotation().Radians().to<double>(), 1E-9);
-
- // Check last point.
- EXPECT_NEAR(poses.back().first.Translation().X().to<double>(),
- b.Translation().X().to<double>(), 1E-9);
- EXPECT_NEAR(poses.back().first.Translation().Y().to<double>(),
- b.Translation().Y().to<double>(), 1E-9);
- EXPECT_NEAR(poses.back().first.Rotation().Radians().to<double>(),
- b.Rotation().Radians().to<double>(), 1E-9);
-
- static_cast<void>(duration);
- }
-};
-} // namespace frc
-
-TEST_F(QuinticHermiteSplineTest, StraightLine) {
- Run(Pose2d(), Pose2d(3_m, 0_m, Rotation2d()));
-}
-
-TEST_F(QuinticHermiteSplineTest, SimpleSCurve) {
- Run(Pose2d(), Pose2d(1_m, 1_m, Rotation2d()));
-}
-
-TEST_F(QuinticHermiteSplineTest, SquigglyCurve) {
- Run(Pose2d(0_m, 0_m, Rotation2d(90_deg)),
- Pose2d(-1_m, 0_m, Rotation2d(90_deg)));
-}
-
-TEST_F(QuinticHermiteSplineTest, ThrowsOnMalformed) {
- EXPECT_THROW(Run(Pose2d(0_m, 0_m, Rotation2d(0_deg)),
- Pose2d(1_m, 0_m, Rotation2d(180_deg))),
- SplineParameterizer::MalformedSplineException);
- EXPECT_THROW(Run(Pose2d(10_m, 10_m, Rotation2d(90_deg)),
- Pose2d(10_m, 11_m, Rotation2d(-90_deg))),
- SplineParameterizer::MalformedSplineException);
-}
diff --git a/wpilibc/src/test/native/cpp/trajectory/CentripetalAccelerationConstraintTest.cpp b/wpilibc/src/test/native/cpp/trajectory/CentripetalAccelerationConstraintTest.cpp
deleted file mode 100644
index 37f471a..0000000
--- a/wpilibc/src/test/native/cpp/trajectory/CentripetalAccelerationConstraintTest.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <memory>
-#include <vector>
-
-#include <units/units.h>
-
-#include "frc/trajectory/constraint/CentripetalAccelerationConstraint.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-#include "gtest/gtest.h"
-#include "trajectory/TestTrajectory.h"
-
-using namespace frc;
-
-TEST(CentripetalAccelerationConstraintTest, Constraint) {
- const auto maxCentripetalAcceleration = 7_fps_sq;
-
- auto config = TrajectoryConfig(12_fps, 12_fps_sq);
- config.AddConstraint(
- CentripetalAccelerationConstraint(maxCentripetalAcceleration));
-
- auto trajectory = TestTrajectory::GetTrajectory(config);
-
- units::second_t time = 0_s;
- units::second_t dt = 20_ms;
- units::second_t duration = trajectory.TotalTime();
-
- while (time < duration) {
- const Trajectory::State point = trajectory.Sample(time);
- time += dt;
-
- auto centripetalAcceleration =
- units::math::pow<2>(point.velocity) * point.curvature / 1_rad;
-
- EXPECT_TRUE(centripetalAcceleration <
- maxCentripetalAcceleration + 0.05_mps_sq);
- }
-}
diff --git a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveKinematicsTest.cpp b/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveKinematicsTest.cpp
deleted file mode 100644
index df5ddbd..0000000
--- a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveKinematicsTest.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <memory>
-#include <vector>
-
-#include <units/units.h>
-
-#include "frc/kinematics/DifferentialDriveKinematics.h"
-#include "frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h"
-#include "gtest/gtest.h"
-#include "trajectory/TestTrajectory.h"
-
-using namespace frc;
-
-TEST(DifferentialDriveKinematicsConstraintTest, Constraint) {
- const auto maxVelocity = 12_fps;
- const DifferentialDriveKinematics kinematics{27_in};
-
- auto config = TrajectoryConfig(12_fps, 12_fps_sq);
- config.AddConstraint(
- DifferentialDriveKinematicsConstraint(kinematics, maxVelocity));
-
- auto trajectory = TestTrajectory::GetTrajectory(config);
-
- units::second_t time = 0_s;
- units::second_t dt = 20_ms;
- units::second_t duration = trajectory.TotalTime();
-
- while (time < duration) {
- const Trajectory::State point = trajectory.Sample(time);
- time += dt;
-
- const ChassisSpeeds chassisSpeeds{point.velocity, 0_mps,
- point.velocity * point.curvature};
-
- auto [left, right] = kinematics.ToWheelSpeeds(chassisSpeeds);
-
- EXPECT_TRUE(left < maxVelocity + 0.05_mps);
- EXPECT_TRUE(right < maxVelocity + 0.05_mps);
- }
-}
diff --git a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveVoltageTest.cpp b/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveVoltageTest.cpp
deleted file mode 100644
index eb230da..0000000
--- a/wpilibc/src/test/native/cpp/trajectory/DifferentialDriveVoltageTest.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <iostream>
-#include <memory>
-#include <vector>
-
-#include <units/units.h>
-
-#include "frc/kinematics/DifferentialDriveKinematics.h"
-#include "frc/trajectory/constraint/DifferentialDriveVoltageConstraint.h"
-#include "gtest/gtest.h"
-#include "trajectory/TestTrajectory.h"
-
-using namespace frc;
-
-TEST(DifferentialDriveVoltageConstraintTest, Constraint) {
- // Pick an unreasonably large kA to ensure the constraint has to do some work
- SimpleMotorFeedforward<units::meter> feedforward{1_V, 1_V / 1_mps,
- 3_V / 1_mps_sq};
- const DifferentialDriveKinematics kinematics{0.5_m};
- const auto maxVoltage = 10_V;
-
- auto config = TrajectoryConfig(12_fps, 12_fps_sq);
- config.AddConstraint(
- DifferentialDriveVoltageConstraint(feedforward, kinematics, maxVoltage));
-
- auto trajectory = TestTrajectory::GetTrajectory(config);
-
- units::second_t time = 0_s;
- units::second_t dt = 20_ms;
- units::second_t duration = trajectory.TotalTime();
-
- while (time < duration) {
- const Trajectory::State point = trajectory.Sample(time);
- time += dt;
-
- const ChassisSpeeds chassisSpeeds{point.velocity, 0_mps,
- point.velocity * point.curvature};
-
- auto [left, right] = kinematics.ToWheelSpeeds(chassisSpeeds);
-
- // Not really a strictly-correct test as we're using the chassis accel
- // instead of the wheel accel, but much easier than doing it "properly" and
- // a reasonable check anyway
- EXPECT_TRUE(feedforward.Calculate(left, point.acceleration) <
- maxVoltage + 0.05_V);
- EXPECT_TRUE(feedforward.Calculate(left, point.acceleration) >
- -maxVoltage - 0.05_V);
- EXPECT_TRUE(feedforward.Calculate(right, point.acceleration) <
- maxVoltage + 0.05_V);
- EXPECT_TRUE(feedforward.Calculate(right, point.acceleration) >
- -maxVoltage - 0.05_V);
- }
-}
diff --git a/wpilibc/src/test/native/cpp/trajectory/TrajectoryGeneratorTest.cpp b/wpilibc/src/test/native/cpp/trajectory/TrajectoryGeneratorTest.cpp
deleted file mode 100644
index 90046c5..0000000
--- a/wpilibc/src/test/native/cpp/trajectory/TrajectoryGeneratorTest.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <vector>
-
-#include "frc/trajectory/Trajectory.h"
-#include "frc/trajectory/TrajectoryGenerator.h"
-#include "frc/trajectory/constraint/CentripetalAccelerationConstraint.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-#include "gtest/gtest.h"
-#include "trajectory/TestTrajectory.h"
-
-using namespace frc;
-
-TEST(TrajectoryGenerationTest, ObeysConstraints) {
- TrajectoryConfig config{12_fps, 12_fps_sq};
- auto trajectory = TestTrajectory::GetTrajectory(config);
-
- units::second_t time = 0_s;
- units::second_t dt = 20_ms;
- units::second_t duration = trajectory.TotalTime();
-
- while (time < duration) {
- const Trajectory::State point = trajectory.Sample(time);
- time += dt;
-
- EXPECT_TRUE(units::math::abs(point.velocity) <= 12_fps + 0.01_fps);
- EXPECT_TRUE(units::math::abs(point.acceleration) <=
- 12_fps_sq + 0.01_fps_sq);
- }
-}
-
-TEST(TrajectoryGenertionTest, ReturnsEmptyOnMalformed) {
- const auto t = TrajectoryGenerator::GenerateTrajectory(
- std::vector<Pose2d>{Pose2d(0_m, 0_m, Rotation2d(0_deg)),
- Pose2d(1_m, 0_m, Rotation2d(180_deg))},
- TrajectoryConfig(12_fps, 12_fps_sq));
-
- ASSERT_EQ(t.States().size(), 1u);
- ASSERT_EQ(t.TotalTime(), 0_s);
-}
diff --git a/wpilibc/src/test/native/cpp/trajectory/TrajectoryJsonTest.cpp b/wpilibc/src/test/native/cpp/trajectory/TrajectoryJsonTest.cpp
deleted file mode 100644
index 999d2bb..0000000
--- a/wpilibc/src/test/native/cpp/trajectory/TrajectoryJsonTest.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/TrajectoryConfig.h"
-#include "frc/trajectory/TrajectoryUtil.h"
-#include "gtest/gtest.h"
-#include "trajectory/TestTrajectory.h"
-
-using namespace frc;
-
-TEST(TrajectoryJsonTest, DeserializeMatches) {
- TrajectoryConfig config{12_fps, 12_fps_sq};
- auto trajectory = TestTrajectory::GetTrajectory(config);
-
- Trajectory deserialized;
- EXPECT_NO_THROW(deserialized = TrajectoryUtil::DeserializeTrajectory(
- TrajectoryUtil::SerializeTrajectory(trajectory)));
- EXPECT_EQ(trajectory.States(), deserialized.States());
-}
diff --git a/wpilibc/src/test/native/cpp/trajectory/TrajectoryTransformTest.cpp b/wpilibc/src/test/native/cpp/trajectory/TrajectoryTransformTest.cpp
deleted file mode 100644
index af69b58..0000000
--- a/wpilibc/src/test/native/cpp/trajectory/TrajectoryTransformTest.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <vector>
-
-#include "frc/trajectory/Trajectory.h"
-#include "frc/trajectory/TrajectoryConfig.h"
-#include "frc/trajectory/TrajectoryGenerator.h"
-#include "gtest/gtest.h"
-
-void TestSameShapedTrajectory(std::vector<frc::Trajectory::State> statesA,
- std::vector<frc::Trajectory::State> statesB) {
- for (unsigned int i = 0; i < statesA.size() - 1; i++) {
- auto a1 = statesA[i].pose;
- auto a2 = statesA[i + 1].pose;
-
- auto b1 = statesB[i].pose;
- auto b2 = statesB[i + 1].pose;
-
- auto a = a2.RelativeTo(a1);
- auto b = b2.RelativeTo(b1);
-
- EXPECT_NEAR(a.Translation().X().to<double>(),
- b.Translation().X().to<double>(), 1E-9);
- EXPECT_NEAR(a.Translation().Y().to<double>(),
- b.Translation().Y().to<double>(), 1E-9);
- EXPECT_NEAR(a.Rotation().Radians().to<double>(),
- b.Rotation().Radians().to<double>(), 1E-9);
- }
-}
-
-TEST(TrajectoryTransforms, TransformBy) {
- frc::TrajectoryConfig config{3_mps, 3_mps_sq};
- auto trajectory = frc::TrajectoryGenerator::GenerateTrajectory(
- frc::Pose2d{}, {}, frc::Pose2d{1_m, 1_m, frc::Rotation2d(90_deg)},
- config);
-
- auto transformedTrajectory =
- trajectory.TransformBy({{1_m, 2_m}, frc::Rotation2d(30_deg)});
-
- auto firstPose = transformedTrajectory.Sample(0_s).pose;
-
- EXPECT_NEAR(firstPose.Translation().X().to<double>(), 1.0, 1E-9);
- EXPECT_NEAR(firstPose.Translation().Y().to<double>(), 2.0, 1E-9);
- EXPECT_NEAR(firstPose.Rotation().Degrees().to<double>(), 30.0, 1E-9);
-
- TestSameShapedTrajectory(trajectory.States(), transformedTrajectory.States());
-}
-
-TEST(TrajectoryTransforms, RelativeTo) {
- frc::TrajectoryConfig config{3_mps, 3_mps_sq};
- auto trajectory = frc::TrajectoryGenerator::GenerateTrajectory(
- frc::Pose2d{1_m, 2_m, frc::Rotation2d(30_deg)}, {},
- frc::Pose2d{5_m, 7_m, frc::Rotation2d(90_deg)}, config);
-
- auto transformedTrajectory =
- trajectory.RelativeTo({1_m, 2_m, frc::Rotation2d(30_deg)});
-
- auto firstPose = transformedTrajectory.Sample(0_s).pose;
-
- EXPECT_NEAR(firstPose.Translation().X().to<double>(), 0, 1E-9);
- EXPECT_NEAR(firstPose.Translation().Y().to<double>(), 0, 1E-9);
- EXPECT_NEAR(firstPose.Rotation().Degrees().to<double>(), 0, 1E-9);
-
- TestSameShapedTrajectory(trajectory.States(), transformedTrajectory.States());
-}
diff --git a/wpilibc/src/test/native/cpp/trajectory/TrapezoidProfileTest.cpp b/wpilibc/src/test/native/cpp/trajectory/TrapezoidProfileTest.cpp
deleted file mode 100644
index bd9ffef..0000000
--- a/wpilibc/src/test/native/cpp/trajectory/TrapezoidProfileTest.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 "frc/trajectory/TrapezoidProfile.h" // NOLINT(build/include_order)
-
-#include <chrono>
-#include <cmath>
-
-#include "gtest/gtest.h"
-
-static constexpr auto kDt = 10_ms;
-
-#define EXPECT_NEAR_UNITS(val1, val2, eps) \
- EXPECT_LE(units::math::abs(val1 - val2), eps)
-
-#define EXPECT_LT_OR_NEAR_UNITS(val1, val2, eps) \
- if (val1 <= val2) { \
- EXPECT_LE(val1, val2); \
- } else { \
- EXPECT_NEAR_UNITS(val1, val2, eps); \
- }
-
-TEST(TrapezoidProfileTest, ReachesGoal) {
- frc::TrapezoidProfile<units::meter>::Constraints constraints{1.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{3_m, 0_mps};
- frc::TrapezoidProfile<units::meter>::State state;
-
- for (int i = 0; i < 450; ++i) {
- frc::TrapezoidProfile<units::meter> profile{constraints, goal, state};
- state = profile.Calculate(kDt);
- }
- EXPECT_EQ(state, goal);
-}
-
-// Tests that decreasing the maximum velocity in the middle when it is already
-// moving faster than the new max is handled correctly
-TEST(TrapezoidProfileTest, PosContinousUnderVelChange) {
- frc::TrapezoidProfile<units::meter>::Constraints constraints{1.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{12_m, 0_mps};
-
- frc::TrapezoidProfile<units::meter> profile{constraints, goal};
- auto state = profile.Calculate(kDt);
-
- auto lastPos = state.position;
- for (int i = 0; i < 1600; ++i) {
- if (i == 400) {
- constraints.maxVelocity = 0.75_mps;
- }
-
- profile = frc::TrapezoidProfile<units::meter>{constraints, goal, state};
- state = profile.Calculate(kDt);
- auto estimatedVel = (state.position - lastPos) / kDt;
-
- if (i >= 400) {
- // Since estimatedVel can have floating point rounding errors, we check
- // whether value is less than or within an error delta of the new
- // constraint.
- EXPECT_LT_OR_NEAR_UNITS(estimatedVel, constraints.maxVelocity, 1e-4_mps);
-
- EXPECT_LE(state.velocity, constraints.maxVelocity);
- }
-
- lastPos = state.position;
- }
- EXPECT_EQ(state, goal);
-}
-
-// There is some somewhat tricky code for dealing with going backwards
-TEST(TrapezoidProfileTest, Backwards) {
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{-2_m, 0_mps};
- frc::TrapezoidProfile<units::meter>::State state;
-
- for (int i = 0; i < 400; ++i) {
- frc::TrapezoidProfile<units::meter> profile{constraints, goal, state};
- state = profile.Calculate(kDt);
- }
- EXPECT_EQ(state, goal);
-}
-
-TEST(TrapezoidProfileTest, SwitchGoalInMiddle) {
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{-2_m, 0_mps};
- frc::TrapezoidProfile<units::meter>::State state;
-
- for (int i = 0; i < 200; ++i) {
- frc::TrapezoidProfile<units::meter> profile{constraints, goal, state};
- state = profile.Calculate(kDt);
- }
- EXPECT_NE(state, goal);
-
- goal = {0.0_m, 0.0_mps};
- for (int i = 0; i < 550; ++i) {
- frc::TrapezoidProfile<units::meter> profile{constraints, goal, state};
- state = profile.Calculate(kDt);
- }
- EXPECT_EQ(state, goal);
-}
-
-// Checks to make sure that it hits top speed
-TEST(TrapezoidProfileTest, TopSpeed) {
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{4_m, 0_mps};
- frc::TrapezoidProfile<units::meter>::State state;
-
- for (int i = 0; i < 200; ++i) {
- frc::TrapezoidProfile<units::meter> profile{constraints, goal, state};
- state = profile.Calculate(kDt);
- }
- EXPECT_NEAR_UNITS(constraints.maxVelocity, state.velocity, 10e-5_mps);
-
- for (int i = 0; i < 2000; ++i) {
- frc::TrapezoidProfile<units::meter> profile{constraints, goal, state};
- state = profile.Calculate(kDt);
- }
- EXPECT_EQ(state, goal);
-}
-
-TEST(TrapezoidProfileTest, TimingToCurrent) {
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{2_m, 0_mps};
- frc::TrapezoidProfile<units::meter>::State state;
-
- for (int i = 0; i < 400; i++) {
- frc::TrapezoidProfile<units::meter> profile{constraints, goal, state};
- state = profile.Calculate(kDt);
- EXPECT_NEAR_UNITS(profile.TimeLeftUntil(state.position), 0_s, 2e-2_s);
- }
-}
-
-TEST(TrapezoidProfileTest, TimingToGoal) {
- using units::unit_cast;
-
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{2_m, 0_mps};
-
- frc::TrapezoidProfile<units::meter> profile{constraints, goal};
- auto state = profile.Calculate(kDt);
-
- auto predictedTimeLeft = profile.TimeLeftUntil(goal.position);
- bool reachedGoal = false;
- for (int i = 0; i < 400; i++) {
- profile = frc::TrapezoidProfile<units::meter>(constraints, goal, state);
- state = profile.Calculate(kDt);
- if (!reachedGoal && state == goal) {
- // Expected value using for loop index is just an approximation since the
- // time left in the profile doesn't increase linearly at the endpoints
- EXPECT_NEAR(unit_cast<double>(predictedTimeLeft), i / 100.0, 0.25);
- reachedGoal = true;
- }
- }
-}
-
-TEST(TrapezoidProfileTest, TimingBeforeGoal) {
- using units::unit_cast;
-
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{2_m, 0_mps};
-
- frc::TrapezoidProfile<units::meter> profile{constraints, goal};
- auto state = profile.Calculate(kDt);
-
- auto predictedTimeLeft = profile.TimeLeftUntil(1_m);
- bool reachedGoal = false;
- for (int i = 0; i < 400; i++) {
- profile = frc::TrapezoidProfile<units::meter>(constraints, goal, state);
- state = profile.Calculate(kDt);
- if (!reachedGoal &&
- (units::math::abs(state.velocity - 1_mps) < 10e-5_mps)) {
- EXPECT_NEAR(unit_cast<double>(predictedTimeLeft), i / 100.0, 2e-2);
- reachedGoal = true;
- }
- }
-}
-
-TEST(TrapezoidProfileTest, TimingToNegativeGoal) {
- using units::unit_cast;
-
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{-2_m, 0_mps};
-
- frc::TrapezoidProfile<units::meter> profile{constraints, goal};
- auto state = profile.Calculate(kDt);
-
- auto predictedTimeLeft = profile.TimeLeftUntil(goal.position);
- bool reachedGoal = false;
- for (int i = 0; i < 400; i++) {
- profile = frc::TrapezoidProfile<units::meter>(constraints, goal, state);
- state = profile.Calculate(kDt);
- if (!reachedGoal && state == goal) {
- // Expected value using for loop index is just an approximation since the
- // time left in the profile doesn't increase linearly at the endpoints
- EXPECT_NEAR(unit_cast<double>(predictedTimeLeft), i / 100.0, 0.25);
- reachedGoal = true;
- }
- }
-}
-
-TEST(TrapezoidProfileTest, TimingBeforeNegativeGoal) {
- using units::unit_cast;
-
- frc::TrapezoidProfile<units::meter>::Constraints constraints{0.75_mps,
- 0.75_mps_sq};
- frc::TrapezoidProfile<units::meter>::State goal{-2_m, 0_mps};
-
- frc::TrapezoidProfile<units::meter> profile{constraints, goal};
- auto state = profile.Calculate(kDt);
-
- auto predictedTimeLeft = profile.TimeLeftUntil(-1_m);
- bool reachedGoal = false;
- for (int i = 0; i < 400; i++) {
- profile = frc::TrapezoidProfile<units::meter>(constraints, goal, state);
- state = profile.Calculate(kDt);
- if (!reachedGoal &&
- (units::math::abs(state.velocity + 1_mps) < 10e-5_mps)) {
- EXPECT_NEAR(unit_cast<double>(predictedTimeLeft), i / 100.0, 2e-2);
- reachedGoal = true;
- }
- }
-}
diff --git a/wpilibc/src/test/native/include/trajectory/TestTrajectory.h b/wpilibc/src/test/native/include/trajectory/TestTrajectory.h
deleted file mode 100644
index 4a496d7..0000000
--- a/wpilibc/src/test/native/include/trajectory/TestTrajectory.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* 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 <utility>
-#include <vector>
-
-#include "frc/trajectory/Trajectory.h"
-#include "frc/trajectory/TrajectoryGenerator.h"
-#include "frc/trajectory/constraint/TrajectoryConstraint.h"
-
-namespace frc {
-class TestTrajectory {
- public:
- static Trajectory GetTrajectory(TrajectoryConfig& config) {
- // 2018 cross scale auto waypoints
- const Pose2d sideStart{1.54_ft, 23.23_ft, Rotation2d(180_deg)};
- const Pose2d crossScale{23.7_ft, 6.8_ft, Rotation2d(-160_deg)};
-
- config.SetReversed(true);
-
- auto vector = std::vector<Translation2d>{
- (sideStart + Transform2d{Translation2d(-13_ft, 0_ft), Rotation2d()})
- .Translation(),
- (sideStart +
- Transform2d{Translation2d(-19.5_ft, 5.0_ft), Rotation2d(-90_deg)})
- .Translation()};
-
- return TrajectoryGenerator::GenerateTrajectory(sideStart, vector,
- crossScale, config);
- }
-};
-
-} // namespace frc