Log in

View Full Version : *** CMUcam2 Frequently-Asked-Questions ***


Kevin Watson
27-01-2006, 01:25
I've started a CMUcam2 frequently-asked-questions document here: http://kevin.org/frc/camera. If you have questions that you think should be added to the document, please post them here.

-Kevin

bear24rw
28-01-2006, 23:45
Q3: Where do we plug in the pan and tilt servos?
A3: By default the pan servo is attached to the robot controller's PWM 1 output and the tilt servo is plugged into the the robot controller's PWM 2 output. These assignments can be changed in camera.h.


Don't you mean "tracking.h" ?

Kevin Watson
29-01-2006, 00:09
Q3: Where do we plug in the pan and tilt servos?
A3: By default the pan servo is attached to the robot controller's PWM 1 output and the tilt servo is plugged into the the robot controller's PWM 2 output. These assignments can be changed in camera.h.


Don't you mean "tracking.h" ?DOH! Thanks for pointing that out <sheepish-grin>.

-Kevin

mallot1243
30-01-2006, 12:01
what is the difference in using the PWM outputs and the Servo0, 1 on the camera?

Kevin Watson
30-01-2006, 12:14
what is the difference in using the PWM outputs and the Servo0, 1 on the camera?The code currently uses the robot controller's PWM outputs to control the pan and tilt servos. I'm working on a version of tracking.c that will allow you to use robot controller or CMUcam2 PWM outputs. I'll post it if I can get it to work correctly.

-Kevin

Kevin Watson
30-01-2006, 22:08
The CMUcam2 Frequently-Asked-Questions document has been substantially updated in the last day or so. Included is a troubleshooting checklist. It can be found here: http://kevin.org/frc/camera.

-Kevin

Ryan O
31-01-2006, 19:35
In the thread titled "Code Errors with Bells and Whistles" I detailed a problem I encountered when I rewrote part of your code so the camera scans in both directions. Since you wrote the origanal, i was wondering if I possibly just left out a neccassary intailization line or something. Can you give any suggestions?

Kevin Watson
01-02-2006, 00:47
In the thread titled "Code Errors with Bells and Whistles" I detailed a problem I encountered when I rewrote part of your code so the camera scans in both directions. Since you wrote the origanal, i was wondering if I possibly just left out a neccassary intailization line or something. Can you give any suggestions?Send me the code and I'll have a look.

-Kevin

Ryan O
01-02-2006, 08:29
Send me the code and I'll have a look.

-Kevin


Ok, I e-mail it to you if it doesn't work. I made a couple changes. One things was to move the intailization to the very top of the code. Before, I was calling Tracking_Config_Data info before intailization, so that might have been the problem. If it was I'll post here to let you know that it was fixed. Otherwise I should have it sent by five tonight. Thanks for the help.

mallot1243
08-02-2006, 11:57
Can you use a different motor to control pan function? if so what would the code have to look like?

bhsrobotics1671
08-02-2006, 18:40
I've started a CMUcam2 frequently-asked-questions document here: http://kevin.org/frc/camera. If you have questions that you think should be added to the document, please post them here.

-Kevin


how do you re-upload the tracking.h file to the camera again after modifying it?

thankss
-bunch of freshman noobs from clovis, CA
team 1671

X-Istence
08-02-2006, 18:46
Can you use a different motor to control pan function? if so what would the code have to look like?

Different :P. First, the motor does not have PWM versus Angle, thus you'd have to find some method of finding how to fix it so that it did, then you'd have to figure out how you want to keep track of what angle it is at. Basically it is complicated.

nehalita
08-02-2006, 18:55
1) I was trying to drive the robot and operate the camera at the same time so I enabled "Default_Routine" in the Process_Data_From_Master_uP function but I think it conflicted with the camera code (i'm not sure if that's right) because the camera wouldn't work at all. So I just put whatever I needed before "putdata" [the pwms, relays, etc.]
i don't know if my assumptions were right or if i messed up but i think you should address this in some form of a question (that I obviously can't come up with right now).

