一个鼠标、一把键盘,一个bug找半年。。。。。。
SW导出了URDF文件,配置助手生成了moveit_config文件,Rviz中拖动目标球也实现了位置到达拖动位置的轨迹规划,本以为完事大吉,但是当通过C++ interface的方式传递目标点的时候,问题来了。
geometry_msgs::Quaternion q;
double roll=-3.127;
double pitch=-0.512;
double yaw=1.559;
q=tf::createQuaternionMsgFromRollPitchYaw(roll,pitch,yaw);
geometry_msgs::Pose target_pose;
target_pose.position.x = 0.480988469635;
target_pose.position.y = 3.28034542767;
target_pose.position.z = -0.037;
target_pose.orientation.x = q.x;
target_pose.orientation.y = q.y;
target_pose.orientation.z = q.z; //设置末端的抓取姿态即末端朝向
target_pose.orientation.w = q.w ; // 四元数
用这种方式将数据传递给Moveit执行的时候,moveit执行不了,不管设置规划次数多少,总是规划失败?抛出如下异常
ABORTED: No motion plan found. No execution attempted.
看到一些文章中提到,你设定的目标点根本就是机械臂到达不了的点,为避免这个情况,想到了一个简单粗暴的方法,直接在Rviz中拖动末端到一个新的位置,点击execute之后,新打开一个终端
在终端中依次输入:
rosrun moveit_commander moveit_commander_cmdline.py
use your_move_group //这里输入你自己的规划组
current
将会看到如下输出
pose:
position:
x: 0.236527053024
y: 3.92467967827
z: -0.037
orientation:
x: 0.999711337402
y: -0.0240109939666
z: -0.00084500728959
w: 1.4090671808e-06 ]
link_5 RPY = [3.141549257277111, 0.001689459872670786, -0.048026657274179825]
这就是当前机械臂末端位置参数和姿态参数,这个点肯定是机械臂可以到达的点吧,(因为他现在就在这啊!)我直接把这个数据用C++接口传递过去,总没问题了吧。
满心欢喜准备尝试,但是最后还是同样的问题!
然后接下来尝试了更换轨迹规划算法,更换逆运动学解算插件,问题依旧存在。
在电脑前趴了两天,突然想到,是不是问题不是出现在配置文件上,而是出现在urdf文件上,于是尝试将URDF文件做出如下修改:
修改前
<joint name="joint_1">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="joint_1_motor">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
修改后
<joint name="joint_1">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="joint_1_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
也就是把EffortJointInterface改成PositionJointInterface,更换一下硬件接口。
保存后,重新运运行demo.launch文件和之前写好的C++文件。
奇迹出现了!规划成功并顺利运动啦!
愿人间再无BUG 下课。