-
Notifications
You must be signed in to change notification settings - Fork 0
/
pose_estimator.py
36 lines (29 loc) · 1.16 KB
/
pose_estimator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Keeps track of the robot's current pose and updates to it."""
import numpy as np
from src.config import START_POSE, LOC_WEIGHT
class PosE(object):
def __init__(self):
self.x, self.y, self.theta = START_POSE
self.b_estimate, self.l_estimate = None, None
def input(self, b_estimate, l_estimate=None):
"""Collect and store position estimates from various sources.
Args:
b_estimate: Estimates from bicycle model.
l_estimate: Estimates from localization.
"""
self.b_estimate, self.l_estimate = b_estimate, l_estimate
def to_list(self):
return [self.x, self.y, self.theta]
def update_pose(self):
if self.l_estimate is not None:
print('Localization Correction.')
b_estimate = (1 - LOC_WEIGHT) * np.array(self.b_estimate)
l_estimate = LOC_WEIGHT * np.array(self.l_estimate)
estimate = b_estimate + l_estimate
else:
estimate = self.b_estimate
if estimate is not None:
self.x, self.y, self.theta = estimate
def output(self):
self.update_pose()
return self.to_list()