Go to Post What is it about inefficient design and operation that either pushes the envelope or deserves to be awarded? - Madison [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-03-2014, 21:34
xForceDee's Avatar
xForceDee xForceDee is offline
Registered User
AKA: Bart Kerfeld
FRC #4239 (Warpspeed)
Team Role: College Student
 
Join Date: Dec 2012
Rookie Year: 2012
Location: Minnesota
Posts: 58
xForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to beholdxForceDee is a splendid one to behold
Best Way(s) to Implement a Delay in Command Groups

Today, my former team asked me what the best way to implement a delay in a command group is. They are well aware of the built in delays in the adding of the commands.

Code:
addSequential(new DriveForward(), DELAY_TIME);
But they want there to be a period where the robot does absolutely nothing for a while for some reason (I assume to let the ball settle). They seem convinced
Code:
Timer.delay(DELAY_TIME);
did not do what they wanted. I know one way to do it could be to make a command that does nothing but that seems a bit excessive, and I am not sure if you can make a command that doesn't require a subsystem (never have done that before) and don't know if that is fair game. So if someone could answer that, it would be cool also. Anyway, back to the real question, does anyone have a clean solution to this I could report back to them with?

Last edited by xForceDee : 28-03-2014 at 21:40.
Reply With Quote
  #2   Spotlight this post!  
Unread 28-03-2014, 21:45
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: Best Way(s) to Implement a Delay in Command Groups

AddSequential(new WaitCommand(1)); //Wait 1 second.
__________________
"May the coms be with you"

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

Reply With Quote
  #3   Spotlight this post!  
Unread 04-04-2014, 00:00
Joey1939's Avatar
Joey1939 Joey1939 is offline
Registered User
AKA: Joey Holliday
FRC #1939 (Kuhnigits)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Kansas City, Missouri
Posts: 140
Joey1939 has a spectacular aura aboutJoey1939 has a spectacular aura aboutJoey1939 has a spectacular aura about
Re: Best Way(s) to Implement a Delay in Command Groups

I discovered that it is best to not use Timer.delay() because that will pause your entire robot (Every other command and every other subsystem). My solution was to create a Wait command that accepts a timeout as an argument. It then sets its timeout (this.setTimeout(arg)) to the argument. Then isFinished() returns this.isTimedout(). This will effectively put a delay in the command group because they command won't finish until the timeout has elapsed.
Reply With Quote
  #4   Spotlight this post!  
Unread 04-04-2014, 19:31
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: Best Way(s) to Implement a Delay in Command Groups

Our team uses the same approach mentioned by Joey1939. I've attached the .java file for the command we use. (You might want to just copy/paste the important bits - there's a lot of unnecessary RobotBuilder crap in here that we never cleaned out.)

We call it in command groups like so:

Code:
addSequential(new Delay(1.25));
Attached Files
File Type: java Delay.java (1.7 KB, 27 views)
Reply With Quote
  #5   Spotlight this post!  
Unread 04-04-2014, 22: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: Best Way(s) to Implement a Delay in Command Groups

We use:
Code:
addSequential(new WaitCommand(WAIT_TIME));
This WaitCommand is built into the WPI Library.
Also, it is possible to have a command that does not require a subsystem, as we have done this before, but probably is not recommended.
Reply With Quote
  #6   Spotlight this post!  
Unread 05-04-2014, 20:36
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: Best Way(s) to Implement a Delay in Command Groups

Quote:
Originally Posted by TFleig78 View Post
This WaitCommand is built into the WPI Library.
Wow, I had no idea that was even there. They really ought to put that in the ScreenSteps documentation somewhere...
Reply With Quote
  #7   Spotlight this post!  
Unread 06-04-2014, 15:08
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: Best Way(s) to Implement a Delay in Command Groups

Quote:
Originally Posted by TFleig78 View Post
Also, it is possible to have a command that does not require a subsystem, as we have done this before, but probably is not recommended.
Why would this be a problem? Understandably, you could have two commands trying to use a subsystem at the same time. But I'm sure the WaitCommand itself doesn't require a subsystem, and neither do a lot of the commands that our team used this year.
Reply With Quote
  #8   Spotlight this post!  
Unread 11-04-2014, 07:01
rich2202 rich2202 is offline
Registered User
FRC #2202 (BEAST Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 1,192
rich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond reputerich2202 has a reputation beyond repute
Re: Best Way(s) to Implement a Delay in Command Groups

Our team uses States to determine what to do. Drive has a State Machine that is independent of the Shooter. Delays are implemented using timers. Set a timer, and check the time each loop.

Note: Having everything doing "nothing" requires a little thought. Do you disable the compressor so it does not run too? If you are moving, do you stop moving (and if so, how? Drop power abruptly, or gradually)? etc.
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 22:38.

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