diff --git a/driving.py b/driving.py index cd43f4d7fb5f78aa80783032d4e18df022d0021e..3168a06c100460c1ee7120b35e7a85d28d67ddfd 100644 --- a/driving.py +++ b/driving.py @@ -74,16 +74,19 @@ class Driving_Analyser: # This function caluates the continues odometrie which add the new positon to the old one. # The calculation of the position depending on the speed, rotationspeed and the time.span. """ - def calculate_odometrie_continues (self, w,v,time_delta): + def calculate_odometrie_continues (self, w, v, time_delta): - if w != 0 or v != 0: + if w != 0: #or v != 0: theta = self.theta_old + (w * time_delta) - if w < 0: - y = self.y_old + (v * (-np.cos(theta) / w - 1)) - else: - y = self.y_old + (v * (-np.cos(theta) / w + 1)) - x = self.x_old + (v * (np.sin(theta) / w)) - + x = self.x_old + (v * ((np.sin(theta) - np.sin(self.theta_old)) / w)) + y = self.y_old + (v * (-(np.cos(theta) - np.cos(self.theta_old)) / w)) + + else: + theta = self.theta_old + x = self.x_old + (v * np.cos(self.theta_old) * time_delta) + y = self.y_old + (v * np.sin(self.theta_old) * time_delta) + + self.theta_old = theta self.y_old = round(y, 5) self.x_old = round(x, 5) @@ -94,13 +97,17 @@ class Driving_Analyser: # This function caluates the delta odometrie which return only the delta position of the given time span. # The calculation of the position depending on the speed, rotationspeed and the time.span. """ - def calculate_odometrie_delta (self, w,v,time_delta): - theta_delta = (w * time_delta) - if w < 0: - y_delta = (v * (-np.cos(theta_delta) / w - 1)) + def calculate_odometrie_delta (self, w, v, time_delta): + + if w != 0: + theta_delta = (w * time_delta) + x_delta = (v * (np.sin(theta_delta) / w)) + y_delta = (v * (-(np.cos(theta_delta) + cos(0)) / w)) + else: - y_delta = (v * (-np.cos(theta_delta) / w + 1)) - x_delta = (v * (np.sin(w * time_delta) / w)) + theta_delta = 0 + x_delta = v * (np.cos(0)) + y_delta = v * (np.sin(0)) return (x_delta, y_delta, theta_delta)