Пример #1
0
 def grasp_status_changed(object_dropped, stat):
     self.logger.debug('call grasp_status_changed: {}'.format(stat))
     if not self.run:
         return
     utils.nearly_close_hand(self, 'RHand')
     if stat == 'absent':
         utils.stop_monitoring_arm_move()
         object_dropped.setValue(1)
Пример #2
0
    def stop_all(self):
        """Stop all active processes and handle fall."""
        self.run = False

        # Stop all processes, cancel promises, disconnect callbacks
        try:
            utils.stop_monitoring_arm_move()
            utils.stop_monitoring_grasp_status()
            utils.stop_periodic_say()
        except AttributeError:
            pass
        try:
            self.thinking_sound_fut_1.cancel()
        except (AttributeError, RuntimeError):
            pass
        try:
            self.thinking_sound_fut_2.cancel()
        except (AttributeError, RuntimeError):
            pass
        try:
            self.grasp_object.setCanceled()
            self.grasp_object = None
        except (AttributeError, RuntimeError):
            pass
        try:
            self.stop_sub.signal.disconnect(self.stop_sub_id)
        except:
            pass
        try:
            self.fall_sub.signal.disconnect(self.fall_sub_id)
        except:
            pass

        # Handle a fall: quit app
        if self.fell:
            self.logger.debug('handling fall...')
            time.sleep(3)
            self.stand_up(3)
            self.box.onStopped(1)

        # UGH: be robust to launching from Choregraphe without life
        elif self.memory.getData('AutonomousLife/State') == 'disabled':
            self.motion.setBreathEnabled('Legs', False)
            self.motion.setIdlePostureEnabled('Body', True)
            self.stand_up(3)