Go to Post Will.I.Am is not FIRST. - BrendanB [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 10-12-2007, 10:15
charlie1218 charlie1218 is offline
Registered User
FRC #1218
Team Role: Coach
 
Join Date: Jan 2006
Rookie Year: 2005
Location: PHILADELPHIA
Posts: 55
charlie1218 will become famous soon enoughcharlie1218 will become famous soon enough
Question Help with Angles and distance

I am programming a GPS bot. I am getting to sets of (x,y) one being my current location and the other being the destination. I need to do trig in easy c to get the robot to know at what angle to travel and for what distance. I know how to do this trig on paper but have NO IDEA on how to program this. My advisor has given me the task, and I have little if any knowledge of advanced easyC. I know that i will need to do an inverse tangent([X2-X1]/[Y2-Y1]) to get my angle of heading, and to get my distance i need sq rt([X2-X1]^2 + [Y2-Y1]^2). So as you can see, I know what I need to do, but have no idea on how to put this in terms of EasyC. I also know that I will need trig lookup tables and have NO IDEA on how to use them.
  #2   Spotlight this post!  
Unread 10-12-2007, 11:06
JesseK's Avatar
JesseK JesseK is offline
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,659
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Help with Angles and distance

I would start with pseudo code, literally you can framework out your code either using flow charts or writing IF ... THEN. Most white papers that define software requirements do one or the other and coding from there is as easy as knowing any language's syntax.

For starters in syntax, I don't believe EasyC will like the "^" character, so multiply those variables out.

Now for some issues you'll encounter along the way (note, these are NOT answers to these issues; I'm only making you aware of them)What will boggle your mind is that unless your GPS unit is precisly on the center of rotation of your robot, when it moves to the spot you tell it to it will be off by a distance. That distance, minus all negligible mathematical components, is roughly the distance between the GPS unit and the center of rotation.

Also, you'll need to account for the possible sign errors on your arctan (inverse tangent) output. There are several ways to do this, the most intuitive (but most complex) of which is converting the bearing to the first quadrant, doing the calculation, then reversing the quandrant conversion. Do this on paper using the IF...THEN blocks as well. Doing this will also reduce the amount of arctan tables you need to store, fyi .

Finally, what should happen when Y2 == Y1 ? Do you see the problem that happens in your arctan calculation? When, in the real world for your application, does Y2 == Y1 and how will your code deal with that condition?
__________________

Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub
  #3   Spotlight this post!  
Unread 10-12-2007, 15:14
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,995
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Help with Angles and distance

Quote:
Originally Posted by JesseK View Post
That distance, minus all negligible mathematical components, is roughly the distance between the GPS unit and the center of rotation.
Actually, it is the location of the GPS receive antenna that is the critical item. The location of the GPS engine is irrelevant, but the point remains valid.

Instead of trig, how about just using a ratio, for example for every n units in X you need to also move i units in Y. If your units are meters, and to get to New(X,Y) you need to move 4,11 meters, break that up into little bites and for every 4 bites in the X direction you should move 11 bites in Y.

Doesn't satisfy your assignment, but computationally it is much easier.

Another alternative is a look-up table, just calculate the angles & distance for every possibility (say, up to 50 meters) and store them in a table, so when X,Y = n,i, just look up the answer.

Don
__________________

I am N2IRZ - What's your callsign?
  #4   Spotlight this post!  
Unread 12-12-2007, 09:48
charlie1218 charlie1218 is offline
Registered User
FRC #1218
Team Role: Coach
 
Join Date: Jan 2006
Rookie Year: 2005
Location: PHILADELPHIA
Posts: 55
charlie1218 will become famous soon enoughcharlie1218 will become famous soon enough
Re: Help with Angles and distance

XY and y arent in meters feet or inches, but in lattitude and longitude. I have a lookup table, but need to know how to create a code that say okay you have (x,Y) and (m,n) subtract those and then drag a value from the trig lookup table. Its the only way this can be done. I have no idea what blocks to use b.c as i said, i have never ever programmed before.
  #5   Spotlight this post!  
Unread 13-12-2007, 02:21
amateurrobotguy's Avatar
amateurrobotguy amateurrobotguy is offline
Lead Programmer/Senior Engineer
no team
 
Join Date: Feb 2005
Rookie Year: 2000
Location: ****
Posts: 136
amateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these partsamateurrobotguy is infamous around these parts
Re: Help with Angles and distance

Conceptually, using GPS on one of these robots isn't a good idea because GPS is inaccurate to 10 feet which is pretety huge considering the field is only 20 feet wide. So there really is no benefit to even using GPS on a robot unless you have $60k to spend on one that is accurate to a millimeter...let alone going through the major headache going from point a to point b in easyc is.
__________________
I quit FRC over 2 years ago (more if you're reading this past 2010).

Last edited by amateurrobotguy : 13-12-2007 at 02:23.
  #6   Spotlight this post!  
Unread 13-12-2007, 18:54
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,995
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Help with Angles and distance

Quote:
Originally Posted by charlie1218 View Post
XY and y arent in meters feet or inches, but in lattitude and longitude. I have a lookup table, but need to know how to create a code that say okay you have (x,Y) and (m,n) subtract those and then drag a value from the trig lookup table. Its the only way this can be done. I have no idea what blocks to use b.c as i said, i have never ever programmed before.
Yes, I know GPS outputs in Lat/Lon, but somwehere you need to start thinking in units of distance, even if they are hundred-thousandths of a degree.

How to program it? I can't* give you a direct & complete answer, but here are some things to try.

1. How do you determine the direction the robot will move? Somehow, you need to have a way of determining which direction the robot is "facing" right now, and which way it needs to face before it starts moving.

2. How do you determine distance moved? Needs to be fairly accurate, because GPS isn't. +/- 10 feet on a good day.

3. Do you need to deal with obstructions? If so, that's a problem an order of magnitude or two larger. Beyond the scope here.

OK, once you know 1 and 2, you find where you are, then where you want to be.

Then command the robot to turn until you're facing the right direction. Then move the robot about half the distance and stop. Last, re-check the direction & distance, and repeat until you reach the goal. If the distance is less than some minimum, say 40 feet, just go to the goal.

Do you need help in figuring out how to turn the robot, or make it go a certain distance?

Don

*Won't
__________________

I am N2IRZ - What's your callsign?
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
White Paper Discuss: Measuring Distance with Analog Potentiometers Daniel Extra Discussion 4 26-11-2008 13:52
Long distance network help needed Simon Strauss IT / Communications 16 26-07-2007 10:19
Encoder Help with VEX and MPLAB qnetjoe Programming 5 11-03-2007 21:04
How do I get distance between Camera and the target? sjung9442 Programming 5 27-01-2006 09:44
Help with Autocad and Bryce 5 Keith Chester Inventor 0 25-03-2002 17:33


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

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