go away spammer

Author Topic: distance between objects algorythm  (Read 1663 times)

0 Members and 1 Guest are viewing this topic.

Offline mr robotoTopic starter

  • Full Member
  • ***
  • Posts: 73
  • Helpful? 0
    • http://legomindstormmania.com/
distance between objects algorythm
« on: March 21, 2012, 12:29:38 PM »
hi all
i need some help with an algorythm.
if I have a robot with a sharp ir sensor mounted on a servo scanner and i want to tell the distance between 2 objects in front of me with the variables:
distance 1(the distance to the first objects edge)
distance 2(the distance to the second objects edge)
angel 1(angle to first objects edge(servo angle))
angle 2(i think you get it at this point.)

also how do i find the 2 distances?
THANKS
I once though that my brain was the most wonderful part of my body. then i realized who was telling me this

"A question that sometimes drives me hazy, am i or are the others crazy"?
 Albert Einstein

Offline mstacho

  • Supreme Robot
  • *****
  • Posts: 376
  • Helpful? 10
Re: distance between objects algorythm
« Reply #1 on: March 21, 2012, 12:38:25 PM »
Hm, so you have two sides of a triangle and the angle between them...and you want to know the length of the third side?

Cosine law is your friend:

c^2 = a^2 + b^2 - 2abcos(theta)

Where theta = angle1 + angle2

MIKE
Current project: tactile sensing systems for multifingered robot hands

Offline mr robotoTopic starter

  • Full Member
  • ***
  • Posts: 73
  • Helpful? 0
    • http://legomindstormmania.com/
Re: distance between objects algorythm
« Reply #2 on: March 21, 2012, 01:03:17 PM »
sorry but would you mind explaining it?
im not sure I understand.
I once though that my brain was the most wonderful part of my body. then i realized who was telling me this

"A question that sometimes drives me hazy, am i or are the others crazy"?
 Albert Einstein

Offline mstacho

  • Supreme Robot
  • *****
  • Posts: 376
  • Helpful? 10
Re: distance between objects algorythm
« Reply #3 on: March 21, 2012, 01:57:41 PM »
Well, if c is the distance between the objects, a is what you measured to object 1, b is what you measured to object 2, and the angle that the servo had to turn to get from object a to object b is T, then the law of cosines says that:

c^2 = a^2 + b^2 + 2*a*b*cos(T)

It's sort of a generalization of Pythagorean Theorem, but it works when the triangle isn't a right angled triangle.  You put your stuff into that equation and take the square root and that is the distance between the objects.  Was that what you were looking for?

MIKE
Current project: tactile sensing systems for multifingered robot hands

 


Get Your Ad Here

data_list