Python actionlib.SimpleActionClient() Examples
The following are 30
code examples of actionlib.SimpleActionClient().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
actionlib
, or try the search function
.
Example #1
Source File: patrol_fsm.py From rosbook with Apache License 2.0 | 9 votes |
def __init__(self, position, orientation): State.__init__(self, outcomes=['success']) # Get an action client self.client = actionlib.SimpleActionClient('move_base', MoveBaseAction) self.client.wait_for_server() # Define the goal self.goal = MoveBaseGoal() self.goal.target_pose.header.frame_id = 'map' self.goal.target_pose.pose.position.x = position[0] self.goal.target_pose.pose.position.y = position[1] self.goal.target_pose.pose.position.z = 0.0 self.goal.target_pose.pose.orientation.x = orientation[0] self.goal.target_pose.pose.orientation.y = orientation[1] self.goal.target_pose.pose.orientation.z = orientation[2] self.goal.target_pose.pose.orientation.w = orientation[3]
Example #2
Source File: pose_manager.py From naoqi_bridge with BSD 3-Clause "New" or "Revised" License | 7 votes |
def __init__(self): # ROS initialization: rospy.init_node('pose_manager') self.poseLibrary = dict() self.readInPoses() self.poseServer = actionlib.SimpleActionServer("body_pose", BodyPoseAction, execute_cb=self.executeBodyPose, auto_start=False) self.trajectoryClient = actionlib.SimpleActionClient("joint_trajectory", JointTrajectoryAction) if self.trajectoryClient.wait_for_server(rospy.Duration(3.0)): try: rospy.wait_for_service("stop_walk_srv", timeout=2.0) self.stopWalkSrv = rospy.ServiceProxy("stop_walk_srv", Empty) except: rospy.logwarn("stop_walk_srv not available, pose_manager will not stop the walker before executing a trajectory. " +"This is normal if there is no nao_walker running.") self.stopWalkSrv = None self.poseServer.start() rospy.loginfo("pose_manager running, offering poses: %s", self.poseLibrary.keys()); else: rospy.logfatal("Could not connect to required \"joint_trajectory\" action server, is the nao_controller node running?"); rospy.signal_shutdown("Required component missing");
Example #3
Source File: torso_jtas_test.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self): self._client = actionlib.SimpleActionClient( 'movo/torso_controller/follow_joint_trajectory', FollowJointTrajectoryAction, ) self._goal = FollowJointTrajectoryGoal() self._goal_time_tolerance = rospy.Time(0.1) self._goal.goal_time_tolerance = self._goal_time_tolerance self.total_time = 0.0 server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Joint Trajectory" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear()
Example #4
Source File: fibonacci_client.py From ros-docker with MIT License | 6 votes |
def fibonacci_client(): # Creates the SimpleActionClient, passing the type of the action # (FibonacciAction) to the constructor. client = actionlib.SimpleActionClient('fibonacci', actionlib_tutorials.msg.FibonacciAction) # Waits until the action server has started up and started # listening for goals. client.wait_for_server() # Creates a goal to send to the action server. goal = actionlib_tutorials.msg.FibonacciGoal(order=20) # Sends the goal to the action server. client.send_goal(goal) # Waits for the server to finish performing the action. client.wait_for_result() # Prints out the result of executing the action return client.get_result() # A FibonacciResult
Example #5
Source File: common.py From baxter_demos with Apache License 2.0 | 6 votes |
def __init__(self, limb): self.waiting = False self.jointnames = ['s0', 's1', 'e0', 'e1', 'w0', 'w1', 'w2'] ns = 'robot/limb/' + limb + '/' self._client = actionlib.SimpleActionClient( ns + "follow_joint_trajectory", FollowJointTrajectoryAction, ) self._goal = FollowJointTrajectoryGoal() server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Joint Trajectory" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear(limb)
Example #6
Source File: panda_commander.py From mvp_grasp with BSD 3-Clause "New" or "Revised" License | 6 votes |
def grasp(self, width=0, e_inner=0.1, e_outer=0.1, speed=0.1, force=1): """ Wrapper around the franka_gripper/grasp action. http://docs.ros.org/kinetic/api/franka_gripper/html/action/Grasp.html :param width: Width (m) to grip :param e_inner: epsilon inner :param e_outer: epsilon outer :param speed: Move velocity (m/s) :param force: Force to apply (N) :return: Bool success """ client = actionlib.SimpleActionClient('franka_gripper/grasp', franka_gripper.msg.GraspAction) client.wait_for_server() client.send_goal( franka_gripper.msg.GraspGoal( width, franka_gripper.msg.GraspEpsilon(e_inner, e_outer), speed, force ) ) return client.wait_for_result()
Example #7
Source File: proxy_action_client.py From flexbe_behavior_engine with BSD 3-Clause "New" or "Revised" License | 6 votes |
def setupClient(self, topic, msg_type, wait_duration=10): """ Tries to set up an action client for calling it later. @type topic: string @param topic: The topic of the action to call. @type msg_type: msg type @param msg_type: The type of messages of this action client. @type wait_duration: int @param wait_duration: Defines how long to wait for the given client if it is not available right now. """ if topic not in ProxyActionClient._clients: ProxyActionClient._clients[topic] = actionlib.SimpleActionClient(topic, msg_type) self._check_topic_available(topic, wait_duration)
Example #8
Source File: matlab_manager.py From niryo_one_ros with GNU General Public License v3.0 | 6 votes |
def send_matlab_goal(self, cmd, cmd_type): self.action_client_matlab = actionlib.SimpleActionClient('/niryo_one/commander/robot_action', niryo_one_msgs.msg.RobotMoveAction) rospy.loginfo("waiting for action server: niryo_one/robot_action....") self.action_client_matlab.wait_for_server() rospy.loginfo("Found action server : niryo_one/robot_action") goal = RobotMoveGoal() goal.cmd.joints = cmd goal.cmd.cmd_type = cmd_type self.action_client_matlab.send_goal(goal) rospy.loginfo("waiting for result") self.action_client_matlab.wait_for_result() response = self.action_client_matlab.get_result() rospy.loginfo("..........result.................") rospy.loginfo(response) result = self.create_response(response.status, response.message) return response
Example #9
Source File: joint_trajectory_client.py From intera_sdk with Apache License 2.0 | 6 votes |
def __init__(self, limb, joint_names): self._joint_names = joint_names ns = 'robot/limb/' + limb + '/' self._client = actionlib.SimpleActionClient( ns + "follow_joint_trajectory", FollowJointTrajectoryAction, ) self._goal = FollowJointTrajectoryGoal() self._goal_time_tolerance = rospy.Time(0.1) self._goal.goal_time_tolerance = self._goal_time_tolerance server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Joint Trajectory" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear(limb)
Example #10
Source File: pick_place_interface.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, group="arm", ee_group="gripper", plan_only=False, verbose=False): self._verbose = verbose self._group = group self._effector = ee_group if self._verbose: rospy.loginfo("Connecting to pickup action...") self._pick_action = actionlib.SimpleActionClient("pickup", PickupAction) self._pick_action.wait_for_server() if self._verbose: rospy.loginfo("...connected") rospy.loginfo("Connecting to place action...") self._place_action = actionlib.SimpleActionClient("place", PlaceAction) self._place_action.wait_for_server() if self._verbose: rospy.loginfo("...connected") self._plan_only = plan_only self.planner_id = None self.allowed_planning_time = 30.0
Example #11
Source File: calibrate_arm.py From intera_sdk with Apache License 2.0 | 6 votes |
def __init__(self, limb="right"): """ @param limb: Limb to run CalibrateArm on arm side. """ self._limb=limb self._client = actionlib.SimpleActionClient('/calibration_command', CalibrationCommandAction) # Waits until the action server has started up and started # listening for goals. server_up = self._client.wait_for_server(rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Calibration" " Server to connect. Check your ROS networking" " and/or reboot the robot.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1)
Example #12
Source File: jaco_action_client.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, arm='right', dof=''): if ''==dof: rospy.logerr('DoF parameter needs to be set 6 or 7') return self._client = actionlib.SimpleActionClient( 'movo/%s_arm_controller/follow_joint_trajectory'%arm, FollowJointTrajectoryAction, ) self._goal = FollowJointTrajectoryGoal() self._goal_time_tolerance = rospy.Time(0.1) self._goal.goal_time_tolerance = self._goal_time_tolerance self.dof = dof server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Joint Trajectory" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear(arm)
Example #13
Source File: PR2.py From visual_dynamics with MIT License | 6 votes |
def __init__(self, pr2, lr): assert isinstance(pr2, PR2) self.pr2 = pr2 self.lr = lr self.controller_name = "%s_gripper_controller" % self.lr self.joint_names = [rospy.get_param("/%s/joint" % self.controller_name)] self.n_joints = len(self.joint_names) msg = self.pr2.get_last_joint_message() self.ros_joint_inds = [msg.name.index(name) for name in self.joint_names] self.rave_joint_inds = [pr2.robot.GetJointIndex(name) for name in self.joint_names] self.controller_pub = rospy.Publisher("%s/command" % self.controller_name, pcm.Pr2GripperCommand) self.grip_client = actionlib.SimpleActionClient('%s_gripper_controller/gripper_action' % lr, pcm.Pr2GripperCommandAction) # self.grip_client.wait_for_server() self.vel_limits = [.033] self.acc_limits = [inf] self.diag_pub = rospy.Publisher("/%s_gripper_traj_diagnostic" % lr, tm.JointTrajectory) # XXX self.closed_angle = 0
Example #14
Source File: jaco_jtas_test.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self, arm='right', dof='6dof'): self._client = actionlib.SimpleActionClient( 'movo/%s_arm_controller/follow_joint_trajectory'%arm, FollowJointTrajectoryAction, ) self._goal = FollowJointTrajectoryGoal() self._goal_time_tolerance = rospy.Time(0.1) self._goal.goal_time_tolerance = self._goal_time_tolerance self.dof = dof server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Joint Trajectory" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear(arm)
Example #15
Source File: gripper_action_test.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self,prefix="right"): self._prefix = prefix self._client = actionlib.SimpleActionClient( '/movo/%s_gripper_controller/gripper_cmd'%self._prefix, GripperCommandAction, ) self._goal = GripperCommandGoal() server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Gripper Command" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear()
Example #16
Source File: head_jtas_test.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self): self._client = actionlib.SimpleActionClient( 'movo/head_controller/follow_joint_trajectory', FollowJointTrajectoryAction, ) self._goal = FollowJointTrajectoryGoal() self._goal_time_tolerance = rospy.Time(0.1) self._goal.goal_time_tolerance = self._goal_time_tolerance self.total_time = 0.0 server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Joint Trajectory" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear()
Example #17
Source File: gripper_action_client.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self,prefix="right"): self._prefix = prefix self._client = actionlib.SimpleActionClient( '/movo/%s_gripper_controller/gripper_cmd'%self._prefix, GripperCommandAction, ) self._goal = GripperCommandGoal() server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Gripper Command" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear()
Example #18
Source File: head_action_client.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self): self._client = actionlib.SimpleActionClient( 'movo/head_controller/follow_joint_trajectory', FollowJointTrajectoryAction, ) self._goal = FollowJointTrajectoryGoal() self._goal_time_tolerance = rospy.Time(0.1) self._goal.goal_time_tolerance = self._goal_time_tolerance self.total_time = 0.0 server_up = self._client.wait_for_server(timeout=rospy.Duration(10.0)) if not server_up: rospy.logerr("Timed out waiting for Joint Trajectory" " Action Server to connect. Start the action server" " before running example.") rospy.signal_shutdown("Timed out waiting for Action Server") sys.exit(1) self.clear()
Example #19
Source File: base_controllers.py From pyrobot with MIT License | 5 votes |
def __init__(self, base_state, configs): """ The constructor for MoveBaseControl class. :param configs: configurations read from config file :param base_state: an object consisting of an instance of BaseState. :type configs: dict :type base_state: BaseState """ self.configs = configs self.base_state = base_state self.MAP_FRAME = self.configs.BASE.MAP_FRAME self.BASE_FRAME = self.configs.BASE.VSLAM.VSLAM_BASE_FRAME self.move_base_sac = actionlib.SimpleActionClient( self.configs.BASE.ROSTOPIC_BASE_ACTION_COMMAND, MoveBaseAction ) rospy.Subscriber( self.configs.BASE.ROSTOPIC_MOVE_BASE_STATUS, GoalStatusArray, self._move_base_status_callback, ) self.move_base_cancel_goal_pub = rospy.Publisher( self.configs.BASE.ROSTOPIC_GOAL_CANCEL, GoalID, queue_size=1 ) self.execution_status = None
Example #20
Source File: move_group_interface.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, group, frame, listener=None, plan_only=False): self._group = group self._fixed_frame = frame self._action = actionlib.SimpleActionClient('move_group', MoveGroupAction) self._action.wait_for_server() if listener == None: self._listener = TransformListener() else: self._listener = listener self.plan_only = plan_only self.planner_id = None self.planning_time = 15.0
Example #21
Source File: flexbe_input.py From flexbe_behavior_engine with BSD 3-Clause "New" or "Revised" License | 5 votes |
def execute_cb(self, goal , goal_handle): rospy.loginfo("--> Got a request!") rospy.loginfo('"%s"' % goal.msg) relay_ocs_client_ = actionlib.SimpleActionClient('flexbe/operator_input', BehaviorInputAction) # wait for data msg print("waiting") relay_ocs_client_.wait_for_server() print("done") # Fill in the goal here relay_ocs_client_.send_goal(goal) print("waiting for result") relay_ocs_client_.wait_for_result() print("got result") result = BehaviorInputResult() result = relay_ocs_client_.get_result() #result.data now serialized data_str = result.data print(data_str) if(result.result_code == BehaviorInputResult.RESULT_OK): self._as.set_succeeded(BehaviorInputResult(result_code=BehaviorInputResult.RESULT_OK, data=data_str), "ok",goal_handle) elif(result.result_code == BehaviorInputResult.RESULT_FAILED): # remove self._as.set_succeeded(BehaviorInputResult(result_code=BehaviorInputResult.RESULT_FAILED, data=data_str),"failed",goal_handle) rospy.loginfo("<-- Replied with FAILED") elif(result.result_code == BehaviorInputResult.RESULT_ABORTED ): self._as.set_succeeded(BehaviorInputResult(result_code=BehaviorInputResult.RESULT_ABORTED, data=data_str),"Aborted",goal_handle) rospy.loginfo("<-- Replied with ABORT")
Example #22
Source File: dock_with_bin.py From rosbook with Apache License 2.0 | 5 votes |
def __init__(self): self.move_base = actionlib.SimpleActionClient('move_base', MoveBaseAction) self.move_base.wait_for_server() self.tf_listener = tf.TransformListener() self.head_client = actionlib.SimpleActionClient("head_controller/point_head", PointHeadAction) self.head_client.wait_for_server()
Example #23
Source File: base.py From scikit-robot with MIT License | 5 votes |
def __init__(self, robot_interface, ns, ActionSpec): self.ri = robot_interface self.time_to_finish = 0 self.last_feedback_msg_stamp = rospy.Time.now() actionlib.SimpleActionClient.__init__(self, ns, ActionSpec)
Example #24
Source File: move_base_action_client.py From kinova-movo with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self,frame="map",sim=False): self.client_initialized = False self. _helpers = Helpers() self.n_successes = 0 self.n_goals = 0 self.running_time = 0.0 self.distance_traveled = 0.0 self.last_pose = self._helpers.GetCurrentRobotPose(frame) self.start_time = rospy.get_time() self._frame = frame """ Subscribe to the move_base action server """ self.move_base_client = actionlib.SimpleActionClient("/movo_move_base", MoveBaseAction) rospy.loginfo("Waiting for move_base action server") """ Wait 60 seconds for the action server to become available """ if (self.move_base_client.wait_for_server(rospy.Duration(10))): rospy.loginfo("Connected to move base server") else: rospy.logerr("Could not connect to action server") self._shutdown() return rospy.sleep(1) """ Make sure the robot is in tractor mode so it can accept motion commands """ if not sim: if (False == self. _helpers.SetRobotMode(TRACTOR_REQUEST)): rospy.logerr("Could not set operational state") rospy.logerr("Platform did not respond") self._shutdown() return self.client_initialized = True
Example #25
Source File: pr2.py From scikit-robot with MIT License | 5 votes |
def __init__(self, *args, **kwargs): super(PR2ROSRobotInterface, self).__init__(*args, **kwargs) self.gripper_states = dict(larm=None, rarm=None) rospy.Subscriber('/r_gripper_controller/state', pr2_controllers_msgs.msg.JointControllerState, lambda msg: self.pr2_gripper_state_callback( 'rarm', msg)) rospy.Subscriber('/l_gripper_controller/state', pr2_controllers_msgs.msg.JointControllerState, lambda msg: self.pr2_gripper_state_callback( 'larm', msg)) self.l_gripper_action = actionlib.SimpleActionClient( "/l_gripper_controller/gripper_action", pr2_controllers_msgs.msg.Pr2GripperCommandAction) self.r_gripper_action = actionlib.SimpleActionClient( "/r_gripper_controller/gripper_action", pr2_controllers_msgs.msg.Pr2GripperCommandAction) for action in [self.l_gripper_action, self.r_gripper_action]: if not (self.joint_action_enable and action.wait_for_server( rospy.Duration(3))): self.joint_action_enable = False rospy.logwarn( '{} is not respond, PR2ROSRobotInterface is disabled') break self.ignore_joint_list = ['laser_tilt_mount_joint', ]
Example #26
Source File: speech_to_text.py From respeaker_ros with Apache License 2.0 | 5 votes |
def __init__(self): # format of input audio data self.sample_rate = rospy.get_param("~sample_rate", 16000) self.sample_width = rospy.get_param("~sample_width", 2L) # language of STT service self.language = rospy.get_param("~language", "ja-JP") # ignore voice input while the robot is speaking self.self_cancellation = rospy.get_param("~self_cancellation", True) # time to assume as SPEAKING after tts service is finished self.tts_tolerance = rospy.Duration.from_sec( rospy.get_param("~tts_tolerance", 1.0)) self.recognizer = SR.Recognizer() self.tts_action = None self.last_tts = None self.is_canceling = False if self.self_cancellation: self.tts_action = actionlib.SimpleActionClient( "sound_play", SoundRequestAction) if self.tts_action.wait_for_server(rospy.Duration(5.0)): self.tts_timer = rospy.Timer(rospy.Duration(0.1), self.tts_timer_cb) else: rospy.logerr("action '%s' is not initialized." % rospy.remap_name("sound_play")) self.tts_action = None self.pub_speech = rospy.Publisher( "speech_to_text", SpeechRecognitionCandidates, queue_size=1) self.sub_audio = rospy.Subscriber("audio", AudioData, self.audio_cb)
Example #27
Source File: bumper_client.py From ros_book_programs with BSD 2-Clause "Simplified" License | 5 votes |
def go_until_bumper(): action_client = actionlib.SimpleActionClient('bumper_action', GoUntilBumperAction) action_client.wait_for_server() goal = GoUntilBumperGoal() goal.target_vel.linear.x = 0.8 goal.timeout_sec = 10 action_client.send_goal(goal) action_client.wait_for_result() result = action_client.get_result() if result.bumper_hit: rospy.loginfo('bumper hit!!') else: rospy.loginfo('failed')
Example #28
Source File: bumper_client.py From ros_book_programs with BSD 2-Clause "Simplified" License | 5 votes |
def go_until_bumper(): action_client = actionlib.SimpleActionClient('bumper_action', GoUntilBumperAction) action_client.wait_for_server() goal = GoUntilBumperGoal() goal.target_vel.linear.x = 0.8 goal.timeout_sec = 10 action_client.send_goal(goal) action_client.wait_for_result() result = action_client.get_result() if result.bumper_hit: rospy.loginfo('bumper hit!!') else: rospy.loginfo('failed')
Example #29
Source File: tool_commander.py From niryo_one_ros with GNU General Public License v3.0 | 5 votes |
def __init__(self): self.action_client = actionlib.SimpleActionClient( 'niryo_one/tool_action', ToolAction) rospy.loginfo("Waiting for action server : niryo_one/tool_action...") self.action_client.wait_for_server() rospy.loginfo("Found action server : niryo_one/tool_action") rospy.loginfo("Tool Commander has been started")
Example #30
Source File: simple_navig_goals.py From ROS-Programming-Building-Powerful-Robots with MIT License | 5 votes |
def simple_move(x,w): rospy.init_node('simple_move') #Simple Action Client sac = actionlib.SimpleActionClient('move_base', MoveBaseAction ) #create goal goal = MoveBaseGoal() #use self? #set goal rospy.loginfo("Set X = "+x) rospy.loginfo("Set W = "+w) goal.target_pose.pose.position.x = float(x) goal.target_pose.pose.orientation.w = float(w) goal.target_pose.header.frame_id = 'first_move' goal.target_pose.header.stamp = rospy.Time.now() #start listner rospy.loginfo("Waiting for server") sac.wait_for_server() rospy.loginfo("Sending Goals") #send goal sac.send_goal(goal) rospy.loginfo("Waiting for server") #finish sac.wait_for_result() #print result print sac.get_result()