def transition_cb(self, goal, handler): ''' When a task "transitions" (canceled, started, aborted, succeded), update the log and result pane ''' status = handler.get_goal_status() if status == GoalStatus.ACTIVE: if self.current_task and goal.id != self.current_task: pass # Another active goal happened, clear Feedback and stuff self.result_label.clear() self.current_task = goal.id self.current_task_task = handler.comm_state_machine.action_goal.goal.task self.current_task_status = 'In progress' self.current_task_status_label.setText(self.current_task_status) self.current_task_result = '' self.current_task_label.setText(self.current_task_task) self.ui_log('STARTING: new task {}'.format(self.current_task_task)) if goal.id == self.current_task: terminal_state = TerminalState.to_string(status) if terminal_state == 'NO_SUCH_STATE_1': return result = handler.get_result() if result and result.result != self.current_task_result: self.result_label.setText(result.result) self.ui_log('RESULT: {}'.format(result.result)) if terminal_state != self.current_task_status: self.current_task_status = terminal_state self.current_task_status_label.setText( self.current_task_status) self.ui_log('FINISHED: task finished ({})'.format( self.current_task_status))
def transition_cb(self, goal, handler): ''' When a mission "transitions" (canceled, started, aborted, succeded), update the log and result pane ''' status = handler.get_goal_status() if status == GoalStatus.ACTIVE: if self.current_mission and goal.id != self.current_mission: pass # Another active goal happened, clear Feedback and stuff self.result_label.clear() self.current_mission = goal.id self.current_mission_mission = handler.comm_state_machine.action_goal.goal.mission self.current_mission_status = 'In progress' self.current_mission_status_label.setText(self.current_mission_status) self.current_mission_result = '' self.current_mission_label.setText(self.current_mission_mission) self.ui_log('STARTING: new mission {}'.format(self.current_mission_mission)) if goal.id == self.current_mission: terminal_state = TerminalState.to_string(status) if terminal_state == 'NO_SUCH_STATE_1': return result = handler.get_result() if result and result.result != self.current_mission_result: self.result_label.setText(result.result) self.ui_log('RESULT: {}'.format(result.result)) if terminal_state != self.current_mission_status: self.current_mission_status = terminal_state self.current_mission_status_label.setText(self.current_mission_status) self.ui_log('FINISHED: mission finished ({})'.format(self.current_mission_status))
def _client_cb(self, terminal_state, result): if terminal_state != 3: rospy.logwarn('Station hold goal failed (Status={}, Result={})'.format( TerminalState.to_string(terminal_state), result.result)) return rospy.loginfo('Station holding!') self.broadcaster.clear_alarm()
def _client_cb(self, terminal_state, result): if terminal_state != 3: rospy.logwarn( 'Station hold goal failed (Status={}, Result={})'.format( TerminalState.to_string(terminal_state), result.result)) return rospy.loginfo('Station holding!') self.broadcaster.clear_alarm()
def cb(terminal_state, result): if terminal_state == 3: rospy.loginfo('Thrusters Retracted!') else: rospy.logwarn( 'Error rectracting thrusters: {}, status: {}'.format( TerminalState.to_string(terminal_state), result.status))
def _client_cb(self, terminal_state, result): if terminal_state != 3: rospy.logwarn('Station hold goal failed (Status={}, Result={})'.format( TerminalState.to_string(terminal_state), result)) return try: self.change_wrench('autonomous') rospy.loginfo('Now station holding') self.broadcaster.clear_alarm() except rospy.ServiceException as e: rospy.logwarn('Station hold changing wrench failed: {}'.format(e))
def _client_cb(self, terminal_state, result): if terminal_state != 3: rospy.logwarn( 'Station hold goal failed (Status={}, Result={})'.format( TerminalState.to_string(terminal_state), result)) return try: self.change_wrench('autonomous') rospy.loginfo('Now station holding') self.broadcaster.clear_alarm() except rospy.ServiceException as e: rospy.logwarn('Station hold changing wrench failed: {}'.format(e))
def bag(self, timeout=rospy.Duration(0)): self.client.wait_for_server() self.result = None self.total_it = 0 self.bar = tqdm(desc='Writing bag', unit=' percent', total=100, bar_format='{desc} {bar} {percentage:3.0f}%') self.client.send_goal(self.goal, done_cb=self._done_cb, feedback_cb=self._feedback_cb) while self.result is None and not rospy.is_shutdown(): rospy.sleep(0.1) self.bar.refresh() self.bar.close() (status, result) = self.result if status == 3: print 'Bag successful' else: print 'Bag {}: {}'.format(TerminalState.to_string(status), result.status)
def _bag_done_cb(self, status, result): if status == 3: rospy.loginfo('KILL BAG WRITTEN TO {}'.format(result.filename)) else: rospy.logwarn('KILL BAG {}, status: {}'.format( TerminalState.to_string(status), result.status))
def _bag_done_cb(self, status, result): if status == 3: rospy.loginfo('KILL BAG WRITTEN TO {}'.format(result.filename)) else: rospy.logwarn('KILL BAG {}, status: {}'.format(TerminalState.to_string(status), result.status))
def _kill_task_cb(self, status, result): if status == 3: rospy.loginfo('Killed task success!') return rospy.logwarn('Killed task failed ({}): {}'.format(TerminalState.to_string(status), result.result))