赞
踩
最近我在研究怎么用ros控制机械臂,看了古月居的第七讲有关机械臂讲解的课程,大约两个多小时的课,看完后我跟着教程自己做了一遍仿真,单独在moveit中倒还可以控制机械臂做运动规划,到了moveit和gazebo联动中,按照教程一步一步来出现了问题,导致在moveit中可以plan,一execute就出现错误。
现在问题已经解决了,实现了机械臂moveit和gazebo联动,也算是成就感满满,古月居的视频是没有问题的,有问题的是我自己,我是一个小白,才接触ros没有多久,对一些通讯学的也是稀烂,还是不能够理解。
接下来进入正题!!
这个bug是我解决时间最久的,也是我本次想记录下来,供有需要的同学进行查看,如果我的方法可以帮助到大家,那真的是很好的事情。
当我们有了机械臂的urdf模型之后,可以直接使用ros提供的moveit_setup_assistant进行配置,生成一个功能包,就给它命名marm_moveit_config ,launch文件下有demo.launch文件,我们启动该文件就可以拖动机械臂然后plan和execute。
我先把moveit和gazebo联动最终图片放出来
可以看到gazebo中的机械臂也发生了运动
想实现gazebo和moveit联动需要配置gazebo和moveit两边,古月视频说过 就好比将插头插入插板,把gazebo比作插板,moveit就是插头,两边都需要进行相关配置
先添加marm_gazebo/config/trajectory_control.yaml如下:
- arm:
- arm_joint_controller:
- type: "position_controllers/JointTrajectoryController"
- joints:
- - joint1
- - joint2
- - joint3
- - joint4
- - joint5
- - joint6
-
- gains:
- joint1: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
- joint2: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
- joint3: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
- joint4: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
- joint5: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
- joint6: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
-
-
- gripper_controller:
- type: "position_controllers/JointTrajectoryController"
- joints:
- - finger_joint1
- gains:
- finger_joint1: {p: 50.0, d: 1.0, i: 0.01, i_clamp: 1.0}

后添加相应的launch文件:marm_gazebo/launch/arm_trajectory_controller.launch
- <launch>
-
- <rosparam file="$(find marm_gazebo)/config/trajectory_control.yaml" command="load"/>
-
- <node name="arm_controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
- output="screen" ns="/arm" args="arm_joint_controller gripper_controller"/>
-
- </launch>
gazebo这边就配置好了 接下来要在moveit这边进行配置 直接打开setup assistant自己生成的配置文件marm_moveit_config marm_moveit_config/config/controllers.yaml
- controller_manager_ns: controller_manager
- controller_list:
- - name: arm/arm_joint_controller
- action_ns: follow_joint_trajectory
- type: FollowJointTrajectory
- default: true
- joints:
- - joint1
- - joint2
- - joint3
- - joint4
- - joint5
- - joint6
-
- - name: arm/gripper_controller
- action_ns: follow_joint_trajectory
- type: FollowJointTrajectory
- default: true
- joints:
- - finger_joint1
- - finger_joint2

接下来很重要 我在看古月视频里,他直接从他正确的包里拷贝了一份arm_moveit_controller_manager.launch.xml 如下 粘贴到我自己的launch目录下
文件内容大致就是加载上边配置好的controllers.yaml文件 我觉得没什么问题 然后就roslaunch marm_gazebo arm_bringup_moveit.launch 就出现了我最开始的问题 我看了很多博客 大家遇到这个问题解决方法都不一样 我按照他们的方法也都解决了 但就是没有太大作用
我回看视频 老师讲的是arm_moveit_controller_manager.launch.xml该文件是setup assistant自己生成的 我找了发现我的没有生成 然后我又删掉功能包 又重新配置 也还是没有 那我的配置应该是没有问题的
我在一篇博客上有了启发
我这个版本它自己生成的arm_moveit_controller_manager.launch.xml不叫这个名字 叫做simple_moveit_controller_manager.launch.xml 如下 我们只需要在这个文件里修改就好 把配置的controllers.yaml加进来
simple_moveit_controller_manager.launch.xml配置成功的代码
- <launch>
- <!-- Define the MoveIt controller manager plugin to use for trajectory execution -->
- <param name="moveit_controller_manager" value="moveit_simple_controller_manager/MoveItSimpleControllerManager" />
-
- <!-- Load controller list to the parameter server -->
- <rosparam file="$(find marm_moveit_config)/config/controllers.yaml" />
- <rosparam file="$(find marm_moveit_config)/config/ros_controllers.yaml" />
- </launch>
最后再加一个 marm_moveit_config/launch/moveit_planning_execution.launch
- <launch>
- # The planning and execution components of MoveIt! configured to
- # publish the current configuration of the robot (simulated or real)
- # and the current state of the world as seen by the planner
- <include file="$(find marm_moveit_config)/launch/move_group.launch">
- <arg name="publish_monitored_planning_scene" value="true" />
- </include>
- # The visualization component of MoveIt!
- <include file="$(find marm_moveit_config)/launch/moveit_rviz.launch"/>
-
- <!-- We do not have a robot connected, so publish fake joint states -->
- <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
- <param name="/use_gui" value="false"/>
- <rosparam param="/source_list">[/arm/joint_states]</rosparam>
- </node>
-
- </launch>

以上配置圆满结束 打开终端
就可以随意的玩机械臂了!!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。