-
Notifications
You must be signed in to change notification settings - Fork 45
Curriculum challenge ~ Running XbotEDU on a Real Robot
Wifi IP = 10.4.88.2 USB IP = 172.22.11.2 Time to actually get some code onto a robot computer (a RoboRIO) instead of just running it on your laptop. By the end of this, you will know how to deploy code onto the Robox and potentially even one of our older competition robots!
If you only did the minimal computer setup at the start of the curriculum, you may need to install the FRC Update Suite from Full Programming Onboarding. Check if you have FRC Driver Station installed - if you don't have it, you will need to install the FRC Update Suite.
The Robox is a "robot-in-a-box" that we built a few years ago and have been using for all sorts of testing ever since.
- Get the Robox from the electronics closet (and/or find somebody who knows where the electronics closet is and what the Robox looks like)
- The robox comes with a power adapter. Plug one end into a traditional wall outlet, and the other into the red Anderson battery connector.
- Turn on the robox by closing the main breaker (if this is your first time, find somebody who knows how to do this)
- There should be a USB A to B cable, with the B end plugged into the RoboRIO (the large gray square). Plug the other end into your laptop
- On your laptop, press Win+R, then type cmd, and hit enter. When the command window appears, do the following:
- Type, without the quotes: "ping 172.22.11.2"
- Hit enter
- If you see several lines like "Reply from 172.22.11.2: bytes=32 time<1ms TTL=64". Then things are good. If not, try using Wifi
- If the wired connection didn't work, or if you need to control the robot at a distance, then it's better to use wifi.
- Change your wireless network to "488_2018" or something that looks like that. (All of our robot networks have 488 somewhere in their name).
- On your laptop, press Win+R, then type cmd, and hit enter
- Type, without the quotes: "ping 10.4.88.2"
- Hit enter
- If you see several lines like "Reply from 10.4.88.2: bytes=32 time<1ms TTL=64". Then things are good. If not, seek out a mentor or veteran for help.
It's time to put some code on an actual RoboRIO, instead of just running tests on your computer. We are going to use the FRCRobotTemplate project, a stripped-down "skeleton" project that has just enough code to boot up. Every year, we build the code for the competition robot using this template.
- Create a new repository using our template as a base: https://github.com/new?template_name=FRCRobotTemplate&template_owner=Team488
- Clone your fork onto your computer
- Open the project in IntelliJ
The FRCRobotTemplate already has a DriveSubsystem.java, and it references the ElectricalContract class to determine which devices are being used.
@Inject public DriveSubsystem(XCANTalonFactory talonFactory, XPropertyManager propManager, ElectricalContract contract, PIDManagerFactory pf) { log.info("Creating DriveSubsystem"); this.leftLeader = talonFactory.create(contract.getLeftLeader()); this.rightLeader = talonFactory.create(contract.getRightLeader()); positionPid = pf.create(getPrefix() + "PositionPID"); rotationPid = pf.create(getPrefix() + "RotationPID"); }
On our robots, we typically have multiple implementations of the ElectricalContract. You can think of each copy of the ElectricalContract as a mapping for a specific robot. As an example, you might have a real robot chassis with one device mapping, but the Robox might have different mappings.
In this bot, CompetitionContract is the contract that is used when you deploy to a robot or the Robox. The default contract assumes that there are motors on channels 1 and 2.
@Override public CANTalonInfo getLeftLeader() { return new CANTalonInfo(1, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulationScalingValue); } @Override public CANTalonInfo getRightLeader() { return new CANTalonInfo(2, true, FeedbackDevice.CTRE_MagEncoder_Absolute, true, simulationScalingValue); }
Your target, whether it's the Robox or a real robot, will likely have different numbers. If you're using the Robox, the numbers are labeled directly on the speed controllers. Choose any 2 speed controllers and use their numbers instead of the default ones.
The FRCRobotTemplate already has a TankDriveWithJoysticksCommand.java. It assumes one gamepad - if you have more or different controllers, you may need to modify code here.
If you're using the robox and don't have any controllers on hand, you can modify the command to always drive forward at full speed. (Obviously, this would be a very bad idea if you were using an actual robot with wheels. Don't do that.)
This command is also considered the default command (check SubsystemDefaultCommandMap.java), so it will automatically run when the robot starts.
At the top of the IntelliJ window, from the build target selector, select "Build & Deploy Robot". Wait for the process to complete. Your output window should look something like this:
BUILD SUCCESSFUL in 19s 15 actionable tasks: 8 executed, 7 up-to-date
- Open the FRC Driver Station on your computer (should have already been installed during onboarding as part of the FRC Update Suite).
- Click the gear icon on the left side of your screen, in that screen make the team number "488".
- If you're using an actual robot, make sure your hand is hovering over the ENTER key. Pressing ENTER will disable the robot at anytime.
- Enable the robot, and observe what happens.
- Home
- Challenges
- Setting up your environment
- Basic Robot Principles
- Tank Drive
- Altering Tank Drive
- Moving to a target position
- Rotating to a target orientation
- Factories
- The Power of Injection
- Dependency Injection with Dagger
- Upgrading Using the SeriouslyCommonLib
- Running XbotEDU on a Real Robot
- Auto Stopping Collector