Use meters instead of millimeters for PyRoboViz

This commit is contained in:
simondlevy
2019-01-03 18:20:12 -05:00
parent 2677ee3333
commit e2e6ce53a1
6 changed files with 16 additions and 14 deletions

View File

@@ -45,7 +45,6 @@ from roboviz import Visualizer
from sys import argv, exit from sys import argv, exit
from time import sleep from time import sleep
from threading import Thread from threading import Thread
import pickle
def threadfunc(robot, slam, timestamps, lidars, odometries, mapbytes, pose): def threadfunc(robot, slam, timestamps, lidars, odometries, mapbytes, pose):
''' '''
@@ -112,7 +111,7 @@ def main():
else Deterministic_SLAM(MinesLaser(), MAP_SIZE_PIXELS, MAP_SIZE_METERS) else Deterministic_SLAM(MinesLaser(), MAP_SIZE_PIXELS, MAP_SIZE_METERS)
# Set up a SLAM display, named by dataset # Set up a SLAM display, named by dataset
display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS*1000/MAP_SIZE_PIXELS, dataset) display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS, dataset)
# Pose will be modified in our threaded code # Pose will be modified in our threaded code
pose = [0,0,0] pose = [0,0,0]
@@ -127,7 +126,7 @@ def main():
# Display map and robot pose # Display map and robot pose
display.displayMap(mapbytes) display.displayMap(mapbytes)
display.setPose(*pose) display.setPose(pose[0]/1000., pose[1]/1000., pose[2])
# Refresh the display, exiting gracefully if user closes it # Refresh the display, exiting gracefully if user closes it
if not display.refresh(): if not display.refresh():

View File

@@ -33,7 +33,6 @@ along with this code. If not, see <http://www.gnu.org/licenses/>.
from breezyslam.vehicles import WheeledVehicle from breezyslam.vehicles import WheeledVehicle
from breezyslam.sensors import URG04LX from breezyslam.sensors import URG04LX
import math
# Method to load all from file ------------------------------------------------ # Method to load all from file ------------------------------------------------

View File

@@ -43,7 +43,7 @@ if __name__ == '__main__':
slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS) slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS)
# Set up a SLAM display # Set up a SLAM display
display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS*1000/MAP_SIZE_PIXELS, 'SLAM') display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS, 'SLAM')
# Initialize an empty trajectory # Initialize an empty trajectory
trajectory = [] trajectory = []
@@ -90,7 +90,7 @@ if __name__ == '__main__':
display.displayMap(mapbytes) display.displayMap(mapbytes)
# Display the robot's pose in the map # Display the robot's pose in the map
display.setPose(x, y, theta) display.setPose(x/1000., y/1000., theta)
# Break on window close # Break on window close
if not display.refresh(): if not display.refresh():

View File

@@ -47,7 +47,7 @@ if __name__ == '__main__':
slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS) slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS)
# Set up a SLAM display # Set up a SLAM display
display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS*1000/MAP_SIZE_PIXELS, 'SLAM') display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS, 'SLAM')
# Initialize an empty trajectory # Initialize an empty trajectory
trajectory = [] trajectory = []
@@ -98,9 +98,11 @@ if __name__ == '__main__':
# Get current map bytes as grayscale # Get current map bytes as grayscale
slam.getmap(mapbytes) slam.getmap(mapbytes)
# Display map
display.displayMap(mapbytes) display.displayMap(mapbytes)
display.setPose(x, y, theta) # Display pose after converting from mm to meters
display.setPose(x/1000., y/1000., theta)
# Break on window close # Break on window close
if not display.refresh(): if not display.refresh():

View File

@@ -39,7 +39,7 @@ if __name__ == '__main__':
slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS) slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS)
# Set up a SLAM display # Set up a SLAM display
display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS*1000/MAP_SIZE_PIXELS, 'SLAM') display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS, 'SLAM')
# Initialize empty map # Initialize empty map
mapbytes = bytearray(MAP_SIZE_PIXELS * MAP_SIZE_PIXELS) mapbytes = bytearray(MAP_SIZE_PIXELS * MAP_SIZE_PIXELS)
@@ -55,9 +55,11 @@ if __name__ == '__main__':
# Get current map bytes as grayscale # Get current map bytes as grayscale
slam.getmap(mapbytes) slam.getmap(mapbytes)
# Display map
display.displayMap(mapbytes) display.displayMap(mapbytes)
display.setPose(x, y, theta) # Display pose after converting from mm to meters
display.setPose(x/1000., y/1000., theta)
# Exit on window close # Exit on window close
if not display.refresh(): if not display.refresh():

View File

@@ -30,8 +30,6 @@ from xvlidar import XVLidar as Lidar
from roboviz import Visualizer from roboviz import Visualizer
from sys import stdout
if __name__ == '__main__': if __name__ == '__main__':
# Connect to Lidar unit # Connect to Lidar unit
@@ -41,7 +39,7 @@ if __name__ == '__main__':
slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS) slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS)
# Set up a SLAM display # Set up a SLAM display
display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS*1000/MAP_SIZE_PIXELS, 'SLAM') display = Visualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS, 'SLAM')
# Initialize an empty trajectory # Initialize an empty trajectory
trajectory = [] trajectory = []
@@ -60,9 +58,11 @@ if __name__ == '__main__':
# Get current map bytes as grayscale # Get current map bytes as grayscale
slam.getmap(mapbytes) slam.getmap(mapbytes)
# Display map
display.displayMap(mapbytes) display.displayMap(mapbytes)
display.setPose(x, y, theta) # Display pose after converting from mm to meters
display.setPose(x/1000., y/1000., theta)
# Exit on window close # Exit on window close
if not display.refresh(): if not display.refresh():