Start tidying up algorithms module.
This commit is contained in:
@@ -3,13 +3,13 @@ import math
|
|||||||
|
|
||||||
class Group:
|
class Group:
|
||||||
|
|
||||||
_minX = None
|
|
||||||
_maxX = None
|
|
||||||
_minY = None
|
|
||||||
_maxY = None
|
|
||||||
|
|
||||||
def __init__(self, number, points=[]):
|
def __init__(self, number, points=[]):
|
||||||
self._points = points
|
self._points = points
|
||||||
|
self._number = number
|
||||||
|
self._minX = None
|
||||||
|
self._maxX = None
|
||||||
|
self._minY = None
|
||||||
|
self._maxY = None
|
||||||
|
|
||||||
def add_point(self, point):
|
def add_point(self, point):
|
||||||
self._points.append(point)
|
self._points.append(point)
|
||||||
@@ -18,20 +18,21 @@ class Group:
|
|||||||
def get_points(self):
|
def get_points(self):
|
||||||
return self._points
|
return self._points
|
||||||
|
|
||||||
# Should use property here.
|
@property
|
||||||
def set_number(self, number):
|
def number(self):
|
||||||
self._number = number
|
|
||||||
|
|
||||||
def get_number(self):
|
|
||||||
return self._number
|
return self._number
|
||||||
|
|
||||||
|
@number.setter
|
||||||
|
def number(self, number):
|
||||||
|
self._number = number
|
||||||
|
|
||||||
def _update_min_max(self, new_point):
|
def _update_min_max(self, new_point):
|
||||||
'''
|
'''
|
||||||
Updates the in and max points for this group.
|
Updates the in and max points for this group.
|
||||||
This is to determine when assigning groups whether the
|
This is to determine when assigning groups whether the
|
||||||
same group is selected.
|
same group is selected.
|
||||||
'''
|
'''
|
||||||
converted_point = self.convert_lidar_to_cartesian(new_point)
|
converted_point = convert_lidar_to_cartesian(new_point)
|
||||||
|
|
||||||
if self._minX is None or self._minX > converted_point[0]:
|
if self._minX is None or self._minX > converted_point[0]:
|
||||||
self._minX = converted_point[0]
|
self._minX = converted_point[0]
|
||||||
@@ -45,11 +46,6 @@ class Group:
|
|||||||
if self._maxY is None or self._maxY < converted_point[1]:
|
if self._maxY is None or self._maxY < converted_point[1]:
|
||||||
self._maxY = converted_point[1]
|
self._maxY = converted_point[1]
|
||||||
|
|
||||||
def convert_lidar_to_cartesian(self, new_point):
|
|
||||||
x = new_point[2] * math.sin(new_point[1])
|
|
||||||
y = new_point[2] * math.cos(new_point[1])
|
|
||||||
return (x, y)
|
|
||||||
|
|
||||||
def get_minX(self):
|
def get_minX(self):
|
||||||
return self._minY
|
return self._minY
|
||||||
|
|
||||||
@@ -63,6 +59,12 @@ class Group:
|
|||||||
return self._maxY
|
return self._maxY
|
||||||
|
|
||||||
|
|
||||||
|
def convert_lidar_to_cartesian(new_point):
|
||||||
|
x = new_point[2] * math.sin(new_point[1])
|
||||||
|
y = new_point[2] * math.cos(new_point[1])
|
||||||
|
return (x, y)
|
||||||
|
|
||||||
|
|
||||||
def calc_groups(scan):
|
def calc_groups(scan):
|
||||||
'''
|
'''
|
||||||
Calculates groups of points from a lidar scan. The scan should
|
Calculates groups of points from a lidar scan. The scan should
|
||||||
|
|||||||
Reference in New Issue
Block a user