コード例 #1
0
ファイル: robot.py プロジェクト: jdddog/hri
    def gesture(self, gesture, target=None, duration=None):
        if not self.gesture_found:
            self.wait_for_action_servers(self.gesture_client)
            self.gesture_found = True

        ParamFormatting.assert_types(self.gesture, gesture, IGesture)

        goal = GestureGoal()
        goal.gesture = gesture.name

        if target is None:
            goal.target = ''
        else:
            World().add_to_world(target)
            ParamFormatting.assert_types(self.gesture, target, Entity)
            goal.target = target.get_id()

        if duration is None:
            goal.duration = -1
        else:
            ParamFormatting.assert_types(self.expression, duration, float)
            ParamFormatting.assert_greater_than(self.expression, duration, 0.0)
            goal.duration = duration

        gh = self.gesture_client.send_goal(goal, done_cb=self.gesture_done)

        ah = MultiGoalActionHandle(self.gesture_client, gh)
        self.add_action_handle(ah)
        return ah
コード例 #2
0
ファイル: robot.py プロジェクト: jdddog/hri
    def gesture(self, gesture, target=None, duration=None):
        if not self.gesture_found:
            self.wait_for_action_servers(self.gesture_client)
            self.gesture_found = True

        ParamFormatting.assert_types(self.gesture, gesture, IGesture)

        goal = GestureGoal()
        goal.gesture = gesture.name

        if target is None:
            goal.target = ""
        else:
            World().add_to_world(target)
            ParamFormatting.assert_types(self.gesture, target, Entity)
            goal.target = target.get_id()

        if duration is None:
            goal.duration = -1
        else:
            ParamFormatting.assert_types(self.expression, duration, float)
            ParamFormatting.assert_greater_than(self.expression, duration, 0.0)
            goal.duration = duration

        gh = self.gesture_client.send_goal(goal, done_cb=self.gesture_done)

        ah = MultiGoalActionHandle(self.gesture_client, gh)
        self.add_action_handle(ah)
        return ah
コード例 #3
0
ファイル: test_say_to_parser.py プロジェクト: jdddog/hri
    def test_parse_say_to(self):
        valid_gestures = ['wave', 'point']
        goal_actual = SayToParser.parse_say_to("Hello I am a robot", 1, valid_gestures, tts_duration_srv)
        goal_expected = SayToGoal()
        goal_expected.text = "Hello I am a robot"
        goal_expected.gestures = []
        goal_expected.gesture_indicies = []
        goal_expected.audience_id = 1
        self.assertEqual(goal_actual, goal_expected)

        goal_actual_1 = SayToParser.parse_say_to("<wave>Hello I am a robot</wave>", 1, valid_gestures, tts_duration_srv)
        goal_expected_1 = SayToGoal()
        goal_expected_1.text = "Hello I am a robot"
        wave = GestureGoal()
        wave.type = 'wave'
        wave.duration = 1.0
        goal_expected_1.gestures = [wave]
        goal_expected_1.gesture_indicies = [0]
        goal_expected_1.audience_id = 1
        self.assertEqual(goal_actual_1, goal_expected_1)

        self.assertRaises(GestureDoesNotExistError, SayToParser.parse_say_to, "<nod>Hello I am a robot</nod>", 1, valid_gestures, tts_duration_srv)
        self.assertRaises(TypeError, SayToParser.parse_say_to, "<nod>Hello I am a robot</nod>", 'hello', valid_gestures, tts_duration_srv)
        self.assertRaises(TypeError, SayToParser.parse_say_to, "<nod>Hello I am a robot</nod>", 1, 1, tts_duration_srv)
        self.assertRaises(TypeError, SayToParser.parse_say_to, "<nod>Hello I am a robot</nod>", 1, valid_gestures, '1')
コード例 #4
0
    def test_parse_say_to(self):
        valid_gestures = ['wave', 'point']
        goal_actual = SayToParser.parse_say_to("Hello I am a robot", 1,
                                               valid_gestures,
                                               tts_duration_srv)
        goal_expected = SayToGoal()
        goal_expected.text = "Hello I am a robot"
        goal_expected.gestures = []
        goal_expected.gesture_indicies = []
        goal_expected.audience_id = 1
        self.assertEqual(goal_actual, goal_expected)

        goal_actual_1 = SayToParser.parse_say_to(
            "<wave>Hello I am a robot</wave>", 1, valid_gestures,
            tts_duration_srv)
        goal_expected_1 = SayToGoal()
        goal_expected_1.text = "Hello I am a robot"
        wave = GestureGoal()
        wave.type = 'wave'
        wave.duration = 1.0
        goal_expected_1.gestures = [wave]
        goal_expected_1.gesture_indicies = [0]
        goal_expected_1.audience_id = 1
        self.assertEqual(goal_actual_1, goal_expected_1)

        self.assertRaises(GestureDoesNotExistError, SayToParser.parse_say_to,
                          "<nod>Hello I am a robot</nod>", 1, valid_gestures,
                          tts_duration_srv)
        self.assertRaises(TypeError, SayToParser.parse_say_to,
                          "<nod>Hello I am a robot</nod>", 'hello',
                          valid_gestures, tts_duration_srv)
        self.assertRaises(TypeError, SayToParser.parse_say_to,
                          "<nod>Hello I am a robot</nod>", 1, 1,
                          tts_duration_srv)
        self.assertRaises(TypeError, SayToParser.parse_say_to,
                          "<nod>Hello I am a robot</nod>", 1, valid_gestures,
                          '1')