Go to Post The ChiefDelphi forums are more than just a place for people to kill time and engage in some chit chat. - Karthik [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 17-02-2015, 15:15
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Exclamation Robot Code Problem ** Again**

I run the code and the Driver station accepts it and allows it to run but when I press the buttons nothing happens? Pleas help ASAP
If I try to separate the Initializing of buttons from the button commands it fails to recolonize that they go together and created a whole mess of syntax errors



package org.usfirst.frc.team4284.robot;



import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the IterativeRobot
* 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 Robot extends IterativeRobot {
RobotDrive Drive;
Joystick drivestick;
Joystick joystick;
int autoLoopCounter;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {

Jaguar FL = new Jaguar (5);
Jaguar BL = new Jaguar (2);
Jaguar FR = new Jaguar (3);
Jaguar BR = new Jaguar (4);
Drive = new RobotDrive(FL,BL,FR,BR);
drivestick = new Joystick(0);
joystick = new Joystick(1);


}

/**
* This function is run once each time the robot enters autonomous mode
*/
public void autonomousInit() {
autoLoopCounter = 0;
}

/**
* This function is called periodically during autonomous
*/
public void autonomousPeriodic() {
/*if(autoLoopCounter < 100) //Check if we've completed 100 loops (approximately 2 seconds)
{
Drive.drive(-0.5, 0.0); // drive forwards half speed
autoLoopCounter++;
} else {
Drive.drive(0.0, 0.0); // stop robot
} */
}

/**
* This function is called once each time the robot enters tele-operated mode
*/
public void teleopInit(){

}

/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
Drive.arcadeDrive(drivestick);

Button button1 = new JoystickButton(joystick, 1),
button2 = new JoystickButton(joystick, 2),
button3 = new JoystickButton(joystick, 3),
button4 = new JoystickButton(joystick, 4),
button5 = new JoystickButton(joystick, 5),
button6 = new JoystickButton(joystick, 6),
button7 = new JoystickButton(joystick, 7),
button8 = new JoystickButton(joystick, 8),
button9 = new JoystickButton(joystick, 9),
button10 = new JoystickButton(joystick, 10),
button11 = new JoystickButton(joystick , 11);


button1.whenPressed(new ElevatorOff());
button2.whenPressed(new ElevatorOn());
button3.whenPressed(new ElevatorReverse());
button4.whenPressed(new ArmsOut());
button5.whenPressed(new ArmsIn());
button6.whenPressed(new ArmsVerticalIn());
button7.whenPressed(new ArmsVarticalOut());
button8.whenPressed(new BlueLightShow());
button9.whenPressed(new LigthShowOn());
button10.whenPressed(new RedLightShow());
button11.whenPressed(new LightShowEnd());




}



/**
* This function is called periodically during test mode
*/
public void testPeriodic() {
LiveWindow.run();


}

}


package org.usfirst.frc.team4284.robot;
import edu.wpi.first.wpilibj.Talon;

import edu.wpi.first.wpilibj.command.Command;

public class ArmsIn extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
Talon LeftArm = new Talon(9);
Talon RightArm = new Talon(8);

LeftArm.set(1);
RightArm.set(-1);
try {
Thread.sleep(500); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}

LeftArm.set(0);
RightArm.set(0);


}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}



package org.usfirst.frc.team4284.robot;
import edu.wpi.first.wpilibj.Talon;

import edu.wpi.first.wpilibj.command.Command;

public class ArmsOut extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {

Talon RightArm = new Talon(9);
Talon LeftArm = new Talon(8);

LeftArm.set(-1);
RightArm.set(1);
try {
Thread.sleep(500); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}

LeftArm.set(0);
RightArm.set(0);
// TODO Auto-generated method stub

}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}




package org.usfirst.frc.team4284.robot;

import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.command.Command;

public class ArmsVarticalOut extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
Talon In_Out = new Talon(7);
Talon In__Out = new Talon(0);


In_Out.set(-1);
In__Out.set(-1);
try {
Thread.sleep(500); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}
In_Out.set(0);
In__Out.set(0);
// TODO Auto-generated method stub

}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}



package org.usfirst.frc.team4284.robot;

import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.command.Command;

public class ArmsVerticalIn extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {

Talon In_Out = new Talon (7);
Talon In__Out = new Talon(0);


In_Out.set(1);
In__Out.set(1);
try {
Thread.sleep(500); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}
In_Out.set(0);
In__Out.set(0);

}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}



package org.usfirst.frc.team4284.robot;

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.command.Command;

