当前位置:   article > 正文

机械臂全面学习---moveit和gazebo联合仿真_机械臂yaml仿真

机械臂yaml仿真

1、修改XXX.moveit_config/config/ros_controllers.yaml

  1. # MoveIt-specific simulation settings
  2. moveit_sim_hw_interface:
  3. joint_model_group: controllers_initial_group_
  4. joint_model_group_pose: controllers_initial_pose_
  5. # Settings for ros_control control loop
  6. generic_hw_control_loop:
  7. loop_hz: 300
  8. cycle_time_error_threshold: 0.01
  9. # Settings for ros_control hardware interface
  10. hardware_interface:
  11. joints:
  12. - magician_joint1
  13. - magician_joint2
  14. - magician_joint3
  15. sim_control_mode: 1 # 0: position, 1: velocity
  16. # Publish all joint states
  17. # Creates the /joint_states topic necessary in ROS
  18. joint_state_controller:
  19. type: joint_state_controller/JointStateController
  20. publish_rate: 50
  21. controller_list:
  22. - name: magician_arm_controller
  23. action_ns: follow_joint_trajectory
  24. default: True
  25. type: FollowJointTrajectory
  26. joints:
  27. - magician_joint1
  28. - magician_joint2
  29. - magician_joint3

2、修改XXX.moveit_config/launch/ros_controllers.yaml

  1. <?xml version="1.0"?>
  2. <launch>
  3. <!-- Load joint controller configurations from YAML file to parameter server -->
  4. <rosparam file="$(find magician_moveit_config)/config/ros_controllers.yaml" command="load"/>
  5. <!-- Load the controllers -->
  6. <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
  7. output="screen" args=""/>
  8. </launch>

3、修改XXX.moveit_config/launch/moveit_rviz.launch

  1. <launch>
  2. <arg name="debug" default="false" />
  3. <arg unless="$(arg debug)" name="launch_prefix" value="" />
  4. <arg if="$(arg debug)" name="launch_prefix" value="gdb --ex run --args" />
  5. <arg name="config" default="false" />
  6. <arg unless="$(arg config)" name="command_args" value="" />
  7. <arg if="$(arg config)" name="command_args" value="-d $(find magician_moveit_config)/launch/moveit.rviz" />
  8. <node name="$(anon rviz)" launch-prefix="$(arg launch_prefix)" pkg="rviz" type="rviz" respawn="false"
  9. args="$(arg command_args)" output="screen">
  10. <rosparam command="load" file="$(find magician_moveit_config)/config/kinematics.yaml"/>
  11. </node>
  12. </launch>

4、在XXX.moveit_config/launch/move_group.launch修改一点小细节

  1. <launch>
  2. <include file="$(find magician_moveit_config)/launch/planning_context.launch" />
  3. <!-- GDB Debug Option -->
  4. <arg name="debug" default="false" />
  5. <arg unless="$(arg debug)" name="launch_prefix" value="" />
  6. <arg if="$(arg debug)" name="launch_prefix"
  7. value="gdb -x $(find magician_moveit_config)/launch/gdb_settings.gdb --ex run --args" />
  8. <!-- Verbose Mode Option -->
  9. <arg name="info" default="$(arg debug)" />
  10. <arg unless="$(arg info)" name="command_args" value="" />
  11. <arg if="$(arg info)" name="command_args" value="--debug" />
  12. <!-- move_group settings -->
  13. <arg name="allow_trajectory_execution" default="true"/>
  14. <arg name="fake_execution" default="false"/>
  15. <arg name="max_safe_path_cost" default="1"/>
  16. <arg name="jiggle_fraction" default="0.05" />
  17. <arg name="publish_monitored_planning_scene" default="true"/>
  18. <arg name="capabilities" default=""/>
  19. <arg name="disable_capabilities" default=""/>
  20. <!-- load these non-default MoveGroup capabilities (space seperated) -->
  21. <!--
  22. <arg name="capabilities" value="
  23. a_package/AwsomeMotionPlanningCapability
  24. another_package/GraspPlanningPipeline
  25. " />
  26. -->
  27. <!-- inhibit these default MoveGroup capabilities (space seperated) -->
  28. <!--
  29. <arg name="disable_capabilities" value="
  30. move_group/MoveGroupKinematicsService
  31. move_group/ClearOctomapService
  32. " />
  33. -->
  34. <!-- Planning Functionality -->
  35. <include ns="move_group" file="$(find magician_moveit_config)/launch/planning_pipeline.launch.xml">
  36. <arg name="pipeline" value="ompl" />
  37. </include>
  38. <!-- Trajectory Execution Functionality -->
  39. <include ns="move_group" file="$(find magician_moveit_config)/launch/trajectory_execution.launch.xml" if="$(arg allow_trajectory_execution)">
  40. <arg name="moveit_manage_controllers" value="true" />
  41. <arg name="moveit_controller_manager" value="magician" unless="$(arg fake_execution)"/>
  42. <arg name="moveit_controller_manager" value="fake" if="$(arg fake_execution)"/>
  43. </include>
  44. <!-- Sensors Functionality -->
  45. <include ns="move_group" file="$(find magician_moveit_config)/launch/sensor_manager.launch.xml" if="$(arg allow_trajectory_execution)">
  46. <arg name="moveit_sensor_manager" value="magician" />
  47. </include>
  48. <!-- Start the actual move_group node/action server -->
  49. <node name="move_group" launch-prefix="$(arg launch_prefix)" pkg="moveit_ros_move_group" type="move_group" respawn="false" output="screen" args="$(arg command_args)">
  50. <!-- Set the display variable, in case OpenGL code is used internally -->
  51. <env name="DISPLAY" value="$(optenv DISPLAY :0)" />
  52. <param name="allow_trajectory_execution" value="$(arg allow_trajectory_execution)"/>
  53. <param name="max_safe_path_cost" value="$(arg max_safe_path_cost)"/>
  54. <param name="jiggle_fraction" value="$(arg jiggle_fraction)" />
  55. <param name="capabilities" value="$(arg capabilities)"/>
  56. <param name="disable_capabilities" value="$(arg disable_capabilities)"/>
  57. <!-- Publish the planning scene of the physical robot so that rviz plugin can know actual robot -->
  58. <param name="planning_scene_monitor/publish_planning_scene" value="$(arg publish_monitored_planning_scene)" />
  59. <param name="planning_scene_monitor/publish_geometry_updates" value="$(arg publish_monitored_planning_scene)" />
  60. <param name="planning_scene_monitor/publish_state_updates" value="$(arg publish_monitored_planning_scene)" />
  61. <param name="planning_scene_monitor/publish_transforms_updates" value="$(arg publish_monitored_planning_scene)" />
  62. </node>
  63. </launch>

