View Single Post
  #2   Spotlight this post!  
Unread 21-02-2012, 14:01
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: what could be wrong with this code. The robot is not responding

Two comments. My best guess is that you need a sleep() or wait() or whatever the java equivalent is in the body of your while(isOperatorControl()) loop. If the brackets in your post match your robot code, then your launcher code will probably never get run, or will only get run before you disable the robot.
Code:
public void operatorControl() {

drive.setSafetyEnabled(true);

while (isOperatorControl()) <-- as long as you're in operator control, your robot will be in this loop.  It should be responsive to your joysticks though.  You may want to put a wait(0.001) call in (or whatever the java equivalent is) because this thread may be monopolizing the cRio CPU
{
drive.tankDrive(leftStick, rightStick);
}




drive.setSafetyEnabled(true);
drive.tankDrive(leftStick, rightStick); <-- this will only get called once, since you're not in a loop at the time you call it.
double z = leftStick.getZ();

while(constant = true) <-- if this is java or c++, you need to do constant == true.  As this stands, you're assigning true to constant, and then testing if it is true, which means this loop will never end
{
if (z > 0.5)
{
launcher.set(LAUNCH_CONSTANT * 2);
launcherOpposite.set(LAUNCH_CONSTANT * -2);

}
else
{
launcher.set(LAUNCH_CONSTANT);
launcherOpposite.set(LAUNCH_CONSTANT * -1);
}
}
if (rightStick.getRawButton(3)) arm.set(0.5);
else
arm.set(0);
{
if (rightStick.getRawButton(2))
{
arm.set(-0.5);
}
else 
arm.set(0);
}
if (rightStick.getRawButton(1))
{
claw.set(1);
} 
else 
claw.set(0);
}
}
}
Another thing: Our robot was non-responsive yesterday - it turned out we had a gyro in a non-accumulator port, and using the gyro was causing the robot to crash.

Last edited by Bongle : 21-02-2012 at 14:03.