Go to Post Only on CD would people debate calculus problems involving time and team numbers... - artdutra04 [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 15-02-2016, 19:09
CyberTeam5713 CyberTeam5713 is offline
Registered User
FRC #5713
 
Join Date: Feb 2016
Location: Michigan
Posts: 25
CyberTeam5713 is an unknown quantity at this point
Help ME PLEASE ASAP

Can someone please fix my code or point me in the right direction so i can use a xbox controller to drive. tank drive or arcade drive it doesnt matter

public class Robot extends IterativeRobot {
RobotDrive drive = new RobotDrive(1,2,3,4);
Joystick mXboxController = new Joystick(0);
Joystick controlStick = new Joystick(1);
Talon frontLeft = new Talon(4);
Talon rearLeft = new Talon(3);
Talon frontRight = new Talon(2);
Talon rearRight = new Talon(1);

public void robotInit() {
drive = new RobotDrive(0,1,2,3);
mXboxController = new Joystick(0);
controlStick = new Joystick(1);
frontLeft = new Talon(1);
frontLeft.enableDeadbandElimination(true);
frontLeft.set(+1.0);
rearLeft = new Talon(2);
rearLeft.enableDeadbandElimination(true);
rearLeft.set(-1.0);
frontRight = new Talon(3);
frontRight.enableDeadbandElimination(true);
frontRight.set(+1.0);
rearRight = new Talon(4);
rearRight.enableDeadbandElimination(true);
rearRight.set(-1.0);

}


public void autonomousInit() {
drive = new RobotDrive(1,2,3,4);
frontLeft = new Talon(1);
frontLeft.enableDeadbandElimination(true);
frontLeft.set(-1.0);
rearLeft = new Talon(2);
rearLeft.enableDeadbandElimination(true);
rearLeft.set(+1.0);
frontRight = new Talon(3);
frontRight.enableDeadbandElimination(true);
frontRight.set(-1.0);
rearRight = new Talon(4);
rearRight.enableDeadbandElimination(true);
rearRight.set(+1.0);

}


public void autonomousPeriodic() {
while (isAutonomous() && isEnabled()) {
drive.setSafetyEnabled(true);
drive.drive(-0.5,0.0);
Timer.delay(5);
drive.drive(0.0,0.0);

}
}




public void teleopInit(){
drive = new RobotDrive(1,2,3,4);
mXboxController = new Joystick(0);
controlStick = new Joystick(1);
frontLeft = new Talon(1);
frontLeft.enableDeadbandElimination(true);
frontLeft.set(-1.0);
rearLeft = new Talon(2);
rearLeft.enableDeadbandElimination(true);
rearLeft.set(+1.0);
frontRight = new Talon(3);
frontRight.enableDeadbandElimination(true);
frontRight.set(-1.0);
rearRight = new Talon(4);
rearRight.enableDeadbandElimination(true);
rearRight.set(+1.0);

}




public void teleopPeriodic() {
while (isOperatorControl() && isEnabled()) {
drive.setSafetyEnabled(true);
double speedControl = 1;
double joystickLeftY = mXboxController.getRawAxis(1)*speedControl;
double joystickLeftX = mXboxController.getRawAxis(0)*-1*speedControl;
drive.arcadeDrive(joystickLeftY, joystickLeftX);
Reply With Quote
  #2   Spotlight this post!  
Unread 15-02-2016, 19:21
kmodos kmodos is offline
Registered User
AKA: Alex
FRC #1126 (SparX)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2013
Location: New York
Posts: 57
kmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to beholdkmodos is a splendid one to behold
Re: Help ME PLEASE ASAP

Add one of these to the end }
Reply With Quote
  #3   Spotlight this post!  
Unread 15-02-2016, 19:23
CyberTeam5713 CyberTeam5713 is offline
Registered User
FRC #5713
 
Join Date: Feb 2016
Location: Michigan
Posts: 25
CyberTeam5713 is an unknown quantity at this point
Re: Help ME PLEASE ASAP

and the code will work?
Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2016, 20:03
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Help ME PLEASE ASAP

Code:
RobotDrive drive = new RobotDrive(1,2,3,4); 

Talon frontLeft = new Talon(4); 
Talon rearLeft = new Talon(3);
Talon frontRight = new Talon(2); 
Talon rearRight = new Talon(1);
You are declaring and initializing a RobotDrive and you are also declaring your drivetrain Talons individually.

You need to do one or the other, but not both. Doing this will throw an error saying you are declaring and initializing all your drivetrain Talons twice.

Pick which way you want to program your robot: either using the simpler RobotDrive object, or by manually coding commands to your individual Talons, then delete all the code for the method you are not using.

In the future, it is also a good idea to post a description of the problem you are encountering, including any exceptions or errors messages.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2016, 20:43
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 236
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Help ME PLEASE ASAP

Quote:
Originally Posted by Mr. Lim View Post
[code]

You need to do one or the other, but not both. Doing this will throw an error saying you are declaring and initializing all your drivetrain Talons twice.
Not necessarily. You can do

Code:
Talon = new Talon(0)
Talon2 = new Talon(1)
Talon3 = new Talon(2)
Talon4 = new Talon(3)
drive = new Robotdrive(Talon, Talon2, Talon3, Talon4)
You can do this way, but if you assign the ports to robotdrive then no, you can't do both.
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #6   Spotlight this post!  
Unread 15-02-2016, 21:49
CyberTeam5713 CyberTeam5713 is offline
Registered User
FRC #5713
 
Join Date: Feb 2016
Location: Michigan
Posts: 25
CyberTeam5713 is an unknown quantity at this point
Thanks Guys

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 12:03.

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