Skip to content

Commit

Permalink
Add back path estimation to mpu part
Browse files Browse the repository at this point in the history
  • Loading branch information
DocGarbanzo committed Sep 27, 2024
1 parent cd4ec54 commit 25f5108
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion donkeycar/parts/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ def calibrate(self):
logger.info('Calibrating Mpu6050 ...')
num_loops = 100
gyro = np.zeros(3)
accel = np.zeros(3)
for _ in range(num_loops):
gyro += self.mpu.gyro
accel += self.mpu.acceleration
time.sleep(0.01)
self.gyro_zero = gyro / num_loops
self.accel_zero = accel / num_loops
while self.ahrs.flags.initialising:
self.poll()
time.sleep(0.01)
Expand All @@ -171,7 +174,8 @@ def poll(self):
if not self.ahrs.flags.initialising:
self.euler = self.ahrs.quaternion.to_euler()
self.matrix = self.ahrs.quaternion.to_matrix()
delta_v = np.dot(self.matrix, accel_phys) * dt
lin_accel = accel_phys - self.accel_zero
delta_v = np.dot(self.matrix, lin_accel) * dt
self.speed += delta_v
self.pos += self.speed * dt
self.path.append((self.time, *self.pos))
Expand Down

0 comments on commit 25f5108

Please sign in to comment.