diff --git a/.gitignore b/.gitignore index 275e168..c99bab7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ examples/*.pgm examples/*.png python/breezyslam/__pycache__ python/build +*.swp diff --git a/examples/Makefile b/examples/Makefile index 9d2e85e..36201b6 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -30,7 +30,7 @@ RANDOM_SEED = 9999 all: log2pgm Log2PGM.class -display: +movie: ./logdemo.py exp1 1 9999 pytest: diff --git a/examples/pltslamshow.py b/examples/pltslamshow.py index 4b73dd1..de4096f 100644 --- a/examples/pltslamshow.py +++ b/examples/pltslamshow.py @@ -44,6 +44,7 @@ SENSOR_NEGATIVE_COLOR_BGR = (0,0,255) TRAJECTORY_COLOR_BGR = (255, 0, 0) import cv +import matplotlib.pyplot as plt # Arbitrary font for OpenCV FONT_FACE = cv.CV_FONT_HERSHEY_COMPLEX @@ -75,6 +76,28 @@ class SlamShow(object): cv.SetData(self.image, self.bgrbytes, self.map_size_pixels*3) cv.ShowImage(self.window_name, self.image) + # Make a nice big (10"x10") figure + fig = plt.figure(figsize=(10,10)) + + # Store Python ID of figure to detect window close + self.figid = id(fig) + + fig.canvas.set_window_title('SLAM 2D') + + self.ax = fig.gca() + self.ax.set_aspect("auto") + self.ax.set_autoscale_on(True) + + map_size_mm = map_scale_mm_per_pixel * map_size_pixels + + self.ax.set_xlim([0, map_size_mm]) + self.ax.set_ylim([0, map_size_mm]) + + self.ax.set_xlabel('X (cm)') + self.ax.set_ylabel('Y (cm)') + + self.ax.grid(False) + def displayMap(self, mapbytes): @@ -88,7 +111,6 @@ class SlamShow(object): def displayRobot(self, (x_mm, y_mm, theta_deg), color=ROBOT_COLOR_BGR, scale=1, line_thickness=1): - # Get a polyline (e.g. triangle) to represent the robot icon robot_points = self.robot_polyline(scale)