Go to Post I looked at it and originally thought it was a crazy idea... then I looked at it again and it still sounds like a crazy idea. But crazy ideas tend to produce some excellent results. - Yipyapper [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 02-02-2005, 14:46
magical hands magical hands is offline
Jigar Patel
AKA: Jigar Patel
FRC #2185 (Etobicoke CI)
Team Role: Mentor
 
Join Date: Dec 2003
Rookie Year: 2004
Location: TORONTO
Posts: 93
magical hands is on a distinguished road
Exclamation AUTO TRACKING!!!!!!:(

Hi! We got our cam working and it detects different colours too. Problem is we have to put the colour in front of the cam in order for cam to recognize the colour. Our cam doesn't spin on servos looking for the object we have to spoon feed it! Anyone knows why this is happening or any ideas? Please post thanks!

  #2   Spotlight this post!  
Unread 02-02-2005, 16:26
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: AUTO TRACKING!!!!!!:(

Quote:
Originally Posted by magical hands
Hi! We got our cam working and it detects different colours too. Problem is we have to put the colour in front of the cam in order for cam to recognize the colour. Our cam doesn't spin on servos looking for the object we have to spoon feed it! Anyone knows why this is happening or any ideas? Please post thanks!

The solution I came up with is to make a simple counter that keeps track of program loops and moves the servo until it finds a color.

Code:
int counter = 0; //counter variable

if(camera_find_color(GREEN) == 0)
{
      camera_set_servos(counter, 127); //move pan servo 1 PWM value 40 times a second
}
else camera_auto_servo(1); //stop pan loop

//Increment counter.
if(counter < 255)
{
     counter++;
}
else counter = 0;
  #3   Spotlight this post!  
Unread 03-02-2005, 10:55
magical hands magical hands is offline
Jigar Patel
AKA: Jigar Patel
FRC #2185 (Etobicoke CI)
Team Role: Mentor
 
Join Date: Dec 2003
Rookie Year: 2004
Location: TORONTO
Posts: 93
magical hands is on a distinguished road
Question Re: AUTO TRACKING!!!!!!:(

Quote:
Originally Posted by Tom Bottiglieri
The solution I came up with is to make a simple counter that keeps track of program loops and moves the servo until it finds a color.

Code:
int counter = 0; //counter variable

if(camera_find_color(GREEN) == 0)
{
      camera_set_servos(counter, 127); //move pan servo 1 PWM value 40 times a second
}
else camera_auto_servo(1); //stop pan loop


//Increment counter.
if(counter < 255)
{
     counter++;
}
else counter = 0;

Hi! I really like your code and that was something that simmilar to what our team came up with. Infact our code wasn't as successful as yours but anyways thanks for the code. I just want to mention that their is a problem with the code or our cam configuration because when i put your code into autonomous mode it shows Error in terminal window stating "*Error setting color tracking parameters Expected 8, and got 0" You know what is the reason behind it maybe? Me and my team truly appreciated your help thanks once again!
  #4   Spotlight this post!  
Unread 07-02-2005, 23:19
russell's Avatar
russell russell is offline
Registered User
#1430 (WRONG)
Team Role: Electrical
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Anchorage AK
Posts: 402
russell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to all
Re: AUTO TRACKING!!!!!!:(

Has anyone actually successfully implemented a scanning routine? One problem I notice with the one above is that you have to use camera_stop() before setting the servos.

I have been playing with it the last two days, and the problem I am having is that once I get the camera pointing where I want it, then I have to set auto servos again and I have to call camera_find_color again, and one of the two seems to center the camera. At least all my attempts at a program like this have resulted in the cam exhibiting seizure like behavior. It seems like there has to be a solution to this, but so far it has eluded me quite successfully.....
  #5   Spotlight this post!  
Unread 08-02-2005, 01:29
JoshJ JoshJ is offline
Registered User
#0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Salem County
Posts: 44
JoshJ is on a distinguished road
Send a message via AIM to JoshJ
Re: AUTO TRACKING!!!!!!:(

One problem with the above code is the servos controlled by the camera range from 41-210, with 128 being the middle. NOT the typical 0-254 w/ 127 as middle range

Quote:
Originally Posted by magical hands
Hi! I really like your code and that was something that simmilar to what our team came up with. Infact our code wasn't as successful as yours but anyways thanks for the code. I just want to mention that their is a problem with the code or our cam configuration because when i put your code into autonomous mode it shows Error in terminal window stating "*Error setting color tracking parameters Expected 8, and got 0" You know what is the reason behind it maybe? Me and my team truly appreciated your help thanks once again!
  #6   Spotlight this post!  
Unread 08-02-2005, 23:41
russell's Avatar
russell russell is offline
Registered User
#1430 (WRONG)
Team Role: Electrical
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Anchorage AK
Posts: 402
russell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to all
Re: AUTO TRACKING!!!!!!:(

Thats easy enough to fix. Just change the numbers. But has anyone gotten this to work? I have just about given up on it. I think I am going to have to make the whole robot turn.
  #7   Spotlight this post!  
Unread 08-02-2005, 23:47
logicalhippo logicalhippo is offline
Registered User
AKA: Russell McClellan
#0213 (Dirty Birds)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Keene, NH
Posts: 11
logicalhippo is an unknown quantity at this point
Send a message via AIM to logicalhippo
Re: AUTO TRACKING!!!!!!:(

I'm not really familiar with the code that FIRST gave you, but basically what you want to do is:

send your TC command
wait for 1 T packet
if pixels = 0
{
-send a \r
-send the set servo command to the next counter
-repeat from beginning
}
else
{ //(it found a color)
-send a \r
-enable auto-servo mode
-send the TC command again
}

We're not using servos and just rotating the whole robot. The only advantages I can see to the servos are using the tilt angle to calculate distance and pan and scanning before the match begins.

wow.. commented pseudocode...
  #8   Spotlight this post!  
Unread 09-02-2005, 00:31
russell's Avatar
russell russell is offline
Registered User
#1430 (WRONG)
Team Role: Electrical
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Anchorage AK
Posts: 402
russell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to all
Re: AUTO TRACKING!!!!!!:(

The problem is that when it finds a color and I tell it to try to track the color the servos reset to the center position...
  #9   Spotlight this post!  
Unread 10-02-2005, 01:00
ace123's Avatar
ace123 ace123 is offline
Registered User
AKA: Patrick Horn
FRC #0008 (Paly Robotics - http://robotics.paly.net/)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Palo Alto, CA
Posts: 50
ace123 has a spectacular aura aboutace123 has a spectacular aura about
Send a message via AIM to ace123
Question TC command after camera_stop() doesn't work.

Hmm... I'm trying to get the servos to turn while tracking and I fail every time:
If I use camera_find_color and then set servos, it stops finding color.
If I use camera_stop(), camera_set_servo(), camera_find_color() then it resets to center because that's what camera_find_color() does.
If I put all the color init code at the beginning, and then only run the TC command at the time, then stop it, it doesn't recieve updates:
Code:
///// For some reason camera_track_update() returns 0 unless I call reset before I send the TC command.
static int counter=0;
if (camera_track_update()) {
  // updated
} else {
  // no update
}
counter++;
if (counter>15) {
  counter=0;
  camera_stop(); // in user_camera
  camera_set_pan_servo(...); // sends "SV 0 xxx"
//  camera_reset(); // If I call this then it works, but keeps jumping to the center servo position.
  camera_track_continue(); // function that just sends "TC ... ... ..."
}
I wrote this from memory since I don't have access to the other computer, but it is the general idea (check for updates, stop, turn, track).

I am sure that the individual camera_ functions work as they work when not setting the servo, and the servos move but don't track. But the combination causes it ot not reply with a "T ... ..." packet.

Also, I read something about poll mode ("PM 1") I tried this and it still did not recieve packets. Have any of you had this method work?

Maybe I have to call the TC command twice. (I remember having to click the button twice in the java program to retart the tracking...?

I could also try using HyperTerminal and pasting in all the stuff that it would have sent from the RC.

Do you have any ideas about what works for you?

If I can't figure it out, it won't hurt the time very much to actually turn the entire robot instead (pwm01=80;pwm02=-80;)
__________________
-Patrick Horn, Paly Robotics

Check out the space simulator called Vega Strike, modelled after the space simulator games Elite and Wing Commander. It's Open Source too!
If you have ever played Wing Commander, or especially Privateer, and had a feeling of nostalga derived from the you will enjoy these two Vega Strike mods: Privateer Gemini Gold and Privateer Remake!
I'm working on adding multiplayer support this year...
  #10   Spotlight this post!  
Unread 10-02-2005, 11:37
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: AUTO TRACKING!!!!!!:(

Had the exact same problem...

You have to stop the auto-track to manually set the servo position using the default camera code. My temporary solution (till I find something better) is to not PAN smoothly... and to be very patient.

1) Don't pan the servo, but set three distinct positions: Left, Center, and Right. Make them spread out enough so that you can cover the entire width of the field with these positions.

2) Start at Center, turn on auto-track, wait for a few track packets.

3) If you don't get successfully tracking, set your servo to position left, and wait for a few track packets again.

4) If you don't get successfully tracking, set your servo to position right, and wait for a few track packets again.

The goal is to NOT move the servo manually. When you do this, you have to turn of auto-track, and it takes a little while for the camera to turn it back on again, and to get a track on the object. If you're constantly setting the servo position manually every cycle, you will never give the camera enough time to get a track.

-SlimBoJones...

Quote:
Originally Posted by russell
Has anyone actually successfully implemented a scanning routine? One problem I notice with the one above is that you have to use camera_stop() before setting the servos.

I have been playing with it the last two days, and the problem I am having is that once I get the camera pointing where I want it, then I have to set auto servos again and I have to call camera_find_color again, and one of the two seems to center the camera. At least all my attempts at a program like this have resulted in the cam exhibiting seizure like behavior. It seems like there has to be a solution to this, but so far it has eluded me quite successfully.....
  #11   Spotlight this post!  
Unread 10-02-2005, 19:03
russell's Avatar
russell russell is offline
Registered User
#1430 (WRONG)
Team Role: Electrical
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Anchorage AK
Posts: 402
russell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to all
Re: AUTO TRACKING!!!!!!:(

Hmmm good idea, thanks. Is there something like that in the default code? It seems like I saw something like that, but I never actually saw it happen.
  #12   Spotlight this post!  
Unread 10-02-2005, 23:56
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: AUTO TRACKING!!!!!!:(

Quote:
Originally Posted by russell
Hmmm good idea, thanks. Is there something like that in the default code? It seems like I saw something like that, but I never actually saw it happen.
Yes and no.

There is code to toggle the camera's position between LEFT, CENTER, and RIGHT, but it doesn't automatically turn auto-tracking/servo back on immediately after. To turn it back on, you must re-select the colour you wish to track, wish just resets the servo position back to center anyways... so really it doesn't work very well (read: at all). The code is linked to the top switch on joystick 2 I think? I can't recall exactly, sorry! We've been working on our encoders and have been tuning our PID loops as of late, and haven't gotten back to the camera just yet =(.

-SlimBoJones...
  #13   Spotlight this post!  
Unread 11-02-2005, 00:14
russell's Avatar
russell russell is offline
Registered User
#1430 (WRONG)
Team Role: Electrical
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Anchorage AK
Posts: 402
russell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to allrussell is a name known to all
Re: AUTO TRACKING!!!!!!:(

Hmmmm I should try playing with encoders and gyros some time.. We dont have either now, but I am going to convert our practice bot into an awesome test platform once the season is over... Assuming my team will let me. Anyway thanks. We got kicked out early today because it snowed like six inches, but I will try it tomorrow.
  #14   Spotlight this post!  
Unread 11-02-2005, 18:43
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: AUTO TRACKING!!!!!!:(

Quote:
Originally Posted by russell
The problem is that when it finds a color and I tell it to try to track the color the servos reset to the center position...
I had this same problem. Rather then spend a long time fixing it, I just control the servos right off of the RC.

It's working fine, and is legal (I had thought it wasn't at one point, but there is a question in the Q&A thing that says otherwise, ID 1480)

Here's the code that we are using.. it should be easily changed to other configurations
Code:
//Pan and tilt servos
#define cam_pan pwm01
#define cam_tilt pwm02
//Internal posistion variables
unsigned char cam_p=128;
unsigned char cam_t=128;

if (cam.x == 0 && cam.y == 0) {
		//cam_pan and cam_tilt control the servo's on the mount
		//cam_p and cam_t are our local variables
		cam_pan = cam_p;
		cam_tilt = cam_t;
		//Tell the camera where the servos are,
		//so we get useful values when it finds a target
		camera_set_servos(cam_pan,cam_tilt);
		//What color do we want to track?
		camera_find_color(GREEN);
		//This does all the panning
		cam_p += 10;		//X pan
		if (cam_p > 210) { //if we hit the x limit
			cam_p = 46;		//start over
			cam_t += 10;	//but change the tilt
		}
		//if we've tilted too much
		if (cam_t > 117) cam_t = 97;
	}
	else { 
		//sometimes we get nonsense packets, this fixes them
		if (cam_pan > 0 && cam_tilt > 0) {
			//update the servo and our var with new servo values
			cam_p = cam_pan = cam.pan_servo;
			//update the tilt servo with new tilt value
			cam_tilt = cam.tilt_servo;
		}
	}
The trick here is we fool the servo into thinking the servos are connected to it. We do that with the camera_set_servo command. After it finds a target, we update the servos with where the camera thinks it is. The only thing I wanted to do with this code is get rid of the internal variables that hold the servo posistions.
  #15   Spotlight this post!  
Unread 13-02-2005, 09:36
magical hands magical hands is offline
Jigar Patel
AKA: Jigar Patel
FRC #2185 (Etobicoke CI)
Team Role: Mentor
 
Join Date: Dec 2003
Rookie Year: 2004
Location: TORONTO
Posts: 93
magical hands is on a distinguished road
Re: AUTO TRACKING!!!!!!:(

is their a way we can run two procedures at a time if we can than why not turn the movement of a servo into one procedure and the colour tracking which is already a procedure and than run them at the same time. the only thing i don't know about if procedure stays at a monitor level and so if we try to place a procedure inside a procedure it might show an error. Can someon please try this!
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
Camera Auto Tracking? Ryan Cumings Programming 9 22-01-2005 02:20
IR Tracking & Navigation Tallman General Forum 3 20-01-2004 17:26
auto archiving of posts Joe Ross CD Forum Support 4 01-01-2004 02:04
My auto is better than yours.. lol randomperson Programming 25 07-04-2003 12:10
picking auto program Mike375 Programming 19 03-03-2003 15:47


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

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