Add Documentation for odometrty and robot class. Remove fast_fifo
This commit is contained in:
parent
c800b30e31
commit
866fac9848
7 changed files with 115 additions and 8 deletions
|
@ -13,22 +13,50 @@ orientation = 0
|
|||
|
||||
|
||||
class Odometry():
|
||||
"""DTO used for holding all odometry information. \n
|
||||
Coordinate system: \n
|
||||
X: + Forward; - Backwards \n
|
||||
Y: + Right; - Left \n
|
||||
Orientation: + Right; - Left
|
||||
"""
|
||||
|
||||
def __init__(self, x, y, orientation):
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.orientation = orientation
|
||||
|
||||
def get_x(self) -> float:
|
||||
"""Returns distance driven on x-axis in meters"""
|
||||
return self.x
|
||||
|
||||
def get_y(self) -> float:
|
||||
"""Returns distance driven on y-axis in meters"""
|
||||
return self.y
|
||||
|
||||
def get_orientation(self) -> float:
|
||||
"""Returns degrees turned in radians"""
|
||||
return self.orientation
|
||||
|
||||
def __str__(self):
|
||||
return f"X: {self.x} Y: {self.y} O: {self.orientation}"
|
||||
|
||||
|
||||
class Odom(object):
|
||||
"""Class used to track the movement of the robot in X, Y, Theta (Orientation)
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_odom():
|
||||
def get_odom() -> Odometry:
|
||||
"""
|
||||
:return: Current orientation of the robot
|
||||
"""
|
||||
return Odometry(pos_x, pos_y, orientation)
|
||||
|
||||
@staticmethod
|
||||
def clear():
|
||||
def clear() -> None:
|
||||
"""
|
||||
Clears the current odometry information and start from X, Y, Orientation set to 0
|
||||
"""
|
||||
global last_run, last_enc_left, last_enc_right, pos_x, pos_y, orientation
|
||||
|
||||
last_run = 0
|
||||
|
@ -39,7 +67,11 @@ class Odom(object):
|
|||
orientation = 0
|
||||
|
||||
@staticmethod
|
||||
def update():
|
||||
def update() -> None:
|
||||
"""
|
||||
Updates the current odometry information of the robot, Should be called in a loop with at least 100HZ.
|
||||
Do not clear encoder positions between updates! Must be cleared, when clearing encoders!
|
||||
"""
|
||||
global last_run, last_enc_left, last_enc_right, pos_x, pos_y, orientation
|
||||
|
||||
now = time.time()
|
||||
|
|
Reference in a new issue