Go to Post it would be a sign you do too much robotics when you find toolpaths sexy. - Aren_Hill [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 11-11-2014, 16:10
WilliamR WilliamR is offline
Registered User
FRC #3331
 
Join Date: Nov 2014
Location: Chapel Hill, NC
Posts: 3
WilliamR is an unknown quantity at this point
Question Sequences of Commands

We had trouble getting a command to work after another command in autonomous mode. We used a while statement and ended the command with a limit switch changing states, but the next command did not trigger the pnuematic cylinder to fire. Any hints?
Reply With Quote
  #2   Spotlight this post!  
Unread 11-11-2014, 16:23
BigJ BigJ is online now
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 947
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: Sequences of Commands

This is a situation where you will want to use CommandGroups.
Reply With Quote
  #3   Spotlight this post!  
Unread 11-11-2014, 19:27
JamieKilburn JamieKilburn is offline
Registered User
FRC #0610 (The Coyotes)
Team Role: Driver
 
Join Date: Nov 2014
Rookie Year: 2013
Location: Toronto, Ontario
Posts: 15
JamieKilburn has a spectacular aura aboutJamieKilburn has a spectacular aura about
Re: Sequences of Commands

Quote:
Originally Posted by BigJ View Post
This is a situation where you will want to use CommandGroups.
CommandGroups are definitely what you want here.
Reply With Quote
  #4   Spotlight this post!  
Unread 12-11-2014, 23:09
WilliamR WilliamR is offline
Registered User
FRC #3331
 
Join Date: Nov 2014
Location: Chapel Hill, NC
Posts: 3
WilliamR is an unknown quantity at this point
Re: Sequences of Commands

Quote:
Originally Posted by JamieKilburn View Post
CommandGroups are definitely what you want here.
Here is the code that we are using to test the latching of our winch after a limit switch is activated.

void shoot() {
latchPneumatic.set(DoubleSolenoid.Value.kReverse);
}

void winch(int direction, double unwindTime) {
if (direction == 1) {
while (catapultLimitSwitch.get() == true) {
winchMotor.set(1);
}
//latchPneumatic.set(DoubleSolenoid.Value.kReverse);
winchMotor.set(0);
}
else if (direction == -1) {
for (int i = 0; i < unwindTime*10000; i++) winchMotor.set(-1);
winchMotor.set(0);
}
else winchMotor.set(0);
}
Reply With Quote
  #5   Spotlight this post!  
Unread 13-11-2014, 11:24
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Sequences of Commands

Quote:
Originally Posted by WilliamR View Post
Here is the code that we are using to test the latching of our winch after a limit switch is activated.

Code:
void shoot() {
        latchPneumatic.set(DoubleSolenoid.Value.kReverse);
    }
    
    void winch(int direction, double unwindTime) {
        if (direction == 1) {
            while (catapultLimitSwitch.get() == true) {
                winchMotor.set(1);
            }
            //latchPneumatic.set(DoubleSolenoid.Value.kReverse);
            winchMotor.set(0);
        }
        else if (direction == -1) {
            for (int i = 0; i < unwindTime*10000; i++) winchMotor.set(-1);
            winchMotor.set(0);
        }
        else winchMotor.set(0);
    }
What you are doing here is very dangerous when using the Command Based approach. Long acting while loops are a big no no and should be avoided at all costs. What you want to do is use a single command for each action and combine them into a command group to get them to work in sequence. Your command for moving the wench should be similar to this:

Code:
public void execute() {
     shooter.winch(1);
}

public boolean isFinished() {
     if (timeNow - startTime > unwindTime) {
          return true;
     }
}

public void end() {
     shooter.winch(0);
}
This will run the shooter motor at the power level provided in the parameter:
Code:
shooter.winch(x)
You will use this to tell the command when it is finished:
Code:
public boolean isFinished() {
     if (timeNow - startTime > unwindTime) {
          return true;
     }
}
This will stop the motor once the command is finished (the winch runs for the specified time):
Code:
public void end() {
     shooter.winch(0);
}

Last edited by notmattlythgoe : 13-11-2014 at 11:45.
Reply With Quote
  #6   Spotlight this post!  
Unread 13-11-2014, 14:26
WilliamR WilliamR is offline
Registered User
FRC #3331
 
Join Date: Nov 2014
Location: Chapel Hill, NC
Posts: 3
WilliamR is an unknown quantity at this point
Re: Sequences of Commands

This is why I like being involve with FRC. I appreciate all the tips and advice.
Thanks to everyone who responded. The information will be put to good use on Saturday when our programming group get together to work on this small project for preparation for the new game in January.
Thanks again
William
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 12:41.

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