gazebo_world 基本围墙。
如何使用?
参考gazebo harmonic的官方教程。
本人使用harmonic的template,在里面进行修改就可以分流畅地使用下去。
以下是world 文件.
<?xml version="1.0" ?>
<!--
Try sending commands:
gz topic -t "/model/diff_drive/cmd_vel" -m gz.msgs.Twist -p "linear: {x: 1.0}, angular: {z: -0.1}"
ros2 topic pub /diff_drive/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 5.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: -0.1}}"
Listen to odometry:
gz topic -e -t /model/diff_drive/odometry
ros2 topic echo /model/diff_drive/odometry
-->
<sdf version="1.8">
<world name="slam_demo">
<plugin
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="gz-sim-sensors-system"
name="gz::sim::systems::Sensors">
<render_engine>ogre2</render_engine>
</plugin>
<plugin
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>
<plugin
filename="gz-sim-user-commands-system"
name="gz::sim::systems::UserCommands">
</plugin>
<plugin
filename="BasicSystem"
name="ros_gz_example_gazebo::BasicSystem">
</plugin>
<plugin
filename="FullSystem"
name="ros_gz_example_gazebo::FullSystem">
</plugin>
<light name="sun" type="directional">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>
<model name="ground_plane">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
</collision>
<visual name="visual">
<geometry>
<plane>
<normal>0 0 1</normal>
<size>100 100</size>
</plane>
</geometry>
<material>
<ambient>0.8 0.8 0.8 1</ambient>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.8 0.8 0.8 1</specular>
</material>
</visual>
</link>
</model>
<model name="diff_drive">
<self_collide>true</self_collide>
<pose>0 0 0.35 0 0 0</pose>
<include merge="true">
<uri>package://ros_gz_example_description/models/diff_drive</uri>
</include>
<plugin
filename="gz-sim-joint-state-publisher-system"
name="gz::sim::systems::JointStatePublisher">
</plugin>
<plugin
filename="gz-sim-pose-publisher-system"
name="gz::sim::systems::PosePublisher">
<publish_link_pose>true</publish_link_pose>
<use_pose_vector_msg>true</use_pose_vector_msg>
<static_publisher>true</static_publisher>
<static_update_frequency>1</static_update_frequency>
</plugin>
<plugin
filename="gz-sim-odometry-publisher-system"
name="gz::sim::systems::OdometryPublisher">
<odom_frame>diff_drive/odom</odom_frame>
<robot_base_frame>diff_drive</robot_base_frame>
</plugin>
</model>
<!-- 北墙 -->
<model name="wall_north">
<static>true</static>
<pose>0 11 1 0 0 0</pose> <!-- Y 坐标从 8 增加到 11 -->
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>22 0.4 2</size> <!-- 长度从 16 增加到 22 -->
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>22 0.4 2</size>
</box>
</geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.6 0.6 0.6 1</diffuse>
<specular>0.7 0.7 0.7 1</specular>
</material>
</visual>
</link>
</model>
<!-- 南墙 -->
<model name="wall_south">
<static>true</static>
<pose>0 -11 1 0 0 0</pose> <!-- Y 坐标从 -8 减少到 -11 -->
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>22 0.4 2</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>22 0.4 2</size>
</box>
</geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.6 0.6 0.6 1</diffuse>
<specular>0.7 0.7 0.7 1</specular>
</material>
</visual>
</link>
</model>
<!-- 东墙 -->
<model name="wall_east">
<static>true</static>
<pose>11 0 1 0 0 1.5708</pose> <!-- X 坐标从 8 增加到 11 -->
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>22 0.4 2</size> <!-- 长度从 16 增加到 22 -->
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>22 0.4 2</size>
</box>
</geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.6 0.6 0.6 1</diffuse>
<specular>0.7 0.7 0.7 1</specular>
</material>
</visual>
</link>
</model>
<!-- 西墙 -->
<model name="wall_west">
<static>true</static>
<pose>-11 0 1 0 0 1.5708</pose> <!-- X 坐标从 -8 减少到 -11 -->
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>22 0.4 2</size>
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>22 0.4 2</size>
</box>
</geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.6 0.6 0.6 1</diffuse>
<specular>0.7 0.7 0.7 1</specular>
</material>
</visual>
</link>
</model>
<!-- 分隔客厅和上方房间 -->
<model name="partition_living_to_rooms">
<static>true</static>
<pose>0 2.5 1 0 0 0</pose> <!-- 墙体中心位置:X=0, Y=2.5, Z=1 -->
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>12 0.4 2</size> <!-- 墙体长度=12, 厚度=0.4, 高度=2 -->
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>12 0.4 2</size>
</box>
</geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.6 0.6 0.6 1</diffuse>
<specular>0.7 0.7 0.7 1</specular>
</material>
</visual>
</link>
</model>
<!-- 分隔左边房间和小走廊 -->
<model name="partition_left_room_to_corridor">
<static>true</static>
<pose>-1.5 5 1 0 0 0</pose> <!-- 墙体中心位置:X=-1.5, Y=5, Z=1 -->
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>3 0.4 2</size> <!-- 墙体长度=3, 厚度=0.4, 高度=2 -->
</box>
</geometry>
</collision>
<visual name="visual">
<geometry>
<box>
<size>3 0.4 2</size>
</box>
</geometry>
<material>
<ambient>0.5 0.5 0.5 1</ambient>
<diffuse>0.6 0.6 0.6 1</diffuse>
<specular>0.7 0.7 0.7 1</specular>
</material>
</visual>
</link>
</model>
</world>
</sdf>
``