Skip to content

Commit

Permalink
Zero-angle working
Browse files Browse the repository at this point in the history
  • Loading branch information
simondlevy committed Jan 13, 2019
1 parent cc5db5d commit 5c24712
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions randomwalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ def error(self, message):
prevtime = time()

# Loop till user closes the display
#while True:
for k in range(5):

print(pose[2])
while True:

# Set current pose in visualizer the display, exiting gracefully if user closes it
if not viz.display(*pose):
Expand Down
10 changes: 5 additions & 5 deletions roboviz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'''
'''self.rotate_angle)
roboviz.py - Python classes for displaying maps and robots
Requires: numpy, matplotlib
Expand Down Expand Up @@ -106,19 +106,19 @@ def _setPose(self, x_m, y_m, theta_deg):
theta: rotation (degrees)
'''

if self.start_angle is None:
# If zero-angle was indicated, grab first angle to compute rotation
if self.start_angle is None and self.zero_angle != 0:
self.start_angle = theta_deg
self.rotate_angle = self.zero_angle - self.start_angle

# Rotate by computed angle, or zero if no zero-angle indicated
d = self.rotate_angle

a = np.radians(d)

c = np.cos(a)
s = np.sin(a)

x_m,y_m = x_m*c-y_m*s, y_m*c+x_m*s

# Erase previous vehicle image after first iteration
if not self.vehicle is None:
self.vehicle.remove()

Expand Down

0 comments on commit 5c24712

Please sign in to comment.