Go to Post As Frank said, when an FRC team hurts, we all hurt. - Hallry [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 30-11-2007, 21:10
ruddy ruddy is offline
Registered User
FRC #1261
 
Join Date: Nov 2007
Location: Georgia
Posts: 16
ruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to behold
help getting servo values from camera

I'm not very experienced in C so I was hoping someone could help me out. I'm trying to get the PWM values of the camera servos so i can use them in my code. Is there a function that returns these values? Is there a function that says if its locked on or searching? last thing, i went into the camera menu through the IFI loader, and Kevin said to adjust the pan gain if the camera is oscilating, but i didnt find that option. Thanks a bunch for the help
  #2   Spotlight this post!  
Unread 30-11-2007, 21:35
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,132
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: help getting servo values from camera

Since the default code just uses PWMs 1 and 2 for the camera servos, you should be able to just read the values in directly from the pwm01 and pwm02 variables at any point in the loop after the Camera_Handler() function is called.

As for knowing if the camera is locked on, you can use the camera confidence value - the higher it is, the more sure the camera is that it is locked on to a target. There's a predefined threshold macro (its default value is 20), so you can just do something like this:
Code:
if (T_Packet_Data.confidence >= CONFIDENCE_THRESHOLD_DEFAULT)
{
  // locked on
}
else
{
  // searching
}
Edit: Alternately, you can call the Get_Tracking_State() function, which will return SEARCHING, TARGET_IN_VIEW, or CAMERA_ON_TARGET.

I've never used the camera menu, so unfortunately I can't help you with the last point.
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com

Last edited by Pat Fairbank : 30-11-2007 at 21:39.
  #3   Spotlight this post!  
Unread 30-11-2007, 21:35
Tottanka's Avatar
Tottanka Tottanka is offline
It isnt about bots,its about humans
AKA: Liron Gurvitz
FRC #3211 (The Y Team)
Team Role: Mentor
 
Join Date: Dec 2006
Rookie Year: 2006
Location: Hadera, Israel
Posts: 1,418
Tottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond reputeTottanka has a reputation beyond repute
Re: help getting servo values from camera

Code:
// Tracking_State values
#define STATE_SEARCHING 0
#define STATE_TARGET_IN_VIEW 1
#define STATE_PAN_ON_TARGET 2
#define STATE_TILT_ON_TARGET 4
those are the camera state values.


about the PWMS of noyur servos, you should be able to get them simply be reading the values of your pwms for them (default is 1 and 2).
__________________
My FRC record: 10 Years,FTA (2008-9), 3 Teams(1947,2669,3211).3 RCA, 1 Championship EI(2016), 1 Divisional finalist (2016), 1 Regional winner.
Israeli 2016 Volunteer of the year.
  #4   Spotlight this post!  
Unread 30-11-2007, 21:38
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: help getting servo values from camera

Okay, I'll address this question by question:

1)Is there a function that returns camera PWM values?
Short Answer: No, you don't need one, the PWM value is just a variable you can access in your code.
Long Answer: If you look in tracking.h you'll find two #define statements with which you can change the PWMs for the pan/tilt servos. If you look at these you'll note they say something like "#define PAN_SERVO pwm07" if that was the case the PWM in use would be the seventh one. In other parts of the program, you can read the value of pwm07 (or whatever pwm the servo is set to) just like any other variable. EDIT: Whoops, I just realized that this advice only applies to the Streamlined version. If you are using Bells and Whistles, I think you can change it in the menu, but I am not certain. EDIT2: My previous edit was wrong, the Bells and Whistles code's PWMs are changed in the same as the Streamlined's. Now that I think about it, it makes sense to do it that way--having the PWM assignment menu configurable would be dangerous.


2)Is there a function that says if the camera is locked on?
Short Answer: Yes. Get_Tracking_State() in tracking.c.
Long Answer: When you call Get_Tracking_State, the function will return a 0 if it is searching; 1 if the target is in view, but the camera is not locked on; or 2 if the camera is locked on.

3)How do I adjust pan gain?
Long Answer: This depends on the version on Kevin's code that you are using. In the Bells and Whistles code, it should be changeable in the tracking menu (I don't know where, I don't use the Bells and Whistles version); in the Streamlined version, you should be able to change it in tracking.h. In tracking.h, there is a #define statement for "PAN_GAIN_DEFAULT." Changing the number "PAN_GAIN_DEFAULT" is being defined as (by default, 3) will change the pan gain. Note of caution: don't use decimals, they will be truncated in the camera code. EDIT: To change the pan gain in the Bells and Whistles version, type 't' at the terminal and you should see the option for it.
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain

Last edited by lukevanoort : 30-11-2007 at 22:26. Reason: I really should stop posting when I am sleepy...
  #5   Spotlight this post!  
Unread 30-11-2007, 21:49
ruddy ruddy is offline
Registered User
FRC #1261
 
Join Date: Nov 2007
Location: Georgia
Posts: 16
ruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to behold
Thumbs up Re: help getting servo values from camera

Quote:
Originally Posted by Tottanka View Post
Code:
// Tracking_State values
#define STATE_SEARCHING 0
#define STATE_TARGET_IN_VIEW 1
#define STATE_PAN_ON_TARGET 2
#define STATE_TILT_ON_TARGET 4
.
As I said I'm a c noob. Are these variables predefined in the code, or should I define it in User_routines.c? Could I do something like:

if(STATE_TARGET_IN_VIEW == 1) {
// code...
}

thanks again
  #6   Spotlight this post!  
