当前位置: 首页>>代码示例>>Python>>正文


Python FollowJointTrajectoryGoal.action方法代码示例

本文整理汇总了Python中control_msgs.msg.FollowJointTrajectoryGoal.action方法的典型用法代码示例。如果您正苦于以下问题:Python FollowJointTrajectoryGoal.action方法的具体用法?Python FollowJointTrajectoryGoal.action怎么用?Python FollowJointTrajectoryGoal.action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在control_msgs.msg.FollowJointTrajectoryGoal的用法示例。


在下文中一共展示了FollowJointTrajectoryGoal.action方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from control_msgs.msg import FollowJointTrajectoryGoal [as 别名]
# 或者: from control_msgs.msg.FollowJointTrajectoryGoal import action [as 别名]
    def __init__(self):
        rospy.init_node('trajectory_demo')

        # Set to True to move back to the starting configurations
        reset = rospy.get_param('~reset', False)

        # Set to False to wait for arm to finish before moving head
        sync = rospy.get_param('~sync', True)

        # Which joints define the torso?
        torso_joints = ["torso_lift_joint"]

        # Which joints define the arm?
        arm_joints = ['shoulder_pan_joint',
                      'shoulder_lift_joint',
                      'upperarm_roll_joint',
                      'elbow_flex_joint',
                      'forearm_roll_joint',
                      'wrist_flex_joint',
					  'wrist_roll_joint']

        # Which joints define the head?
        head_joints = ['head_pan_joint', 'head_tilt_joint']

        # Which joints define the gripper
        gripper_joints = ['l_gripper_finger_joint', 'r_gripper_finger_joint']

        if reset:
            # Set the arm back to the resting position
            arm_goal  = [0, 0, 0, 0, 0, 0, 0]

            # Re-center the head
            head_goal = [0, 0]
        else:
            # Set the goal configuration for the gripper
            gripper_open = [0.1]
            gripper_effort = [1.0]

            # Set a goal configuration for the arm
            arm_goal  = [1.3, 1.5, 3.0, -1.7, 0.0, -1.7, 0.0, 0.0]

            # Set a goal configuration for the head
            head_goal = [0.0, 0.0]

            # Set a goal configuration for torso
            torso_goal = [0.0]

        # Connect to the gripper trajectory action server
        rospy.loginfo('Waiting for gripper controller...')
        gripper_client = actionlib.SimpleActionClient('gripper_controller/gripper_action', GripperCommandAction)
        gripper_client.wait_for_server()
        rospy.loginfo('...connected.')

        # Connect to the right arm trajectory action server
        rospy.loginfo('Waiting for arm trajectory controller...')
        arm_client = actionlib.SimpleActionClient('arm_controller/follow_joint_trajectory', FollowJointTrajectoryAction)
        arm_client.wait_for_server()
        rospy.loginfo('...connected.')

        # Connect to the head trajectory action server
        rospy.loginfo('Waiting for head trajectory controller...')
        head_client = actionlib.SimpleActionClient('head_controller/follow_joint_trajectory', FollowJointTrajectoryAction)
        head_client.wait_for_server()
        rospy.loginfo('...connected.')

        # Connect to the torso trajectory action server
        rospy.loginfo('Waiting for torso trajectory controller ...')
        torso_client = actionlib.SimpleActionClient('torso_controller/follow_joint_trajectory', FollowJointTrajectoryAction)
        torso_client.wait_for_server()
        rospy.loginfo('... connected.')

        # Create a single-point gripper action as the end-point
        gripper_action = GripperCommandAction()
        #gripper_action.position = gripper_open
        gripper_action.effort = gripper_effort
        #gripper_action.points.append(GripperActionGoal())
        #gripper_action.points[0].positions = gripper_open
        #gripper_action.points[0].velocities = [0.0 for i in gripper_joint]
        #gripper_action.points[0].accelerations = [0.0 for i in gripper_joint]
        #gripper_action.points[0].time_from_start = rospy.Duration(3.0)

        # Send the trajectory to the arm action server
        rospy.loginfo('Gripping object ...')

        # Create an empty trajectory goal
        gripper_goal = FollowJointTrajectoryGoal()

        # Set the trajectory component to the goal trajectory created above
        gripper_goal.action = gripper_action

        # Specify zero tolerance for the execution time
        gripper_goal.goal_time_tolerance = rospy.Duration(0.0)

        # Send the goal to the action server
        gripper_client.send_goal(gripper_goal)

        # Create a single-point arm trajectory with the arm_goal as the end-point
        arm_trajectory = JointTrajectory()
        arm_trajectory.joint_names = arm_joints
        arm_trajectory.points.append(JointTrajectoryPoint())
#.........这里部分代码省略.........
开发者ID:luandoan,项目名称:Fetch,代码行数:103,代码来源:test.py


注:本文中的control_msgs.msg.FollowJointTrajectoryGoal.action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。