public class BlueLightShow extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
// TODO Auto-generated method stub
Relay relay1 = new Relay(0);
Relay relay2 = new Relay(1);
relay1.set(Relay.Value.kOn);
relay2.set(Relay.Value.kOff);

}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}

package org.usfirst.frc.team4284.robot;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.command.Command;

public class ElevatorOff extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
// TODO Auto-generated method stub
Jaguar Elevator1 = new Jaguar(5);
Jaguar Elevator2 = new Jaguar(0);


Elevator1.set(0);
Elevator2.set(0);

}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}


package org.usfirst.frc.team4284.robot;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.command.Command;

public class ElevatorOn extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
// TODO Auto-generated method stub
Jaguar Elevator1 = new Jaguar(5);
Jaguar Elevator2 = new Jaguar(0);

Elevator1.set(.25);
Elevator2.set(.25);


}

@Override
protected boolean isFinished() {
return false;
}

@Override
protected void end() {


}

@Override
protected void interrupted() {

}

}


package org.usfirst.frc.team4284.robot;
import edu.wpi.first.wpilibj.Jaguar;
import edu.wpi.first.wpilibj.command.Command;

public class ElevatorReverse extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
// TODO Auto-generated method stub
Jaguar Elevator1 = new Jaguar(5);
Jaguar Elevator2 = new Jaguar(0);

Elevator1.set(-.25);
Elevator2.set(-.25);


}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}


package org.usfirst.frc.team4284.robot;
import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.command.Command;

public class LightShowEnd extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
// TODO Auto-generated method stub
Relay relay1 = new Relay(0);
Relay relay2 = new Relay(1);
relay1.set(Relay.Value.kOff);
relay2.set(Relay.Value.kOff);


}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}

package org.usfirst.frc.team4284.robot;

import edu.wpi.first.wpilibj.Relay;
import edu.wpi.first.wpilibj.command.Command;

public class LigthShowOn extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
// TODO Auto-generated method stub

Relay relay1 = new Relay(0);
Relay relay2 = new Relay(1);

relay1.set(Relay.Value.kReverse);
relay2.set(Relay.Value.kOn);
try {
Thread.sleep(5000); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}
//Turn on lights Blue and Green)
relay1.set(Relay.Value.kOn);
relay2.set(Relay.Value.kReverse);
try {
Thread.sleep(5000); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}
// Turns on blue and red lights
relay1.set(Relay.Value.kOn);
relay2.set(Relay.Value.kForward);
try {
Thread.sleep(5000); //stop for 1/2 second
} catch(InterruptedException ex) { // allows for interruption of the sleep period
Thread.currentThread().interrupt();
}
relay1.set(Relay.Value.kReverse);
relay2.set(Relay.Value.kOn);


}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}


package org.usfirst.frc.team4284.robot;
import edu.wpi.first.wpilibj.Relay;

import edu.wpi.first.wpilibj.command.Command;

public class RedLightShow extends Command {

@Override
protected void initialize() {
// TODO Auto-generated method stub

}

@Override
protected void execute() {
// TODO Auto-generated method stub
Relay relay1 = new Relay(0);
Relay relay2 = new Relay(1);
relay2.set(Relay.Value.kForward);
relay1.set(Relay.Value.kReverse);

}

@Override
protected boolean isFinished() {
// TODO Auto-generated method stub
return false;
}

@Override
protected void end() {
// TODO Auto-generated method stub

}

@Override
protected void interrupted() {
// TODO Auto-generated method stub

}

}



Please and thank you
  #2   Spotlight this post!  
