File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 11
11
from ca_msgs .msg import Bumper
12
12
from nav_msgs .msg import Path
13
13
from std_msgs .msg import Empty
14
+ import signal
14
15
15
16
home_x = - 4.5
16
17
home_y = 7.5
26
27
27
28
listener = tf .TransformListener ()
28
29
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
+
29
38
def move_base_client ():
30
39
31
40
client = actionlib .SimpleActionClient ('move_base' , move_base_msgs .msg .MoveBaseAction )
@@ -239,6 +248,8 @@ def move2goal(points):
239
248
240
249
for point in points :
241
250
251
+ signal .alarm (10 )
252
+
242
253
point_x = point [0 ]
243
254
point_y = point [1 ]
244
255
@@ -256,7 +267,12 @@ def move2goal(points):
256
267
current_x = trans [0 ]
257
268
current_y = trans [1 ]
258
269
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 )
260
276
261
277
x = Empty ()
262
278
print check_camera ()
You can’t perform that action at this time.
0 commit comments