Skip to content

Commit 59e13b0

Browse files
authored
Merge pull request #500 from JdeRobot/small_laser_mapping
Small universe for laser mapping exercise
2 parents 73ee467 + 104d9fc commit 59e13b0

File tree

6 files changed

+593
-1
lines changed

6 files changed

+593
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" ?>
2+
<model>
3+
<name>small_mapping_warehouse</name>
4+
<version>1.0</version>
5+
<sdf version="1.8">model.sdf</sdf>
6+
<author>
7+
<name>Generated by blender SDF tools</name>
8+
</author>
9+
</model>
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
<?xml version="1.0" ?>
2+
<sdf version='1.8'>
3+
<model name='small_mapping_warehouse'>
4+
<static>true</static>
5+
<link name='Wall_0'>
6+
<collision name='Wall_0_Collision'>
7+
<geometry>
8+
<box>
9+
<size>9 0.5 2.5</size>
10+
</box>
11+
</geometry>
12+
<pose>0 0 0 0 -0 0</pose>
13+
<max_contacts>10</max_contacts>
14+
<surface>
15+
<bounce/>
16+
<friction>
17+
<ode/>
18+
</friction>
19+
<contact>
20+
<ode/>
21+
</contact>
22+
</surface>
23+
</collision>
24+
<visual name='Wall_0_Visual'>
25+
<pose>0 0 0 0 -0 0</pose>
26+
<geometry>
27+
<box>
28+
<size>9 0.5 2.5</size>
29+
</box>
30+
</geometry>
31+
<material>
32+
<script>
33+
<uri>file://media/materials/scripts/gazebo.material</uri>
34+
<name>Gazebo/White</name>
35+
</script>
36+
</material>
37+
</visual>
38+
<velocity_decay>
39+
<linear>0</linear>
40+
<angular>0</angular>
41+
</velocity_decay>
42+
<pose>12 -0.5 1.25 0 -0 1.57</pose>
43+
<self_collide>0</self_collide>
44+
<kinematic>0</kinematic>
45+
<gravity>1</gravity>
46+
</link>
47+
48+
<link name='Wall_1'>
49+
<collision name='Wall_1_Collision'>
50+
<geometry>
51+
<box>
52+
<size>6 0.5 2.5</size>
53+
</box>
54+
</geometry>
55+
<pose>0 0 0 0 -0 0</pose>
56+
<max_contacts>10</max_contacts>
57+
<surface>
58+
<bounce/>
59+
<friction>
60+
<ode/>
61+
</friction>
62+
<contact>
63+
<ode/>
64+
</contact>
65+
</surface>
66+
</collision>
67+
<visual name='Wall_1_Visual'>
68+
<pose>0 0 0 0 -0 0</pose>
69+
<geometry>
70+
<box>
71+
<size>6 0.5 2.5</size>
72+
</box>
73+
</geometry>
74+
<material>
75+
<script>
76+
<uri>file://media/materials/scripts/gazebo.material</uri>
77+
<name>Gazebo/White</name>
78+
</script>
79+
</material>
80+
</visual>
81+
<velocity_decay>
82+
<linear>0</linear>
83+
<angular>0</angular>
84+
</velocity_decay>
85+
<pose>2 -8 1.25 0 -0 1.57</pose>
86+
<self_collide>0</self_collide>
87+
<kinematic>0</kinematic>
88+
<gravity>1</gravity>
89+
</link>
90+
91+
<link name='Wall_2'>
92+
<collision name='Wall_2_Collision'>
93+
<geometry>
94+
<box>
95+
<size>10 0.5 2.5</size>
96+
</box>
97+
</geometry>
98+
<pose>0 0 0 0 -0 0</pose>
99+
<max_contacts>10</max_contacts>
100+
<surface>
101+
<bounce/>
102+
<friction>
103+
<ode/>
104+
</friction>
105+
<contact>
106+
<ode/>
107+
</contact>
108+
</surface>
109+
</collision>
110+
<visual name='Wall_2_Visual'>
111+
<pose>0 0 0 0 -0 0</pose>
112+
<geometry>
113+
<box>
114+
<size>10 0.5 2.5</size>
115+
</box>
116+
</geometry>
117+
<material>
118+
<script>
119+
<uri>file://media/materials/scripts/gazebo.material</uri>
120+
<name>Gazebo/White</name>
121+
</script>
122+
</material>
123+
</visual>
124+
<velocity_decay>
125+
<linear>0</linear>
126+
<angular>0</angular>
127+
</velocity_decay>
128+
<pose>7.25 -5.25 1.25 0 -0 0</pose>
129+
<self_collide>0</self_collide>
130+
<kinematic>0</kinematic>
131+
<gravity>1</gravity>
132+
</link>
133+
134+
<link name='Wall_3'>
135+
<collision name='Wall_3_Collision'>
136+
<geometry>
137+
<box>
138+
<size>8.5 0.5 2.5</size>
139+
</box>
140+
</geometry>
141+
<pose>0 0 0 0 -0 0</pose>
142+
<max_contacts>10</max_contacts>
143+
<surface>
144+
<bounce/>
145+
<friction>
146+
<ode/>
147+
</friction>
148+
<contact>
149+
<ode/>
150+
</contact>
151+
</surface>
152+
</collision>
153+
<visual name='Wall_3_Visual'>
154+
<pose>0 0 0 0 -0 0</pose>
155+
<geometry>
156+
<box>
157+
<size>8.5 0.5 2.5</size>
158+
</box>
159+
</geometry>
160+
<material>
161+
<script>
162+
<uri>file://media/materials/scripts/gazebo.material</uri>
163+
<name>Gazebo/White</name>
164+
</script>
165+
</material>
166+
</visual>
167+
<velocity_decay>
168+
<linear>0</linear>
169+
<angular>0</angular>
170+
</velocity_decay>
171+
<pose>-2 -11.25 1.25 0 -0 0</pose>
172+
<self_collide>0</self_collide>
173+
<kinematic>0</kinematic>
174+
<gravity>1</gravity>
175+
</link>
176+
177+
<link name='Wall_4'>
178+
<collision name='Wall_4_Collision'>
179+
<geometry>
180+
<box>
181+
<size>15 0.5 2.5</size>
182+
</box>
183+
</geometry>
184+
<pose>0 0 0 0 -0 0</pose>
185+
<max_contacts>10</max_contacts>
186+
<surface>
187+
<bounce/>
188+
<friction>
189+
<ode/>
190+
</friction>
191+
<contact>
192+
<ode/>
193+
</contact>
194+
</surface>
195+
</collision>
196+
<visual name='Wall_4_Visual'>
197+
<pose>0 0 0 0 -0 0</pose>
198+
<geometry>
199+
<box>
200+
<size>15 0.5 2.5</size>
201+
</box>
202+
</geometry>
203+
<material>
204+
<script>
205+
<uri>file://media/materials/scripts/gazebo.material</uri>
206+
<name>Gazebo/White</name>
207+
</script>
208+
</material>
209+
</visual>
210+
<velocity_decay>
211+
<linear>0</linear>
212+
<angular>0</angular>
213+
</velocity_decay>
214+
<pose>-6 -3.5 1.25 0 -0 1.57</pose>
215+
<self_collide>0</self_collide>
216+
<kinematic>0</kinematic>
217+
<gravity>1</gravity>
218+
</link>
219+
220+
<link name='Wall_5'>
221+
<collision name='Wall_5_Collision'>
222+
<geometry>
223+
<box>
224+
<size>18.5 0.5 2.5</size>
225+
</box>
226+
</geometry>
227+
<pose>0 0 0 0 -0 0</pose>
228+
<max_contacts>10</max_contacts>
229+
<surface>
230+
<bounce/>
231+
<friction>
232+
<ode/>
233+
</friction>
234+
<contact>
235+
<ode/>
236+
</contact>
237+
</surface>
238+
</collision>
239+
<visual name='Wall_5_Visual'>
240+
<pose>0 0 0 0 -0 0</pose>
241+
<geometry>
242+
<box>
243+
<size>18.5 0.5 2.5</size>
244+
</box>
245+
</geometry>
246+
<material>
247+
<script>
248+
<uri>file://media/materials/scripts/gazebo.material</uri>
249+
<name>Gazebo/White</name>
250+
</script>
251+
</material>
252+
</visual>
253+
<velocity_decay>
254+
<linear>0</linear>
255+
<angular>0</angular>
256+
</velocity_decay>
257+
<pose>3 4.25 1.25 0 -0 0</pose>
258+
<self_collide>0</self_collide>
259+
<kinematic>0</kinematic>
260+
<gravity>1</gravity>
261+
</link>
262+
263+
<static>1</static>
264+
<pose>0 0 0 0 -0 0</pose>
265+
</model>
266+
</sdf>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import os
2+
3+
from ament_index_python.packages import get_package_share_directory
4+
5+
from launch import LaunchDescription
6+
from launch.actions import (
7+
DeclareLaunchArgument,
8+
IncludeLaunchDescription,
9+
SetEnvironmentVariable,
10+
AppendEnvironmentVariable
11+
)
12+
from launch.launch_description_sources import PythonLaunchDescriptionSource
13+
from launch.substitutions import LaunchConfiguration, Command
14+
from launch_ros.actions import Node
15+
from launch.substitutions import LaunchConfiguration
16+
from launch_ros.actions import Node
17+
18+
19+
def generate_launch_description():
20+
21+
x = LaunchConfiguration('x')
22+
y = LaunchConfiguration('y')
23+
z = LaunchConfiguration('z')
24+
roll = LaunchConfiguration('R')
25+
pitch = LaunchConfiguration('P')
26+
yaw = LaunchConfiguration('Y')
27+
28+
package_dir = get_package_share_directory('custom_robots')
29+
ros_gz_sim = get_package_share_directory('ros_gz_sim')
30+
31+
gazebo_models_path = os.path.join(package_dir, "models")
32+
33+
robot_launch_dir = "/opt/jderobot/Launchers/marker_visual_loc"
34+
robot_model_dir = os.path.join(package_dir, 'models/turtlebot3_waffle')
35+
36+
use_sim_time = LaunchConfiguration('use_sim_time', default='true')
37+
x_pose = LaunchConfiguration('x_pose', default='0')
38+
y_pose = LaunchConfiguration('y_pose', default='0')
39+
z_pose = LaunchConfiguration('z_pose', default='0.0')
40+
world_file_name = "small_laser_mapping.world"
41+
worlds_dir = "/opt/jderobot/Worlds"
42+
world_path = os.path.join(worlds_dir, world_file_name)
43+
44+
gazebo_server = IncludeLaunchDescription(
45+
PythonLaunchDescriptionSource(
46+
os.path.join(ros_gz_sim, 'launch', 'gz_sim.launch.py')),
47+
launch_arguments={'gz_args': ['-r -s -v4 ', world_path], 'on_exit_shutdown': 'true'}.items()
48+
)
49+
50+
declare_x_cmd = DeclareLaunchArgument(
51+
'x', default_value='0'
52+
)
53+
54+
declare_y_cmd = DeclareLaunchArgument(
55+
'y', default_value='0'
56+
)
57+
58+
declare_z_cmd = DeclareLaunchArgument(
59+
'z', default_value='0.0'
60+
)
61+
62+
declare_roll_cmd = DeclareLaunchArgument(
63+
'R', default_value='0.0'
64+
)
65+
66+
declare_pitch_cmd = DeclareLaunchArgument(
67+
'P', default_value='0.0'
68+
)
69+
70+
declare_yaw_cmd = DeclareLaunchArgument(
71+
'Y', default_value='0.0'
72+
)
73+
74+
robot_state_publisher_cmd = IncludeLaunchDescription(
75+
PythonLaunchDescriptionSource(
76+
os.path.join(robot_launch_dir, 'robot_state_publisher.launch.py')
77+
),
78+
launch_arguments={'use_sim_time': use_sim_time}.items()
79+
)
80+
81+
spawn_robot_cmd = IncludeLaunchDescription(
82+
PythonLaunchDescriptionSource(
83+
os.path.join(robot_launch_dir, 'spawn_robot.launch.py')
84+
),
85+
launch_arguments={
86+
'x_pose': x_pose,
87+
'y_pose': y_pose,
88+
'z_pose': z_pose
89+
}.items()
90+
)
91+
92+
world_entity_cmd = Node(package='ros_gz_sim', executable='create',
93+
arguments=['-name',
94+
'world',
95+
'-file',
96+
world_path
97+
],
98+
output='screen')
99+
100+
ld = LaunchDescription()
101+
102+
ld.add_action(SetEnvironmentVariable('GZ_SIM_RESOURCE_PATH', gazebo_models_path))
103+
set_env_vars_resources = AppendEnvironmentVariable('GZ_SIM_RESOURCE_PATH', os.path.join(package_dir,'models'))
104+
ld.add_action(set_env_vars_resources)
105+
ld.add_action(gazebo_server)
106+
# ld.add_action(gazebo_client)
107+
ld.add_action(declare_x_cmd)
108+
ld.add_action(declare_y_cmd)
109+
ld.add_action(declare_z_cmd)
110+
ld.add_action(declare_roll_cmd)
111+
ld.add_action(declare_pitch_cmd)
112+
ld.add_action(declare_yaw_cmd)
113+
ld.add_action(world_entity_cmd)
114+
ld.add_action(robot_state_publisher_cmd)
115+
ld.add_action(spawn_robot_cmd)
116+
117+
return ld

0 commit comments

Comments
 (0)