Reputation: 9
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.
Upvotes: -1
Views: 98
Reputation: 1630
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 ;)
Upvotes: 0