-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslam-mapping-basic.py
32 lines (26 loc) · 1.03 KB
/
slam-mapping-basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import env, sensors
import pygame
environment = env.buildEnvironment((600,1200))
environment.originalMap = environment.map.copy()
laser = sensors.LaserSensor(200, environment.originalMap, uncertainty=(0.5,0.01))
environment.map.fill((0,0,0)) #fill main map with black to hide everything
environment.infomap = environment.map.copy() #where pointCloud is drawn
running = True
while running :
sensorON = False
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if pygame.mouse.get_focused():
#sensor is only on when mouse is inside window to prevent negative values
sensorON = True
elif not pygame.mouse.get_focused():
sensorON = False
if sensorON:
position = pygame.mouse.get_pos()
laser.position=position
sensor_data = laser.sense_obstacles()
environment.dataStorage(sensor_data)
environment.show_sensorData()
environment.map.blit(environment.infomap, (0,0))
pygame.display.update()