Go to Post OK guys, the robot's overweight. You know the drill. - DonRotolo [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-18-2015, 06:02 PM
Jefferson Jefferson is offline
Registered User
AKA: Jeff Clements
FRC #0016 (Bomb Squad)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Mountain Home, AR
Posts: 257
Jefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant future
Re: Using a separate thread for driving motors?

Quote:
Originally Posted by lopsided98 View Post
Sorry for the misunderstanding: I meant that it will run away until you realize what is happening and press disable/e-stop, which isn't that big a problem.
But I still don't think that's the case. I don't believe separate threads outside the main robot thread can keep the robot alive if the main thread has died.
Reply With Quote
  #2   Spotlight this post!  
Unread 03-18-2015, 06:13 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Using a separate thread for driving motors?

Quote:
Originally Posted by Jefferson View Post
But I still don't think that's the case. I don't believe separate threads outside the main robot thread can keep the robot alive if the main thread has died.
Yes, your right. I'm more used to working with Java, where this is not the case, but in C++ (which I just realized the OP was using), exiting the main thread does cause all other threads to terminate.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #3   Spotlight this post!  
Unread 03-18-2015, 06:25 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,002
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: Using a separate thread for driving motors?

Quote:
Originally Posted by Jefferson View Post
I don't believe separate threads outside the main robot thread can keep the robot alive if the main thread has died.
Quote:
Originally Posted by lopsided98 View Post
Yes, your [sic] right... in C++, exiting the main thread does cause all other threads to terminate.
Jefferson wrote "if the main thread has died", and lopsided98 wrote "exiting the main thread".

So it's not yet clear if you are both saying exactly the same thing. It depends on Jefferson's intended meaning of "died": If the main thread is blocked or busy-waiting for an event that never occurs, it could be considered to have "died" but not "exited".



Last edited by Ether : 03-18-2015 at 06:30 PM.
Reply With Quote
  #4   Spotlight this post!  
Unread 03-18-2015, 06:33 PM
Ben Wolsieffer Ben Wolsieffer is offline
Dartmouth 2020
AKA: lopsided98
FRC #2084 (Robots by the C)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Manchester, MA (Hanover, NH)
Posts: 520
Ben Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud ofBen Wolsieffer has much to be proud of
Re: Using a separate thread for driving motors?

Ether brings up a good point. I was thinking about the case where the main thread finished its execution or threw an exception, in which case all other threads would exit.

But if for the main thread locked up without actually exiting or crashing (something that becomes more likely when you start communicating between multiple threads), the other threads (such as the one controlling the driving) could continue executing. Like I mentioned before, the e-stop/disable buttons would still be able to stop the robot in this case.
__________________



2016 North Shore District - Semifinalists and Excellence in Engineering Award
2015 Northeastern University District - Semifinalists and Creativity Award
2014 Granite State District - Semifinalists and Innovation in Control Award
2012 Boston Regional - Finalists
Reply With Quote
  #5   Spotlight this post!  
Unread 03-18-2015, 07:51 PM
connor.worley's Avatar
connor.worley connor.worley is offline
Registered User
FRC #0973 (Greybots)
Team Role: Mentor
 
Join Date: Mar 2011
Rookie Year: 2010
Location: Berkeley/San Diego
Posts: 598
connor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond reputeconnor.worley has a reputation beyond repute
Re: Using a separate thread for driving motors?

OP, would you mind posting your code? I would advise trying to find the root of the problem in the main thread rather than moving drive code out.
__________________
Team 973 (2016-???)
Team 5499 (2015-2016)
Team 254 (2014-2015)

Team 1538 (2011-2014)
2014 Driver (25W 17L 1T)
日本語でOK
Reply With Quote
  #6   Spotlight this post!  
Unread 03-18-2015, 07:57 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,002
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: Using a separate thread for driving motors?

Quote:
Originally Posted by connor.worley View Post
I would advise trying to find the root of the problem
ditto that.

Reply With Quote
  #7   Spotlight this post!  
Unread 03-19-2015, 02:21 AM
Jefferson Jefferson is offline
Registered User
AKA: Jeff Clements
FRC #0016 (Bomb Squad)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Mountain Home, AR
Posts: 257
Jefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant futureJefferson has a brilliant future
Re: Using a separate thread for driving motors?

Quote:
Originally Posted by Ether View Post
Jefferson wrote "if the main thread has died", and lopsided98 wrote "exiting the main thread".

So it's not yet clear if you are both saying exactly the same thing. It depends on Jefferson's intended meaning of "died": If the main thread is blocked or busy-waiting for an event that never occurs, it could be considered to have "died" but not "exited".


Good point. I meant exiting the main thread.

I'll throw in with everybody else and recommend finding the root cause of the motor safety errors in the first place.
Reply With Quote
  #8   Spotlight this post!  
Unread 03-19-2015, 11:59 AM
DanG100 DanG100 is offline
DanG!
FRC #2367
Team Role: Programmer
 
Join Date: Mar 2015
Rookie Year: 2013
Location: California
Posts: 6
DanG100 is an unknown quantity at this point
Re: Using a separate thread for driving motors?

This is the code for the robot, except all the camera code was commented out at competition.
https://github.com/Saint-Francis-Rob...367/FinalRobot
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