Go to Post Bottom line - keep your passion for FIRST and don't let others spoil your fun! - Sean Schuff [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 4 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 10-02-2015, 11:36
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 189
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: Conditional Command Group?

I didn't even pay attention to the team number of the OP. But yes I do believe I know one of your mentors.

If I'm understanding why you want to skip a command correctly then personally I would code the command to finish instantly if it didn't need to run. This is easier if you have sensors/feedback on all your mechanisms.

Ex.

Code:
class IntakeToteCommand: public CommandGroup
{
public:
	IntakeToteCommand(){
		AddSequential(new StackerGoToTopCommand());
		AddSequential(new IntakeTurnOn());

	}
};
Code:
class StackerGoToTopCommand: public CommandBase
{
public:
	StackerGoToTopCommand() : CommandBase() {
		Requires(stacker);
	}
	void Initialize(){
		if (!IsFinished()){
			CommandBase::stacker->SetPosition(15);			
		}
 	}
	void Execute() {}
	bool IsFinished(){
		return (CommandBase::stacker->GetPosition() > 15);
	}
	void End(){
		CommandBase::stacker->Disable();
	}
	void Interrupted(){
		End();
	}
};
Our stacker has to be at it's top position to intake a tote. 99% of the time the Stacker is already at the top of the robot when we start to intake a tote. However we still fire off the StackerGoToTopCommand() as a safety precaution because if we don't we won't be able to pickup a tote. If it is already at the top then the command finishes instantly.

With this approach you can take everything into account that would ever need to occur for the given action to run without error. In doing so you can call the command group at anytime by itself and not have to think about wrapping the call of the command in additional logic.
__________________
"May the coms be with you"

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

Reply With Quote
 


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 14:04.

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