Go to Post If you find yourself extremely upset, frustrated, angry, or any other term of emotion, please stop and ask yourself why you participate in FIRST. - indieFan [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 18-01-2013, 22:50
jfitz0807 jfitz0807 is offline
Registered User
FRC #2877 (Ligerbots)
Team Role: Parent
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Newton, MA
Posts: 67
jfitz0807 is an unknown quantity at this point
Can't get a command to run

I created a Drive1 command class as follows:

public class Drive1 extends Command {
public Drive1() {
// Use requires() here to declare subsystem dependencies
// eg. requires(chassis);
requires(Robot.driveTrain);

// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=REQUIRES
}
private Timer timer;
private boolean running;

// Called just before this Command runs the first time
protected void initialize() {
timer.start();
timer.reset();
}
// Called repeatedly when this Command is scheduled to run
protected void execute() {
if (running != true) {
running = true;
timer.reset() ;
}
Robot.driveTrain.runMotor1( 0.5 );
}
// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return timer.get() > 3.0e6;
}
// Called once after isFinished returns true
protected void end() {
Robot.driveTrain.runMotor1( 0 );
}
// Called when another command which requires one or more of the same
// subsystems is scheduled to run
protected void interrupted() {
end();
}

I would expect this command to run the motor connected to jaguar1 for 3 seconds at half speed. It's not doing anything.

I put numerous System.out.println calls throughout my code to try to see what's happening. Maybe some of this is my lack of java proficiency, but I'm having trouble understanding how this is behaving.

In my Oi constructor, I have the following:

joystickButton2 = new JoystickButton(joystick1, 2);
joystickButton2.whenPressed(new Drive1());

I expected this to construct a new Drive1() command when button2 on joystick1 is pressed. My printlns indicate that the constructor of Drive1 is being called in Disabled mode. I would not have expected this constructor to be called until the button was pressed.

Any thoughts?

The next thing I did was to construct a Drive1() command in the disabledInit() method. I expected this to construct a Drive1 command. In any case, how does this newly constructed command become runnable? Do I have to do anything else to make it's execute() method get called on every iteration?
Reply With Quote
 


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:24.

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