环境 ROS2-IRON Gazebo11

1. 如何获取Gazebo中的机器人、世界模型的状态信息

找到gazebo中你是用的世界模型,在<world>...<world>标签下设置libgazebo_ros_state.so插件。默认获取全部模型。(指定想要的模型不知道为啥设置参数不生效)

  • 配置完后启动gazebo,就可以在ros中看到/gazebo/model_states/gazebo/link_states话题了。里面包含Pose和Velocity。
  • 注意一定要在world下添加,在机器人下不生效。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0"?>
<sdf version="1.6">
<world name="default">

<plugin name="gazebo_ros_init" filename="libgazebo_ros_init.so"/>
<plugin name="gazebo_ros_state" filename="libgazebo_ros_state.so">
<ros>
<namespace>/gazebo</namespace>
</ros>
<update_rate>50.0</update_rate>
<!-- <model_name>robot_name</model_name> -->
</plugin>

<include>
<uri>model://ground_plane</uri>
</include>

<include>
<uri>model://sun</uri>
</include>

<scene>
<shadows>false</shadows>
</scene>

<gui fullscreen='0'>
<camera name='user_camera'>
<pose frame=''>0.319654 -0.235002 9.29441 0 1.5138 0.009599</pose>
<view_controller>orbit</view_controller>
<projection_type>perspective</projection_type>
</camera>
</gui>

<physics type="ode">
<real_time_update_rate>1000.0</real_time_update_rate>
<max_step_size>0.001</max_step_size>
<real_time_factor>1</real_time_factor>
<ode>
<solver>
<type>quick</type>
<iters>150</iters>
<precon_iters>0</precon_iters>
<sor>1.400000</sor>
<use_dynamic_moi_rescaling>1</use_dynamic_moi_rescaling>
</solver>
<constraints>
<cfm>0.00001</cfm>
<erp>0.2</erp>
<contact_max_correcting_vel>2000.000000</contact_max_correcting_vel>
<contact_surface_layer>0.01000</contact_surface_layer>
</constraints>
</ode>
</physics>

<model name="world_house">
<static>1</static>
<include>
<uri>model://world_house</uri>
</include>
</model>

<include>
<pose>-2.0 -0.5 0.01 0.0 0.0 0.0</pose>
<uri>model://robot</uri>
</include>

</world>
</sdf>