解决gazebo中urdf模型显示不正常的问题,rviz中显示模型

之前使用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"/>
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值