2) This is a stupid mistake, but someone else might have done it before. If you "accidentally" switch the servos hooked up to the RC, you get that "searching searching searching" thing also and it took me an hour to figure that one out (it's always gotta be the simple things that take forever to figure out).

3) I think you should put something at the top or inside the code about being careful when you load the code for the first time. I had the pwms hooked up to the camera and my motors hooked up to pwm01 and pwm02. So, as the camera tracked the green light, the robot went crazy and i nearly killed myself. After reading the FAQs, I figured out why but maybe if there's a warning somewhere inside the code, it won't happen to another team.

4) When i started using the camera for the first few times, i had the serial cable hooked up to the camera along with the pwm to the ttl port. It's obvious to me now that I can't have both hooked up to the camera at the same time but it wasn't then. You could put that in your FAQs

....those are all the mistakes i can remember but i'm sure i have plenty more to come. =)

btw, after my series of errors, my camera worked wonderfully. you're the man kevin. my whole team's amazed how "i got" the camera to dance around but really, it was all your hard work and i got the credit for it. great job.
oh, and the FAQs helped a lot!

bhsrobotics1671
08-02-2006, 19:23
I've started a CMUcam2 frequently-asked-questions document here: http://kevin.org/frc/camera. If you have questions that you think should be added to the document, please post them here.

-Kevin


Kevin We Need Your Help Re-Uploading the tracking.h file

Anyone!?!?!?

mallot1243
09-02-2006, 11:00
I should have explained my self a little more. We're planning on taking the pan servo off and using the code to control a turret, is there a way to develope a potentiometer structure in replacement of the servo function?

http://www.danasoft.com/sig/Mallot.jpg

Alan Anderson
09-02-2006, 12:32
...is there a way to develope a potentiometer structure in replacement of the servo function?
Absolutely. What you want is something called PID position control. Search the forums for PID and you'll find plenty of pointers.

Briefly, you control the motor speed based on the difference between the desired and measured position (in order to move it into place), modified by the rate at which the difference is changing (in order to keep it from overshooting), with a term that pushes harder as it's out of place longer (in order to nudge it if it settles a little short of the target).

Keith Watson
09-02-2006, 13:27
Kevin We Need Your Help Re-Uploading the tracking.h file

Anyone!?!?!?I haven't tried it yet but it appears to be in target.c in the function Initialize_Tracking(). Look for the call to Get_Tracking_Configuration() and see what the second parameter is used for.

nheft
09-02-2006, 14:55
We ended up using the pan servo to pan the camera, then use the data to the pan servo to run a motor that steers our turret. In effect, the turret motor keeps the camera steered to the target. When the pan servo is looking straight ahead, the turret motor stops. When the pan servo is off-center, the turret motor turns the whole business in the required direction to get pan servo looking straight ahead. If the tracker is searching rather than tracking, we disable the turret motor until the tracker acquires the target. You can test if the tracker has acquired the target by examining T_Packet_Data.my. Zero signifies searching; nonzero signifies tracking.

Can you use a different motor to control pan function? if so what would the code have to look like?

bhsrobotics1671
10-02-2006, 00:37
I haven't tried it yet but it appears to be in target.c in the function Initialize_Tracking(). Look for the call to Get_Tracking_Configuration() and see what the second parameter is used for.


okay thanks but i need to know how to re-upload those config files to the camera...
thanks

nehalita
10-02-2006, 00:46
okay thanks but i need to know how to re-upload those config files to the camera...
thanks

is this what you are talking about?
Do this by copying the two files to your project directory and then right clicking on "Source Files" in the
project tree, selecting "Add Files...", if necessary, navigate to the project directory and then double click on the file you need

that was in the readme file under "other files" you should check them out, they give a nice summary of all the files.

bhsrobotics1671
10-02-2006, 00:50
is this what you are talking about?


that was in the readme file under "other files" you should check them out, they give a nice summary of all the files.


THANKS SO MUCH

we'll check it out
we got the pan to work but just not the tilt, and were not using pan i do not think..so yeah..big help

thanks!

bhsrobotics1671
10-02-2006, 00:55
is this what you are talking about?


