Go to Post ...I've changed my position. I'm fully supportive of Joe's suggestion... - Chris Hibner [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 07-02-2017, 17:03
ebernerrd ebernerrd is offline
Registered User
FRC #3236
 
Join Date: Jan 2017
Location: Franklin, MA
Posts: 8
ebernerrd is an unknown quantity at this point
Command stops my teleop process

Hey there again!
I've been writing my program in a command-based format. This works fine until I try to run a program through a joystick button. My command runs, but halts my teleop program.

I am not sure what code is useful in this situation. My TeleopDefault.h and .cpp are my teleop control scheme, and I have other commands like "DropGear" and "DropFuel". When I use a joystick buttons' ->WhenPressed() to run the DropGear command, the TeleopDefault stops and does not return.

Any reason for this?
Thank you. I will post code if someone knows which files are needed to diagnose the problem.
-Eric
Reply With Quote
  #2   Spotlight this post!  
Unread 07-02-2017, 18:01
SamCarlberg's Avatar
SamCarlberg SamCarlberg is offline
GRIP, WPILib. 2084 alum
FRC #2084
Team Role: Mentor
 
Join Date: Nov 2015
Rookie Year: 2009
Location: MA
Posts: 161
SamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to beholdSamCarlberg is a splendid one to behold
Re: Command stops my teleop process

Sounds like you have a loop in the commands initialize or execute method
__________________
WPILib
GRIP, RobotBuilder
Reply With Quote
  #3   Spotlight this post!  
Unread 08-02-2017, 14:34
ebernerrd ebernerrd is offline
Registered User
FRC #3236
 
Join Date: Jan 2017
Location: Franklin, MA
Posts: 8
ebernerrd is an unknown quantity at this point
Re: Command stops my teleop process

If I place a return statement at the end of the execute statement, should I be okay? Because at the moment I have something like this
Code:
TeleopDefault::Initialize(){
//some code
     button->WhenPressed(new DropGear());
     button->WhenReleased(this);
}
This almost works for now. I will look into it a bit further.
Reply With Quote
  #4   Spotlight this post!  
Unread 08-02-2017, 14:55
GavinL GavinL is offline
intensely stares at program
FRC #5726 (RhumBotz)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2016
Location: San Antonio, Texas
Posts: 46
GavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to behold
Re: Command stops my teleop process

Are you sure the "button->WhenPressed" stuff should be in initialized?
I'm a bit new to command based but I feel like that should belong in your Execute.
It should go in OI, above text is wrong.

Last edited by GavinL : 09-02-2017 at 00:53. Reason: wrong info
Reply With Quote
  #5   Spotlight this post!  
Unread 08-02-2017, 15:01
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,770
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Command stops my teleop process

Quote:
Originally Posted by ebernerrd View Post
If I place a return statement at the end of the execute statement, should I be okay? Because at the moment I have something like this
Code:
TeleopDefault::Initialize(){
//some code
     button->WhenPressed(new DropGear());
     button->WhenReleased(this);
}
This almost works for now. I will look into it a bit further.
I believe he was referring to a loop in the DropGear command initializer or execute method. These methods should return quickly (milliseconds or less), not have the loop that goes through the entire process of dropping a gear internal to the command. Let the command based robot infrastructure do that.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #6   Spotlight this post!  
Unread 08-02-2017, 17:27
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,603
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: Command stops my teleop process

Quote:
Originally Posted by GavinL View Post
Are you sure the "button->WhenPressed" stuff should be in initialized?
I'm a bit new to command based but I feel like that should belong in your Execute.
It should go in OI, not in a command.
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2017, 00:51
GavinL GavinL is offline
intensely stares at program
FRC #5726 (RhumBotz)
Team Role: Programmer
 
Join Date: Jan 2016
Rookie Year: 2016
Location: San Antonio, Texas
Posts: 46
GavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to beholdGavinL is a splendid one to behold
Re: Command stops my teleop process

Quote:
Originally Posted by Joe Ross View Post
It should go in OI, not in a command.
yeah your right, my bad
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:20.

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