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 beca96f commit cd4ec54
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions donkeycar/parts/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,19 @@ def poll(self):
new_time = time.time()
if self.time is None:
self.time = new_time
delta_t = new_time - self.time
dt = new_time - self.time
gyro = np.array(self.mpu.gyro) - self.gyro_zero
# convert from radians to degrees
scaled_gyro = np.array(gyro) * 180 / math.pi
adj_gyro = self.offset.update(scaled_gyro)
accel = np.array(self.mpu.acceleration) / 9.81
self.ahrs.update_no_magnetometer(adj_gyro, accel, delta_t)
gyro_degree = np.array(gyro) * 180 / math.pi
adj_gyro = self.offset.update(gyro_degree)
accel_phys = np.array(self.mpu.acceleration)
self.ahrs.update_no_magnetometer(adj_gyro, accel_phys/9.81, dt)
if not self.ahrs.flags.initialising:
self.euler = self.ahrs.quaternion.to_euler()
self.matrix = self.ahrs.quaternion.to_matrix()
accel = self.mpu.acceleration
delta_v = np.dot(self.matrix, accel) * delta_t
delta_v = np.dot(self.matrix, accel_phys) * dt
self.speed += delta_v
self.pos += self.speed * delta_t
self.pos += self.speed * dt
self.path.append((self.time, *self.pos))
self.time = new_time

Expand Down

0 comments on commit cd4ec54

Please sign in to comment.