Skip to content

Commit 7d541f8

Browse files
authored
Add files via upload
1 parent 229d7e2 commit 7d541f8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

create_1_return_to_dock.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from ca_msgs.msg import Bumper
1212
from nav_msgs.msg import Path
1313
from std_msgs.msg import Empty
14+
import signal
1415

1516
home_x = -4.5
1617
home_y = 7.5
@@ -26,6 +27,14 @@
2627

2728
listener = tf.TransformListener()
2829

30+
class TimeoutException(Exception): # Custom exception class
31+
pass
32+
33+
def timeout_handler(signum, frame): # Custom signal handler
34+
raise TimeoutException
35+
36+
signal.signal(signal.SIGALRM, timeout_handler)
37+
2938
def move_base_client():
3039

3140
client = actionlib.SimpleActionClient('move_base', move_base_msgs.msg.MoveBaseAction)
@@ -239,6 +248,8 @@ def move2goal(points):
239248

240249
for point in points:
241250

251+
signal.alarm(10)
252+
242253
point_x = point[0]
243254
point_y = point[1]
244255

@@ -256,7 +267,12 @@ def move2goal(points):
256267
current_x = trans[0]
257268
current_y = trans[1]
258269
movement_distance = sqrt((point_x-current_x)**2+(point_y-current_y)**2)
259-
moveTo(movement_distance)
270+
try:
271+
moveTo(movement_distance)
272+
except TimeoutException:
273+
continue
274+
else:
275+
signal.alarm(0)
260276

261277
x = Empty()
262278
print check_camera()

0 commit comments

Comments
 (0)