Unread 17-02-2015, 15:24
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,679
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by AnnaliseDonavan View Post
Code:
public class Robot extends IterativeRobot {
RobotDrive Drive;
Joystick drivestick;
Joystick joystick;
int autoLoopCounter;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {

    Jaguar FL = new Jaguar (5);
    Jaguar BL = new Jaguar (2);
    Jaguar FR = new Jaguar (3);
    Jaguar BR = new Jaguar (4);
    Drive = new RobotDrive(FL,BL,FR,BR);
    drivestick = new Joystick(0);
    joystick = new Joystick(1);


}
Declaring objects inside a method makes them local objects that (unless copied elsewhere) disappear when the method returns. I'm presuming you want these to be instance variables. In this case, declare them earlier and just assign them in robotInit():
Code:
public class Robot extends IterativeRobot {
RobotDrive Drive;
Joystick drivestick;
Joystick joystick;
Jaguar FL, BL, FR, BR;

int autoLoopCounter;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {

    FL = new Jaguar (5);
    BL = new Jaguar (2);
    FR = new Jaguar (3);
    BR = new Jaguar (4);
    Drive = new RobotDrive(FL,BL,FR,BR);
    drivestick = new Joystick(0);
    joystick = new Joystick(1);
}
P.S.: Also, enclosing your code with the tags makes it easier to read!

P.P.S.: After seeing this, I did not review the rest of the code.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
  #3   Spotlight this post!  
Unread 17-02-2015, 15:36
BitBlt BitBlt is offline
Registered User
no team
 
Join Date: Jan 2015
Location: Orlando
Posts: 3
BitBlt is an unknown quantity at this point
Re: Robot Code Problem ** Again**

Are you sure your joysticks are setup correctly in the driverstation?
Can you drive the robot with what you expect to be the "drivestick"?

Put a breakpoint in the execute() function of one of your commands. Make sure you do a Debug As to deploy your project. Press the button of the command you have the breakpoint in. Does your breakpoint get hit?

As for your other question about declaring the buttons on separate lines, I saw in another thread that you were not giving a type to each declaration. So you need something like:

Button button1 = new JoystickButton(joystick, 1);
Button button2 = new JoystickButton(joystick, 2);
Button button3 = new JoystickButton(joystick, 3);

And so on.

You have a lot of local variables declared in each function. What happens when a Talon (for example) goes out of scope and is garbage collected?
  #4   Spotlight this post!  
Unread 17-02-2015, 15:55
Poseidon5817's Avatar
Poseidon5817 Poseidon5817 is offline
Founder and CEO, DeadMemes Studios
AKA: Mitchel Stokes
FRC #5817 (Uni-Rex)
Team Role: Mentor
 
Join Date: Aug 2013
Rookie Year: 2014
Location: Clovis, CA
Posts: 403
Poseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud ofPoseidon5817 has much to be proud of
Re: Robot Code Problem ** Again**

I noticed in your LightShowOn class you have thread.sleep(5000). You say in the comment that you are sleeping for half a second. Since it is measured in milliseconds shouldn't it be thread.sleep(500)?
__________________
My FRC History:

2014 - Team 1671: Central Valley Regional Finalist and Chairman's Award Winner, Sacramento Regional Finalist, Archimedes Quarterfinalist
2015 - Team 1671: Central Valley Regional Semifinalist, Sacramento Regional Semifinalist and Chairman's Award Winner, Newton Winner, Einstein Winner
2016 - Team 5817: Central Valley Regional Finalist and Rookie All-Star, Orange County Regional Quarterfinalist and Rookie All-Star, Newton Division
2017 - Team 5817: Return of the bench grinder


