gazebo moveit ros_control设置初探
1配置文件调用顺序
**_moveit_planning_execution.launch
->move_group.launch→ **_moveit_controller_manager.launch.xml (填写控制器)->controllers.yaml
2.新建controllers.yaml
3.编写一个启动文件
https://blog.****.net/lingchen2348/article/details/81709404
在ur5的启动过程中,执行了一条launch命令
roslaunch ur5_moveit_config ur5_moveit_planning_execution.launch sim:=true
那我们就依葫芦画瓢也编写一份相同的文件。保存为**_moveit_planning_execution.launch
比如aubo_i5_moveit_planning_execution.launch,文件位置在moveit配置文件夹中的launch目录下。
<launch>
<arg name="sim" default="false" />
<arg name="limited" default="false"/>
<arg name="debug" default="false" />
<!-- Remap follow_joint_trajectory -->
<remap if="$(arg sim)" from="/follow_joint_trajectory" to="/arm_controller/follow_joint_trajectory"/>
<!-- Launch moveit -->
<!--此段代码来自moveit配置文件demo.launch-->
<include file="$(find moveit配置目录)/launch/move_group.launch">
<!-- arg name="limited" default="$(arg limited)"/-->
<arg name="debug" default="$(arg debug)" />
</include>
<!-- added -->
<!-- if We have a robot connected, so publish actual joint states -->
<node if="$(arg sim)" name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
<!-- param name="use_gui" value="$(arg use_gui)"/ -->
<rosparam param="source_list">[/机器人名字/joint_states]</rosparam>#添加的
<!-- /robotname/joint_states]</rosparam -->
</node>
<!-- Given the published joint states, publish tf for the robot links ,robot states-->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen" />
<!-- Run Rviz and load the default config to see the state of the move_group node -->
<include file="$(find moveit配置目录)/launch/moveit_rviz.launch">
<arg name="config" value="true"/>
<arg name="debug" value="$(arg debug)"/>
</include>
</launch>
4.改写move_group.launch
修改moveit_controller_manager参数。
https://blog.****.net/lingchen2348/article/details/80300069
<!-- Trajectory Execution Functionality -->
<include ns="move_group" if="$(arg allow_trajectory_execution)" file="$(find 配置目录)/launch/trajectory_execution.launch.xml" >
<arg name="moveit_manage_controllers" value="true" />
<arg name="moveit_controller_manager" value="机器人名字" unless="$(arg fake_execution)"/>#注意
<arg name="moveit_controller_manager" value="fake" if="$(arg fake_execution)"/>
</include>
例如:
我们注意到在moveit_planning_execution.launch文件中并没有对fake_execution进行赋值,又因为fake_execution的默认值为false所以采用实物反馈的方法
5改写**_moveit_controller_manager.launch.xml
其中××为机器人的名字
例如:
注意,上文中 find my_robot_name_moveit_config其实不准确,应该为moveit_config文件夹的名字才对如下所示:
改写如下:
其 中robot_moveit_config/config/controllers.yaml为路径
6.修改planning_context.launch
修改为 <arg name="load_robot_description" default="true"/>#默认为false,需要改为true
7.后面可能会遇到的情况,暂时还没遇到
8xacro的gazebo文件设置
由
<!-- ros_control plugin -->
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/机器人名字</robotNamespace>
</plugin>
</gazebo>
改为如下内容,加载DefaultRobotHWSim配置实现与gazebo的通信
<!-- ros_control plugin -->
<gazebo>
<static>false</static>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/机器人名字</robotNamespace>
<robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
<legacyModeNS>true</legacyModeNS>
</plugin>
</gazebo>
9.gazebo下面的config的trajectory_control.yaml的相关配置文件中设置pid参数
pid设置格式如下所示:
/gazebo_ros_control/pid_gains:
j1: {p: 1000.0,i: 0.0, d: 0.1, i_clamp: 1.0}
j2: {p: 1000.0,i: 0.0, d: 0.1, i_clamp: 1.0}
j3: {p: 1000.0,i: 0.0, d: 0.1, i_clamp: 1.0}
j4: {p: 1000.0,i: 0.0, d: 0.1, i_clamp: 1.0}
j5: {p: 1000.0,i: 0.0, d: 0.1, i_clamp: 1.0}
j6: {p: 1000.0,i: 0.0, d: 0.1, i_clamp: 1.0}
否则终端会显示找不到pid的设置
10.roslaunch gazebo文件下的.bringup.lauch
文件则加载rivz和gazebo
但是发现机器人在重力作用下瘫了,底座翻了,推测是底座没有固定的原因,经过查看aubo的xacro文件发下如下内容:
11.接下来的一些思考
在moveit调试助手中重新设置设置world和world_link来固定基座
发现base_link的父连杆是world,
而在其moveit生成的srdf文件中
发现设置了虚拟关节为固定关节,parent_frame为"world"
所以照猫画虎,我们需要重新配置moveit来设定world连杆和world_joint fixed关节