def init_rec_odom_action_client(self): self._rec_odom_action_client = actionlib.SimpleActionClient( '/rec_odom_as', record_odomAction) # waits until the action server is up and running rospy.loginfo('Waiting for action Server') self._rec_odom_action_client.wait_for_server() rospy.loginfo('Action Server Found...') self._rec_odom_action_goal = record_odomGoal()
def _call_server(self): goal = record_odomGoal() self._action_client.send_goal(goal) rate = rospy.Rate(1) state = self._action_client.get_state() while state < DONE: rospy.loginfo("Waiting for server to return result") rate.sleep() state = self._action_client.get_state() rospy.loginfo("[Result] State: " + str(state)) if state == 4: rospy.logerr("Something went wrong in the Server Side") if state == 3: rospy.logwarn("There is a warning in the Server Side") result = self._action_client.get_result() rospy.loginfo("Result: " + str(result))
# initializes the action client node rospy.init_node('record_odom_action_client_node') # create the connection to the action server client = actionlib.SimpleActionClient('/rec_odom_as', record_odomAction) rate = rospy.Rate(1) # waits until the action server is up and running rospy.loginfo('Waiting for action Server') client.wait_for_server() rospy.loginfo('Action Server Found...') # creates a goal to send to the action server goal = record_odomGoal() # sends the goal to the action server, specifying which feedback function # to call when feedback received client.send_goal(goal, feedback_cb=feedback_callback) # simple_state will be 1 if active, and 2 when finished. It's a variable, better use a function like get_state. #state = client.simple_state # state_result will give the FINAL STATE. Will be 1 when Active, and 2 if NO ERROR, 3 If Any Warning, and 3 if ERROR state_result = client.get_state() """ class SimpleGoalState: PENDING = 0
def send_goal_to_action_server(self): goal = record_odomGoal() self.action_client.send_goal(goal, feedback_cb=self.action_feedback_callback)
def init_action_client(self,action_name = '/my_sphero_Ac_server'): self.action_client = actionlib.SimpleActionClient(action_name, record_odomAction) rospy.loginfo('Waiting for action Server') self.action_client.wait_for_server() rospy.loginfo('Action Server Found...') self._goal_object = record_odomGoal()