之前使用roslaunch将urdf模型加载到rosparam参数服务器中
而在rviz中模型颜色显示正常,gazebo中显示白色。
正确的解决办法是:
单独文件materials.xacro中定义材料的性质
<?xml version="1.0"?>
<!--
These are some material descriptions of the Pioneer 3DX.
Copyright (C) 2013 Rafael Berkvens rafael.berkvens@uantwerpen.be
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This project is based on work by Tracy Davies, where it was in turn based on
work original in ucs-ros-pkg.-->
<robot>
<material name="black">
<color rgba="0.0 0.0 0.0 1.0"/>
</material>
<material name="blue">
<color rgba="0.0 0.0 0.8 1.0"/>
</material>
<material name="green">
<color rgba="0.0 0.8 0.0 1.0"/>
</material>
<material name="gray">
<color rgba="0.7 0.7 0.7 1.0"/>
</material>
<material name="darkgray">
<color rgba="0.3 0.3 0.3 1.0"/>
</material>
<material name="red">
<color rgba="0.8 0.0 0.0 1.0"/>
</material>
<material name="white">
<color rgba="1.0 1.0 1.0 1.0"/>
</material>
<material name="yellow">
<color rgba="0.8 0.8 0.0 1.0"/>
</material>
</robot>
修改pxdx.xacro中引用material,注意删除visual中的name,否则显示不正常
<material name="red"/> visual元素中用来定义材料
<?xml version="1.0"?>
<!--
This is the xacro description of a Pioneer 3DX, to be used in rviz and gazebo.
Copyright (C) 2013 Rafael Berkvens rafael.berkvens@uantwerpen.be
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
This project is based on work by Tracy Davies, where it was in turn based on
work original in ucs-ros-pkg.-->
<robot name="pxdx" xmlns:xacro="http://www.ros.org/wiki/xacro">
<!-- import all gazebo-customization elements, including gazebo colors -->
<xacro:include filename="pxdx.gazebo" />
<!-- import the pioneer 3dx's wheels -->
<xacro:include filename="pxdx_wheel.xacro" />
<xacro:include filename="materials.xacro" />
<!-- chassis -->
<link name="base_link">
<inertial>
<mass value="3.5" />
<!--<origin xyz="-0.025 0 -0.223"/> -->
<origin xyz="-0.05 0 0" />
<inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1" />
</inertial>
<visual>
<origin xyz="-0.045 0 0.145" rpy="0 0 0" />
<geometry name="pioneer_geom">
<box size="0.35 0.25 0.14" />
</geometry>
<material name="red"/>

最低0.47元/天 解锁文章
5664

被折叠的 条评论
为什么被折叠?



