Open vectorcrumb opened 7 years ago
The way Toast's Simulation GUI currently works is by redirecting WPILib JNI calls to the GUI. Toast has a wrapper system that doesn't require a Toast module and will work with a normal WPILib jar. This won't work for 2017 binaries just yet, but works fine for 2016 codebases. Drop your .jar
file into toast/modules
and run Toast to get it up and running.
I created a module with Hotplate and the instructions from the wiki and ran the basic module. The project has a run/toast/modules
directory, so I suppose it goes in there. However, I'm not sure how to get the simulator running without compiling and loading the code in the src
folder. Also, how does the sim manage calls to joysticks? If the code requires joysticks but they aren't connected to the computer when running the .jar
will Toast crash?
1) To use joysticks, you need to connect the driver station to the simulator. If no joysticks are connected, all axis will read 0 and all buttons will read false.
2) You can run simulation as normal and Toast will pickup the jar
Ok, so I added the module and used the TestModule-Sim run config in IntelliJ 2016.3 with code compiled with the 2016 FRC plugins in Eclipse Mars (the code was developed with Eclipse but I felt like running Toast in IntelliJ). I dropped the the .jar
into the modules folder: run/toast/modules/FRCUserProgram.jar
. Initially I had an error with an ADIS16448_IMU class that tried to initialize a SPI port, so I removed all calls to that class. However, I'm now getting errors with the Encoder class provided with the FRC plugins. I've included the output:
________ ______ __
(( ) /_ __/___ ____ ______/ /_
|| o o | / / / __ \/ __ `/ ___/ __/
|| 3 | / / / /_/ / /_/ (__ ) /_
\\_______/ /_/ \____/\__,_/____/\__/
[09/01/17-01:43:34] [Toast] [Bootstrap] [INFO] Toast Version: 2.4.14
[09/01/17-01:43:34] [Toast] [Bootstrap] [INFO] Toast Commit Hash: 2022e41
[09/01/17-01:43:35] [Toast] [Core-Initialization] [INFO] Toast Started with Run Arguments: [-sim, --search, -ide, IDEA]
[09/01/17-01:43:35] [Toast] [Pre-Initialization] [INFO] Slicing Loaf...
[09/01/17-01:43:35] [Toast] [Initialization] [INFO] Nuking Toast...
platform: /Windows/amd64/
[09/01/17-01:43:36] [Toast] [Pre-Start] [INFO] Buttering Bread...
[09/01/17-01:43:36] [Toast|Loader] [Pre-Start] [INFO] Module Loaded: TestModule@0.0.1
[09/01/17-01:43:36] [Toast|Loader] [Pre-Start] [INFO] Module Loaded: FRCUserProgram.jar!wrapper@0.0.0
[09/01/17-01:43:36] [Toast] [Start] [INFO] Fabricating Sandwich...
[09/01/17-01:43:36] [Toast] [Start] [INFO] Verdict: Hot, Hot, HOT!!
[09/01/17-01:43:36] [Toast] [Main] [INFO] Total Initiation Time: 1.302 seconds
[09/01/17-01:43:37] [Toast] [Thread-9] [ERROR] Could not instantiate Wrapped Module reflection on robotInit: java.lang.reflect.InvocationTargetException
[09/01/17-01:43:37] [Toast] [Thread-9] [ERROR] java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at jaci.openrio.toast.lib.module.ModuleWrapper.reflectMethod(ModuleWrapper.java:150)
at jaci.openrio.toast.lib.module.ModuleWrapper.lambda$start$21(ModuleWrapper.java:92)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsatisfiedLinkError: edu.wpi.first.wpilibj.hal.EncoderJNI.initializeEncoder(BIZBIZZLjava/nio/IntBuffer;)J
at edu.wpi.first.wpilibj.hal.EncoderJNI.initializeEncoder(Native Method)
at edu.wpi.first.wpilibj.Encoder.initEncoder(Encoder.java:87)
at edu.wpi.first.wpilibj.Encoder.<init>(Encoder.java:171)
at com.team2576.robot.io.SensorInput.<init>(SensorInput.java:82)
at com.team2576.robot.io.SensorInput.getInstance(SensorInput.java:71)
at com.team2576.lib.Kapellmeister.<init>(Kapellmeister.java:28)
at com.team2576.lib.Kapellmeister.getInstance(Kapellmeister.java:34)
at com.team2576.robot.ChiliRobot.robotInit(ChiliRobot.java:57)
... 7 more
The error occurs in this call:
public static SensorInput getInstance() {
if(instance == null) {
instance = new SensorInput();
}
return instance;
}
which calls the following constructor:
private SensorInput() {
this.inputValues = Collections.synchronizedMap(new LinkedHashMap<String, Double>());
pdp = new PowerDistributionPanel();
// adIMU = new ADIS16448_IMU();
cuiLeft = new Encoder(ChiliConstants.iLeftEncoderA, ChiliConstants.iLeftEncoderB, false, EncodingType.k4X);
cuiRight = new Encoder(ChiliConstants.iRightEncoderA, ChiliConstants.iRightEncoderB, false, EncodingType.k4X);
intakeAngle = new Encoder(ChiliConstants.iIntakeEncoderA, ChiliConstants.iIntakeEncoderB, false, EncodingType.k4X);
camLeft = new USBCamera(ChiliConstants.kCamLeft);
camCenter = new AxisCamera(ChiliConstants.kCamCenter);
//camRight = new USBCamera(ChiliConstants.kCamRight);
camLeft.openCamera();
//camRight.openCamera();
camLeft.startCapture();
//camRight.startCapture();
abort_vision = false;
this.initEncoders();
}
The error occurs when initializing cuiLeft
.
Your code is using Encoders, however Toast doesn't currently support Encoder simulation. See #35
My bad, I forgot to look through the other issues. Thanks!
Would it be possible to have an independent simulator to aid teams who are using the default tools given to them by FIRST? Maybe a sort of wrapper which takes calls to the WPIlib classes and redirects those function calls to the GUI