def ask_slider_entry(self): goal = AskOnGuiGoal() goal.type = "slider" goal.content = "How many steps would you like to walk?" goal.options = ["steps"] goal.args = ["100", "500", "50", "200"] self._action_client.wait_for_server() self._action_client.send_goal(goal) self._action_client.wait_for_result() response = self._action_client.get_result()
def ask_multiple_choice(self): goal = AskOnGuiGoal() goal.type = "multiple choice" goal.content = "How are you doing today? Is everything good?" goal.options = ["Great", "Okay", "Bad"] goal.args = [] self._action_client.wait_for_server() self._action_client.send_goal(goal) self._action_client.wait_for_result() response = self._action_client.get_result()
def ask_text_entry(self): goal = AskOnGuiGoal() goal.type = "text entry" goal.content = "What is your name?" goal.options = ["Is my name"] goal.args = ["Your name"] self._action_client.wait_for_server() self._action_client.send_goal(goal) self._action_client.wait_for_result() response = self._action_client.get_result()
def ask_time_entry(self): goal = AskOnGuiGoal() goal.type = "time entry" goal.content = "When would you like to walk?" goal.options = ["is when"] goal.args = ["30", "12:30"] self._action_client.wait_for_server() self._action_client.send_goal(goal) self._action_client.wait_for_result() response = self._action_client.get_result() rospy.wait_for_service(self._ASK_SERVICE)
def call_ask_action_service(self, message): rospy.loginfo("Calling action") if type(message) is not Message: raise TypeError("Invalid message class.") goal = AskOnGuiGoal() goal.type = message.message_type goal.content = message.content goal.options = message.options goal.args = message.args self._cordial_action_client.wait_for_server() self._cordial_action_client.send_goal(goal, feedback_cb=self._cordial_feedback_cb) self._cordial_action_client.wait_for_result() response = self._cordial_action_client.get_result() return response.data
def test_ask_on_gui_action_preempt(self): client = actionlib.SimpleActionClient( _SAY_AND_ASK_ON_GUI_ACTION, AskOnGuiAction ) goal = AskOnGuiGoal() goal.type = "multiple choice" goal.content = "Hello there" goal.options = ["Next"] goal.args = [] self.assertTrue(client.wait_for_server(rospy.Duration(2)), "Could not connect") rospy.loginfo("Connected to server") client.send_goal(goal) rospy.sleep(1) client.cancel_goal() rospy.sleep(1) self.assertEqual(actionlib.GoalStatus.PREEMPTED, client.get_state())
def test_ask_on_gui_action(self): client = actionlib.SimpleActionClient( _SAY_AND_ASK_ON_GUI_ACTION, AskOnGuiAction ) goal = AskOnGuiGoal() goal.type = "multiple choice" goal.content = "Hello there" goal.options = ["Next"] goal.args = [] self.assertTrue(client.wait_for_server(rospy.Duration(2)), "Could not connect") rospy.loginfo("Connected to server") client.send_goal(goal) self.assertTrue(client.wait_for_result(rospy.Duration(5)), "Goal didn't finish") self.assertEqual(actionlib.GoalStatus.SUCCEEDED, client.get_state()) self.assertEqual(client.get_result().data, "Debugging")