Running Your Code on the XRP
Running your code is different from running a regular Java Project. If you run your XRP's code using the Run | Debug button, your code might run, but it won't actually move the robot. This is where WPILIB's built-in SimulationInterface can help a lot.
Setting up the XRP
To simulate the program, you have to first set up a few things. First off, you have to turn on your XRP. You can do this by flicking the switch on the side of the hardware on the XRP. Once you flick the switch, the lights should turn on around the hardware.
Connecting to the XRP
Before running the program, you have to first connect to the XRP. To do this, you should have the XRP turned on already. Then, go to your WiFi settings and select your XRP's WiFi network (This part of the XRP should be set up and you should know the network name and password). After that is done you are ready to start simulating.
Simulating the XRP
Now that you finished making the program, open the command palette and select the option "WPILIB: Simulate Robot Code". After selecting the command, some processing will happen (shown in the console) before a new window opens up, This is the Simulation Interface.
The Simulation Interface is the window that will help you use the XRP while the code is being run. Here is a diagram of everything in the window.
Here is what each thing is in detail:
Robot State Changer: Allows you to change the state/mode of the robot (These are the modes of the different methods in the Robot class).
Connected Devices: Shows what devices are connected to your computer such as controllers or keyboards.
Controller Readings: Shows what devices (mostly controllers) are being used and what readings are they returning. You can drag and drop controllers from the connected devices list into here.
Connecting Controllers to the XRP
To connect a controller to your robot, firstly you need to connect it to your computer. It should then show up in the Connected Devices tab.
After this, simply drag it into one of the slots in the "Joysticks" tab. Make sure to remember which slot you put your controller into.
Now that you know how the simulation interface works, simulate the program with the new code we added to the Robot class and switch the mode to Autonomous mode. If done correctly, your Robot should start going straight once you switch to the Autonomous mode.
Now that the program works, you can stop it from running. To do this properly, click on Workspace in the top left corner, then click Exit. This should delete the window and stop the program.
Now that you know how to run the program, you can test future methods and systems in the course.
Last updated