Errors running WPILib simulation

I’m trying to test robot code using the new-ish simulation support and I’ve run into a couple of issues.

Running from within VSCode, the debugger is unable to find the Main class.


The gradle tasks simulateJava and simulateExternalJava work without errors, though the generated script at build/gradlerio_simulateJava.sh errors.

java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
	attempted to load for platform /linux/x86-64/

	at edu.wpi.first.wpiutil.RuntimeLoader.loadLibrary(RuntimeLoader.java:78)
	at edu.wpi.first.hal.JNIWrapper.<clinit>(JNIWrapper.java:38)
	at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:316)
	at com.team4099.robot2020.Main$Companion.main(Main.kt:10)
	at com.team4099.robot2020.Main.main(Main.kt)

This testing was done on Arch Linux, running kernel 5.4.6-arch3-1, if that happens to be helpful. An older thread with a similar issue mentioned updating Ubuntu being the solution, though didn’t explain why.

Our code is on github at: GitHub - team4099/InfiniteRecharge-2020

Launching with Gradle or VS Code are the only supported ways to start the simulator.

Oh, your project is missing a bunch of things. You can’t just update a 2019 project to 2020 by just changing the version number. If you look at a new project, you’ll see some new things were added in the dependencies section. It also needs to be running Gradle 6.

You also need to update to 2020.1.2.

VS Code does not support Kotlin, so thats the reason you’re seeing the error attempting to run simulation via VS Code. You will need to use the Gradle simulateJava task as the way to run simulation.

I noticed the dependencies changes during the above testing and copied it over, and updated to 2020.1.2. I was already running Gradle 6. After copying over the dependency and jar blocks, the simulation does start, but crashes at runtime. Not sure quite why, I’m assuming it’s something to do with the disclaimer: It is important to note that enabling desktop/simulation support can have unintended consequences. Not all vendors will support this option, and code that uses their libraries may even crash when attempting to run simulation!

Whats the crash? It could be a few things, would be helpful to know if its something in a vendor library, or something in our code.

It could be an Arch issue at that point, but its harder to tell if thats the case. Only 18.04 Ubuntu is officially supported for linux, so anything else is not guaranteed to work. All depends on how compatible the versions of libc and libstdc++ are.

I did initially try to launch through both Gradle and VSCode, but both provided no clue as to the actual problem. It would be useful to have these errors present themselves better, since none of the stderr output is actually shown to the user without running through build/gradlerio_simulateJava.sh.

It’s actually a crash in our crash tracking code (ironic) due to being unable to find /home/lvuser.

3 Likes

I’m trying to go though this install/Getting Started process myself as I have been out of FRC for a while, and I want to understand what my students (who are rookies) will see. Is the simulator supposed to work out of the box?

I followed the instructions on the WPILib Installation guide to install the tools onto a new computer using the new WPILib today. This included needing to install Java 11 which VS Studio prompted me to do (though from an outside link, not from the SDK included in the WPILib download).

I created a new project using the arcade drive example and tried it in the simulator. This resulted in the same message:

java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
        attempted to load for platform /osx/x86-64/

        at edu.wpi.first.wpiutil.RuntimeLoader.loadLibrary(RuntimeLoader.java:78)
        at edu.wpi.first.hal.JNIWrapper.<clinit>(JNIWrapper.java:38)
        at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:316)
        at frc.robot.Main.main(Main.java:27)

I’m curious what I might have missed. Any ideas?

There is a known issue with Mac simulation.

1 Like

Ah - should have checked. Workaround works for me.

Thanks!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.