Go to Post We have donut eating contests to see who has the best legs. We paint our pigs. We argue about which time zone we are in. About 400,000 of us gather together to watch cars go around in a circle. We also build robots.Yep, our cultural norm is a bit different. - Andy Baker [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 19-01-2011, 00:23
Pmaxm00 Pmaxm00 is offline
Lead Programmer
FRC #2974 (Team WALT)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Marietta, GA
Posts: 17
Pmaxm00 has a spectacular aura aboutPmaxm00 has a spectacular aura about
Re: How to use JAVADOCS?

I am willing to help you as much as you need, just I have a few questions first. Do you know java? About how much experience in Java do you have?
__________________

Impossibility? I accept your challenge.
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2011, 20:54
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Re: How to use JAVADOCS?

thanks, I am in APCS currently so I know enough. I also had some c++ last year so im not new to programming.
basically what I want to do is use the Joystick class and System.out.println the x and y value of the joystick.
I also want to get boolean for if a button is pressed or not, but I dont understand the parameters: getButton(Joystick.ButtonType button)
I can't find any examples of using the Joystick class other than the stuff for like tank drive.
btw, have they made sunspot for win 7 yet? or is there another virtual Crio thing?

THANKS A LOT for helping!
Reply With Quote
  #3   Spotlight this post!  
Unread 19-01-2011, 23:57
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: How to use JAVADOCS?

Okay, you want to print out the Joystick values right?

I'm assuming you have created a FRC Java project and figured out all the cRIO, Java plugins...etc stuff. I find the Iterative framework the best for us.

Joysticks

First, you declare a Joystick object, after the place where you declare the class and before your constructor:
Code:
Joystick leftStick;
Then, you initialize it in the constructor. I use "1" because it's the first joystick:
Code:
leftStick = new Joystick(1);
After that, you can begin to use it. In your teleopPeriodic (or teleopContinuous) function, print out the value of the x and y axis:
Code:
System.out.println(leftStick.getX());
System.out.println(leftStick.getY());
Another way you can do it is:
Code:
System.out.println(leftStick.getAxis(Joystick.AxisType.kX));
To get the trigger button, you would do this:
Code:
leftStick.getButton(Joystick.ButtonType.kTrigger)
If you use Joystick.AxisType or Joystick.ButtonType, you would need to import them. (A nifty shortcut in netbeans is Shift+Ctrl+I which imports everything you need.)

More detailed explanation on the Button stuff and Javadocs:

See what getButton() has inside the parenthesis in the docs? It says "Joystick.ButtonType button" which means it takes in one (and only one) parameter with type Joystick.ButtonType. This means that you may NOT use integers, doubles, floats, booleans...etc, and you MUST use Joystick.ButtonType (kTop, kTrigger, kNumButton)

If you have a button that's not the trigger or the enumerated buttons in Joystick.ButtonType, you can use the getRawButton() function. So, if you know the button number of what you want, you'd just do (example for button number 4):
Code:
leftStick.getRawButton(4);
To find out the button number, go to your Control Panel (switch to Classic View) and find Game Controllers. Pull up the properties menu of your controller and the rest should be pretty self-explanatory.

Drive System

A simple 2-motor tank drive system (Jaguars plugged into PWM 1 and 2) would look like this:

Declaration:
Code:
RobotDrive drive;
Joystick leftStick, rightStick;
Initialization:
Code:
drive = new RobotDrive(1,2);
leftStick = new Joystick(1);
rightStick = new Joystick(2);
teleopContinuous:
Code:
drive.tankDrive(leftStick.getY(),rightStick.getY());
According to the Javadocs, you can also directly feed the Joysticks into the RobotDrive. Never done it before, but it should work exactly the same (code is the same too, except for the teleopContinuous portion):
Code:
drive.tankDrive(leftStick, rightStick);
If you need more help (for the drive system, joysticks...etc), just ask.

Last edited by Patrick Chiang : 20-01-2011 at 00:06.
Reply With Quote
  #4   Spotlight this post!  
Unread 20-01-2011, 10:41
drakesword drakesword is offline
Registered User
AKA: Bryant
FRC #0346 (Robohawks)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: USA
Posts: 200
drakesword is on a distinguished road
Re: How to use JAVADOCS?

Javadocs are the bible of java there are 3 main sections.

1 Constructors
2 Fields
3 Methods

Constructors explain what parameters (if any) are needed to be passed to create the object. From the example above ...

Code:
Joystick joy = new Joystick(1);
Take a peek into the javadoc to see . . .

Code:
Joystick
public Joystick(int$@#port)
Construct an instance of a joystick. The joystick index is the usb port on the drivers station.

Parameters:
port - The port on the driver station that the joystick is plugged into.
So if you look at an example then the javadoc everything starts to become self explanatory.

Also note that if you run into a method or field that is declared static then you do not need to construct an object to use those methods or fields.

An example of static call would be

Code:
System.out.println("Something");
the System.out object is declared static so there is no

Code:
System.out = new ...
Reply With Quote
  #5   Spotlight this post!  
Unread 20-01-2011, 12:14
Ryan O's Avatar
Ryan O Ryan O is offline
FRC Eclipse Plug-in Developer
no team (FRC Eclipse)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Plaistow
Posts: 111
Ryan O is an unknown quantity at this point
Send a message via AIM to Ryan O
Re: How to use JAVADOCS?

As to your other question about sunspot for win7, there is no reason it shouldn't work. The file which installs the SDK now also recognizes 64-bit systems as valid. This is true whether you are using the NetBeans plug-ins or the Eclipse plug-ins (since the SDK for both is the same).
__________________
CRUD Name: Windows
Rookie Year: 2005
Alumni to Team: 350
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 11:18.

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