that was in the readme file under "other files" you should check them out, they give a nice summary of all the files.

hey side note: what program are you using to do this?

Keith Watson
10-02-2006, 01:01
okay thanks but i need to know how to re-upload those config files to the camera...
thanksPreviously you mentioned tracking.h. We encountered the same problem where changing values in tracking.h were not taking effect. From reading the code this appears to be the place which controls it.* FUNCTION: Get_Tracking_Configuration()
*
* PURPOSE: Initializes the Tracking_Config_Data structure with data
* stored in EEPROM. If valid data isn't present in EEPROM
* or the force_default flag is set, default values from
* tracking.h will be used.
*
* CALLED FROM: Initialize_Tracking(), above
*
* PARAMETERS: Calling this function with a value greater than zero will
* force it to load the configuration structure with the
* default values found in tracking.h.

Were you asking about something else?

bhsrobotics1671
10-02-2006, 01:10
Previously you mentioned tracking.h. We encountered the same problem where changing values in tracking.h were not taking effect. From reading the code this appears to be the place which controls it.* FUNCTION: Get_Tracking_Configuration()
*
* PURPOSE: Initializes the Tracking_Config_Data structure with data
* stored in EEPROM. If valid data isn't present in EEPROM
* or the force_default flag is set, default values from
* tracking.h will be used.
*
* CALLED FROM: Initialize_Tracking(), above
*
* PARAMETERS: Calling this function with a value greater than zero will
* force it to load the configuration structure with the
* default values found in tracking.h.

Were you asking about something else?


ok so my programmer guy know about these files, and knows how to change the data and what to change it too, we just need to know how to re-upload these config files i guess you could call them (i.e. tracking.h traching.c) to the camera's programming, and what program you use to do this

--thanks for all your help guys

Kevin Watson
10-02-2006, 01:20
Previously you mentioned tracking.h. We encountered the same problem where changing values in tracking.h were not taking effect... You can also just select "Load default values" from either menu to get the values from the header file. Don't forget to save to EEPROM.

-Kevin

Keith Watson
10-02-2006, 02:03
ok so my programmer guy know about these files, and knows how to change the data and what to change it too, we just need to know how to re-upload these config files i guess you could call them (i.e. tracking.h traching.c) to the camera's programming, and what program you use to do this

--thanks for all your help guysIf your programmer is including tracking.c in your software build then nothing special needs to be done after changing the parameter I mentioned. It is contained in code that is already being run. Just do a normal rebuild and a normal download to the robot controller. This will pick up the change.

nehalita
10-02-2006, 16:28
bhsrobotics1671: We are using MPLAB IDE v7.20; it came in a cd in the kit of parts. If you go to kevin watson's website, http://kevin.org/frc, you can dl the code and everything you could possibly need is in there. then go read the FAQs and you'll avoid many mistakes you might end up making

arizonafoxx
20-01-2007, 14:01
When we tested the camera code it works perfectly. The camera will track the green light. We have our programming cable hooked up so that we get our Pan and Tilt angles displayed on the computer screen. Our question is what variable can we use from the code to take the Pan angle displayed on the computer and use it to change the position of the robot. We want to use a comparison statement like:

Psuedo Code
if(Pan_Angle > 10)
{
Turn robot left
}

if(Pan_Angle < -10)
{
Turn Robot right
}

if(Pan_Angle > -10 && Pan_Angle < 10)
{
Robot does not turn
}

We also want to do a similar thing with the tilt to calculate the distance. This is my first year with FRC but I am very familar with C programming and MPLab. I have looked through Kevin's code but I can't figure out what variable will acvhive our desired output. If anyone knows what i'm talking about please help me out.

The Vrooman
20-01-2007, 17:21
We have our camera working fine in teleoperated mode, but for some reason, we can't get it to work in autonomous mode. The red light comes on when the target is in front of the camera lens, but the camera will not actively search for a target, and it won't follow the target once we set it in position.

Is there something that needs to be added to user_routines_fast that activates the camera in autonomous?

Alan Anderson
20-01-2007, 17:49
Is there something that needs to be added to user_routines_fast that activates the camera in autonomous?

