FRC 174 Code and Simulator

The FRC 174 Software Team is proud to release our 2017 software for our robot, vision app, SmartDashboard plugins, and simulator.

Robot Code:
Autonomous scripting using the Command framework
Global positioning system using feedback from encoders and a gyroscope to ascertain our (X,Y,Angle) position on the field at all times
Motion profiling for autonomous driving and turning (based on work done by The Cheesy Poofs)
Path Planning for curved autonomous driving (100% stolen from The Cheesy Poofs)
Android vision app which ran on my old Samsung Galaxy S5 (based on work CheezyVision)
Lag compensating autonomous driving to the vision targets (based on The Cheesy Poofs)

SmartDashboard Features:
Custom widgets to show the current state of our superstructure
Coordinate Viewer which draws our currents robot position as it relates to the field, where the camera thinks the targets are, and the paths/trajectories we are trying to drive in autonomous
Autonomous Script widget that allows us to edit our auto scripts right from the SmartDashboard instead of having to FTP into the robot, change the file, FTP it back
Match Number widget which crawls the driver station logs and tries to figure out the current match number, which is used in our various debugging logs. This should no longer be necessary in 2018 (finally)

Vision App:
Android App that uses the front facing camera to detect the vision targets
Had ability to change the vision parameters on the fly
Would save every image into a match number stamped folder on the phone. This was incredibly useful for tweaking our parameters during practice matches at the two events we went to, and we could stitch them together post mortem to make cool videos like this https://www.youtube.com/watch?v=DMLI6_s4Wrs

Simulator:

A java-based simulator built to simulate any java robot. It also should simulate C++, Python, C# (anything with a native interface that talks to the HAL) robot. We often don’t get a robot to play with until the end of a season, so this allows us to test our code ASAP. Over the course of the offseason, I’ve worked to get this more ready for public use.

It has been modified to comply with the WPILib mocking framework, and we have merged a lot of our simulators down into the library for 2018. With the Gazebo simulator not quite ready for primetime, this provides a simple, albeit not 100% physically accurate way to simulate your robot.

At the moment, we have support for the most used features in WPILib (standard speed controllers, encoders, analog IO, digital IO, SPI gyro, 3-axis accelerometers), as well as the NavX systems 3-axis gyro and 3-axis accelerometer. It has beta support for the 2018 CTRE beta libraries for the TalonSRX and PigeonIMU, but without them having open sourced code everything outside of the AppliedVoltage mode might not behave anything like what would happen in the real world.

After the post-kickoff craziness settles down, I’ll button everything up and make the 1.0.0 release when all of the WPI/3rd Party code gets released and make sure the documentation us up to snuff. In the meantime, you can read more about it on the simulators wiki

If you have any questions feel free to ask,

PJ - Lead Software Mentor FRC 174

2 Likes

Hello,

I’m looking for some assistance here.

I am having issues with the FRC 174 Java Simulator. I have installed in to Eclipse, the Simulator V9.0 pulled down from GitHub. I followed the steps in your Wiki Instruction Page (the 2nd procedure - the one for Eclipse obviously). It seem to install ok, but when I run the Sim. I get the below errors. I verified that the I have CTRE_PhoenixCCI in the build path for both the Simulator Project and my Robot Project just in case, and still get the error. One of my teammates had the same condition after he installed, and he was able to resolve it, but I had him look at my eclipse settings, and he had no luck after about an hour. I can not figure it out making all the build patch/setting changes I can think of given the error messages. Any suggestions? I’m running Eclipse Oxygen with Java 8 and the FRC 2018 Command Based Framework, if that matters.

Thank You, Rufus.

2018-03-10 01:06:22 INFO SimulatorConfigReader:65 - Loading C:\Users\qzlxs6\Documents\ADM0001\SourceJava\Simul ator9.0\simulator_config\simulator_config.yml
2018-03-10 01:06:22 INFO Simulator:135 - Starting Robot Code
java.lang.UnsatisfiedLinkError: no CTRE_PhoenixCCI in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java :1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
.
.
.

Hey Rufus, thanks for playing around with the simulator.

The build season got a little bit more hectic than I expected, but our season is now over so I’ll be working on fixing the issues other people have created and making some of the improvements our team wanted during the build season. It might take a couple days to get an updated version, but your issues seems pretty similar to this one, so you can try that out while I work on publishing a new Eclipse Quickstart version.

Let me know if that doesn’t solve the problem,

PJ

The simulator link doesn’t seem to be working, it leads to a 404 page.

