Go to Post I care that teams took some time to put in safe guards to prevent shrapnel hitting people because I'm selfish and I enjoy the use of all of my limbs. - Andrew Schreiber [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

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-02-2011, 14:50
Ruckus2109 Ruckus2109 is offline
Registered User
FRC #2895
 
Join Date: Feb 2011
Location: NYC
Posts: 3
Ruckus2109 is an unknown quantity at this point
New To Java

I am new to coding with Java and I would like to know where I can find a basic code to run my bot. it has four jaguar motors and our drve station has dual joystics to operate it. Any help will be greatly appreciated
Reply With Quote
  #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
Reply


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 22:19.

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