当前位置:   article > 正文

关于ROS中对moveit和gazebo联动出现的问题进行解决_rosnoetic让moveit和gazebo联动

rosnoetic让moveit和gazebo联动

我的Ubuntu版本:20.04   rosnoetic

最近我在研究怎么用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如下:

  1. arm:
  2. arm_joint_controller:
  3. type: "position_controllers/JointTrajectoryController"
  4. joints:
  5. - joint1
  6. - joint2
  7. - joint3
  8. - joint4
  9. - joint5
  10. - joint6
  11. gains:
  12. joint1: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
  13. joint2: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
  14. joint3: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
  15. joint4: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
  16. joint5: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
  17. joint6: {p: 1000.0, i: 0.0, d: 0.1, i_clamp: 0.0}
  18. gripper_controller:
  19. type: "position_controllers/JointTrajectoryController"
  20. joints:
  21. - finger_joint1
  22. gains:
  23. finger_joint1: {p: 50.0, d: 1.0, i: 0.01, i_clamp: 1.0}

后添加相应的launch文件:marm_gazebo/launch/arm_trajectory_controller.launch

  1. <launch>
  2. <rosparam file="$(find marm_gazebo)/config/trajectory_control.yaml" command="load"/>
  3. <node name="arm_controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
  4. output="screen" ns="/arm" args="arm_joint_controller gripper_controller"/>
  5. </launch>

gazebo这边就配置好了  接下来要在moveit这边进行配置   直接打开setup assistant自己生成的配置文件marm_moveit_config      marm_moveit_config/config/controllers.yaml

  1. controller_manager_ns: controller_manager
  2. controller_list:
  3. - name: arm/arm_joint_controller
  4. action_ns: follow_joint_trajectory
  5. type: FollowJointTrajectory
  6. default: true
  7. joints:
  8. - joint1
  9. - joint2
  10. - joint3
  11. - joint4
  12. - joint5
  13. - joint6
  14. - name: arm/gripper_controller
  15. action_ns: follow_joint_trajectory
  16. type: FollowJointTrajectory
  17. default: true
  18. joints:
  19. - finger_joint1
  20. - 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自己生成的 我找了发现我的没有生成  然后我又删掉功能包 又重新配置 也还是没有  那我的配置应该是没有问题的

我在一篇博客上有了启发

RViz与gazebo联合仿真时报错[ERROR] [1701506431.253044843, 25.636000000]: Unable to identify any set of contro_[error] [1703047686.751982463, 28.705000000]: unab-CSDN博客

我这个版本它自己生成的arm_moveit_controller_manager.launch.xml不叫这个名字 叫做simple_moveit_controller_manager.launch.xml  如下  我们只需要在这个文件里修改就好 把配置的controllers.yaml加进来

simple_moveit_controller_manager.launch.xml配置成功的代码

  1. <launch>
  2. <!-- Define the MoveIt controller manager plugin to use for trajectory execution -->
  3. <param name="moveit_controller_manager" value="moveit_simple_controller_manager/MoveItSimpleControllerManager" />
  4. <!-- Load controller list to the parameter server -->
  5. <rosparam file="$(find marm_moveit_config)/config/controllers.yaml" />
  6. <rosparam file="$(find marm_moveit_config)/config/ros_controllers.yaml" />
  7. </launch>

最后再加一个 marm_moveit_config/launch/moveit_planning_execution.launch

  1. <launch>
  2. # The planning and execution components of MoveIt! configured to
  3. # publish the current configuration of the robot (simulated or real)
  4. # and the current state of the world as seen by the planner
  5. <include file="$(find marm_moveit_config)/launch/move_group.launch">
  6. <arg name="publish_monitored_planning_scene" value="true" />
  7. </include>
  8. # The visualization component of MoveIt!
  9. <include file="$(find marm_moveit_config)/launch/moveit_rviz.launch"/>
  10. <!-- We do not have a robot connected, so publish fake joint states -->
  11. <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
  12. <param name="/use_gui" value="false"/>
  13. <rosparam param="/source_list">[/arm/joint_states]</rosparam>
  14. </node>
  15. </launch>

以上配置圆满结束 打开终端

就可以随意的玩机械臂了!!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/703786
推荐阅读
相关标签
  

闽ICP备14008679号