-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstateEstimator.py
More file actions
30 lines (20 loc) · 1.18 KB
/
stateEstimator.py
File metadata and controls
30 lines (20 loc) · 1.18 KB
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
windows_length = 20
class StateEstimator:
def __init__(self, robot):
self._robot = robot
self._windows_length = windows_length
self._linear_velocity_x_container = [0.0]*windows_length
self._linear_velocity_y_container = [0.0]*windows_length
self._linear_velocity_z_container = [0.0]*windows_length
self._estimate_linear_velocity = [0.0]*3
def run(self, current_time):
linear_velocity_x, linear_velocity_y, linear_velocity_z = self._robot.getRobotLinearVelocity()
del self._linear_velocity_x_container[0]
del self._linear_velocity_y_container[0]
del self._linear_velocity_z_container[0]
self._linear_velocity_x_container.append(linear_velocity_x)
self._linear_velocity_y_container.append(linear_velocity_y)
self._linear_velocity_z_container.append(linear_velocity_z)
self._estimate_linear_velocity[0] = sum(self._linear_velocity_x_container) / self._windows_length
self._estimate_linear_velocity[1] = sum(self._linear_velocity_y_container) / self._windows_length
self._estimate_linear_velocity[2] = sum(self._linear_velocity_z_container) / self._windows_length