Download presentation
Presentation is loading. Please wait.
Published byElisabeth Stephens Modified over 9 years ago
1
FRC Java for Robotics Introduction Team 1279 ColdFusion January 8, 2011
2
NetBeans IDE Full featured development environment –Edit –Build –Debug –Deploy Bundled with the latest Java SE JDK FRC plug-ins for WPILibJ
3
Advantages Widely Used –AP Test means school support Many Resources –Books –Websites –Mentors Economical –Free and can run on older hardware under Linux Early in its life
4
Disadvantages New to FIRST –Still Bugs & Rough Edges –Teams have, at most,1 season of experience Fewer Robotics resources –Not much existing code –CAN not up to C++ Not 100% standard Java –Based in Java ME –No formatted output (yet)
5
Sample Code Walk-through Example from SimpleRobotTemplate –Check IterativeRobot too –Good Sample code Described in the Getting Started Guide –Still a typo or two –Suggest everyone new try it
6
Sample Code I The File Environment Package groups related classes together package edu.wpi.first.wpilibj.templates; Import pulls in other classes import edu.wpi.first.wpilibj.RobotDrive; import edu.wpi.first.wpilibj.SimpleRobot; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj.Joystick;
7
Sample Code II Your Robot Class Derived from the sample Don’t change the name! public class Team1279Robot extends SimpleRobot { private RobotDrive drivetrain; private Joystick leftStick; private Joystick rightStick;
8
Sample Code III The Constructor Called Once when Class object is Instantiated Create and Initialize Instance Objects and Variables public Team1279Robot() { // create RobotDrive drivetrain = new RobotDrive(1, 2); // and joysticks leftStick = new Joystick(1); rightStick = new Joystick(2); }
9
Sample Code IV Methods Called by FMS Don’t Change These! Called by the Field Management System public void autonomous() { public void OperatorControl() {
10
Sample Code V autonomous() for (int i = 0; i < 4; i++) { //note turning rate and size of square is different //for every robot, adj delay, speed,turn for yours drivetrain.drive(0.5, 0.0); //50% fwd 0% turn Timer.delay(2.0); // wait 2 seconds drivetrain.drive(0.25, 0.75); //25% fwd 75% turn Timer.delay(1.0); // wait 1 second } drivetrain.drive(0.0, 0.0); //0% fwd 0% turn (stop)
11
Sample Code VI operatorControl() while (isOperatorControl() && isEnabled()) { // drive w/joysticks drivetrain.tankDrive(leftStick,rightStick); Timer.delay(0.05); }
12
Javadocs
13
Debugging println Output –Console –Debugger –Files NetBeans Debugger –Main Project only –Set at least 1 breakpoint –Download debug code –Debugger now attaches automatically
14
Resources The reference guide for this presentation on the NJ/NY FIRST website www.coldfusion1279.com WPI website FIRST website
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.