Indeed there is. You need to call the same CameraHandler() and ServoTrack() functions that Process_Data_From_Master_uP() does. Make sure you put them in the part of the autonomous loop that only executes once for each data packet from the OI.

The Vrooman
20-01-2007, 18:15
Indeed there is. You need to call the same CameraHandler() and ServoTrack() functions that Process_Data_From_Master_uP() does. Make sure you put them in the part of the autonomous loop that only executes once for each data packet from the OI.

We have already tried to place those function calls into various places in user_routines_fast.c to no avail.
Where and how specifically do these function calls go in the code?

Also how do we disable the camera from searching in the teleoperated period?

Thanks

Alan Anderson
20-01-2007, 19:56
We have already tried to place those function calls into various places in user_routines_fast.c to no avail.
Where and how specifically do these function calls go in the code?
I don't have a specific answer right now. Maybe someone else can help before I get back to the code next week.
Also how do we disable the camera from searching in the teleoperated period?
That's easy -- just don't call the ServoTrack() routine.

Phalanx
20-01-2007, 21:07
We have already tried to place those function calls into various places in user_routines_fast.c to no avail.
Where and how specifically do these function calls go in the code?
Thanks

We coded them here last season in user_routines_fast.c which worked perfectly.

while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
Camera_Handler(); //You must call BOTH of these
Servo_Track(); //functions to use the camera

The Vrooman
22-01-2007, 09:23
We coded them here last season in user_routines_fast.c which worked perfectly.

while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
Camera_Handler(); //You must call BOTH of these
Servo_Track(); //functions to use the camera

We added this into the code, and the camera sees the target and tracks it during autonomous.

Thank you very much for that!!! :D

Although it isn't printing any of the info about the camera on the terminal window.

I don't know if it isn't getting the info in the first place, or is it just not printing it out.

Please help

The Vrooman
22-01-2007, 10:16
We added this into the code, and the camera sees the target and tracks it during autonomous.

Thank you very much for that!!! :D

Although it isn't printing any of the info about the camera on the terminal window.

I don't know if it isn't getting the info in the first place, or is it just not printing it out.

Please help

I played around with it some more, and then I realized that I was putting things in the wrong places.

I moved them to the correct places, and then amazingly it worked.

It printed out all the things that I wanted it to printing out and all was good.

So once again thank you for all that you did to help us.

sniggel
24-01-2007, 23:05
Ok this is really a newbie question, but we are trying to get the robot into autonomous mode, we dont have a dongle and not sure if we have what we need to make one. In the documentation from innovation first I saw you can force autonomous mode by setting the team to 0000. will this work? we got kevins code working, but when we tried the 2007 easy c demo it doesnt work. I realized it needed autonomous mode, tried resetting team to 0000 and still the camera doesnt work. The program runs because we get prints from the intialize code, but nothing from the autonomus module. My students are more comfortable with easy c , if possible I would like to get this the easy c 2007 demo code up and running, I think it would be easier for them to deal with.
Has any one had success with this, and am I right that the 2007 demo code for easy c only works in autonomous mode.

DanDon
24-01-2007, 23:23
Yes, you would need to kick the robot into autonomous mode for the 2007 demo code to work. If you want, you can buy an autonomous dongle from andymark.biz here: http://andymark.biz/am-0016.html . Hope this helps, /dan

sniggel
28-01-2007, 16:42
Helps a lot! we are now able to get autonomous mode, the 0000 team number into the controller does not work this year

adengler
28-01-2007, 17:41
This is probably a really stupid question but I see you guys talking about this tracking.h and tracking.c files etc. and I have no clue where to get them. The only one I could find was the CameraDemo folder off of the team resources section of the FIRST website. Where can I get these so I can get cracking on this camera?

lukevanoort
28-01-2007, 17:48
This is probably a really stupid question but I see you guys talking about this tracking.h and tracking.c files etc. and I have no clue where to get them. The only one I could find was the CameraDemo folder off of the team resources section of the FIRST website. Where can I get these so I can get cracking on this camera?

http://kevin.org/frc (http://kevin.org/frc/)