  #5   Spotlight this post!  
Unread 17-02-2015, 15:55
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: Robot Code Problem ** Again**

When The ArmsVertical Talon is activated the Arms extend, Our robot has the option to extend and recall the arms.
as for the Arms in and out it goes inward in both directions to pick up/ let go of the bins/ garbage cans
  #6   Spotlight this post!  
Unread 17-02-2015, 15:56
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by Poseidon1671 View Post
I noticed in your LightShowOn class you have thread.sleep(5000). You say in the comment that you are sleeping for half a second. Since it is measured in milliseconds shouldn't it be thread.sleep(500)?
That accidentally got left on from the previous use of Thread.sleep
  #7   Spotlight this post!  
Unread 17-02-2015, 15:57
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by GeeTwo View Post
Declaring objects inside a method makes them local objects that (unless copied elsewhere) disappear when the method returns. I'm presuming you want these to be instance variables. In this case, declare them earlier and just assign them in robotInit():
Code:
public class Robot extends IterativeRobot {
RobotDrive Drive;
Joystick drivestick;
Joystick joystick;
Jaguar FL, BL, FR, BR;

int autoLoopCounter;

/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
public void robotInit() {

    FL = new Jaguar (5);
    BL = new Jaguar (2);
    FR = new Jaguar (3);
    BR = new Jaguar (4);
    Drive = new RobotDrive(FL,BL,FR,BR);
    drivestick = new Joystick(0);
    joystick = new Joystick(1);
}
P.S.: Also, enclosing your code with the tags makes it easier to read!

P.P.S.: After seeing this, I did not review the rest of the code.
The robot drive works, that is not the problem that I am running into I cannot get the buttons to work.
  #8   Spotlight this post!  
Unread 17-02-2015, 16:00
AWoL's Avatar
AWoL AWoL is offline
Lvl. 225 Dark Code Mage (Java Type)
AKA: Adam Wolnikowski
FRC #0225 (TechFire)
Team Role: Programmer
 
Join Date: Mar 2014
Rookie Year: 2014
Location: York, Pennsylvania
Posts: 116
AWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond repute
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by AnnaliseDonavan View Post
Code:
/**
* This function is called periodically during operator control
*/
public void teleopPeriodic() {
Drive.arcadeDrive(drivestick);

Button button1 = new JoystickButton(joystick, 1),
button2 = new JoystickButton(joystick, 2),
button3 = new JoystickButton(joystick, 3),
button4 = new JoystickButton(joystick, 4),
button5 = new JoystickButton(joystick, 5),
button6 = new JoystickButton(joystick, 6),
button7 = new JoystickButton(joystick, 7),
button8 = new JoystickButton(joystick, 8),
button9 = new JoystickButton(joystick, 9),
button10 = new JoystickButton(joystick, 10),
button11 = new JoystickButton(joystick , 11);


button1.whenPressed(new ElevatorOff());
button2.whenPressed(new ElevatorOn());
button3.whenPressed(new ElevatorReverse());
button4.whenPressed(new ArmsOut());
button5.whenPressed(new ArmsIn());
button6.whenPressed(new ArmsVerticalIn());
button7.whenPressed(new ArmsVarticalOut());
button8.whenPressed(new BlueLightShow());
button9.whenPressed(new LigthShowOn());
button10.whenPressed(new RedLightShow());
button11.whenPressed(new LightShowEnd());
}
First off, each of the buttons needs a type to specified. I personally do the declarations as all one line, and don't even name them. I would recommend you write them as such:
Code:
new JoystickButton(joystick, 0).whenPressed(new Command());
I'm not really sure whether or not this would cause compile errors, but I would definitely recommend using the OI class that even comes with the command based template to define the buttons, or at least do them in the Robot class constructor or as fields. Doing them in the periodic loop definitely isn't smart, as you want that loop to run as fast as possible, and creating 22 new objects every couple of milliseconds or so is a sure fire way to slow down the speed at which driver commands will be processed and to give the roboRIO memory issues. I'm also not sure if that is allowed, as I thought that joystick buttons are the same as DIO, PWM, etc. ports, in that you cannot allocate them multiple times.

As for anything beyond that, I'm sorry, but I didn't read it all. When posting code on chief, or anywhere else on the internet for that matter, always remember to format your code with code tags, which on chief look like this: [*CODE][*/CODE], except without the star. Another good rule of thumb is that people won't help you if you post more than 200 lines of code. So try and meet that, even if it takes some abstraction on your part.
__________________
2016 Competition Results (Co-captain, Driver, and Lead Programmer; Junior)
Springside-Chestnut Hill District Event - WINNER / #2 Seed, #1 Seed's First Pick / Gracious Professionalism Award
Westtown District Event - WINNER / #1 Seed / Industrial Design Award
MAR District Championship - WINNER / #1 Seed / Industrial Design Award / Dean's List Finalist Award (Me)
World Championship, Carson Subdivision - QUARTERFINALIST / #3 Seed, #2 Seed's First Pick
Indiana Robotics Invitational - FINALIST / #14 Seed, #2 Seed's Second Pick
  #9   Spotlight this post!  
Unread 17-02-2015, 16:07
Andrew Lobos Andrew Lobos is offline
Registered User
FRC #0225 (TechFire)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Lancaster, PA
Posts: 61
Andrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the roughAndrew Lobos is a jewel in the rough
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by AWoL View Post
Doing them in the periodic loop definitely isn't smart, as you want that loop to run as fast as possible, and creating 22 new objects every couple of milliseconds or so is a sure fire way to slow down the speed at which driver commands will be processed and to give the roboRIO memory issues.
Adam is right - you should only be creating the JoystickButton object once for each object and calling the method to bind to a command once (whenPressed, etc)

The command you specified will be automatically triggered as long as you are running the Scheduler every teleop loop
__________________
2012-2014: 225 Driver, Programmer & Co-Captain
2012-2014: FTC 4977 Driver, Programmer, & Team Captain
2011: 225 Operator & Programmer

2013: FRC: Springside-Chestnut Hill Winner (w/341 & 1495), Midknight Mayhem Winner (w/316, 369, & 869), Battle O' Baltimore Winner (w/1640, 2914 & 339), Duel on the Delaware Finalist (w/816 & 369), Ramp Riot Winner (w/341, 304, & 4637) FTC: PA State Finalist
2014: FRC: Springside-Chestnut Hill Winner (w/316 & 1495), Greater DC Winner (w/1731 & 4464), Midknight Mayhem Winner (w/25, 1626 & 329) FTC: PA State Champion
  #10   Spotlight this post!  
Unread 17-02-2015, 16:40
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: Robot Code Problem ** Again**

Would this be a better way to set it up ? The template that I am using dose not have a OI

public void teleopPeriodic() {
Drive.arcadeDrive(drivestick);


new JoystickButton(joystick, 1).whenPressed(new ElevatorOff());
new JoystickButton(joystick, 2).whenPressed(new ElevatorOn());
new JoystickButton(joystick, 3).whenPressed(new ElevatorReverse());
new JoystickButton(joystick, 4).whenPressed(new ArmsOut());
new JoystickButton(joystick, 5).whenPressed(new ArmsIn());
new JoystickButton(joystick, 6).whenPressed(new ArmsVerticalIn());
new JoystickButton(joystick, 7).whenPressed(new ArmsVarticalOut());
new JoystickButton(joystick, 8).whenPressed(new BlueLightShow());
new JoystickButton(joystick, 9).whenPressed(new LigthShowOn());
new JoystickButton(joystick, 10).whenPressed(new RedLightShow());
new JoystickButton(joystick, 11).whenPressed(new LightShowEnd());




}
  #11   Spotlight this post!  
Unread 17-02-2015, 16:56
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: Robot Code Problem ** Again**

Would this be a better way to set it up ? The template that I am using dose not have a OI

public void teleopPeriodic() {
Drive.arcadeDrive(drivestick);


new JoystickButton(joystick, 1).whenPressed(new ElevatorOff());
new JoystickButton(joystick, 2).whenPressed(new ElevatorOn());
new JoystickButton(joystick, 3).whenPressed(new ElevatorReverse());
new JoystickButton(joystick, 4).whenPressed(new ArmsOut());
new JoystickButton(joystick, 5).whenPressed(new ArmsIn());
new JoystickButton(joystick, 6).whenPressed(new ArmsVerticalIn());
new JoystickButton(joystick, 7).whenPressed(new ArmsVarticalOut());
new JoystickButton(joystick, 8).whenPressed(new BlueLightShow());
new JoystickButton(joystick, 9).whenPressed(new LigthShowOn());
new JoystickButton(joystick, 10).whenPressed(new RedLightShow());
new JoystickButton(joystick, 11).whenPressed(new LightShowEnd());




}
  #12   Spotlight this post!  
Unread 17-02-2015, 17:12
GBilletdeaux930's Avatar
GBilletdeaux930 GBilletdeaux930 is offline
Registered User
AKA: Greg
FRC #0930 (Mukwonago Bears)
Team Role: Coach
 
Join Date: Nov 2007
Rookie Year: 2007
Location: Milwaukee,Wisconsin
Posts: 171
GBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to allGBilletdeaux930 is a name known to all
Re: Robot Code Problem ** Again**

Another issue may be that you are declaring your buttons in teleopPeriodic. That will create these commands every 20ms. Instead declare them in your constructor or in teleopInit.
  #13   Spotlight this post!  
Unread 17-02-2015, 17:15
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: Robot Code Problem ** Again**

Quote:
Originally Posted by GBilletdeaux930 View Post
Another issue may be that you are declaring your buttons in teleopPeriodic. That will create these commands every 20ms. Instead declare them in your constructor or in teleopInit.
When I remove them from that section it dose not put the two sets as connected and pulls up tons of syntax errors
  #14   Spotlight this post!  
Unread 18-02-2015, 15:50
AWoL's Avatar
AWoL AWoL is offline
Lvl. 225 Dark Code Mage (Java Type)
AKA: Adam Wolnikowski
FRC #0225 (TechFire)
Team Role: Programmer
 
Join Date: Mar 2014
Rookie Year: 2014
Location: York, Pennsylvania
Posts: 116
AWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond reputeAWoL has a reputation beyond repute
Re: Robot Code Problem ** Again**

When you remove them where do you put them?
__________________
2016 Competition Results (Co-captain, Driver, and Lead Programmer; Junior)
Springside-Chestnut Hill District Event - WINNER / #2 Seed, #1 Seed's First Pick / Gracious Professionalism Award
Westtown District Event - WINNER / #1 Seed / Industrial Design Award
MAR District Championship - WINNER / #1 Seed / Industrial Design Award / Dean's List Finalist Award (Me)
World Championship, Carson Subdivision - QUARTERFINALIST / #3 Seed, #2 Seed's First Pick
Indiana Robotics Invitational - FINALIST / #14 Seed, #2 Seed's Second Pick
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:09.

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