Go to Post People aren't getting angry at teams who play defense. They are getting angry at the teams who play BattleBots in the middle of a FIRST match. - 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 04-02-2014, 21:08
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
addSequential NOT Working for Servos

I have two programs to run a servo - if I assign the programs individually to buttons they work but if I build a command group with those two commands in it - so they go one after another - nothing happens - I assigned this command group to a button and it doesn't work - nothing happens when I assign the group as the autonomous command either.

Here it is:

Code:
addSequential(new Move45());
addSequential(new Move0());
ANY help will be GREATLY appreciated! THANKS!
Reply With Quote
  #2   Spotlight this post!  
Unread 04-02-2014, 21:41
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 990
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: addSequential NOT Working for Servos

what do the commands look like? I'm guessing you're sending the servo one command to go to 45 degrees (for ~20ms) then immediately telling it to go back to 0.
Reply With Quote
  #3   Spotlight this post!  
Unread 04-02-2014, 21:56
TFleig78's Avatar
TFleig78 TFleig78 is offline
Registered User
AKA: Tyler
FRC #0078 (Air Strike)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2012
Location: Rhode Island
Posts: 58
TFleig78 will become famous soon enoughTFleig78 will become famous soon enough
Re: addSequential NOT Working for Servos

you might want to add :
Code:
addSequential(new Move45());
addSequential(new WaitCommand(timeout));
addSequential(new Move0());
This will pause for the specified amount of time between the two commands.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-02-2014, 23:27
LFRobotics's Avatar
LFRobotics LFRobotics is offline
Registered User
FRC #4623
 
Join Date: Jan 2014
Location: Little Falls, MN
Posts: 95
LFRobotics is on a distinguished road
Re: addSequential NOT Working for Servos

Here are the commands:

Code:
package edu.wpi.first.LFRobot2014.commands;

/**
 *
 * @author FrankyMonezz
 */
public class PrepBall extends CommandBase {
    
    public PrepBall() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(launchservo);
    }

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

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        //move servo to 45 degrees
        launchservo.setPos(45);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return (launchservo.getPos() == 45);
         
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
Code:
package edu.wpi.first.LFRobot2014.commands;

/**
 *
 * @author FrankyMonezz
 */
public class PrepBall2 extends CommandBase {
    
    public PrepBall2() {
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
        requires(launchservo);
    }

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

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        //move servo back to default location
        launchservo.setPos(0);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return (launchservo.getPos() == 0);
    }

    // Called once after isFinished returns true
    protected void end() {
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}
I will try putting in a wait command tomorrow - THANKS!
Reply With Quote
  #5   Spotlight this post!  
Unread 04-02-2014, 23:56
kylelanman's Avatar
kylelanman kylelanman is online now
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 191
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
Re: addSequential NOT Working for Servos

A delay should fix your problem. While you are using what seems like a logical isFinished condition the reality is that it won't work. A servo provides no feedback to the rest of the system. A servo takes time to move from point A to point B. calling setPos(45) and then calling getPos() will yield 45. getPos() only tells you where the servo was last set. It doesn't take into account where the servo actually is.

Kyle
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

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 13:11.

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