Go to Post The card system worked. Well. It was used properly and (except for when Paul yellow carded Andy during his "Thank you" speech) wasn't abused. I applaud the referees. Kudos. - Collin Fultz [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 20-02-2011, 15:54
Sotha Sotha is offline
Registered User
FRC #2501
 
Join Date: Feb 2011
Location: Minnesota
Posts: 3
Sotha is an unknown quantity at this point
Re: New To Java

Well first off here are some links to get you started.

WPI Robotics Library Users Guide (PDF) This explains the general use of the library and include examples, though some are missing Java examples C++ is very similar to Java.

Java Getting Started Guide (PDF) Contains infomation of Netbeans, the templates, and java in general. Also has sample source code.

If you have netbeans and the FRC Java updates installed already then you also have examples too. Here is a picture showing how to access the samples.

If you just want to see source code, and dont want to download a PDF or make a sample project, here is the exact example out of the Java getting Started Guide.

Code:
package edu.wpi.first.wpilibj.templates; 
 
import edu.wpi.first.wpilibj.Joystick; 
import edu.wpi.first.wpilibj.RobotDrive; 
import edu.wpi.first.wpilibj.SimpleRobot; 
import edu.wpi.first.wpilibj.Timer; 
 
public class RobotTemplate extends SimpleRobot { 
 
    RobotDrive drive = new RobotDrive(1, 2); 
    Joystick leftStick = new Joystick(1); 
    Joystick rightStick = new Joystick(2); 
 
    public void autonomous() { 
        for (int i = 0; i < 4; i++) { 
            drive.drive(0.5, 0.0); // drive 50% forward speed with 0% turn 
            Timer.delay(2.0);  
// wait 2 seconds 
            drive.drive(0.0, 0.75); // drive 0% forward speed with 75% turn 
 
 
Timer.delay(0.75); 
// wait for the 90 degree turn to complete 
        } 
        drive.drive(0.0, 0.0); 
// drive 0% forward speed with 0% turn (stop) 
    } 
 
    public void operatorControl() { 
        while (isOperatorControl() && isEnabled()) 
// loop during enabled teleop mode 
        { 
            drive.tankDrive(leftStick, rightStick); 
// drive with the joysticks 
            Timer.delay(0.005); 
        } 
    } 
}
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi