From 25cb93d8050e28179982ab1e230be0bc0b6afe72 Mon Sep 17 00:00:00 2001 From: Alfredo Rwagaju Date: Mon, 15 Aug 2016 12:26:00 -0400 Subject: [PATCH] Added the scanning code for the slam sensor but there is severe slow of the animation --- examples/pltslamshow.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/pltslamshow.py b/examples/pltslamshow.py index 91a455e..230c8d7 100644 --- a/examples/pltslamshow.py +++ b/examples/pltslamshow.py @@ -48,6 +48,7 @@ TRAJECTORY_COLOR_BGR = (255, 0, 0) import matplotlib.pyplot as plt from math import sin, cos, radians +import numpy as np class SlamShow(object): @@ -87,14 +88,20 @@ class SlamShow(object): self._add_vehicle(16000,16000,0) def displayMap(self, mapbytes): - + + mapimg = np.reshape(np.frombuffer(mapbytes, dtype=np.uint8), (self.map_size_pixels, self.map_size_pixels)) + + plt.imshow(mapimg) + plt.set_cmap('gray') + # Interleave the grayscale map bytes into the color bytes self.bgrbytes[0::3] = mapbytes self.bgrbytes[1::3] = mapbytes self.bgrbytes[2::3] = mapbytes - - # Put color bytes into image - + + # Put color bytes into image - this line causes error + #plt.set_cmap('BlueRedAlpha') + def displayVelocities(self, dxy_mm, dtheta_deg): # Add velocity bars