-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (27 loc) · 897 Bytes
/
main.py
File metadata and controls
33 lines (27 loc) · 897 Bytes
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
32
33
# main.py
import numpy as np
from robot import Robot
from grid_map import GridMap
from lidar import LidarSensor
from filter import Filter
GRID_SIZE = 10
motion_kernel = [0.6, 0.3, 0.1]
sensor_noise=1
# Initialize grid, robot, lidar, and filter
grid_map = GridMap(GRID_SIZE)
robot = Robot(grid_map, motion_kernel)
lidar = LidarSensor(grid_map, sensor_noise)
bayes_filter = Filter(grid_map, lidar, motion_kernel, sensor_noise)
# Control loop
while True:
print("Enter direction (N, S, W, E) or 'q' to quit:")
user_input = input().strip().upper()
if user_input == "Q":
break
# Move the robot and get noisy sensor readings
robot.move(user_input)
measurements = lidar.get_noisy_measurement(robot.x, robot.y)
# Update belief using Bayesian filter
belief = bayes_filter.step(user_input, measurements)
print("Current belief:")
grid_map.display(belief)