frc java for robotics introduction

Post on 14-Jan-2016

62 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

FRC Java for Robotics Introduction. Team 1279 ColdFusion November 6, 2010. NetBeans IDE. Full featured development environment Edit Build Debug Deploy Bundled with the latest Java SE JDK FRC plug-ins for WPILibJ. Advantages. Widely Used AP Test means school support Many Resources - PowerPoint PPT Presentation

TRANSCRIPT

FRC Java for RoboticsIntroduction

Team 1279 ColdFusionNovember 6, 2010

NetBeans IDE

• Full featured development environment– Edit– Build– Debug– Deploy

• Bundled with the latest Java SE JDK

• FRC plug-ins for WPILibJ

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

Disadvantages

• New to FIRST– Still Bugs & Rough Edges– Teams have at most a few months on it

• Fewer Robotics resources– Not much existing code– CAN not up to C++

• Not 100% standard Java– Based in Java ME– No formatted output (yet)

Sample CodeWalk-through

• Example from SimpleRobotTemplate– Check IterativeRobot too– Good Sample code

• Described in the Getting Started Guide– Still a typo or two

• Example 7– Suggest everyone new try it

Sample Code IThe 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;

Sample Code IIYour 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;

Sample Code IIIThe 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);

}

Sample Code IV

Methods Called by FMS • Don’t Change These!• Called by the Field Management System

public void autonomous() {

public void OperatorControl() {

Sample Code Vautonomous()

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)

Sample Code VIoperatorControl()

while (isOperatorControl() && isEnabled()){

// drive w/joysticksdrivetrain.tankDrive(leftStick,rightStick);Timer.delay(0.005);

}

Javadocs

Debugging

• println Output– Console– Debugger– Files

• NetBeans Debugger– Main Project only– Set at least 1 breakpoint– Download debug code– Attach debugger

Resources

• The reference guide for this presentation on the NJ/NY FIRST website

• www.coldfusion1279.com

• WPI website

• FIRST website

top related