Unread 30-11-2007, 21:51
ruddy ruddy is offline
Registered User
FRC #1261
 
Join Date: Nov 2007
Location: Georgia
Posts: 16
ruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to behold
Re: help getting servo values from camera

Quote:
Originally Posted by lukevanoort View Post
Okay, I'll address this question by question:

1)Is there a function that returns camera PWM values?
Short Answer: No, you don't need one, the PWM value is just a variable you can access in your code.
Long Answer: If you look in tracking.h you'll find two #define statements with which you can change the PWMs for the pan/tilt servos. If you look at these you'll note they say something like "#define PAN_SERVO pwm07" if that was the case the PWM in use would be the seventh one. In other parts of the program, you can read the value of pwm07 (or whatever pwm the servo is set to) just like any other variable. EDIT: Whoops, I just realized that this advice only applies to the Streamlined version. If you are using Bells and Whistles, I think you can change it in the menu, but I am not certain.


2)Is there a function that says if the camera is locked on?
Short Answer: Yes. Get_Tracking_State() in tracking.c.
Long Answer: When you call Get_Tracking_State, the function will return a 0 if it is searching; 1 if the target is in view, but the camera is not locked on; or 2 if the camera is locked on.

3)How do I adjust pan gain?
Long Answer: This depends on the version on Kevin's code that you are using. In the Bells and Whistles code, it should be changeable in the tracking menu (I don't know where, I don't use the Bells and Whistles version); in the Streamlined version, you should be able to change it in tracking.h. In tracking.h, there is a #define statement for "PAN_GAIN_DEFAULT." Changing the number "PAN_GAIN_DEFAULT" is being defined as (by default, 3) will change the pan gain. Note of caution: don't use decimals, they will be truncated in the camera code.
Great, thanks! Thats what I wanted to know about the search state function.
  #7   Spotlight this post!  
Unread 30-11-2007, 22:00
ruddy ruddy is offline
Registered User
FRC #1261
 
Join Date: Nov 2007
Location: Georgia
Posts: 16
ruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to behold
Re: help getting servo values from camera

i tried using the function Get_Tracking_State but i get the error "could not find definition of symbol 'Get_Tracking_State' in file"
Any suggestions?
  #8   Spotlight this post!  
Unread 30-11-2007, 22:02
Pat Fairbank's Avatar
Pat Fairbank Pat Fairbank is offline
Circuit Breaker
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2001
Location: San Jose, CA
Posts: 2,132
Pat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond reputePat Fairbank has a reputation beyond repute
Send a message via MSN to Pat Fairbank
Re: help getting servo values from camera

Just put this at the top of whatever file you're writing in:
Code:
#include "tracking.h"
__________________
Patrick Fairbank
Team 254 | Mentor (2012-)
Team 1503 | Mentor (2007-2011)
Team 296 | Alumnus (2001-2004) | Mentor (2005-2006)

patfairbank.com
  #9   Spotlight this post!  
Unread 30-11-2007, 22:09
ruddy ruddy is offline
Registered User
FRC #1261
 
Join Date: Nov 2007
Location: Georgia
Posts: 16
ruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to behold
Re: help getting servo values from camera

Quote:
Originally Posted by Pat Fairbank View Post
Just put this at the top of whatever file you're writing in:
Code:
#include "tracking.h"
It already has been.
  #10   Spotlight this post!  
Unread 30-11-2007, 22:18
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: help getting servo values from camera

Quote:
Originally Posted by ruddy View Post
It already has been.
That's weird. Can you post which version of Kevin's code you are using (streamlined vs bells & whistles) and how you are calling the Get_Tracking_State() function?
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #11   Spotlight this post!  
Unread 30-11-2007, 22:30
ruddy ruddy is offline
Registered User
FRC #1261
 
Join Date: Nov 2007
Location: Georgia
Posts: 16
ruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to behold
Re: help getting servo values from camera

Quote:
Originally Posted by lukevanoort View Post
That's weird. Can you post which version of Kevin's code you are using (streamlined vs bells & whistles) and how you are calling the Get_Tracking_State() function?

if(Get_Tracking_State() == X) {
//do code
}
  #12   Spotlight this post!  
Unread 30-11-2007, 22:50
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: help getting servo values from camera

Now I'm really puzzled. I just compiled some camera code with
Code:
if (Get_Tracking_State() == 2)
{
//do stuff
}
in user_routines.c->Default_Routine() file and it worked fine. I tried removing tracking.h from the includes and got something errors, but not the same as yours. Judging from this thread, it appears that this problem has been encountered before and is caused by misspellings/miscapitalization, and Kevin Watson himself suggests here that it can be caused by overly long directory names. If neither one of those works, I'm out of ideas.
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
  #13   Spotlight this post!  
Unread 30-11-2007, 23:18
ruddy ruddy is offline
Registered User
FRC #1261
 
Join Date: Nov 2007
Location: Georgia
Posts: 16
ruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to beholdruddy is a splendid one to behold
Re: help getting servo values from camera

wow good find. i had the same bug as him. i didnt know you couldn't have a space in your if statement..
Thanks
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Servo Values to Degrees... How? mogunus Programming 16 11-04-2007 02:03
Servo input values bush Motors 5 03-02-2006 18:49
Finding the *final* Servo Center values? Andrew Blair Programming 2 22-01-2006 18:02
Servo Values DanDon Motors 8 14-02-2005 15:49
Dashboard View of Pan and Tilt Servo Values JoeXIII'007 Programming 1 02-02-2005 22:34


All times are GMT -5. The time now is 19:39.

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