gazebo 加载出来的自定义世界一片漆黑(小鱼课程中的custom_room)
-
ROS2
: Humble
Arch
: Arm64
Ubuntu
: 22.04
Gazebo Version
: Gazebo Fortress已经提问过AI,但还是无法解决
~/Desktop/mysh ❯ ros2 launch sim_world import_sim_world.launch.py 13:24:47 [INFO] [launch]: All log files can be found below /home/orin/.ros/log/2025-09-11-13-24-51-165552-jetson-1385478 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [ign gazebo-1]: process started with pid [1385506] [ign gazebo-1] [Wrn] [Conversions.cc:722] <gui><camera> can't be converted yet [ign gazebo-1] [Dbg] [gz.cc:161] Subscribing to [/gazebo/starting_world]. [ign gazebo-1] [Dbg] [gz.cc:163] Waiting for a world to be set from the GUI... [ign gazebo-1] [Msg] Received world [/home/orin/ros2_ws/install/sim_world/share/sim_world/worlds/custom_room.world] from the GUI. [ign gazebo-1] [Dbg] [gz.cc:167] Unsubscribing from [/gazebo/starting_world]. [ign gazebo-1] [Msg] Ignition Gazebo Server v6.17.0 [ign gazebo-1] [Msg] Loading SDF world file[/home/orin/ros2_ws/install/sim_world/share/sim_world/worlds/custom_room.world]. [ign gazebo-1] [Msg] Serving entity system service on [/entity/system/add] [ign gazebo-1] [Msg] Loaded level [3] [ign gazebo-1] [Msg] No systems loaded from SDF, loading defaults [ign gazebo-1] [Dbg] [ServerConfig.cc:1043] Loaded (3) plugins from file [/home/orin/.ignition/gazebo/6/server.config] [ign gazebo-1] [Dbg] [Physics.cc:804] Loaded [ignition::physics::dartsim::Plugin] from library [/usr/lib/aarch64-linux-gnu/ign-physics-5/engine-plugins/libignition-physics-dartsim-plugin.so] [ign gazebo-1] [Dbg] [SystemManager.cc:73] Loaded system [gz::sim::systems::Physics] for entity [1] [ign gazebo-1] [Msg] Create service on [/world/default/create] [ign gazebo-1] [Msg] Remove service on [/world/default/remove] [ign gazebo-1] [Msg] Pose service on [/world/default/set_pose] [ign gazebo-1] [Msg] Pose service on [/world/default/set_pose_vector] [ign gazebo-1] [Msg] Light configuration service on [/world/default/light_config] [ign gazebo-1] [Msg] Physics service on [/world/default/set_physics] [ign gazebo-1] [Msg] SphericalCoordinates service on [/world/default/set_spherical_coordinates] [ign gazebo-1] [Msg] Enable collision service on [/world/default/enable_collision] [ign gazebo-1] [Msg] Disable collision service on [/world/default/disable_collision] [ign gazebo-1] [Msg] Material service on [/world/default/visual_config] [ign gazebo-1] [Msg] Material service on [/world/default/wheel_slip] [ign gazebo-1] [Dbg] [SystemManager.cc:73] Loaded system [gz::sim::systems::UserCommands] for entity [1] [ign gazebo-1] [Dbg] [SystemManager.cc:73] Loaded system [gz::sim::systems::SceneBroadcaster] for entity [1] [ign gazebo-1] [Msg] Serving world controls on [/world/default/control], [/world/default/control/state] and [/world/default/playback/control] [ign gazebo-1] [Msg] Serving GUI information on [/world/default/gui/info] [ign gazebo-1] [Msg] World [default] initialized with [default_physics] physics profile. [ign gazebo-1] [Msg] Serving world SDF generation service on [/world/default/generate_world_sdf] [ign gazebo-1] [Msg] Serving world names on [/gazebo/worlds] [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] qrc:/qml/StyleDialog.qml:112:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] qrc:/qml/StyleDialog.qml:105:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] qrc:/qml/StyleDialog.qml:98:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] qrc:qml/Main.qml:102:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] qrc:/qml/PluginMenu.qml:27:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/Gazebo/GazeboDrawer.qml:242:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:57:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:52:3: QML RenderWindowOverlay: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:67:3: QML EntityContextMenu: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:52:3: QML RenderWindowOverlay: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:67:3: QML EntityContextMenu: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:52:3: QML RenderWindowOverlay: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:67:3: QML EntityContextMenu: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:52:3: QML RenderWindowOverlay: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:67:3: QML EntityContextMenu: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:52:3: QML RenderWindowOverlay: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:67:3: QML EntityContextMenu: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:52:3: QML RenderWindowOverlay: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:67:3: QML EntityContextMenu: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [Msg] Resource path add service on [/gazebo/resource_paths/add].[Msg] Ignition Gazebo GUI v6.17.0 [ign gazebo-1] [Dbg] [Gui.cc:253] Waiting for subscribers to [/gazebo/starting_world]... [ign gazebo-1] [Dbg] [Application.cc:92] Initializing application. [ign gazebo-1] [GUI] [Dbg] [Application.cc:555] Create main window [ign gazebo-1] [GUI] [Dbg] [PathManager.cc:66] Requesting resource paths through [/gazebo/resource_paths/get] [ign gazebo-1] [GUI] [Dbg] [Gui.cc:333] GUI requesting list of world names. The server may be busy downloading resources. Please be patient. [ign gazebo-1] [GUI] [Dbg] [PathManager.cc:55] Received resource paths. [ign gazebo-1] [GUI] [Dbg] [Gui.cc:391] Requesting GUI from [/world/default/gui/info]... [ign gazebo-1] [GUI] [Dbg] [GuiRunner.cc:145] Requesting initial state from [/world/default/state]... [ign gazebo-1] [GUI] [Msg] Loading config [/home/orin/.ignition/gazebo/6/gui.config] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [MinimalScene] [ign gazebo-1] [GUI] [Msg] Added plugin [3D View] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [MinimalScene] from path [/usr/lib/aarch64-linux-gnu/ign-gui-6/plugins/libMinimalScene.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [EntityContextMenuPlugin] [ign gazebo-1] [GUI] [Msg] Added plugin [Entity Context Menu] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [EntityContextMenuPlugin] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libEntityContextMenuPlugin.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [GzSceneManager] [ign gazebo-1] [GUI] [Msg] Added plugin [Scene Manager] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [GzSceneManager] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libGzSceneManager.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [InteractiveViewControl] [ign gazebo-1] [GUI] [Msg] Camera view controller topic advertised on [/gui/camera/view_control] [ign gazebo-1] [GUI] [Msg] Camera reference visual topic advertised on [/gui/camera/view_control/reference_visual] [ign gazebo-1] [GUI] [Msg] Camera view control sensitivity advertised on [/gui/camera/view_control/sensitivity] [ign gazebo-1] [GUI] [Msg] Added plugin [Interactive view control] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [InteractiveViewControl] from path [/usr/lib/aarch64-linux-gnu/ign-gui-6/plugins/libInteractiveViewControl.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [CameraTracking] [ign gazebo-1] [GUI] [Msg] Added plugin [Camera tracking] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [CameraTracking] from path [/usr/lib/aarch64-linux-gnu/ign-gui-6/plugins/libCameraTracking.so] [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/Spawn/Spawn.qml:32:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/WorldControl/WorldControl.qml:30:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [MarkerManager] [ign gazebo-1] [GUI] [Msg] Listening to stats on [/world/default/stats] [ign gazebo-1] [GUI] [Msg] Added plugin [Marker Manager] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [MarkerManager] from path [/usr/lib/aarch64-linux-gnu/ign-gui-6/plugins/libMarkerManager.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [SelectEntities] [ign gazebo-1] [GUI] [Msg] Added plugin [Select entities] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [SelectEntities] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libSelectEntities.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [Spawn] [ign gazebo-1] [GUI] [Msg] Added plugin [Spawn] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [Spawn] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libSpawn.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [VisualizationCapabilities] [ign gazebo-1] [GUI] [Msg] View as transparent service on [/gui/view/transparent] [ign gazebo-1] [GUI] [Msg] View as wireframes service on [/gui/view/wireframes] [ign gazebo-1] [GUI] [Msg] View center of mass service on [/gui/view/com] [ign gazebo-1] [GUI] [Msg] View inertia service on [/gui/view/inertia] [ign gazebo-1] [GUI] [Msg] View collisions service on [/gui/view/collisions] [ign gazebo-1] [GUI] [Msg] View joints service on [/gui/view/joints] [ign gazebo-1] [GUI] [Msg] View frames service on [/gui/view/frames] [ign gazebo-1] [GUI] [Msg] Added plugin [Visualization capabilities] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [VisualizationCapabilities] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libVisualizationCapabilities.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [WorldControl] [ign gazebo-1] [GUI] [Msg] Using world control service [/world/default/control] [ign gazebo-1] [GUI] [Msg] Listening to stats on [/world/default/stats] [ign gazebo-1] [GUI] [Dbg] [WorldControl.cc:246] Using an event to share WorldControl msgs with the server [ign gazebo-1] [GUI] [Msg] Added plugin [World control] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [WorldControl] from path [/usr/lib/aarch64-linux-gnu/ign-gui-6/plugins/libWorldControl.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [WorldStats] [ign gazebo-1] [GUI] [Msg] Listening to stats on [/world/default/stats] [ign gazebo-1] [GUI] [Msg] Added plugin [World stats] to main window [ign gazebo-1] [Wrn] [Model.hh:69] [Wrn] [Model.hh:69] [Wrn] [Model.hh:69] Skipping serialization / deserialization for models with //pose/@relative_to attribute.with //pose/@relative_to attribute. [ign gazebo-1] [Wrn] [Model.hh:69] Skipping serialization / deserialization for models with //pose/@relative_to attribute.with //pose/@relative_to attribute.Skipping serialization / deserialization for models with //pose/@relative_to attribute. [ign gazebo-1] [Wrn] [Model.hh:69] Skipping serialization / deserialization for models with //pose/@relative_to attribute. [ign gazebo-1] Skipping serialization / deserialization for models with //pose/@relative_to attribute. [ign gazebo-1] [Wrn] [Component.hh:144] Trying to serialize component with data type [N3sdf3v125WorldE], which doesn't have `operator<<`. Component will not be serialized. [ign gazebo-1] [Wrn] [Model.hh:69] Skipping serialization / deserialization for models with //pose/@relative_to attribute. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/TransformControl/TransformControl.qml:104:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/TransformControl/TransformControl.qml:99:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/TransformControl/TransformControl.qml:94:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/TransformControl/TransformControl.qml:89:3: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityTree/EntityTree.qml:148:7: QML ToolButton: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Component.hh:189] Trying to deserialize component with data type [N3sdf3v125WorldE], which doesn't have `operator>>`. Component will not be deserialized. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityTree/EntityTree.qml:148:7: QML ToolButton: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/WorldStats/WorldStats.qml:53:3: QML RowLayout: Binding loop detected for property "x" [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:52:3: QML RenderWindowOverlay: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Wrn] [Application.cc:797] [QT] file::/EntityContextMenuPlugin/EntityContextMenuPlugin.qml:67:3: QML EntityContextMenu: Detected anchors on an item that is managed by a layout. This is undefined behavior; use Layout.alignment instead. [ign gazebo-1] [GUI] [Msg] Loaded plugin [WorldStats] from path [/usr/lib/aarch64-linux-gnu/ign-gui-6/plugins/libWorldStats.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [Shapes] [ign gazebo-1] [GUI] [Msg] Added plugin [Shapes] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [Shapes] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libShapes.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [Lights] [ign gazebo-1] [GUI] [Msg] Added plugin [Lights] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [Lights] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libLights.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [TransformControl] [ign gazebo-1] [GUI] [Dbg] [TransformControl.cc:222] Legacy mode is disabled; this plugin must be used with MinimalScene. [ign gazebo-1] [GUI] [Msg] Added plugin [Transform control] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [TransformControl] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libTransformControl.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [Screenshot] [ign gazebo-1] [GUI] [Msg] Screenshot service on [/gui/screenshot] [ign gazebo-1] [GUI] [Msg] Added plugin [Screenshot] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [Screenshot] from path [/usr/lib/aarch64-linux-gnu/ign-gui-6/plugins/libScreenshot.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [CopyPaste] [ign gazebo-1] [GUI] [Msg] Added plugin [Copy/Paste] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [CopyPaste] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libCopyPaste.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [ComponentInspector] [ign gazebo-1] [GUI] [Msg] Added plugin [Component inspector] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [ComponentInspector] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libComponentInspector.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:426] Loading plugin [EntityTree] [ign gazebo-1] [GUI] [Msg] Added plugin [Entity tree] to main window [ign gazebo-1] [GUI] [Msg] Loaded plugin [EntityTree] from path [/usr/lib/aarch64-linux-gnu/ign-gazebo-6/plugins/gui/libEntityTree.so] [ign gazebo-1] [GUI] [Dbg] [Application.cc:296] Loading window config [ign gazebo-1] [GUI] [Msg] Using server control service [/server_control] [ign gazebo-1] [GUI] [Dbg] [Application.cc:569] Applying config [ign gazebo-1] [GUI] [Msg] Loading plugin [ignition-rendering-ogre2] [ign gazebo-1] [GUI] [Dbg] [MinimalScene.cc:602] Create scene [scene] [ign gazebo-1] [GUI] [Msg] Loading plugin [ignition-rendering-ogre2]
-
Based on the provided SDF file, here is a detailed breakdown of the potential causes for your models appearing black and the steps you can take to fix them.
原因分析:模型显示为黑色的根本问题
您提供的 SDF 文件暴露了几个可能导致模型在 Ignition Gazebo 6 中显示为黑色的关键问题。这些问题主要集中在 材质定义 和 场景光照 的配置上。
1. 材质定义兼容性问题
您的
ground_plane
、room
和bookshelf
模型都使用了<material>
标签中的<script>
属性,并引用了file://media/materials/scripts/gazebo.material
脚本。- 问题所在: Ignition Gazebo 6 不再像 Gazebo Classic 那样自动加载这些旧版 Gazebo 的材质脚本。它需要完整的、绝对的 URI 路径或在本地模型文件夹中找到这些脚本。由于您的文件是从 Gazebo Classic 迁移过来的,Ignition Gazebo 无法找到并解析这些材质,因此模型的渲染会退回到默认的黑色或无光照状态。
2. 场景光照配置不完整
您的 SDF 文件中定义了两个光源:
sun
和room_lamp
。- 问题所在:
- 光照参数缺失: 在
<light name='sun'>
的定义中,您缺少了<direction>
标签。一个定向光源必须有方向向量来定义光线从何处射来。尽管在 SDFstate
中有<direction>0 0 -1</direction>
的定义,但在主要的<light>
标签中却没有。 - 阴影设置: 在
<scene>
标签中,您将<shadows>
设置为了0
。这意味着场景中的所有物体都不会投射阴影。虽然这本身不会导致黑色,但它会使场景看起来非常平淡和不真实,因为它没有阴影深度。
- 光照参数缺失: 在
解决方案
要解决这些问题并让您的模型在 Ignition Gazebo 6 中正确显示,请按照以下步骤修改您的 SDF 文件。
1. 修复材质引用
将所有模型的
<material>
标签从引用脚本的方式更改为直接指定颜色。这是确保兼容性和可靠性的最简单方法。-
示例:
找到您所有模型(room
,bookshelf
,cabinet
)中所有<visual>
下的<material>
标签。
将所有类似下面的代码:<material> <script> <uri>file://media/materials/scripts/gazebo.material</uri> <name>Gazebo/Grey</name> </script> <ambient>1 1 1 1</ambient> </material>
替换为:
<material> <ambient>0.8 0.8 0.8 1</ambient> <diffuse>0.8 0.8 0.8 1</diffuse> <specular>0.1 0.1 0.1 1</specular> </material>
您可以根据需要调整
ambient
,diffuse
和specular
的 RGBa 值(范围0
到1
),以获得不同的颜色和光泽度。ambient
控制环境光颜色,diffuse
控制漫反射颜色(物体本身颜色),specular
控制高光颜色。
2. 修正光照和场景设置
确保您的光照定义完整且合理。
-
添加定向光方向: 在
<world>
标签下的sun
光源定义中,补全<direction>
标签。<light name='sun' type='directional'> <cast_shadows>1</cast_shadows> <pose>0 0 10 0 -0 0</pose> <diffuse>1.0 1.0 1.0 1.0</diffuse> <specular>1.0 1.0 1.0 1.0</specular> <attenuation> <range>1000</range> <constant>0.9</constant> <linear>0.01</linear> <quadratic>0.001</quadratic> </attenuation> <direction>0.5 0.5 -1</direction> </light>
-
启用阴影: 在
<scene>
标签中,将<shadows>
的值改为1
。<scene> <ambient>1.0 1.0 1.0 1</ambient> <background>0.7 0.7 0.7 1</background> <shadows>1</shadows> </scene>
3. 检查模型位置和相机视角
如果上述更改后仍然是黑色,很可能是您的相机视角在房间模型(
room
)外部,而您添加的room_lamp
点光源位于房间内部。由于房间的墙壁是实体,它会阻挡光线。- 确认相机位置: 在 Ignition Gazebo 中,你可以使用鼠标和键盘移动相机视角,进入房间内部查看。
通过这些修改,您应该能够解决模型在 Ignition Gazebo 6 中显示为黑色的问题。 Ignition Gazebo 对 SDF 文件的要求更严格,尤其是在光照和材质引用方面。