Go to Post Is it legal? Yes. Is it Graciously Professional? Yes. Is it smart? No. - dlavery [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

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-01-2016, 19:06
Snapperbot Snapperbot is offline
Registered User
FRC #4501 (Humans)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2012
Location: Santa Monica
Posts: 6
Snapperbot is an unknown quantity at this point
Question 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
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2016, 20:34
TimTheGreat's Avatar
TimTheGreat TimTheGreat is offline
ArchdukeTim
FRC #1418 (Vae Victis)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2011
Location: Falls Church
Posts: 234
TimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura aboutTimTheGreat has a spectacular aura about
Re: Updating Joysticks in a Command

It's really hard to understand what's wrong if you don't post code.
__________________
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.



2012 - Gracious Professionalism - Greater DC
2014 - Regional Finalist - Virginia | Industrial Design - Virginia | Regional Finalist - Greater DC
2015 - Innovation in Control - Greater DC
2016 - District Event Winner - VAHAY | Innovation in Control - VAHAY | District Event Winner - MDBET | Industrial Design - MDBET | District Champion - CHCMP | Innovation in Control - CHCMP
Reply With Quote
  #3   Spotlight this post!  
Unread 28-01-2016, 22:48
Snapperbot Snapperbot is offline
Registered User
FRC #4501 (Humans)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2012
Location: Santa Monica
Posts: 6
Snapperbot is an unknown quantity at this point
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.
Reply With Quote
  #4   Spotlight this post!  
Unread 28-01-2016, 23:34
mmaunu's Avatar
mmaunu mmaunu is offline
Registered User
FRC #2485 (W.A.R. Lords)
Team Role: Mentor
 
Join Date: Mar 2013
Rookie Year: 2010
Location: San Diego, CA
Posts: 87
mmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the roughmmaunu is a jewel in the rough
Re: Updating Joysticks in a Command

Quote:
Originally Posted by Snapperbot View Post
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
__________________
2014 Las Vegas (Winners with 987, 2478; Excellence in Engineering)
2014 San Diego (Finalists with 987, 3250; Quality Award)
2013 Inland Empire (Winners with 1538, 968; Excellence in Engineering Award)
2013 San Diego (Finalists with 2984, 4322; Creativity Award)
2012 Las Vegas (Finalists with 2034, 3187; Quality Award)
Reply With Quote
  #5   Spotlight this post!  
Unread 29-01-2016, 14:05
Snapperbot Snapperbot is offline
Registered User
FRC #4501 (Humans)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2012
Location: Santa Monica
Posts: 6
Snapperbot is an unknown quantity at this point
Thumbs up Re: Updating Joysticks in a Command

Thanks for linking me to that thread, it really helped me out.
Reply With Quote
  #6   Spotlight this post!  
Unread 29-01-2016, 15:20
fovea1959's Avatar
fovea1959 fovea1959 is offline
Herder of programmers
AKA: Doug Wegscheid
FRC #3620 (The Average Joes)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2011
Location: St Joseph
Posts: 330
fovea1959 will become famous soon enough
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.
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 10:51.

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