采用python对基于moveit的机械臂不同功能操作

8 篇文章 0 订阅
3 篇文章 0 订阅

此处对于机械臂的操作是实例类MoveGroupCommander(是一个接口类),其父类是move_group,基本的关系大概就是这样的

类的继承关系如下:

moveit的操作,ros的底层是用c++实现的,但是也有python的接口方便调用,以下分别是c++与python的接口文件

move_group.cpp的链接

http://docs.ros.org/groovy/api/moveit_ros_planning_interface/html/classmoveit_1_1planning__interface_1_1MoveGroup_1_1MoveGroupImpl.html#a7f3e7abc480abc842d15889d9e6f5e07

http://docs.ros.org/groovy/api/moveit_ros_planning_interface/html/move__group_8cpp_source.html

python类接口的链接

http://docs.ros.org/kinetic/api/moveit_commander/html/classmoveit__commander_1_1move__group_1_1MoveGroupCommander.html

http://docs.ros.org/kinetic/api/moveit_commander/html/move__group_8py_source.html

首先初始化move_group的API

moveit_commander.roscpp_initialize(sys.argv)

arm = moveit_commander.MoveGroupCommander('arm')

1.获取终端link的名称

end_effector_link = arm.get_end_effector_link()

2.设置目标位置所使用的参考坐标系,也是后期计算所用的坐标系

reference_frame = 'base_link'
arm.set_pose_reference_frame(reference_frame)

3.允许重新规划
arm.allow_replanning(True)

4.根据名称设置机械臂位置

arm.set_named_target('initial')   #initial是moveit set中设置的初始化位置
arm.go()

5.获取机械臂各joint的值

gets_value = arm.get_joint_value_target()
print(gets_value)

6.根据posestamped设置机械臂终端位置

target_pose = PoseStamped()

 target_pose.header.frame_id = reference_frame
 target_pose.header.stamp = rospy.Time.now()     
 target_pose.pose.position.x = 0.6
 target_pose.pose.position.y = 0.6
 target_pose.pose.position.z = 0.6
 target_pose.pose.orientation.x = 0.5
 target_pose.pose.orientation.y = 0.5
 target_pose.pose.orientation.z = 0.5
 target_pose.pose.orientation.w = 0.2
arm.set_pose_target(target_pose, end_effector_link)

arm.go()

7.设置机械臂末端xyz位置

xyz = [0.6,0.6,1]
arm.set_position_target(xyz, end_effector_link)
traj = arm.plan()
arm.execute(traj)
 

8.获取当前机械臂终端位置

arm_pose =  PoseStamped()
arm_pose = arm.get_current_pose()

print(arm_pose)

或者

print(arm.get_current_pose().pose)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值