Interesting, it just worked for me at work…

Well here is my response to that persons issue

Simulator quickstart needs to be updated. Probably will push this till after ship (plus a R&R period). In the meantime, I think if you can download the [native package](https://github.com/pjreiniger/maven_repo/blob/master/com/snobot/simulator/ctre_override/0.8.0/ctre_override-0.8.0-native-windows.jar) (use the correct version for your quickstart to be safe. Shouldn't matter for CTRE libraries) and extract the two DLL's to <simulator_project>/dependencies/native

The whole time I've been testing the quickstart I tie it to our robot (which then inherits its dependencies) causing me to miss this

Here is that link in raw form in case that gets busted too.
https://github.com/pjreiniger/maven_repo/blob/master/com/snobot/simulator/ctre_override/0.8.0/ctre_override-0.8.0-native-windows.jar

I get the same 404 page when I click the simulator link in the OP as well.

You/your team might have switched the simulator repo to private - they show up as 404 to anyone who doesn’t have access.

Works for me.

Partial success. Adding the jar ā€œctre_override-0.9.0-native-windows.jarā€ to Simulator9.0/dependencies/native where ā€œSimulator9.0ā€ is the name I call the simulator project didn’t work directly, until I had to assign my ā€œnativeā€ library directory in my project properties to ā€œdependencies/nativeā€ then it was able to get past the library link error for ā€œCTRE_PhoenixCCI.dllā€

Then the simulator crashed (error message below) because we have a camera connected via USB is our robot software and apparently the Simulator does not support USB connected inputs. I will temporarily disable that input in our software and see if we can move forward.

Also, it will be interesting to look through your Sim to see if it sends out Field Data from a virtual FMS. :slight_smile:

Thanks.

Info C:/projects/snobotsim/snobot_sim_java/cpp/lib/SnobotSimJava/Jni/RegisterCallbacksJni.cpp:34 - Initializing the simulator
2018-03-22 20:38:29 INFO PluginSniffer:72 - Searching for robot plugins in C:\Users\qzlxs6\Documents\ADM0001\SourceJava\Simulator9.0\user_libs
2018-03-22 20:38:29 INFO SimulatorConfigReader:65 - Loading C:\Users\qzlxs6\Documents\ADM0001\SourceJava\Simulator9.0\simulator_config\simulator_config.yml
2018-03-22 20:38:29 INFO Simulator:135 - Starting Robot Code
2018-03-22 20:38:30 ERROR CtreManager:227 - Unknown motor callback: SetNeutralMode
2018-03-22 20:38:30 ERROR CtreManager:227 - Unknown motor callback: SetNeutralMode
2018-03-22 20:38:30 ERROR CtreManager:227 - Unknown motor callback: SetNeutralMode
2018-03-22 20:38:30 ERROR CtreManager:227 - Unknown motor callback: SetNeutralMode
2018-03-22 20:38:30 ERROR DefaultSpiSimulatorFactory:41 - Could not create simulator for SPI on port 0
2018-03-22 20:38:30 ERROR DefaultSpiSimulatorFactory:41 - Could not create simulator for SPI on port 0
2018-03-22 20:38:30 ERROR JoystickDiscoverer:130 - Unknown joystick name 3Dconnexion KMJ Emulator
2018-03-22 20:38:30 ERROR JoystickFactory:188 - Unknown joystick name : Controller (XBOX 360 For Windows) 1
2018-03-22 20:38:30 INFO Simulator:213 - Starting simulator
drive straight
Gyro Calibrated, Analog Baud Rate Set
2018-03-22 20:38:30 FATAL Simulator:313 - Unexpected exception, shutting down simulator
java.lang.UnsupportedOperationException: USB is not supported yet
at edu.wpi.cscore.CameraServerJNI.createUsbCameraDev(Native Method)
at edu.wpi.cscore.UsbCamera.<init>(UsbCamera.java:20)
at edu.wpi.first.wpilibj.CameraServer.startAutomaticCapture(CameraServer.java:496)
at edu.wpi.first.wpilibj.CameraServer.startAutomaticCapture(CameraServer.java:482)
at org.usfirst.frc.team1322.robot.Robot.robotInit(Robot.java:73)
at edu.wpi.first.wpilibj.IterativeRobot.startCompetition(IterativeRobot.java:31)
at com.snobot.simulator.robot_container.JavaRobotContainer.startCompetition(JavaRobotContainer.java:32)
at com.snobot.simulator.Simulator$2.run(Simulator.java:301)
at java.lang.Thread.run(Thread.java:748)
2018-03-22 20:38:30 INFO Simulator:325 - Stopping simulator

the Simulator does not support USB connected inputs

The camera thing is caused by wpilib not supporting cameras on windows (and/or potentially anything other than the roborio, haven’t checked in a while).

One thing you can do to make it work in the simulator AND your robot code simultaneously is to put a ā€œis this a simulation?ā€ guard around it, i.e.



if(RobotBase.isReal())
{
    // initialize camera
}


I don’t know how far reaching your vision code is, but adding a couple of those might give you the ability to to run the same code in simulation and real world.

Also, it will be interesting to look through your Sim to see if it sends out Field Data from a virtual FMS.

When you run SnobotSim there should be a combobox that you can use to specify the plate locations. I added that at the start of the season when all 8 combinations were valid, and I never updated it to only have the 4 that are actually possible.

Besides the plate location, you can also set the ā€œmatch typeā€. I currently don’t provide configuration options for the match number, event name, or if it is a replay. I plan on adding these options soon.

I am having the same problems as rufus, except I’m not running the quick start. I’m using gradlerio and getting this as well.

java.lang.UnsatisfiedLinkError: no CTRE_PhoenixCCI in java.library.path

I’ve tried the solution you posted in the issue response, and the solution rufus posted above, but to no avail. I can see CTRE_PhoenixCCI.dll and CtreMockHooks.dll in build/native_libs.

Any suggestions?

Rufus posted a suggestion to you on the github issue. If that, or this, doesn’t solve the issue, feel free to reopen it.

One thing you can do is similar to the boilerplate fix. You can try to extract the zip files from the fake maven repo, and place CTRE_PhoenixCCI.dll into <your_project_dir>/build/native_libs. That should fix it, but then you run into the annoyance of that getting blown away whenever you do a clean.

If you are anything like me, you get a right after build season buzz about you and want to continue playing. However, if you can kick the can down the road a bit, improvements will be coming. wpilib is undergoing a major refactoring which will in turn cause the simulator to change quite a bit. During this update, I plan on fixing dumb oversights like this. It might take a month or so before the upgrades are ready to test, but the hope is that everything will be more seamless. Especially if you are transitioning to gradleRIO since it is the future, and I can let the boilerplate stuff die off.

I have a simulator working in VSCode (picture attached with simulator config file.). It uses one of our own robots and will be the basis for training for the rest of this year.

Definitely an impressive piece of software and a big step forward for us to be able to have students practise without access to Roborios. Thankyou for releasing this code.

One thing I haven’t figured out yet is how to trigger digital inputs. I see analog ins have a numeric entry field but can’t find a mechanism for digital inputs.

What am i missing?


SimCgg.txt (4.01 KB)

That is something that doesn’t implicitly exist, but would be pretty easy to add. In the past when we had something like an elevator with an upper and lower limit switch, we wrote an extension that would set them based on the height so we could test our ā€œIf at the bottom, don’t allow it to move downā€ logic.

I was mainly looking at using input simulation for short term training and can find other mechanisms for that.

In general we have not used inputs much and can patch in a joystick button if necessary when simulating for a robot.

Thanks for the quick reply.

@pjreiniger

First off, thanks for all the hard work you’ve done regarding simulation. I am a relatively new mentor for 4611 and still coming up to speed on the under-the-covers stuff, though I am a 30 year veteran unix/c++/java developer (and a complete Maven noob)

We have been playing with the new VS/Gradle environment and have been able to build and deploy last year’s code base to our bot. I have been trying to get SnobotSim working and I think I am chasing my tail with all of the changes that WPI is making which your Sim is dependent on. We are not a ā€œbeta teamā€ so I think I am going to be stuck until the changes settle. Recently I set up the WPI alpha and got is working. then i followed your instructions for SIM and got a dependency failure with something related to Beta. I just found the Beta VS plugin and got it working and updated to the latest SIM release:

id "com.snobot.simulator.plugin.SnobotSimulatorPlugin" version "2019-0.0.0"

when I

worthp@localhost $ ./gradlew runSnobotSim

on my Fedora 28 distro, I get the following error(s) which suggests that the Sim requires WPI Beta and we are out of luck until all of the Beta stuff settles.

I would appreciate any advice/guidance you can give me around getting SIM set up.

Build file ā€˜/home/worthp/devel/play/OzonePlay/build.gradle’ line: 4