movegroup运动控制函数总结

1.set_pose_target( ):

INPUT:pose, end_effector_link = “”
Set the pose of the end-effector, if one is available. The expected input is a Pose message, a PoseStamped message or a list of 6 floats:
[x, y, z, rot_x, rot_y, rot_z] or a list of 7 floats [x, y, z, qx, qy, qz, qw]
Example:

     target_pose = PoseStamped()
     target_pose.header.frame_id = reference_frame
     target_pose.header.stamp = rospy.Time.now()     
     target_pose.pose.position.x = 0.25
     target_pose.pose.position.y = -0.15
     target_pose.pose.position.z = 0.28
     target_pose.pose.orientation.x = 0.0
     target_pose.pose.orientation.y = 0.0
     target_pose.pose.orientation.z = 0.0
     target_pose.pose.orientation.w = 1.0
     # Set the start state to the current state
     right_arm.set_start_state_to_current_state()
     # Set the goal pose of the end effector to the stored pose
     right_arm.set_pose_target(target_pose, end_effector_link)
     # Plan the trajectory to the goal
     traj = right_arm.plan()
     # Execute the planned trajectory
     right_arm.execute(traj)

2.set_pose_targets():

INPUT:poses, end_effector_link = “”
Set the pose of the end-effector, if one is available. The expected input is a list of poses. Each pose can be a Pose message, a list of 6 floats: [x, y, z, rot_x, rot_y, rot_z] or a list of 7 floats [x, y, z, qx, qy, qz, qw]

3.set_joint_value_target():

INPUT: arg1, arg2 = None, arg3 = None
Specify a target joint configuration for the group.

# Set an initial position for the arm
start_position = [0.0, 0.5, -0.0074579719079, -1.67822729461, -3.1415174069, -1.1, 3.1415174069]
# Set the goal pose of the end effector to the stored pose
arm.set_joint_value_target(start_position)

4.shift_pose_target():

INPUT:axis, value, end_effector_link = “”
Get the current pose of the end effector, add value to the corresponding axis (0..5: X, Y, Z, R, P, Y) and set the new pose as the pose target

     # Shift the end-effector to the right 5cm
        right_arm.shift_pose_target(1, -0.05, end_effector_link)
        right_arm.go()
        rospy.sleep(1)

        # Rotate the end-effector 90 degrees
        right_arm.shift_pose_target(3, -1.57, end_effector_link)
        right_arm.go()
        rospy.sleep(2) 

5.compute_cartesian_path( ):

INPUT:waypoints, eef_step, jump_threshold, avoid_collisions = True
RETURN:(RobotTrajectory, fraction)
Compute a sequence of waypoints that make the end-effector move in straight line segments that follow the poses specified as waypoints.
Configurations are computed for every eef_step meters; The jump_threshold specifies the maximum distance in configuration space between consecutive points in the resultingpath.
The return value is a tuple: a fraction of how much of the path was followed, the actual RobotTrajectory.

if cartesian:                 
     fraction = 0.0
     maxtries = 100
     attempts = 0
     # Set the internal state to the current state
     right_arm.set_start_state_to_current_state()
     # Plan the Cartesian path connecting the waypoints
     while fraction < 1.0 and attempts < maxtries:
        (plan, fraction) = right_arm.compute_cartesian_path (
                                        waypoints,   # waypoint poses
                                        0.01,        # eef_step
                                        0.0,         # jump_threshold
                                        True)        #avoid_collisions

          # Increment the number of attempts 
          attempts += 1
          # Print out a progress message
          if attempts % 10 == 0:
             rospy.loginfo("Still trying after " + str(attempts) + " attempts...")         
          # If we have a complete plan, execute the trajectory
          if fraction == 1.0:
              rospy.loginfo("Path computed successfully. Moving the arm."
              right_arm.execute(plan)            
              rospy.loginfo("Path execution complete.")
  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
`move_group.MoveGroupCommander.retime_trajectory` 是 MoveIt 中 `MoveGroupCommander` 类的一个成员函数,用于重新计算规划轨迹的时间。具体用法如下: ```python retime_trajectory(self, planning_scene, trajectory, velocity_scaling_factor=1.0, acceleration_scaling_factor=1.0) ``` 函数参数: - `planning_scene`:规划场景,类型为 `moveit_msgs.msg.PlanningScene`。 - `trajectory`:需要重新计算时间的轨迹,类型为 `moveit_msgs.msg.RobotTrajectory`。 - `velocity_scaling_factor`:速度缩放因子,范围为 [0, 1],默认值为 1。 - `acceleration_scaling_factor`:加速度缩放因子,范围为 [0, 1],默认值为 1。 函数返回值: 重新计算时间后的轨迹,类型为 `moveit_msgs.msg.RobotTrajectory`。 使用示例: ```python import rospy import moveit_commander from moveit_msgs.msg import PlanningScene rospy.init_node('retime_trajectory_example', anonymous=True) robot = moveit_commander.RobotCommander() scene = moveit_commander.PlanningSceneInterface() group_name = "manipulator" move_group = moveit_commander.MoveGroupCommander(group_name) # 设置机械臂的允许误差值 move_group.set_goal_joint_tolerance(0.001) # 设置机械臂的运动速度和加速度 move_group.set_max_velocity_scaling_factor(0.5) move_group.set_max_acceleration_scaling_factor(0.5) # 获取当前的机械臂姿态 joint_goal = move_group.get_current_joint_values() # 设置机械臂目标位置 joint_goal[0] = 1.57 joint_goal[1] = -1.57 joint_goal[2] = 1.57 joint_goal[3] = -1.57 joint_goal[4] = 1.57 joint_goal[5] = 0.0 move_group.set_joint_value_target(joint_goal) # 进行运动规划 plan = move_group.plan() # 进行轨迹时间重新计算 scene_msg = PlanningScene() trajectory_msg = plan.joint_trajectory new_trajectory = move_group.retime_trajectory(scene_msg, trajectory_msg) # 执行新的轨迹 move_group.execute(new_trajectory) ``` 以上示例代码演示了如何使用 `retime_trajectory` 函数对机械臂运动轨迹的时间进行重新计算,使得机械臂的运动速度和加速度符合用户的要求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值