Log in

View Full Version : Updating Joysticks in a Command


Snapperbot
28-01-2016, 19:06
I want to make a command that when hold a button it sets two motors speeds to the value of the throttle of a joystick(we're using the Logitech ATK3). I'm running into an issue where it doesn't like updating the value of the joystick when I hold the button(It crashes the robot and the driver station gives me the Robots don't quit message). When the command is constantly running there's no issue, but I would like it to not constantly run. I can make the command's parameters request a double and then in OI put in the joysticks throttle value there but it doesn't update after the init of the robot.

Any help is appreciated :]

TimTheGreat
28-01-2016, 20:34
It's really hard to understand what's wrong if you don't post code.

Snapperbot
28-01-2016, 22:48
Here's the GitHub page. (https://github.com/FRCHumans4501/Sonic-Shiftier-Bot/tree/Shooter-Testing/2-Speed%20Sonic%20Shifter%20Robot/src/org/usfirst/frc/team4501/robot)
The code I'm talking about would be in these classes:
Robot
OI
subsystems/Shooter
commands/ShooterArcade
commands/ShooterIdle.

Here's a part of the ShooterArcade class:
public class ShooterArcade extends Command {
OI oi;
Shooter shooter;
public ShooterArcade() {
requires(Robot.shooter);
shooter = Robot.shooter;
oi = Robot.oi;
}

// Called just before this Command runs the first time
protected void initialize() {
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {
double shooterSpeed = oi.getShooterThrottle();

shooter.shooterArcade(shooterSpeed);
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return true;
}
If you need more info feel free to ask. :)

mmaunu
28-01-2016, 23:34
Here's the GitHub page. (https://github.com/FRCHumans4501/Sonic-Shiftier-Bot/tree/Shooter-Testing/2-Speed%20Sonic%20Shifter%20Robot/src/org/usfirst/frc/team4501/robot)
The code I'm talking about would be in these classes:
Robot
OI
subsystems/Shooter
commands/ShooterArcade
commands/ShooterIdle.

Here's a part of the ShooterArcade class:
public class ShooterArcade extends Command {
OI oi;
Shooter shooter;
public ShooterArcade() {
requires(Robot.shooter);
shooter = Robot.shooter;
oi = Robot.oi;
}

// Called just before this Command runs the first time
protected void initialize() {
}

// Called repeatedly when this Command is scheduled to run
protected void execute() {
double shooterSpeed = oi.getShooterThrottle();

shooter.shooterArcade(shooterSpeed);
}

// Make this return true when this Command no longer needs to run execute()
protected boolean isFinished() {
return true;
}
If you need more info feel free to ask. :)

Our team doesn't use the Command-based template, but I'm guessing that having isFinished() always return true immediately is a problem. I think that you are starting and stopping the command over and over. Try changing isFinished() to return false and see if that helps.

Here is a good thread to read for a bit more:
http://www.chiefdelphi.com/forums/showthread.php?t=125671

Snapperbot
29-01-2016, 14:05
Thanks for linking me to that thread, it really helped me out.:)

fovea1959
29-01-2016, 15:20
the other part of information that is helpful is the lines above "robots don't quit". Those lines tell people trying to help you where your code was when it had trouble.