Wpilib rocks!

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.

There are some bugs with projects that have a space in their filepath. Try moving it outside of “Code Projects” and into a path without spaces.

My path was changed so it doesn’t have spaces in it, however it’s still not working.

PS C:\Users\kinze\Desktop\SimRobot> cd 'c:\Users\kinze\Desktop\SimRobot'; ${env:DYLD_LIBRARY_PATH}='C:\Users\kinze\Desktop\SimRobot\build\tmp\jniExtractDir'; ${env:HALSIM_EXTENSIONS}='C:\Users\kinze\Desktop\SimRobot\libs\halsim_ds_socketd.dll;'; ${env:LD_LIBRARY_PATH}='C:\Users\kinze\Desktop\SimRobot\build\tmp\jniExtractDir'; ${env:PATH}='C:\Users\kinze\Desktop\SimRobot\build\tmp\jniExtractDir'; & 'C:\Users\Public\frc2019\jdk\bin\java' '-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:60196'
'-Djava.library.path=C:\Users\kinze\Desktop\SimRobot\build\tmp\jniExtractDir' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\kinze\Desktop\SimRobot\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 **********
Warning at edu.wpi.first.wpilibj.IteDefault disabledInit() method... Overload me!rativeRobotBase.printLoopO
verrunMessage(ItDefault disabledPeriodic() method... Overload me!era
tivDefault robotPeriodic() method... Overload me!eRobotBase.java:273):
 Loop time of 0.02s overrun

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

I can’t get the connection to the driver station to work. I am up to date with the NI software and the WPIlib. I downloaded the libraries (halsim_ds_socket.dll, libhalsym_ds_socketd.dylib, libhalsim_ds_socketd.so) and put them in a folder called “libs” in my project folder. I added the dependencies in build.gradle. When I started up the simulation it asks me if I want to use the extension called “halsim_lofi.dll”, but not the one you gave before “halsim_ds_socketd.dll”. Is there something else I need to do? Since I am using 2019.3.2 is there anything differently I need to do?

For people who’s simulation doesn’t work, adding this line to build.gradle under dependencies worked for us

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

OK, I need some basic help getting simulations to even launch. I am guessing I am missing something basic, but since I can’t find any guides at all other than this thread on running simulations it could really be anything.

So, when I click “simulate robot code on desktop” my code compiles, then the terminal sits for a few minutes then eventually I get an error box stating “Failed to launch debuggee in terminal. Reason : com.sun.jdi.connect. TransportTimeoutException”.

Thoughts please :slight_smile:



Got it, excellent.

I am currently trying to get Snobot simulation working with our code and the above mentioned Driver Station HAL.
I am getting REALLY close, but not quite there yet and believe the comment above is related to my current issue, but not sure how to use the solution suggested (not really a Gradle/Java programmer, although 40+ years of software experience with micro-controllers/C/assembler etc…)
Here is what I have…
Compiled Snobot sim & extensions, made Jaci’s changes to build.gradle. Copied the required HAL DLLs to the project libs directory.
Everything compiles fine and desktop simulations start as expected. I get simulation feedback from the motor controller we are using as expected.
Our code has a drivetrain sub-system that has a default command that reads the joystick analogs and buttons to allow controlling the drive train when our semi-auto helper commands are not running, and this works great too. We get the joystick data for analogs and buttons and can correctly ‘control’ the motors. Note, the drivetrain default command calls methods in OI to retrieve joystick data, hence uses the same, single instance of the joysticks.
Now, we also have joystick button command trigger events in OI (whileHeld etc…) but these don’t seem to fire in simulation.
I know the joystick buttons are actually being sensed/read since I see specific button actions in the drivetrain default command, but the OI events attached to the same buttons don’t fire. (also have alternate buttons, no action either. In fact we normally don’t have duplicate button usage but added this for testing)
My guess is that the joystick button events are not causing interrupts and/or we need to manually do something to force them to trigger the OI events, and the comment above seems to be the solution, but I have no idea how to implement it.
Any help would be greatly appreciated.

Here are the steps I used to get the Driver Station to interact with the simulator. Be sure you are on the 2019 FRC Updates. Did not need to add any DLLs as they were already present.

WPI does indeed rock!

Add to build.gradle in the dependency section (this is a single line)
<see ■■■■■■■ Feb 27 post>

Under View/Command Palette select

WLILib: Simulate Robot Code on Desktop

When prompted for DLL to run select
Then press OK

1 Like