Go to Post (Yes, I'm that much of a dork.) - Madison [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 29-02-2012, 19:10
Michael_Lee Michael_Lee is offline
Registered User
FRC #2976
 
Join Date: Jan 2012
Location: Issaquah, WA
Posts: 21
Michael_Lee is an unknown quantity at this point
How to tell if hardware component is detached?

How can a program tell if a component on the robot is working/attached or not?

For example, if I wrote...

Code:
void MyFunction()
{
    Jaguar *j = new Jaguar(3);
    j->Set(1.0);
}
... how can I tell if the Jaguar is actually responsive and connected to the cRIO? What about for a camera? For joysticks?
Reply With Quote
  #2   Spotlight this post!  
Unread 29-02-2012, 21:04
Sharpes Sharpes is offline
Registered User
FRC #3815 (Raider Robotics)
Team Role: Electrical
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Cumming, GA
Posts: 1
Sharpes is an unknown quantity at this point
Re: How to tell if hardware component is detached?

Well. First make sure the Jag has power. When you turn on your robot, your Jaguar should have a yellow flashing light.

Enable the code, and that light should stay solid. Solid yellow light means it's connected.

If you were to use the axis a Jaguar was on, it would change from a yellow solid light to a green light in 1 direction, and red in the other.

The camera, I'm not exactly sure of the process of seeing if it's connected or not.

Joysticks should be listed in the Driver station if they are working. I believe under Diagnostics.
Reply With Quote
  #3   Spotlight this post!  
Unread 29-02-2012, 21:17
Michael_Lee Michael_Lee is offline
Registered User
FRC #2976
 
Join Date: Jan 2012
Location: Issaquah, WA
Posts: 21
Michael_Lee is an unknown quantity at this point
Re: How to tell if hardware component is detached?

Sorry, I meant to ask how I can programmatically determine that so that if, for example, the camera is disconnected, the code will recognize that and just skip over the piece that uses it.
Reply With Quote
  #4   Spotlight this post!  
Unread 29-02-2012, 23:10
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: How to tell if hardware component is detached?

Why do you need to dynamically skip over the code? We use #ifdef to enclose code for some components such as Vision, so if we don't have the camera connected, that code won't compile. Isn't that good enough?
__________________
Reply With Quote
  #5   Spotlight this post!  
Unread 29-02-2012, 23:19
Michael_Lee Michael_Lee is offline
Registered User
FRC #2976
 
Join Date: Jan 2012
Location: Issaquah, WA
Posts: 21
Michael_Lee is an unknown quantity at this point
Re: How to tell if hardware component is detached?

Call me paranoid, but I'm worried about the robustness of the robot. For example, if a wire somehow comes loose during the competition, I'd like to have an error message pop up so we can diagnose it later and continue playing, and still be assured that the robot will continue to function and not accidentally go haywire.
Reply With Quote
  #6   Spotlight this post!  
Unread 29-02-2012, 23:27
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 671
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: How to tell if hardware component is detached?

Well then, if you want to do the work. Unfortunately, different components have different ways to report failures. For example, if you are using CANJaguar, WPILib will set error status when an operation failed. So in theory, you can query this status.
So for each component that you wish to write recovery code for, you need to look through the source code of WPILib and find a way to "poll" the health status of the hardware. CANJaguar is an easy one. If you are using PWM for Jaguars, that may be harder. Since PWM is an output only signal. So there is no feedback you can examine. Regarding camera, I haven't looked through it in too much details, but it seems the camera task also has some sort of status that you may be able to query. Like I said, if you want to do the work, you need to dig into the source code of WPILib.
__________________
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 03: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