Lidar fixes
This commit is contained in:
@@ -83,11 +83,11 @@ def convert_cartesian_to_lidar(x, y):
|
||||
A tuple (distance, angle) that represents the point. Angle is in degrees.
|
||||
"""
|
||||
# Angle depends on x/y position.
|
||||
# if x is positive and y is positive, then angle = 90 - tan-1(y/x)
|
||||
# if x is positive and y is negative, then angle = 90 + tan-1(y/x)
|
||||
# if x is negative and y is positive, then angle = 270 + tan-1(y/x)
|
||||
# if x is negative and y is negative, then angle = 270 - tan-1(y/x)
|
||||
return (math.sqrt(x ** 2 + y ** 2), math.degrees(math.atan(y/x) + (180 if ))
|
||||
# if x is positive and y is positive, then angle = tan-1(y/x)
|
||||
# if x is positive and y is negative, then angle = 360 + tan-1(y/x)
|
||||
# if x is negative and y is positive, then angle = 180 + tan-1(y/x)
|
||||
# if x is negative and y is negative, then angle = 180 + tan-1(y/x)
|
||||
return (math.sqrt(x ** 2 + y ** 2), math.degrees(math.atan(y/x)) + (180 if x < 0 else 270 if y < 0 else 0))
|
||||
|
||||
|
||||
def calc_groups(scan):
|
||||
|
||||
@@ -4,13 +4,14 @@ from tracking.lidar_cache import LidarCache
|
||||
from multiprocessing import Process
|
||||
import messaging.message_factory as mf
|
||||
from rplidar import RPLidar
|
||||
from Messaging import messages
|
||||
from messaging import messages
|
||||
|
||||
|
||||
class LidarServicer(PersonTrackingServicer):
|
||||
|
||||
def __init__(self):
|
||||
# TODO: Put the rplidar creation in a factory or something, to make it possible to test this servicer.
|
||||
# Also, it would allow creating the service without the lidar being connected.
|
||||
self.cache = LidarCache(RPLidar('/dev/ttyUSB0'), measurements=100)
|
||||
self._mFactory = None
|
||||
self._port = None
|
||||
|
||||
Reference in New Issue
Block a user