Skip to content

Commit 6af36c8

Browse files
committed
now use default level on all launch file, in addition use multi_robot_launcher which can launch multiple robots in a scripted manner.
1 parent 45918c4 commit 6af36c8

File tree

9 files changed

+85
-13
lines changed

9 files changed

+85
-13
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.swp
2+
*.swo

bwi_launch/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ catkin_package()
66
install(DIRECTORY launch/
77
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
88

9+
install(DIRECTORY config/
10+
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
11+
12+
catkin_install_python(PROGRAMS scripts/multi_robot_launcher
13+
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
14+
915
# unit tests are enabled selectively
1016
if (CATKIN_ENABLE_TESTING)
1117
find_package(roslaunch REQUIRED)

bwi_launch/config/simulation.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
robots:
2+
- name: marvin
3+
location: [0.0, 8.0, 0.0]
4+
- name: roberto
5+
location: [0.0, 10.0, 0.0]
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<launch>
22

33
<arg name="multimap_file" default="$(find utexas_gdc)/maps/simulation/multimap/test.yaml" />
4-
<arg name="robot1" default="marvin" />
5-
<arg name="robot2" default="roberto" />
64

75
<!-- start the simulation environment -->
86
<include file="$(find utexas_gdc)/launch/simulation_3ne.launch" />
@@ -14,16 +12,8 @@
1412

1513
<include file="$(find segbot_simulation_apps)/launch/door_handler.launch" />
1614

17-
<!-- launch robot1 -->
18-
<include file="$(find bwi_launch)/launch/includes/simulation_ns.launch.xml">
19-
<arg name="y" value="8.0" />
20-
<arg name="ns" value="$(arg robot1)" />
21-
</include>
22-
23-
<!-- launch robot2 -->
24-
<include file="$(find bwi_launch)/launch/includes/simulation_ns.launch.xml">
25-
<arg name="y" value="10.0" />
26-
<arg name="ns" value="$(arg robot2)" />
27-
</include>
15+
<node name="multi_robot_launcher" pkg="bwi_launch" type="multi_robot_launcher">
16+
<rosparam command="load" param="configuration" file="$(find bwi_launch)/config/simulation.yaml" />
17+
</node>
2818

2919
</launch>

bwi_launch/launch/segbot_v1.launch

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<param name="map_file" value="$(arg multimap_file)" />
77
</node>
88

9+
<!-- Set the default level we'd like this robot to start on -->
10+
<param name="level_mux/default_current_level" value="3rdFloor" />
11+
912
<include file="$(find bwi_launch)/launch/includes/segbot.launch.xml" />
1013

1114
<include file="$(find segbot_bringup)/launch/segbot_v1.launch" />

bwi_launch/launch/segbot_v2.launch

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<param name="map_file" value="$(arg multimap_file)" />
77
</node>
88

9+
<!-- Set the default level we'd like this robot to start on -->
10+
<param name="level_mux/default_current_level" value="3rdFloor" />
11+
912
<include file="$(find bwi_launch)/launch/includes/segbot.launch.xml">
1013
<arg name="laser_max_range" value="20.0" />
1114
</include>

bwi_launch/launch/simulation.launch

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<param name="map_file" value="$(arg multimap_file)" />
1111
</node>
1212

13+
<!-- Set the default level we'd like this robot to start on -->
14+
<param name="level_mux/default_current_level" value="level1" />
15+
1316
<include file="$(find segbot_simulation_apps)/launch/door_handler.launch" />
1417

1518
<include file="$(find bwi_launch)/launch/includes/simulation.launch.xml">

bwi_launch/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<buildtool_depend>catkin</buildtool_depend>
2020

21+
<depend>bwi_msgs</depend>
2122
<depend>bwi_kr_execution</depend>
2223
<depend>multi_level_map_server</depend>
2324
<depend>multi_level_map_utils</depend>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import rospy
5+
import tempfile
6+
7+
from bwi_msgs.msg import AvailableRobot, AvailableRobotArray
8+
from bwi_tools import start_roslaunch_process, stop_roslaunch_process
9+
10+
def construct_launch_file(fd, config, msg):
11+
msg.robots = []
12+
launch_file_str = "<launch>"
13+
for robot in config['robots']:
14+
robot_name = robot['name']
15+
robot_x = robot['location'][0]
16+
robot_y = robot['location'][1]
17+
robot_yaw = robot['location'][2]
18+
launch_file_str += '<include file="$(find bwi_launch)/launch/includes/simulation_ns.launch.xml"><arg name="x" value="%f" /><arg name="y" value="%f" /><arg name="yaw" value="%f" /><arg name="ns" value="%s" /></include> '%(robot_x, robot_y, robot_yaw, robot_name)
19+
msg.robots.append(AvailableRobot(robot_name, AvailableRobot.SEGBOT))
20+
launch_file_str += '</launch>'
21+
fd.write(launch_file_str)
22+
23+
def robot_publisher():
24+
25+
process = None
26+
temp_file_name = None
27+
try:
28+
pub = rospy.Publisher('/available_robots', AvailableRobotArray, latch=True)
29+
30+
# Create a temporary file.
31+
temp_launch_file = tempfile.NamedTemporaryFile(suffix=".launch", delete=False)
32+
temp_file_name = temp_launch_file.name
33+
34+
# Construct the launch file.
35+
msg = AvailableRobotArray()
36+
configuration = rospy.get_param('~configuration')
37+
construct_launch_file(temp_launch_file, configuration, msg)
38+
39+
temp_launch_file.close()
40+
start_roslaunch_process(None, temp_file_name)
41+
42+
pub.publish(msg)
43+
rospy.spin()
44+
45+
except rospy.ROSInterruptException:
46+
pass
47+
48+
if process is not None:
49+
stop_roslaunch_process(process)
50+
51+
if temp_file_name is not None:
52+
try:
53+
os.remove(temp_file_name)
54+
except OSError:
55+
pass
56+
57+
if __name__ == '__main__':
58+
rospy.init_node('robot_publisher', anonymous=True)
59+
robot_publisher()

0 commit comments

Comments
 (0)