-
Notifications
You must be signed in to change notification settings - Fork 10
/
target_selection.py
executable file
·36 lines (26 loc) · 1.14 KB
/
target_selection.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
32
33
34
35
#!/usr/bin/env python
import rospy
import random
# Class for selecting the next best target
class TargetSelection:
# Constructor
def __init__(self):
pass
def selectTarget(self, ogm, coverage, robot_pose):
# The next target in pixels
next_target = [0, 0]
# YOUR CODE HERE ------------------------------------------------------
# Here you must select the next target of the robot. The next target
# should exist in unoccupied and uncovered space. Thus, you must use the
# ogm and coverage variables or / and the robot pose. The easier way is to
# randomly select points of the map until one such point can be a target
# Of course you should try something smarter...!
found = False
while not found:
x_rand = random.randint(0, ogm.shape[0] - 1)
y_rand = random.randint(0, ogm.shape[1] - 1)
if ogm[x_rand][y_rand] < 50:
next_target = [x_rand, y_rand]
found = True
# ---------------------------------------------------------------------
return next_target