Go to Post RTM does not stop after competition. - rtfgnow [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 23-02-2016, 11:55
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Commands Ending Other Commands

I have a commands that runs the rollers outwards and a command that runs the rollers inwards, but if one is running and you call the other one (through pressing a button), then both commands attempt to run at the same time. Is there any way to have each command end the other one when called?
I had an idea where you declare a Command object in the command of the other command (i.e. Inwards has an Outwards Command object in it) and when one is initialized it calls End() from the object, but I don't know if that would work, and don't have the robot electronics board with me to test right now. Any ideas?
__________________
Isaac
Chief of Programming and Head of Autonomous Control
FRC Team 1410
Reply With Quote
  #2   Spotlight this post!  
Unread 23-02-2016, 12:17
euhlmann's Avatar
euhlmann euhlmann is offline
CTO, Programmer
AKA: Erik Uhlmann
FRC #2877 (LigerBots)
Team Role: Leadership
 
Join Date: Dec 2015
Rookie Year: 2015
Location: United States
Posts: 322
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: Commands Ending Other Commands

Make them both call Requires(YourRollerSubsystem) and SetInterruptible(true) in the constructor. Wpilib will then take care of ending the running one when the other is called for you.
Reply With Quote
  #3   Spotlight this post!  
Unread 23-02-2016, 13:15
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: Commands Ending Other Commands

Quote:
Originally Posted by euhlmann View Post
Make them both call Requires(YourRollerSubsystem) and SetInterruptible(true) in the constructor. Wpilib will then take care of ending the running one when the other is called for you.
Thanks. I knew about the Requires, but I had no clue SetInterruptible was a thing. I'll add that in now.
__________________
Isaac
Chief of Programming and Head of Autonomous Control
FRC Team 1410
Reply With Quote
  #4   Spotlight this post!  
Unread 23-02-2016, 14:17
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Commands Ending Other Commands

Quote:
Originally Posted by euhlmann View Post
Make them both call Requires(YourRollerSubsystem) and SetInterruptible(true) in the constructor.
interruptable is true by default.
Reply With Quote
  #5   Spotlight this post!  
Unread 23-02-2016, 14:49
King Nerd III's Avatar
King Nerd III King Nerd III is offline
Chief Programmer/Head of Autonomous
AKA: Isaac
FRC #1410 (The Kraken)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Denver, CO
Posts: 113
King Nerd III is an unknown quantity at this point
Re: Commands Ending Other Commands

Quote:
Originally Posted by Joe Ross View Post
interruptable is true by default.
I thought that was the case, but calling a command that requires the same subsystem doesn't interrupt the original command for us. Any clue on how to fix this?
__________________
Isaac
Chief of Programming and Head of Autonomous Control
FRC Team 1410
Reply With Quote
  #6   Spotlight this post!  
Unread 24-02-2016, 13:31
Waz Waz is offline
Strategy and programming mentor
AKA: Steve
FRC #2357 (System Meltdown)
Team Role: Mentor
 
Join Date: Feb 2013
Rookie Year: 2009
Location: Raymore, MO
Posts: 12
Waz is an unknown quantity at this point
Re: Commands Ending Other Commands

Quote:
Originally Posted by King Nerd III View Post
I thought that was the case, but calling a command that requires the same subsystem doesn't interrupt the original command for us. Any clue on how to fix this?
We have never had a problem with this in several years of using the command based programming model. Is it possible that you have accidentally created two instances of the subsystem and the two commands each have their own? That could cause this behavior.

Hope this helps,
Steve
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 13:28.

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