Running Your Code on the Romi

Running your code is different from running a regular Java Project. If you run your Romi'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 Romi

To simulate the program, you have to first set up a few things. First off, you have to turn on your Romi. You can do this by flicking the switch on the side of the hardware on the Romi. Once you flick the switch, the lights should turn on around the hardware.

Drawing
Switch location on the Romi

To turn the Romi off, flick the switch and then press the button next to it in the corner. The lights on the robot should turn off signaling that you turned it off correctly.


Connecting to the Romi

Before running the program, you have to first connect to the Romi. To do this, you should have the Romi turned on already. Then, go to your WiFi settings and select your Romi's WiFi network (This part of the Romi should be set up and you should know the network name and password). After that is done you are ready to start simulating your program on the Romi.

After connecting to the Romi, your internet connection will disappear. This is because your WiFi is solely connected to the Romi and the Romi doesn't have access to the internet leading to all devices connected to the Romi losing internet connection.


Simulating the Romi

Now that you're connected to the Romi via WiFi. You can start stimulating code. So for now let's make a simple program that goes straight when in Autonomous mode. To do this, use the m_drivetrain object (that RomiDrivetrain class) in the Robot.java class to access the go() method inside the autonomousPeriodic() method. Put the parameters 1 and 1 into the go() method to make it go straight.

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 Romi while the code is being run. Here is a diagram of everything in the window.

Drawing

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.


Now that you know how the simulation interface works. Run/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.

Drawing

Now that you know how to run the program, you can test future methods and systems in the course.

Last updated