Go to Post Although I'm 2-0 against 217 when Paul coaches, I'm 0-2 against them when he doesn't....hmmm.... :rolleyes: - Lil' Lavery [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 13-02-2015, 12:53
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 Code problem

the code runs but when it comes to pressing the buttons nothing happens

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();


}

}

Last edited by AnnaliseDonavan : 13-02-2015 at 12:58.
Reply With Quote
  #2   Spotlight this post!  
Unread 13-02-2015, 13:22
Adamz_'s Avatar
Adamz_ Adamz_ is offline
Who wants coffee?
AKA: Connor Adams
FRC #4519 (Kings Mechavaliers)
Team Role: Mentor
 
Join Date: May 2013
Rookie Year: 2013
Location: Oakville
Posts: 33
Adamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to beholdAdamz_ is a splendid one to behold
Re: Code problem

Based on the block of code below, i feel its safe to assume that you have differnt classes for all of the commands you wish to run once the button is pressed, and it would be easier to diagnose if you posted your full robot code.

If this is infact your only class, your attempting to refernce a null command, so the button press is trying to reach a null comand, in result doing nothing.
Quote:
Originally Posted by AnnaliseDonavan View Post
Code:
   	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());
__________________
2016 North Bay Regional Finalists
2016 Greater Toronto Central Regional Semi-Finalists
2015 Windsor Essex Great Lakes Regional Quarter-Finalists
2014 Windsor Essex Great Lakes Regional Semi-Finalists
2014 Waterloo Regional Quarter-finalists
2013 Waterloo Regional Highest Rookie Seed
2013 Waterloo Regional Rookie All Star Recipient
Reply With Quote
  #3   Spotlight this post!  
Unread 13-02-2015, 13:27
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: Code problem

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

}

}
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 20:57.

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