MoveIt!+ Gazebo 联合仿真环境搭建(巨简单版)
参考书籍和大佬们的贴子,笔者将MoveIt!实现机器人控制的方法总结为以下四个步骤:
1)创建机器人URDF模型(改为xacro格式也行),并添加运动插件。
在已建立的URDF模型里面,为 joints 添加传动装置 (add transmission for every joint),添加 gazebo 插件(add one gazebo plugin),可参考以下代码。
<transmission name="trans_joint1">
<type>transmission_interface/SimpleTransmission</type>
<joint name="joint1">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="joint1_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="trans_joint2">
<type>transmission_interface/SimpleTransmission</type>
<joint name="joint2">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="joint2_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="trans_joint3">
<type>transmission_interface/SimpleTransmission</type>
<joint name="joint3">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="joint3_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="trans_joint4">
<type>transmission_interface/SimpleTransmission</type>
<joint name="joint4">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="joint4_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="trans_joint5">
<type>transmission_interface/SimpleTransmission</type>
<joint name="joint5">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="joint5_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<transmission name="trans_joint6">
<type>transmission_interface/SimpleTransmission</type>
<joint name="joint6">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
<actuator name="joint6_motor">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/</robotNamespace>
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
<legacyModeNS>true</legacyModeNS>
</plugin>
</gazebo>
2)使用 MoveIt!Setup Assistant 工具生成配置文件。
就不详细说了,网上很多教程,按照教程一步一步来就行。
可以参考这篇moveit规划机器人轨迹控制gazebo里的仿真 ,参考配置 moveit 包这部分就够了,该作者的教程能走通但是更复杂。(感谢大佬的教程)
3)添加机器人控制器或控制插件
修改由 MoveIt!Setup Assistant 创建的功能包_moveit_config/config/ros_controllers.yaml, 在最末尾添加控制器或控制插件。(# the blow lines are added for need!)后面部分是需要添加的,可以参考然后为自己的机器人添加插件。
moveit_sim_hw_interface:
joint_model_group: arm
joint_model_group_pose: home
generic_hw_control_loop:
loop_hz: 300
cycle_time_error_threshold: 0.01
hardware_interface:
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- joint6
sim_control_mode: 1
joint_state_controller:
type: joint_state_controller/JointStateController
publish_rate: 50
controller_list:
- name: arm_controller
action_ns: follow_joint_trajectory
default: True
type: FollowJointTrajectory
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
- name: gripper_controller
action_ns: follow_joint_trajectory
default: True
type: FollowJointTrajectory
joints:
- joint6
arm_controller:
type: position_controllers/JointTrajectoryController
joints:
- joint1
- joint2
- joint3
- joint4
- joint5
gains:
joint1:
p: 100
d: 1
i: 1
i_clamp: 1
joint2:
p: 100
d: 1
i: 1
i_clamp: 1
joint3:
p: 100
d: 1
i: 1
i_clamp: 1
joint4:
p: 100
d: 1
i: 1
i_clamp: 1
joint5:
p: 100
d: 1
i: 1
i_clamp: 1
gripper_controller:
type: position_controllers/JointTrajectoryController
joints:
- joint6
gains:
joint6:
p: 100
d: 1
i: 1
i_clamp: 1
修改 _moveit_config/launch/ros_controllers.launch。 args=“joint_state_controller arm_controller gripper_controller” 双引号里面的内容是自己添加的。注意这几个控制器名字必须和ros_controllers.yaml文件里面的名字一样。
<?xml version="1.0"?>
<launch>
<rosparam file="$(find arm_g2_moveit_config)/config/ros_controllers.yaml" command="load"/>
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
output="screen" args="joint_state_controller arm_controller gripper_controller"/>
</launch>
4)运行demo_gazebo.launch,使用MoveIt! 控制机器人运动。
使用以上教程,顺利完成的联合仿真,如下图所示。
一些会出现的bug, 可忽略不影响。
[TERROR][1648205080.5748877891: Could not find the planner confiquration ‘None’ on the param server
修改方法:找到创建的功能包_moveit_config/config/ompl_planning.yaml,修改对应代码:
arm:
default_planner_config: None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)