-1

I got a LED stripe connected with a RasPi3. The stripe should be installed at an automated guided vehicle as the human maschine interface. I would like to program the stripe so that there are "eyes" on it (e.g. 3 LED pixel on -- 5 LED pixel off -- 3 LED pixel on), which follow automatically a person who is standing in front of it.

Actually i have the methods:

"set_eye_position(msg)" which is able to set the LED pixel on an interval from -99 (completely left) to +99 (completely right) as input parameter (msg) and

"set_eyes_to_coord(msg)" which get two input parameters: The x and y coordinates of the person who is standing next to the vehicle. My approach is to set a coordinate system in the middle of the robot (see Picture)

The reason for my question is, if there is an opportunity to calculate the exact position of the LED pixel at given input parameters (x,y)?

I'm writing with Python and I'm quite a newbee in programming, so I would really appreciate if I get some ideas how to realize my issue.

Thanks in advance


EDIT:

Assuming the approach from bendl THIS is the new setup, right? I do not really know what to do with the variables boe_left, boe_right and boe_dist. But maybe I'm just too dumb to understand it.

Luke Mue
  • 9
  • 4
  • It seems to me that you may want to try to find a fixed point slightly behind each 'eye' and trace a line from that point to the person. The point where the line intersects the LED panel will be the point where you should center the 3 LED stripe – bendl Aug 29 '17 at 17:16
  • You may take a look at [similar triangles](https://www.youtube.com/watch?time_continue=4&v=R-6CAr_zEEk). They can help you solve where on one of your four sides the person "is". Then you could center the eyes about that point? – TheCrzyMan Aug 29 '17 at 17:33
  • Being 'dumb' and 'new to programming' are two very different things. Don't start thinking you're dumb because someone with years of experience is better at something than yourself. I would also struggle with the code I gave you back when I was a newbie. That being said, have you solved your problem, or do you need more guidance? – bendl Sep 05 '17 at 17:01
  • Yes, you're rigth. I solved this problem with polar coordinates. With given input parameters (x,y) i generate the angle phi. But thank you so much for your fast and friendly help! – Luke Mue Sep 11 '17 at 11:44

1 Answers1

0

Here's something to get you started off:

def pixels_on(x, y):
    assert y > 0                                # person must be in front of robot
    boe_left, boe_right = -10, 10               # x location of back of eye left, back of eye right
    boe_dist = - 3                              # distance to back of eye

    m_left =  (x - boe_left) / (y - boe_dist)   # slope from back of left eye to person
    m_right =  (x - boe_right) / (y - boe_dist) # slope from back of right eye to person

    c_left = boe_left - m_left * boe_dist       # center of front of left eye
    c_right = boe_right - m_right * boe_dist    # center of front of right eye

    return list(map(int, [c_left - 1, c_left, c_left + 1, c_right - 1, c_right, c_right + 1]))

This works by drawing a line between an fixed point you can think of as the imaginary back of the robot's eye and the person. The point where this line intersects the LED strip is the point that the eye should be centered. This solution makes the (naive) assumption that there is one LED per unit distance, so you'll have to make some changes, but we can't do EVERYTHING for you ;)

bendl
  • 1,583
  • 1
  • 18
  • 41
  • Thank's a lot for your approach! Can you explain why you assert y>0? When the coordinate system is in the middle of the robot, there must be a possibility to reach all points around the robot, right? – Luke Mue Aug 30 '17 at 14:12
  • This approach makes the assumption that the coordinate system is centered around the middle of the LED strip, not the robot, so you'll have to account for that as well. In that case, it wouldn't make sense for the robot to try and turn its eyes to focus on something at a coordinate y<0 (i.e. behind it) It won't actually fail, but it will make the robot go "anti-crosseyed" – bendl Aug 30 '17 at 14:21