Running the Simulator
The simulator runs your robot code on your laptop and shows the robot driving around a virtual field. You can try out your code without a physical robot, which matters because the real robots are shared between a lot of people.
Running it takes two programs side by side:
- Robot Simulation -- runs your code, and is where you plug in a controller and enable the robot
- AdvantageScope -- draws the robot on the field so you can watch what it does
Come back to this page whenever a challenge says to try something in the simulator.
What you need
- The XbotEdu project open in IntelliJ (see Environment Setup)
- A USB gamepad. The team usually has spares, so ask if you don't have one.
No gamepad?
The simulator can use your keyboard as a joystick, but only for the left stick: W/S push it up and down, A/D push it left and right, and Z X C V are buttons. That is enough for single-stick controls like arcade drive. Tank drive needs a real gamepad, since the keyboard has no right stick.
1. Start the simulator
In the top-right corner of IntelliJ, select the Simulate Robot launch configuration, then click the green play triangle beside it.
Your code builds, and then a new window called Robot Simulation opens.
2. Connect your controller and enable the robot
In the Robot Simulation window:
- Find your gamepad under System Joysticks on the left, and drag it into the Joystick[0] slot. Slot 0 is the one the robot code reads from (
operatorInterface.gamepad).- Using the keyboard instead? Drag Keyboard 0 into Joystick[0].
- Under Robot State in the top left, select Teleoperated. This enables the robot -- until you do, it ignores the controller.
When you're done it should look like this:
3. Watch the robot in AdvantageScope
- Open AdvantageScope (WPILib). It can take a while to start. The app name ends with the year of the WPILib version you installed, for example "AdvantageScope (WPILib) 2026".
- Choose File → Connect to Simulator.
- Choose File → Import Layout... and select
AdvantageScope_layout.jsonfrom the top folder of your XbotEdu repository. This sets up tabs for viewing the robot. - Pick a tab at the top of the window.
The tabs the layout gives you:
| Tab | What it shows |
|---|---|
| 2d top view | The robot on the field from above. The easiest view for most challenges. |
| 3d view | The same thing in 3D. |
| Joysticks | What the robot thinks your controller is doing. Handy when the robot doesn't respond. |
| Swerve | Swerve module angles and speeds. Its data sources need setting up before it shows anything -- see the Advanced Swerve Challenges. |
| Table | Every value the robot code is logging. |
| Console | Messages printed by the robot code. |
Now drive! The robot on screen should move as you use the controller.
Making changes
Your code only updates when the simulator restarts:
- Stop the simulator with the red square button in IntelliJ.
- Edit your code.
- Start Simulate Robot again, and re-enable the robot by selecting Teleoperated.
If AdvantageScope shows no data after a restart, choose File → Connect to Simulator again.
Troubleshooting
The robot doesn't move at all. Check that Teleoperated is selected in the Robot Simulation window -- a disabled robot ignores every input. Then check that your controller is in the Joystick[0] slot, not one of the others. The Joysticks tab in AdvantageScope shows whether the robot is seeing your input.
My gamepad isn't listed under System Joysticks. Make sure it's plugged in. If it still doesn't appear, stop and restart the simulator.
Only one side of a tank drive moves. You're probably using the keyboard, which has no right stick. Use a gamepad.
AdvantageScope is blank. The simulator has to be running before AdvantageScope can connect. Start it, then choose File → Connect to Simulator. If the field is there but the robot isn't, re-import the layout file.
The robot drives the wrong way. That's usually your code rather than the simulator -- check the signs on the values you send to the motors.
Learn more
- AdvantageScope -- more on AdvantageScope, including replaying logs from a real robot
- Elastic -- the dashboard used for tuning values and starting commands, introduced in Moving to a Target Position