From b49919a7ed6c444a1f12f52c044012eb39a49b17 Mon Sep 17 00:00:00 2001 From: jureao Date: Fri, 23 Mar 2018 11:36:44 +0100 Subject: [PATCH] reapplied commit: c323a6e --- src/odometry.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/odometry.py b/src/odometry.py index 2e514cb..862f1e1 100644 --- a/src/odometry.py +++ b/src/odometry.py @@ -39,19 +39,20 @@ class Odometry: def degree(self, delta_rotation_l, delta_rotation_r,star_Direc): #delta_rotation_l/r should work with getmovement method self.alpha = 0 #should be start_Direc self.alpha=star_Direc - while True: + self.alpha = ((self.delta_rotation_l * self._distance_per_tick - self.delta_rotation_r * self._distance_per_tick)/self._wheel_axis) + self.alpha self.distance=(self.delta_rotation_r * self._distance_per_tick + self.delta_rotation_l * self._distance_per_tick)/2 + self.distance - if self.alpha % (2 * self._pi) >=0 and self.alpha % (2 * pi) = 7/4*pi and self.alpha %(2 * pi) <2*pi: - return(Direction.NORTH) + if self.alpha % (2 * self._pi) >=0 and self.alpha % (2 * self._pi) = 7/4*self._pi and self.alpha %(2 * pi) <2*pi: + return(Direction.NORTH,"Distance = ",self.distance) - elif self.alpha % (2 * self._pi) >= self._pi*0.25 and self.alpha % ( 2 * pi ) < self._pi*0.5 or self.alpha % (2 * self._pi ) >= self._pi * 0.5 and self.alpha % (2 * self._pi ) < self._pi *0.75: - return(Direction.EAST) + elif self.alpha % (2 * self._pi) >= self._pi*0.25 and self.alpha % ( 2 * self._pi ) < self._pi*0.5 or self.alpha % (2 * self._pi ) >= self._pi * 0.5 and self.alpha % (2 * self._pi ) < self._pi *0.75: + return(Direction.EAST,"Distance = ",self.distance) - elif self.alpha % (2 * self._pi)>=self._pi * 0.75 and self.alpha % (2* self._pi)< self._pi or self.alpha % (2 * self_pi) >=self._pi and self.alpha < self.alpha * 5/4 pi : - return(Direction.SOUTH) + elif self.alpha % (2 * self._pi)>=self._pi * 0.75 and self.alpha % (2* self._pi)< self._pi or self.alpha % (2 * self._pi) >=self._pi and self.alpha < self.alpha * 5/4 pi : + return(Direction.SOUTH,"Distance = ",self.distance) else: - return(Direction.WEST) + return(Direction.WEST,"Distance = ",self.distance) + def coordinates(self,delta_rota_l,delta_rota_r,Y_koord,X_koord): # worked as function outside the class self.y= self.Y_koord