Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Updating Joysticks in a Command (http://www.chiefdelphi.com/forums/showthread.php?t=142732)

Snapperbot 01-28-2016 07:06 PM

Updating Joysticks in a Command
 
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 01-28-2016 08:34 PM

Re: Updating Joysticks in a Command
 
It's really hard to understand what's wrong if you don't post code.

Snapperbot 01-28-2016 10:48 PM

Re: Updating Joysticks in a Command
 
Here's the GitHub page.
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:
Code:

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 01-28-2016 11:34 PM

Re: Updating Joysticks in a Command
 
Quote:

Originally Posted by Snapperbot (Post 1531805)
Here's the GitHub page.
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:
Code:

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/sh...d.php?t=125671

Snapperbot 01-29-2016 02:05 PM

Re: Updating Joysticks in a Command
 
Thanks for linking me to that thread, it really helped me out.:)

fovea1959 01-29-2016 03:20 PM

Re: Updating Joysticks in a Command
 
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.


All times are GMT -5. The time now is 08:25 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi