Go to Post The holiday season is formally known as "kick-off rendering season" - dlavery [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-01-2006, 22:06
Steve Orr's Avatar
Steve Orr Steve Orr is offline
iusorr
FRC #1293 (D5Robotics)
Team Role: Coach
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Irmo, South Carolina
Posts: 8
Steve Orr is an unknown quantity at this point
Send a message via AIM to Steve Orr Send a message via Yahoo to Steve Orr
Moving robot while tracking with camera questions...

I have the camera functioning correctly and have used LabView as well as the RC camera code to have it track properly from good distances so I am ready to move forward but have run into some questions. I have read countless threads here and can't get to the bottom of these questions...

1. If I want to use the camera for autonomous mode, do I need to add #include statements in user_routines_fast.c referencing the camera, tracking, eeprom, and terminal c and h files (as in the user_routines.c file)?

2. In order to drive motors in autonomous, I am guessing that all I need to do is generate code calling on data sent from the camera to control my drive train pwm's (13 and 15) in the section that says /* Add your own autonomous code here. */ ... Is this correct and what exactly are the variables called for blob size, and pan or tilt positions relative to the target? (or do I need to calculate things like blob size as in terminal.c?)

3. It looks like underneath the camera code in user_routines.c that all of the pwm's are reset to neutral (127) and should work as the camera is tracking. Yet, I realize for safety, something has been commented in order to keep us from driving the robot as camera is tracking, and that pwm01 should not be used for the camera and the port 1 y-axis. Can you help me get the robot moving via joystick input (while tracking!) by pointing me to the code I need to consider? Should I just comment out pwm 1-3 joystick mapping so I don't use them for anything but the camera?


4. Once I get the robot moving via OI input from the joysticks, I kind of need to repeat part of question 1 because I don't know where to call the variables that have the info I need to aim my shooter. (i.e. what are the specific names of the variables which tell me target position within the screen as it is tracking, or do I need to define those as done in the printf statements in terminal.c?)


I hope I am not out of line by asking for these clarifications, but I am trying to learn this while burning too many candles in too many areas outside of FIRST... I really want my students to learn this and have the experience of FIRST, but I don't have the personnel I need to assist me and I feel like I almost have it. I'm missing a little of the big picture because of the way the code is compartmentalized. It is truly awesome seeing what you guys are able to offer, and working through understanding it. Yet, I can't get to the creative part and it is driving me a little bonkers. I am just one marble short of putting it all together. It must be one of the many I have lost over the past 2 weeks...

Any assistance you could offer would be much appreciated!

Steve Orr
D5Robotics : Team 1293
__________________
S.Orr
D5Robotics : Team 1293
Irmo, SC
  #2   Spotlight this post!  
Unread 30-01-2006, 22:22
bush's Avatar
bush bush is offline
Registered User
AKA: Aaron
FRC #0710 (Pine Crest School)
Team Role: Programmer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Fort Lauderdale, Florida
Posts: 42
bush has a spectacular aura aboutbush has a spectacular aura about
Send a message via AIM to bush
Re: Moving robot while tracking with camera questions...

1. You might want to #include camera.h which will give the autonomous code access to the T_Packet_Data (camera) variables.

2. You are correct. The tracking code automatically moves the servos to get the target in the center of the camera's field of view. The variables that the camera gives you are T_Packet_Data.mx, T_Packet_Data.my, T_Packet_Data.x1, T_Packet_Data.x2, T_Packet_Data.y1, T_Packet_Data.y2, T_Packet_Data.pixels, T_Packet_Data.confidence. mx and my are the coordinates of the center mass of the target. x1, y1, x2, and y2 are the coordinates for the bounding rectangle of the target. pixels is the blob size, and confidence relates to how close the actual target color is to the pre-programmed target color. The servo positions are accessed via PWM. You can use the constants PAN_SERVO and TILT_SERVO to get the positions.

3. If you map your drive train PWM's to the joysticks and don't mess with the PWM's that control the 2 servos, then you won't have any problems.

4. See #2 for the variables.
  #3   Spotlight this post!  
Unread 30-01-2006, 22:54
6600gt's Avatar
6600gt 6600gt is offline
Registered User
AKA: Lohit
FRC #0226 (Hammerhead)
Team Role: Alumni
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Troy, MI
Posts: 221
6600gt is a jewel in the rough6600gt is a jewel in the rough6600gt is a jewel in the rough
Re: Moving robot while tracking with camera questions...

You might want to use trig fuctions to calculate the horizontal distance of target.

first include <math.h> where ever you want to do the trig calculations.

then look in terminal.c for the pan angle and tilt angle ratios
65/124 degrees for every pan pwm increment and 25/50 degrees for every tilt pwm increment

going to have to make it output 0 degrees when looking completely horizontal
adjust the -124 value

then just set up the equation
target_distance = height/tan(tilt_angle)

height = the vertical distance between the camera on the robot and the green light.

you can just make pwm03 = p1_y for example

you need to uncomment the default() function and remember to comment out the pwm's being used by the camera

Last edited by 6600gt : 30-01-2006 at 22:58.
  #4   Spotlight this post!  
Unread 31-01-2006, 22:59
Steve Orr's Avatar
Steve Orr Steve Orr is offline
iusorr
FRC #1293 (D5Robotics)
Team Role: Coach
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Irmo, South Carolina
Posts: 8
Steve Orr is an unknown quantity at this point
Send a message via AIM to Steve Orr Send a message via Yahoo to Steve Orr
Re: Moving robot while tracking with camera questions...

Success!
We now have the camera tracking from very respectable distances and driving at the same time! At first it didn't work when I inserted the Default_Routine();
statement in between the Getdata(&rxdata); and Putdata(&txdata); statements... because you also have to uncomment the Generate_Pwms(pwm13,pwm14,pwm15,pwm16); before the Putdata(&txdata); command...

So, after a couple of debugging moments, assisted by an upcoming freshman-programming-guru named C.J. got it tracking on the fly!

Next up, autonomous and targeting with our soon to be built shooter.
All the rest of those candles I have burning are still blazing but it is so much more fun when you are able to juggle them and not catch on fire.

I'll keep you updated on the progress...

Thanks for the help and encouragement!
__________________
S.Orr
D5Robotics : Team 1293
Irmo, SC
  #5   Spotlight this post!  
Unread 01-02-2006, 07:19
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Moving robot while tracking with camera questions...

Take special care when employing the "user-generated" pwm signals (13-16). If your code uses many interrupts (lots of serial activity, gear tooth sensors, rotary encoders, etc.) those pwms can get a little jittery.
  #6   Spotlight this post!  
Unread 02-02-2006, 22:14
Steve Orr's Avatar
Steve Orr Steve Orr is offline
iusorr
FRC #1293 (D5Robotics)
Team Role: Coach
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Irmo, South Carolina
Posts: 8
Steve Orr is an unknown quantity at this point
Send a message via AIM to Steve Orr Send a message via Yahoo to Steve Orr
Re: Moving robot while tracking with camera questions...

Quote:
Originally Posted by Alan Anderson
Take special care when employing the "user-generated" pwm signals (13-16). If your code uses many interrupts (lots of serial activity, gear tooth sensors, rotary encoders, etc.) those pwms can get a little jittery.
What would be the alternatives?
__________________
S.Orr
D5Robotics : Team 1293
Irmo, SC
  #7   Spotlight this post!  
Unread 02-02-2006, 22:24
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Moving robot while tracking with camera questions...

Quote:
Originally Posted by Steve Orr
What would be the alternatives?
Any of pwm01 through pwm12.
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
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
Have you gotten your robot to go towards the vision tetra? Bharat Nain Programming 20 25-02-2005 20:18
Trying to import Camera code into program without. Kingofl337 Programming 1 18-02-2005 00:43
Camera Only Tracking Green sybert1ger Programming 2 08-02-2005 20:21
about how Drive Train push the robot... shouldn't the force accelerate the robot? Ken Leung Technical Discussion 12 26-11-2001 09:39


All times are GMT -5. The time now is 10:22.

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