Go to Post You've got to love the great connection between FIRST teams, and their members. - zakk [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 23-03-2016, 14:43
axiomofdarkness's Avatar
axiomofdarkness axiomofdarkness is offline
Registered User
FRC #1403 (Cougar Robotics)
Team Role: Alumni
 
Join Date: Mar 2015
Rookie Year: 2013
Location: United States
Posts: 21
axiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura about
Manually cancelling a Command

Hello,

I am trying to create a Command subclass which listens for an interrupt to cancel the command. When cancelling the command, I have tried using the Cancel() method, but it fails when the command is part of a CommandGroup. Is there a universal way to forcibly end a command from within the command itself?

EDIT: Also, can the Cancel() method be used on a CommandGroup object? If so, I could work around this issue.

Last edited by axiomofdarkness : 23-03-2016 at 14:52.
  #2   Spotlight this post!  
Unread 23-03-2016, 14:56
euhlmann's Avatar
euhlmann euhlmann is online now
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 312
euhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud ofeuhlmann has much to be proud of
Re: Manually cancelling a Command

Within your command:

Code:
if(getGroup() != null) getGroup().cancel();
else cancel();
  #3   Spotlight this post!  
Unread 23-03-2016, 14:57
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is online now
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,713
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: Manually cancelling a Command

Quote:
Originally Posted by axiomofdarkness View Post
Hello,

I am trying to create a Command subclass which listens for an interrupt to cancel the command. When cancelling the command, I have tried using the Cancel() method, but it fails when the command is part of a CommandGroup. Is there a universal way to forcibly end a command from within the command itself?

EDIT: Also, can the Cancel() method be used on a CommandGroup object? If so, I could work around this issue.
What about listening for the interrupt and setting a variable that will finish the command during the next iteration?
  #4   Spotlight this post!  
Unread 23-03-2016, 15:27
axiomofdarkness's Avatar
axiomofdarkness axiomofdarkness is offline
Registered User
FRC #1403 (Cougar Robotics)
Team Role: Alumni
 
Join Date: Mar 2015
Rookie Year: 2013
Location: United States
Posts: 21
axiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura about
Re: Manually cancelling a Command

Quote:
Originally Posted by euhlmann View Post
Within your command:

Code:
if(getGroup() != null) getGroup().cancel();
else cancel();
Will this cause issues if multiple commands are trying to end their parent CommandGroup?
  #5   Spotlight this post!  
Unread 23-03-2016, 15:29
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,028
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Manually cancelling a Command

Quote:
Originally Posted by notmattlythgoe View Post
What about listening for the interrupt
Hmm. What does it mean to "listen" for an interrupt?


  #6   Spotlight this post!  
Unread 23-03-2016, 15:48
axiomofdarkness's Avatar
axiomofdarkness axiomofdarkness is offline
Registered User
FRC #1403 (Cougar Robotics)
Team Role: Alumni
 
Join Date: Mar 2015
Rookie Year: 2013
Location: United States
Posts: 21
axiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura about
Re: Manually cancelling a Command

Quote:
Originally Posted by Ether View Post
Hmm. What does it mean to "listen" for an interrupt?
I have a background thread that checks for a certain button combination on the joystick being pressed. The Cancel() method will be called when that condition is true.

Last edited by axiomofdarkness : 23-03-2016 at 15:50. Reason: Made wording clearer
  #7   Spotlight this post!  
Unread 23-03-2016, 15:53
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,028
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Manually cancelling a Command

Quote:
Originally Posted by axiomofdarkness View Post
I have a background thread that checks for a certain button combination on the joystick being pressed.
That's polling, not an interrupt.


  #8   Spotlight this post!  
Unread 23-03-2016, 16:38
axiomofdarkness's Avatar
axiomofdarkness axiomofdarkness is offline
Registered User
FRC #1403 (Cougar Robotics)
Team Role: Alumni
 
Join Date: Mar 2015
Rookie Year: 2013
Location: United States
Posts: 21
axiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura aboutaxiomofdarkness has a spectacular aura about
Re: Manually cancelling a Command

Quote:
Originally Posted by Ether View Post
That's polling, not an interrupt.
My mistake - I apologize for the error. What would an interrupt be then?
  #9   Spotlight this post!  
Unread 23-03-2016, 17:05
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,028
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Manually cancelling a Command

Quote:
Originally Posted by axiomofdarkness View Post
What would an interrupt be then?
The hardware generates an electrical signal (called an interrupt) that causes the CPU to stop what it's doing, save its "context", jump to a new location in program memory, and start executing there. That location is called an ISR -- interrupt service routine. When the ISR is done executing, it tells the CPU to go back to where it was when the interrupt occurred. The CPU uses the saved "context" to go back to where it was, as it was.

You can see there is no polling involved. That's the advantage of interrupts.

The disadvantage is that interrupts can occur at any time -- asynchronously -- so you have to be careful when using them.


Closed Thread


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

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