Go to Post If time only weren't a factor, everything would be done. - Schnabel [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

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-07-2015, 04:20 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
COmmand based software Interrupts

Hello again! I'm back with another (possibly) stupid question. Does anyone have any documentation on how command interrupts are handled in command based code? I'm having issues where effectively command 1 which requires subsystem A gets called initially, then before it finishes command 2 gets called which also requires subsystem A, but then they both keep getting called in parallel (I am not using command groups)? I would love to know what exactly goes on inside the code and what order functions are run in, etc., etc., for when situations like these happen.

My google-fu and delphi-fu isn't doing much
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #2   Spotlight this post!  
Unread 03-07-2015, 04:50 PM
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: COmmand based software Interrupts

Do you have anything in the interrupted function of the first command? The command itself may be ending but whatever it's doing may continue unless you explicitly tell it to stop in the interrupted function. How do you know they both keep getting called in parallel?

Here's some general command based documentation, but it has some specific detail about interrupting and requires():


http://wpilib.screenstepslive.com/s/...uling-commands

http://wpilib.screenstepslive.com/s/...ed-programming
Reply With Quote
  #3   Spotlight this post!  
Unread 03-07-2015, 09:09 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: COmmand based software Interrupts

Ok thank you so much, that was exactly what I wanted! Also, if you know, how do you make a command non-interruptible? It said that in the flow chart about halfway down the page on the second link you gave me.
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #4   Spotlight this post!  
Unread 03-07-2015, 09:32 PM
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: COmmand based software Interrupts

Quote:
Ok thank you so much, that was exactly what I wanted! Also, if you know, how do you make a command non-interruptible?
You can use the Command::setInterruptible(bool interruptible) function.
Reply With Quote
  #5   Spotlight this post!  
Unread 03-09-2015, 06:04 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: COmmand based software Interrupts

Ok, thank you. I tried using the cancel command in the Interrupted function, but it still did not work :/ do you know how you can force a command to stop once it is interrupted?
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #6   Spotlight this post!  
Unread 03-09-2015, 06:19 PM
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 985
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: COmmand based software Interrupts

Quote:
Originally Posted by Sparkyshires View Post
Ok, thank you. I tried using the cancel command in the Interrupted function, but it still did not work :/ do you know how you can force a command to stop once it is interrupted?
If Interrupted() is being called, the command is already being canceled.

You didn't answer the question about how you know they are running in parallel. It shouldn't be possible for two commands that Require the same subsystem to run at the same time.
Reply With Quote
  #7   Spotlight this post!  
Unread 03-09-2015, 07:13 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: COmmand based software Interrupts

I'm adding some diagnostics and should be able to test it soon, but I'm assuming that's whats happening because when we call command A that goes to, say, 1000 encoder counts, and then command B (which should go to -1000) before it reaches, it will kinda stutter like it's being repeatedly told to go positive and then zero, going forwards until it hits 1000 and then run in reverse at normal speed until it hits -1000 then stop.

Btw those were arbitrary numbers
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #8   Spotlight this post!  
Unread 03-10-2015, 09:10 AM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: COmmand based software Interrupts

Yeah, that's exactly what happened. When we did the printf's, it showed:

CommandA execute
CommandB execute
CommandA execute
CommandB execute
CommandA execute
CommandB execute
CommandA execute
CommandB execute
CommandA execute
CommandB execute
CommandA execute
CommandB execute
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #9   Spotlight this post!  
Unread 03-10-2015, 05:18 PM
Sparkyshires Sparkyshires is offline
Registered User
AKA: Michael Shires
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2006
Location: Virginia
Posts: 226
Sparkyshires is an unknown quantity at this point
Re: COmmand based software Interrupts

Our code is at https://github.com/Sparky384/Team384...ree/master/src if anyone wants to take a look.
__________________
"Measure with a micrometer, mark with chalk, cut with an axe."
Reply With Quote
  #10   Spotlight this post!  
Unread 03-10-2015, 05:34 PM
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 429
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: COmmand based software Interrupts

Is your repository private? Link doesn't work.

For the commands that are running "in parallel".
* Do they both require the same subsystem?
* What does their isFinished() code look like?
* What command is set as the default command for the subsystem?
* What does the code in OI look like that associates the commands with buttons (or where is new CommandXYZ() called for each command in question)?
__________________
http://team2168.org
Reply With Quote
  #11   Spotlight this post!  
Unread 03-10-2015, 11:01 PM
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: COmmand based software Interrupts

Quote:
Originally Posted by otherguy View Post
Is your repository private? Link doesn't work.

For the commands that are running "in parallel".
* Do they both require the same subsystem?
* What does their isFinished() code look like?
* What command is set as the default command for the subsystem?
* What does the code in OI look like that associates the commands with buttons (or where is new CommandXYZ() called for each command in question)?
Also, what is in interrupted()?

Quote:
Ok, thank you. I tried using the cancel command in the Interrupted function, but it still did not work :/ do you know how you can force a command to stop once it is interrupted?
You should very rarely (if ever) have to explicitly cancel a command. The command will end(the scheduler will stop it) if it is interrupted by another command using the same subsystem or if isFinished() returns true. From what's going on, it seems as though your two commands A and B don't require the same subsystem.
Also, how are you starting the commands? It's possible they both keep trying to start, and are therefore interrupting each other repeatedly.
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:47 AM.

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