Go to Post ...if you don't ask, you won't get. - Billfred [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-02-2012, 22:04
Team1605 Team1605 is offline
Registered User
FRC #1605
 
Join Date: Feb 2012
Location: toronto
Posts: 30
Team1605 is an unknown quantity at this point
Java coding

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.Joystick.AxisType;
import edu.wpi.first.wpilibj.*;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/
public class RobotTemplate extends SimpleRobot {



Joystick stickDriverLeft = new Joystick(1);
Joystick stickDriverRight = new Joystick(2);
Joystick trigger = new Joystick (3);
Joystick button = new Joystick (4);

Jaguar leftMotor = new Jaguar(2);
Jaguar rightMotor = new Jaguar(1);
Jaguar shootermotor1 = new Jaguar(3);
Jaguar shootermotor2 = new Jaguar(4);
Jaguar gathermotor1 = new Jaguar (5);
Jaguar gathermotor2 = new Jaguar(6);

RobotDrive robotDrive = new RobotDrive(leftMotor, rightMotor);
Shooter TRIGGER_BUTTON = new Shooter(shootermotor1, shootermotor2);
Gatherer gatherer = new Gatherer(gathermotor1, gathermotor2);

final int buttonTriggerNumber = 1;
final int gatherstartbuttonnumber = 2;
final int gatherstopbuttonnumber = 3;

/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {
Timer.delay(1);
}

/**
* This function is called once each time the robot enters operator control.
*/
public void operatorControl() {
robotDrive.tankDrive(stickDriverLeft.getAxis(AxisT ype.kY), stickDriverRight.getAxis(AxisType.kY));


if (trigger.getRawButton(buttonTriggerNumber)){
TRIGGER_BUTTON.set(1);
}
else {
TRIGGER_BUTTON.set(0);
}


if (button.getRawButton(gatherstartbuttonnumber)) {
gatherer.set(1);

}

if(button.getRawButton(gatherstopbuttonnumber)) {
gatherer.set(0);
}


}
}

Last edited by Team1605 : 28-02-2012 at 22:24.
  #2   Spotlight this post!  
Unread 28-02-2012, 22:41
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,077
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Java coding

Is there a question here?
  #3   Spotlight this post!  
Unread 28-02-2012, 23:11
jp1247's Avatar
jp1247 jp1247 is offline
No the cRio does not like aluminum!
FRC #1247 (ROK BOT)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2010
Location: New Hampshire
Posts: 60
jp1247 is an unknown quantity at this point
Re: Java coding

Not sure if this was intended or not, i could be wrong, but you have 'trigger' and 'button' as separate joysticks, do you actually have 4 joystick that you're only using one button off of two of them?
__________________
"No, you can't use the Kinect to do pelvic thrusts."
  #4   Spotlight this post!  
Unread 01-03-2012, 13:09
Team1605 Team1605 is offline
Registered User
FRC #1605
 
Join Date: Feb 2012
Location: toronto
Posts: 30
Team1605 is an unknown quantity at this point
Re: Java coding

yes i have only two joystick and u sing one button
  #5   Spotlight this post!  
Unread 02-03-2012, 07:34
dbeckwith's Avatar
dbeckwith dbeckwith is offline
Lead Programmer
AKA: Daniel Beckwith
FRC #3205 (The Patriots)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: USA
Posts: 84
dbeckwith is an unknown quantity at this point
Re: Java coding

I see a big problem with this. operatorControl() is only called once, not continuously, so you need to put all your drive code and whatnot in that method in a loop so it will run more than just once. Alternatively you could use the IterativeRobot template, which calls its method periodically so you don't need a loop.

Quote:
Originally Posted by Team1605 View Post
Joystick stickDriverLeft = new Joystick(1);
Joystick stickDriverRight = new Joystick(2);
Joystick trigger = new Joystick (3);
Joystick button = new Joystick (4);
You should only make Joystick objects for actual joysticks. To get the trigger and buttons, you would get them from whichever joystick they're on. For example, if they were on the left joystick, you would use stickDriverLeft.getTrigger() (or stickDriverLeft.getRawButton(1)) for the trigger and stickDriverLeft.getRawButton(number) for other buttons.

Also I think you should get rid of the delay in autonomous, it's not helping anything and could actually slow you down.
__________________
q = (2*b) | ~(2*b);

if (life.getLemons() != null) this.lemonade = new Drink(life.getLemons());
else throw new NoLemonsException("What now?");


Closed Thread


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 21:15.

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