34 from actionlib_msgs.msg
import GoalStatus
35 from robot_controllers_msgs.msg
import QueryControllerStatesAction, \
36 QueryControllerStatesGoal, \
39 ACTION_NAME =
"/query_controller_states" 41 if __name__ ==
"__main__":
42 rospy.init_node(
"get_robot_controllers_state")
44 rospy.loginfo(
"Connecting to %s..." % ACTION_NAME)
46 client.wait_for_server()
48 rospy.loginfo(
"Requesting state of controllers...")
50 goal = QueryControllerStatesGoal()
51 client.send_goal(goal)
52 client.wait_for_result()
53 if client.get_state() == GoalStatus.SUCCEEDED:
54 result = client.get_result()
55 for state
in result.state:
56 if state.state == state.RUNNING:
57 print(
"%s[%s]: RUNNING" % (state.name, state.type))
58 elif state.state == state.STOPPED:
59 print(
"%s[%s]: STOPPED" % (state.name, state.type))
60 elif state.state == state.ERROR:
61 print(
"%s[%s]: ERROR!!" % (state.name, state.type))
62 elif client.get_state() == GoalStatus.ABORTED:
63 rospy.logerr(client.get_goal_status_text())