![]() |
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 :)
|
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)I've never used the camera menu, so unfortunately I can't help you with the last point. |
Re: help getting servo values from camera
Code:
// Tracking_State valuesabout 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). |
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. |
Re: help getting servo values from camera
Quote:
if(STATE_TARGET_IN_VIEW == 1) { // code... } thanks again |
Re: help getting servo values from camera
Quote:
|
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? |
Re: help getting servo values from camera
Just put this at the top of whatever file you're writing in:
Code:
#include "tracking.h" |
Re: help getting servo values from camera
Quote:
|
Re: help getting servo values from camera
Quote:
|
Re: help getting servo values from camera
Quote:
if(Get_Tracking_State() == X) { //do code } |
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) |
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.. :yikes:
Thanks |
| All times are GMT -5. The time now is 13:52. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi