#NEWLINE# def do_timer( goal ) : #NEWLINE# #INDENT# start_time = time . time ( ) #NEWLINE# update_count = 0 #NEWLINE# if ( goal . time_to_wait . to_sec ( ) > 60.0 ) : #NEWLINE# #INDENT# result = TimerResult ( ) #NEWLINE# result . time_elapsed = rospy . Duration . from_sec ( ( time . time ( ) - start_time ) ) #NEWLINE# result . updates_sent = update_count #NEWLINE# server . set_aborted ( result , 'Timer aborted due to too-long wait' ) #NEWLINE# return #NEWLINE# #UNINDENT# while ( ( time . time ( ) - start_time ) < goal . time_to_wait . to_sec ( ) ) : #NEWLINE# #INDENT# if server . is_preempt_requested ( ) : #NEWLINE# #INDENT# result = TimerResult ( ) #NEWLINE# result . time_elapsed = rospy . Duration . from_sec ( ( time . time ( ) - start_time ) ) #NEWLINE# result . updates_sent = update_count #NEWLINE# server . set_preempted ( result , 'Timer preempted' ) #NEWLINE# return #NEWLINE# #UNINDENT# feedback = TimerFeedback ( ) #NEWLINE# feedback . time_elapsed = rospy . Duration . from_sec ( ( time . time ( ) - start_time ) ) #NEWLINE# feedback . time_remaining = ( feedback . time_to_wait - feedback . time_elapsed ) #NEWLINE# server . publish_feedback ( feedback ) #NEWLINE# update_count += 1 #NEWLINE# time . sleep ( 1.0 ) #NEWLINE# #UNINDENT# result = TimerResult ( ) #NEWLINE# result . time_elapsed = rospy . Duration . from_sec ( ( time . time ( ) - start_time ) ) #NEWLINE# result . updates_sent = update_count #NEWLINE# server . set_succeeded ( result , 'Timer completed successfully' )