Commit Graph

798 Commits

Author SHA1 Message Date
Peter Johnson
b10063da9a [sim] Set Encoder reset to false when count set (#2692) 2020-09-04 20:51:08 -07:00
Peter Johnson
f1b1bdb121 [hal] Add HAL_Shutdown and simulation shutdown callbacks
This is useful for clean shutdown of simulation extensions.
2020-09-04 16:26:09 -07:00
Peter Johnson
0365557b25 [sim] Make extension registry thread-safe 2020-09-04 16:26:09 -07:00
Peter Johnson
de0277713b [sim] Add API for extensions to discover each other (#2681) 2020-09-03 10:09:01 -07:00
Peter Johnson
47cc71ea01 [hal] Add HALSIM_GetJoystickCounts 2020-09-02 21:13:38 -07:00
Peter Johnson
9453d67273 [sim] Output more error details on extension load failure (#2680) 2020-09-02 20:07:03 -07:00
sciencewhiz
f758af826d [wpilib] Use misspell to find more spelling errors (NFC) (#2679) 2020-09-02 19:41:05 -07:00
Peter Johnson
7d6f09f5c7 [sim] SimDataValue: Fix cancellation
The uid was getting incremented by 1 during registration but not decremented
by 1 during cancellation, so cancellation didn't work correctly.

As the underlying registration ensures a non-zero result, don't increment
the result.
2020-09-01 21:32:21 -07:00
Peter Johnson
148eed3cdc [sim] Make sure NotifyListener members are initialized 2020-09-01 21:32:21 -07:00
Thad House
05701317b4 [build] Make loading sim extensions from MyRobot easier (#2671) 2020-08-31 00:34:34 -07:00
Thad House
7548fdae5d [hal] Fix InitialzeInterrupts naming (#2673)
Closes #2605
2020-08-31 00:33:49 -07:00
sciencewhiz
3e41d92c18 [wpilib] Use misspell to fix spelling errors (NFC) (#2674) 2020-08-31 00:33:11 -07:00
sciencewhiz
ad6c8b882e [hal] Fix PDP Energy Calculation (#2672)
Fixes #2642
2020-08-31 00:31:30 -07:00
Peter Johnson
007b03a2c2 [hal] Fix wpiformat errors (#2670)
These were introduced in the previous commit.
2020-08-29 23:25:41 -07:00
Thad House
ed18693345 [hal] Add no throw/error version of CAN Write methods (#2063) 2020-08-29 23:07:22 -07:00
Austin Shalit
0d88213de5 [sim] Add missing new line to extension loader message (#2663) 2020-08-27 20:39:40 -07:00
Zhiquan Yeo
932bfcf374 [sim] Add WebSocket extension (client/server) (#2589)
This allows access to HAL-level simulation data via a WebSocket connection.

The server additionally serves local files.

The following environment variables can be used for configuration:
HALSIMWS_USERROOT (server) - local directory to use for file serving for /user/ URIs, defaults to ./sim/user
HALSIMWS_SYSROOT (server) - local directory to use for file serving for all other URIs, defaults to ./sim
HALSIMWS_URI (client or server) - WebSocket URI, defaults to /wpilibws
HALSIMWS_PORT (client or server) - port number, defaults to 8080
HALSIMWS_HOST (client) - host to connect to, defaults to localhost

Co-authored-by: Zhiquan Yeo <zyeo8@bloomberg.net>
Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
Co-authored-by: jpokornyiii <jpokornyiii@gmail.com>
2020-08-19 22:14:03 -07:00
Peter Johnson
e127bac7fd [sim] Properly initialize AnalogTrigger (#2646) 2020-08-19 21:58:07 -07:00
Peter Johnson
dc9e560f9b [sim] Add callback for NotifyNewData 2020-08-15 13:47:30 -07:00
Peter Johnson
ae5b07ba01 [hal] Add stubs for sim joysticks and match info on Rio 2020-08-15 13:47:30 -07:00
Peter Johnson
ad817d4f23 [sim] Map wpi::Now() to simulated FPGA time (#2631)
This matches on-robot behavior for things like NetworkTables timestamps.
2020-08-06 23:03:42 -07:00
Peter Johnson
1b8ceb36fc [sim] Add callbacks for joysticks and match info (#2628) 2020-08-03 22:38:48 -07:00
Peter Johnson
5cf4c16f5b [wpilibj] Suppress serialVersionUID warnings (#2618)
These are all classes (e.g. Exception classes) which will never be serialized.
2020-07-26 17:06:17 -07:00
Thad House
a6a71f8c76 [hal] Fix RoboRIO notifier never starting (#2611) 2020-07-23 18:09:00 -07:00
Peter Johnson
33d8363297 [sim] Fix HAL notifier race condition (#2606)
WaitForNotifierAlarm was waiting on the CV without first checking to see if
the exit condition was met.
2020-07-20 23:30:14 -07:00
Peter Johnson
b9feb81226 [sim] Add joystick simulation support (#2595)
This adds joystick functions to DriverStationSim, and new GenericHIDSim,
JoystickSim, and XboxControllerSim classes.
2020-07-15 00:33:57 -07:00
Peter Johnson
16ef372b53 [hal] Merge WaitForCachedData into WaitForDSData (#2587)
Remove WaitForCachedData as it's no longer required.

Also properly handle caching / transition detection logic that occurs at the
WPILib level.

This also changes DriverStation::IsNewControlData() to check for WPILib-level
caching instead of wrapping the HAL function.
2020-07-13 21:57:54 -07:00
Peter Johnson
227084e92e [hal] Implement stub mockdata on RoboRIO (#2575)
This makes it much more user-friendly to use simulation classes without needing
to ifdef for C++ to avoid linker errors or be very careful about construction
to avoid runtime errors in Java.
2020-07-07 21:49:05 -07:00
Peter Johnson
5bd2dca463 [sim] Move HAL_LoadExtensions to end of HAL_Initialize (#2571)
Previously, HAL_InitializeDriverStation would reset any callbacks set in
extensions during load.
2020-07-05 22:12:12 -07:00
Peter Johnson
3050e935a1 [sim] Add WPILib-class-taking constructors (#2538)
When not direct mapped, make index constructors private and add factory
functions for channel and index.

Co-authored-by: GabrielDeml <gabrielddeml@gmail.com>
2020-07-04 10:10:43 -07:00
Peter Johnson
80a1fa9ece [sim] Add support for disabling SimDevices (#2568)
This allows disabling/enabling SimDevices via prefix matching.  This can be
used to force devices that normally use SimDevice in simulation mode to
instead talk directly to the hardware as in normal operation.
2020-07-04 01:09:49 -07:00
Peter Johnson
1851ba1434 [sim] Remove index from RoboRIO simulation interface (#2567) 2020-07-04 00:44:56 -07:00
Peter Johnson
c4b8a2505d [sim] Add Java wrapper for getProgramStarted (#2566)
Also move SimHooks to wpilibj (to match wpilibc).
2020-07-04 00:44:37 -07:00
Peter Johnson
c6e6346642 [sim] Support StepTiming() even when timing is not paused (#2558) 2020-06-29 21:52:23 -07:00
Vasista Vovveti
dac0e5b133 [sim] Set Windows timer precision to 1ms (#2557) 2020-06-28 17:45:40 -07:00
Peter Johnson
ce3bc91946 [sim] Move Sim classes from HAL to wpilibc/j (#2549)
Also move some things in HAL for consistency.

WAS:
C++:
- C APIs: #include "mockdata/AccelerometerData.h"
- User side class: #include "simulation/AccelerometerSim.h"
Java:
- JNI APIs: hal.sim.mockdata.AccelerometerData (and a few classes in hal.sim)
- User side classes: hal.sim.AccelerometerSim

IS:
C++:
- C APIs: #include "hal/simulation/AccelerometerData.h"
- C++ class: #include "frc/simulation/AccelerometerSim.h"
Java:
- JNI APIs: hal.simulation.AccelerometerData
- User side class: wpilibj.simulation.AccelerometerSim
2020-06-27 22:11:24 -07:00
Peter Johnson
629e8b41f2 [sim] Provide method to set the runtime type (#2539)
This is needed for extensions that effectively access real hardware and
want to disable the "simulation" parts of user code.
2020-06-26 20:46:13 -07:00
Peter Johnson
71c187a1ed [hal] Add GetIndex() to handles classes (#2548)
This provides a lock-free way to get just the handle index.
2020-06-26 19:56:05 -07:00
Peter Johnson
8a80f97c06 [hal] Move JNI helpers and sim namespace to hal namespace (#2543) 2020-06-26 17:12:55 -07:00
Thad House
3cbec411c7 [build] Add package declaration check to checkstyle (#2446)
Co-authored-by: Austin Shalit <austinshalit@gmail.com>
2020-06-26 11:10:34 -07:00
Peter Johnson
62b8a36ce9 [sim] Wrap timing functions in C++ SimHooks (#2540)
These are present in Java but were missed for C++.
2020-06-20 23:47:55 -07:00
Peter Johnson
1557a4c3b0 [sim] Make SimDeviceInfo/SimValueInfo data members public (#2531) 2020-06-13 20:50:34 -07:00
Thad House
cf20b068ca [sim] Map HAL_GetSystemActive to HALSIM_GetDriverStationEnabled (#2501)
Vendors have requested this for testing purposes.
2020-05-01 09:05:54 -07:00
Thad House
21aafea098 [hal] Use std::thread for Notifier thread on Rio (#2152)
This gives us more control over the thread than using the NI manager.
2020-04-03 08:38:00 -07:00
Thad House
3ed2908563 [sim] Add HALSIM accessors for encoder rate and distance (#2467) 2020-04-03 08:33:38 -07:00
Thad House
303194b08b Add missing CAN definition for IO Breakout (#2394)
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2020-03-22 22:56:07 -07:00
Thad House
7b7f44d937 Use netcomm function to get target class rather then hardcoded (#2391)
It reports the correct value now, and helps for future proofing
2020-03-14 22:04:12 -07:00
Thad House
6cf89aa0f3 Fix interrupt cancellation (#2406) 2020-03-14 22:03:04 -07:00
Thad House
554bda3332 HAL: Expose NetComm SendConsoleLine (#2337)
This can be use to synchronize writes between threads, assuming writes all go through this and not stdout.
2020-02-18 20:44:40 -08:00
Thad House
2a968df779 Add method for releasing a waiting interrupt (#2347)
Useful for a new high level interrupt implementation.
2020-02-18 20:41:42 -08:00