5、修改trajectory_execution.launch.xml

  1. <launch>
  2. <!-- This file makes it easy to include the settings for trajectory execution -->
  3. <!-- Flag indicating whether MoveIt! is allowed to load/unload or switch controllers -->
  4. <arg name="moveit_manage_controllers" default="true"/>
  5. <param name="moveit_manage_controllers" value="$(arg moveit_manage_controllers)"/>
  6. <!-- When determining the expected duration of a trajectory, this multiplicative factor is applied to get the allowed duration of execution -->
  7. <param name="trajectory_execution/allowed_execution_duration_scaling" value="2"/> <!-- default 1.2 -->
  8. <!-- Allow more than the expected execution time before triggering a trajectory cancel (applied after scaling) -->
  9. <param name="trajectory_execution/allowed_goal_duration_margin" value="0.5"/> <!-- default 0.5 -->
  10. <!-- Allowed joint-value tolerance for validation that trajectory's first point matches current robot state -->
  11. <param name="trajectory_execution/allowed_start_tolerance" value="0.01"/> <!-- default 0.01 -->
  12. <!-- Load the robot specific controller manager; this sets the moveit_controller_manager ROS parameter -->
  13. <arg name="moveit_controller_manager" default="magician" />
  14. <include file="$(find magician_moveit_config)/launch/$(arg moveit_controller_manager)_moveit_controller_manager.launch.xml" />
  15. </launch>

6、创建magician_moveit_controller_manager.launch.xml文件,并且启动ros_controllers.yaml

  1. <launch>
  2. <!-- loads moveit_controller_manager on the parameter server which is taken as argument
  3. if no argument is passed, moveit_simple_controller_manager will be set -->
  4. <arg name="moveit_controller_manager" default="moveit_simple_controller_manager/MoveItSimpleControllerManager" />
  5. <param name="moveit_controller_manager" value="$(arg moveit_controller_manager)"/>
  6. <!-- loads ros_controllers to the param server -->
  7. <rosparam file="$(find magician_moveit_config)/config/ros_controllers.yaml"/>
  8. </launch>

7、新建一个功能包,里面放置启动文件

  1. <?xml version="1.0"?>
  2. <launch>
  3. <arg name="paused" default="true"/>
  4. <arg name="gazebo_gui" default="true"/>
  5. <arg name="urdf_path" default="$(find magician_description)/urdf/magician.urdf.xacro"/>
  6. <!-- startup simulated world -->
  7. <include file="$(find gazebo_ros)/launch/empty_world.launch">
  8. <arg name="world_name" default="worlds/empty.world"/>
  9. <arg name="paused" value="$(arg paused)"/>
  10. <arg name="gui" value="$(arg gazebo_gui)"/>
  11. </include>
  12. <!-- send robot urdf to param server -->
  13. <param name="robot_description" command="$(find xacro)/xacro --inorder '$(find magician_description)/urdf/magician.urdf.xacro'" />
  14. <!-- push robot_description to factory and spawn robot in gazebo at the origin, change x,y,z arguments to spawn in a different position -->
  15. <node name="spawn_model" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
  16. args="-urdf -model magician
  17. -param robot_description
  18. -x 0
  19. -y 0
  20. -z 0.14
  21. -J magician_joint1 0
  22. -J magician_joint2 0.785
  23. -J magician_joint3 0.785
  24. -unpause"/>
  25. <rosparam file="$(find magician_description)/config/joint_state_controller.yaml" command="load"/>
  26. <node name="joint_state_controller_spawner" pkg="controller_manager" type="controller_manager" args="spawn joint_state_controller" respawn="false" output="screen"/>
  27. <rosparam file="$(find magician_description)/config/magician_arm_controller.yaml" command="load"/>
  28. <node name="elfin_arm_controller_spawner" pkg="controller_manager" type="controller_manager" args="spawn magician_arm_controller" respawn="false" output="screen"/>
  29. <!-- # The planning and execution components of MoveIt! configured to
  30. # publish the current configuration of the robot (simulated or real)
  31. # and the current state of the world as seen by the planner
  32. -->
  33. <include file="$(find magician_moveit_config)/launch/move_group.launch">
  34. <arg name="publish_monitored_planning_scene" value="true" />
  35. </include>
  36. <!-- # The visualization component of MoveIt! -->
  37. <arg name="display" default="true"/>
  38. <include file="$(find magician_moveit_config)/launch/moveit_rviz.launch" if="$(arg display)">
  39. <arg name="config" value="true"/>
  40. </include>
  41. </launch>

最后编译一下,启动launch文件

 

 到这里moveit和gazebo的联动到此结束。

我们通过以上部分举一反三,其他的机械臂在moveit和gazebo联动时也是这样配置的。

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

闽ICP备14008679号