Wpilib rocks!

You guys rock!

We literally created a robot project yesterday with the 2019 tools for the first time. I pulled it, added our webserver libraries in 10 minutes, and hit the F5 key instinctively.

Apparently this launches a desktop simulation of your robot code.

I pull up a webbrowser and navigate to our onboard webpage. It is running simulated on my PC. Zero questions asked. Holy crud!

This is a crazy good level of integration folks! Hats off to you on this!!! I have a new standard for “Easy” when it comes to software!


Have you or anyone else had luck connecting this simulated robot code to the driver station? Not being able to enable the simulation’s teleop mode severely limits the functionality one is able to test.

1 Like

This is really funny… I just was running into the same issue and mentioned it to @gerthworm . Neither of us know of a solution to this yet either, so hopefully someone who has figured it out or worked on WPILib can chime in.

One solution is to call tele-op from the test method which could work depending on your integration.

1 Like

I just got the simulator working in teleop/auto earlier today! You can use the DriverStationSim class to set the enabled/disabled mode and switch between autonomous and teleop. Here’s the Kotlin code we’re using:

val sim = DriverStationSim()

sim.dsAttached = true
sim.enabled = false

GlobalScope.launch {

    sim.enabled = true

    println("Enabling auto")
    sim.autonomous = true


    println("Enabling teleop")
    sim.autonomous = false


    println("Ending simulation")
    sim.enabled = false

In this example, I’m first creating a DriverStationSim instance, then simulating the match as below:

  • Wait 2s
  • Enable the robot/autonomous
  • Wait 15s
  • Switch to autonomous
  • Wait 135s
  • Disable the robot

Note that in this example I’m using Kotlin coroutines, but you can use those simulator calls anywhere. Also note that I haven’t tried using IterativeRobot yet, but in my testing, I had to remove the call to ds.waitForData() and I’d expect you to have to do the same in IterativeRobot here. Presumably, this is because there is no connection to a real DriverStation, so the robot code will be stuck waiting. I’m not sure if this is the expected WPILib behavior (maybe @Peter_Johnson can chime in), but removing that waitForData() call worked for me.

Edit: Just realized IterativeRobot is deprecated. I’m guessing TimedRobot works as-is, so test something like the above out and let me know how it goes!

This is along the lines of what I was thinking - sim infrastructure would have to call the appropriate enabled functions?

I would in general want to have access to the HAL IO so we could write a plant model to interact directly with the robot code (rather than introducing an alternate IO layer for sim). Also, joystick input would be slick for students to interactively test.

All things i have in my head which is not necessarily reality.

2019 updates coming soon


You can also run an interactive simulation with a real driverstation using a HAL extension. This is still a bit of a WIP, hence no solid docs (and a less elegant impl), but in your build.gradle chuck the following:

dependencies {
  simulation "edu.wpi.first.halsim:halsim_lowfi:${wpi.wpilibVersion}:${wpi.platforms.desktop}@zip"

Set your Driverstation team # to localhost and it should connect. We have a few other simulation harnesses as well, like one which lets you use NetworkTables / Shuffleboard as a Driverstation (halsim_ds_nt), and one that just prints values (halsim_print). They’re all on the simulation/ subproject in allwpilib.

We’re improving the simulation stuff as we go along, https://github.com/wpilibsuite/GradleRIO/pull/293 and https://github.com/wpilibsuite/vscode-wpilib/pull/181 are big parts of it from the editor side.

Shameless plug: my team code setup also uses the new simulation stuff with an OpenCV GUI, so there’s no external dependencies. Worth a look if you’re interested: https://github.com/CurtinFRC/2019-DeepSpace


You don’t even need to set your ds to localhost. If its in the same system, it will automatically switch the ds to connect to simulation. But jacis instructions are how to get them enabled.

We forgot to put the notifyNewData call in the DriverStationSim class, but it can be found in the raw jni static functions here.

If you call that, it will cause the joystick data and the enable state data to update. Call it in a 20ms loop to match the official ds.

If you don’t call that, you won’t get any state updates at all.

These are not needed if using the ds shim Jaci posted above.

1 Like

Any documentation on how to get the “Simulate Robot Code on Desktop” set up? I am able to run the simulated robot but not sure how to make it do anything. Unable to get the driver station to recognize that the simulator is running on my desktop like mentioned above. This is what I get.

`NetworkTables LowFi Simulator Initializing.
NetworkTables LowFi Simulator Initialized!
********** Robot program starting **********
Default disabledInit() method… Overload me!
Default disabledPeriodic() method… Overload me!
Default robotPeriodic() method… Overload me!
Watchdog not fed within 0.020000s
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:273): Loop time of 0.02s overrun

Watchdog not fed within 0.020000s
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:273): Loop time of 0.02s overrun`

I’ll admit, I still haven’t gotten the shim @Jaci mentioned to fully function. While launching VS code reports that there’s a new “Hal Sim” thing available to select, but my DS won’t connect on my local machine. I strongly suspect it’s a “my PC configuration” thing, but we’ve had other things to do of recent :). As soon as bag day rolls around, this will start to get a bit more prioity from us.

We’re still able to simulate in disabled, which is allowing for plenty of checkout anyway.

The post I made was a little wrong, it had the wrong library. There’s currently a bug in the halsim stuff for the driverstation that messes with joystick button bindings, but I’ve built a shim for windows, mac and linux until 2019.3.1 rolls around. Here’s the files: https://github.com/CurtinFRC/2019-DeepSpace/tree/master/libs, and here’s the relevant build.gradle: https://github.com/CurtinFRC/2019-DeepSpace/blob/master/teams.gradle#L34-L46

That will allow you to connect a DS.


Hello, @Jaci I am trying your solution for connecting the simulation to the driver station, and the simulation runs and I see it on the Shuffleboard. However, I tried putting the 3 halsim libraries in a folder called libs in the robot directory, but the driver station still won’t connect.


I’ve also tried setting team number to my team and also localhost.

Ensure that you can see the “DriverStation Initialized” / etc text in the console log when you start the simulation. If it’s not there, delete build/debug and try launching from VSCode, making sure you select the HALSIM dll when it prompts for extensions.

I were not aware that a simulation was available. Is there some documentation to get started? Thanks!

1 Like


got a different name, but nothing in the log indicating DriverStation Initialized … Looking some more…

I have the exact same problem as above.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject> cd 'c:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject'; ${env:DYLD_LIBRARY_PATH}='C:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject\build\tmp\jniExtractDir'; ${env:HALSIM_EXTENSIONS}='C:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject\libs\halsim_ds_socketd.dll;'; ${env:LD_LIBRARY_PATH}='C:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject\build\tmp\jniExtractDir'; ${env:PATH}='C:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject\build\tmp\jniExtractDir'; & 'C:\Users\Public\frc2019\jdk\bin\java' '-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:59168' '-Djava.library.path=C:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject\build\tmp\jniExtractDir' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\kinze\Desktop\Minutebots Robotics Code\ExampleProject\ExampleProject\bin\main;C:\Users\Public\frc2019\maven\edu\wpi\first\wpilibj\wpilibj-java\2019.2.1\wpilibj-java-2019.2.1.jar;C:\Users\Public\frc2019\maven\edu\wpi\first\ntcore\ntcore-java\2019.2.1\ntcore-java-2019.2.1.jar;C:\Users\Public\frc2019\maven\edu\wpi\first\wpiutil\wpiutil-java\2019.2.1\wpiutil-java-2019.2.1.jar;C:\Users\Public\frc2019\maven\edu\wpi\first\thirdparty\frc2019\opencv\opencv-java\3.4.4-4\opencv-java-3.4.4-4.jar;C:\Users\Public\frc2019\maven\edu\wpi\first\cscore\cscore-java\2019.2.1\cscore-java-2019.2.1.jar;C:\Users\Public\frc2019\maven\edu\wpi\first\cameraserver\cameraserver-java\2019.2.1\cameraserver-java-2019.2.1.jar;C:\Users\Public\frc2019\maven\edu\wpi\first\hal\hal-java\2019.2.1\hal-java-2019.2.1.jar;C:\Users\kinze\.gradle\caches\modules-2\files-2.1\junit\junit\4.12\2973d150c0dc1fefe998f834810d68f278ea58ec\junit-4.12.jar;C:\Users\kinze\.gradle\caches\modules-2\files-2.1\org.hamcrest\hamcrest-core\1.3\42a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar' 'frc.robot.Main'
********** Robot program starting **********
Default disabledInit() method... Overload me!
Default disabledPeriodic() method... Overload me!
Default robotPeriodic() method... Overload me!
Watchdog not fed within 0.020000s
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:273): Loop time of 0.02s overrun

Watchdog not fed within 0.020000s
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:273): Loop time of 0.02s overrun

I’m running “Simulate code on Desktop”, by the way.

That’s the one you need to check in order to run the DS simulation

I’ve tried again, using a new project and putting the DLLS inside of it. Here are the steps that I did in a screenshot. I see networktables connected, but I don’t see anything about the driver station.
On the driver station program I try both my team number and localhost as the team number.