Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,7 +54,6 @@ def check_collision(x, z):
|
|
| 54 |
return True
|
| 55 |
return False
|
| 56 |
|
| 57 |
-
# Movement logic
|
| 58 |
def move_robot(direction):
|
| 59 |
global pose, trajectory
|
| 60 |
step = 1
|
|
@@ -76,13 +75,8 @@ def move_robot(direction):
|
|
| 76 |
return render_env(), render_slam_map(), None, "❌ Invalid Key"
|
| 77 |
|
| 78 |
if check_collision(new_x, new_z):
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
try:
|
| 82 |
-
display(Audio("collision1.mp3", autoplay=True))
|
| 83 |
-
except:
|
| 84 |
-
pass
|
| 85 |
-
return render_env(), render_slam_map(), None, "🚫 Collision detected!"
|
| 86 |
|
| 87 |
pose["x"], pose["z"] = new_x, new_z
|
| 88 |
if noise_enabled:
|
|
@@ -94,6 +88,7 @@ def move_robot(direction):
|
|
| 94 |
|
| 95 |
return render_env(), render_slam_map(), None, "Moved " + direction
|
| 96 |
|
|
|
|
| 97 |
# Environment view
|
| 98 |
def render_env():
|
| 99 |
global obstacle_hits
|
|
|
|
| 54 |
return True
|
| 55 |
return False
|
| 56 |
|
|
|
|
| 57 |
def move_robot(direction):
|
| 58 |
global pose, trajectory
|
| 59 |
step = 1
|
|
|
|
| 75 |
return render_env(), render_slam_map(), None, "❌ Invalid Key"
|
| 76 |
|
| 77 |
if check_collision(new_x, new_z):
|
| 78 |
+
audio_path = "collision1.mp3" if os.path.exists("collision1.mp3") else None
|
| 79 |
+
return render_env(), render_slam_map(), audio_path, "🚫 Collision detected!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
pose["x"], pose["z"] = new_x, new_z
|
| 82 |
if noise_enabled:
|
|
|
|
| 88 |
|
| 89 |
return render_env(), render_slam_map(), None, "Moved " + direction
|
| 90 |
|
| 91 |
+
|
| 92 |
# Environment view
|
| 93 |
def render_env():
|
| 94 |
global obstacle_hits
|