forked from pollen-robotics/rosa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
94b4da4
commit 09b1fdc
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import time | ||
import numpy as np | ||
|
||
from rosa import Rosa | ||
|
||
|
||
""" | ||
Exploration mode. | ||
The robot will goes straightforward until it sees an obstacle or detect void below it. | ||
It will then do a random turn and keep going. | ||
The program runs forever until stops via Ctrl-c. | ||
""" | ||
|
||
|
||
cruise_speed = 0.15 | ||
|
||
if __name__ == '__main__': | ||
rosa = Rosa('rosa.local') | ||
|
||
while True: | ||
dist = np.array([rosa.get_distance(s) for s in rosa.front_distance_sensors]) | ||
obstacle_detected = np.any(dist > 200) | ||
|
||
ground = np.array([rosa.get_distance(s) for s in rosa.ground_distance_sensors]) | ||
void_detected = np.any(ground < 100) | ||
|
||
if obstacle_detected or void_detected: | ||
rosa.left_wheel.speed = np.random.rand() - 0.5 # random value within [-1/2, 1/2] | ||
rosa.right_wheel.speed = np.random.rand() - 0.5 # random value within [-1/2, 1/2] | ||
|
||
time.sleep(1) | ||
|
||
rosa.left_wheel.speed = rosa.right_wheel.speed = cruise_speed | ||
time.sleep(0.1) |