Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session 11 Intro to FRC API.

Similar presentations


Presentation on theme: "Session 11 Intro to FRC API."— Presentation transcript:

1 Session 11 Intro to FRC API

2 What is an API? API stands for application programming interface
It’s a set of routines, protocols, and tools for building software You can think of it as a bunch of classes that does stuff for us If we didn’t have an API, programming a robot in 6 weeks would be impossible for most people

3 New Robot Project Go to File > New > Other…
Open the “WPILib Robot Java Development” folder Select “Robot Java Project” and click next If you don’t have that folder: /m/13809/l/ installing- eclipse-c-java

4 3 Main Types of Robot Projects
Command-Based Robot A more complicated project for more complicated robots Iterative Robot Much more simple, but functionality is more limited Sample Robot Just the raw basics. Used for testing small things, or for highly advanced control flow.

5 New Robot Project Give your project a name Leave the package as is
That’s how packages are supposed to be named Select “Iterative Robot” Click “Finish”

6 Looking at your new project
Robot.java – the main class Referenced Libraries – the API wpilib – main robot stuff networktables – network communication stuff JRE System Library – what java version the project runs on

7 Robot.java IterativeRobot – the parent class
robotInit() – called when the robot starts up periodic methods – called periodically while the robot is running All of these methods were inherited from IterativeRobot

8 FRC Driver Station The software that controls the robot from your computer First tab is the operation tab (left half of the screen)

9 Robot Run Modes TeleOperated – a human controls the robot
Autonomous – the robot does stuff itself Practice – a simulation of a real match Test – anything you want it to be

10 Misc Information Elapsed Time – how long the robot has been running
PC stats Window – how the DS appears windowed / fullscreen Team Station – where you are Can get this from the API

11 Robot Information Team # - ours is 5002 Battery Voltage – battery life
Communications – if the DS can “see” the roboRIO Robot Code – if the roboRIO has code on it Joysticks – if a joystick is plugged in

12 Logs The log shows errors that happen while the robot’s running
The chart shows packet loss % and other information about the roboRIO Third tab is both of them at once

13 Driver Station: Diagnostics Tab
Shows what the DS can communicate with FMS – Field Management System, the thing at a competition Lets you reboot roboRIO Also shows version and memory usage

14 Driver Station: Setup Tab
Team Number – determines what IP the DS looks for Practice Timing – the timing of practice mode Don’t touch dashboard type and protocols for now

15 Driver Station – USB Devices Tab
Shows any joysticks plugged in Says what buttons are pressed Gives values of the axes

16 Driver Station – Power & CAN Tab
Faults – very bad errors CAN Metrics – we’ll get into later

17 Motor Controllers They control motors via a signal from the roboRIO
Simple ones use a PWM signal Advanced ones use CAN

18 Robot Wiring PWM ports on the right control basic motor controllers
Use the number on the port to determine which one you’re controlling in code

19 Classes for a Basic Program
Joystick – gets axes and buttons from a joystick Constructor takes which port the joystick is plugged into Talon – controls a standard Talon SR motor controller Constructor takes the PWM port it’s plugged into RobotDrive – a utility class that drives a robot Constructor takes the motor controllers

20 Writing the Code: Declaring Variables
Declare your variables If you get an error, then the classes haven’t been imported Hover over it with your mouse and select the “Import” option

21 Writing the Code: Initializing Variables
Make a constructor and initialize your variables in it First joystick will be 0 Need to look at roboRIO for the PWM ports of the Talons RobotDrive takes those motor controller objects

22 Writing the Code: TeleOp
Driving around the robot in teleop is as easy as this line of code: arcadeDrive takes a joystick object and uses it to control the robot The true is for squared inputs Makes lower values of the axes less sensitive Allows for more precise control over the robot

23 Writing the Code: Autonomous
Set a motor controller’s speed manually by using the method public void set(double speed) 0 is neutral, -1 is full reverse, 1 is full forward

24 Uploading the Code Connect to the roboRIO (USB, ethernet, or wireless)
Run the project as “WPILib Java Deploy” Wait for the roboRIO to load the new code Run the robot


Download ppt "Session 11 Intro to FRC API."

Similar presentations


Ads by Google