Go to Post The only thing "an eye for an eye" has ever settled is two eyeless people. - Cory [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 20-02-2007, 12:52
Tz0m Tz0m is offline
Registered User
FRC #0333
Team Role: Programmer
 
Join Date: Feb 2006
Rookie Year: 2006
Location: New York
Posts: 17
Tz0m is an unknown quantity at this point
Autonomous calculations

How exactly can I implement my formula to calculate distance into my autonomous code? I want the robot to move forward while the distance is greater than a certain number. If I use a while loop the rc crashes and does nothing. This is the code I have so far:
Quote:
while (autonomous_mode || p3_sw_trig == 1) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */

// Start autonomous code

// call camera functions
Servo_Track();
Camera_Handler();
Tracking_Info_Terminal();

if (Get_Tracking_State() == CAMERA_ON_TARGET)
{
pwm13 = pwm14 = 104;
pwm15 = pwm16 = 150;
}
else if (Get_Tracking_State() == SEARCHING)
{
pwm13 = pwm14 = 150;
pwm15 = pwm16 = 104;
}

// End autonomous code

PWM(pwm13,pwm14,pwm15,pwm16);

Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
}
}
How can I build my code around this?
  #2   Spotlight this post!  
Unread 20-02-2007, 13:50
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: Autonomous calculations

The User_Autonomous_Code() function is a while loop. Put your calculation in the middle of it, where it will be executed every time through the loop.

Do you want the calculation to be made only when the camera is locked on the light? If so, put it inside the first if.
  #3   Spotlight this post!  
Unread 20-02-2007, 13:50
bcieslak
 
Posts: n/a
Re: Autonomous calculations

We use the value of tilt servo to tell us when we want to stop. As we get closer to the light the camera must look up higher. Tilt servo value decreases the higher we look. When we get below a certain value we stop.

Determine different tilt servo values associated with different distances from the target to create a ranging system..OR create a formula to convert tilt servo value to distance from light.

BC
  #4   Spotlight this post!  
Unread 20-02-2007, 14:26
Mandi_|<o>|'s Avatar
Mandi_|<o>| Mandi_|<o>| is offline
Registered User
AKA: Marina Stetner Dias
no team
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Brazil
Posts: 34
Mandi_|<o>| will become famous soon enoughMandi_|<o>| will become famous soon enough
Send a message via ICQ to Mandi_|<o>| Send a message via MSN to Mandi_|<o>|
Re: Autonomous calculations

Quote:
Originally Posted by bcieslak View Post
We use the value of tilt servo to tell us when we want to stop. As we get closer to the light the camera must look up higher. Tilt servo value decreases the higher we look. When we get below a certain value we stop.

Determine different tilt servo values associated with different distances from the target to create a ranging system..OR create a formula to convert tilt servo value to distance from light.

BC

That's what I'm doing, the problem is, we made an auto-pan routine that takes us near the target, but sometimes we get there diagonally. We're still looking for the perfect routine, unfortunately it seems to be very far...
__________________
Mandi | F(RC + LL) Volunteer
*
  #5   Spotlight this post!  
Unread 20-02-2007, 14:36
Tz0m Tz0m is offline
Registered User
FRC #0333
Team Role: Programmer
 
Join Date: Feb 2006
Rookie Year: 2006
Location: New York
Posts: 17
Tz0m is an unknown quantity at this point
Re: Autonomous calculations

Thanks for the help. Just for testing, we tried using the tilt servo value to get it to stop. This is our code:
Quote:
if (Get_Tracking_State() == CAMERA_ON_TARGET)
{
if ((int) TILT_SERVO < 170)
{
pwm13 = pwm14 = 104;
pwm15 = pwm16 = 157;
}
else if ((int) TILT_SERVO > 170)
{
pwm13 = pwm14 = pwm15 = pwm16 = 127;
}
}
else if (Get_Tracking_State() == SEARCHING)
{
pwm13 = pwm14 = pwm15 = pwm16 = 127;
}
However, the robot continues to drive forward. The camera seems to stop moving once we initiate autonomous mode. We have these three functions, Servo_Track(); Camera_Handler(); and Tracking_Info_Terminal();, called right after Getdata(&rxdata);.

Last edited by Tz0m : 20-02-2007 at 16:21.
  #6   Spotlight this post!  
Unread 24-02-2007, 06:15
Bomberofdoom's Avatar
Bomberofdoom Bomberofdoom is offline
Biggest FIRST addict in Israel
AKA: Nir Levanon
FRC #2230 (Zcharia's Angels)
Team Role: Programmer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Israel
Posts: 471
Bomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond reputeBomberofdoom has a reputation beyond repute
Send a message via MSN to Bomberofdoom
Re: Autonomous calculations

hmmm...mabye you should try with angles? take the calculation of the tilt angle from terminal.c and find what is your requested tilt angle where the robot will stop in your opinion and then do the tilt angle in relation to the distance(too far, go forward. too close, stop.).
Shouldn't be too complicated and it worked for us, but if you prefer to use your own function like that, I have no idea what the problem can be...
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
Motor Calculations John Gutmann Motors 3 25-06-2006 08:39
Volume/Weight Calculations in Inventor =Martin=Taylor= Inventor 2 08-04-2006 10:21
Distance calculations Max Brin Programming 3 22-02-2006 21:38
Autonomous danielkitchener Rumor Mill 3 03-01-2004 01:08
Seeding Calculations archiver 2000 50 23-06-2002 21:57


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

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