Skip to content

Commit 9630c74

Browse files
nkoenigNate Koenig
and
Nate Koenig
authored
Allow a custom name to be used for the teambase, and handle different capitalization for teambase config (#477)
Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]>
1 parent 89362d0 commit 9630c74

9 files changed

+66
-63
lines changed

subt_ign/launch/cave_circuit.ign

+11-11
Original file line numberDiff line numberDiff line change
@@ -1290,15 +1290,15 @@
12901290
return spawn, exec
12911291
end
12921292
1293-
def spawnTeamBase(_x, _y, _z, _yaw)
1293+
def spawnTeamBase(_name, _x, _y, _z, _yaw)
12941294
spawn = <<-HEREDOC
1295-
<spawn name='TEAMBASE'>
1296-
<name>TEAMBASE</name>
1295+
<spawn name='#{_name}'>
1296+
<name>#{_name}</name>
12971297
<allow_renaming>false</allow_renaming>
12981298
<world>#{$worldName}</world>
12991299
<is_performer>false</is_performer>
13001300
<sdf version='1.6'>
1301-
<model name='TEAMBASE'>
1301+
<model name='#{_name}'>
13021302
<pose>#{_x} #{_y} #{_z} 0 0 #{_yaw}</pose>
13031303
<static>true</static>
13041304
<link name='link'>
@@ -1318,10 +1318,10 @@
13181318
13191319
exec = <<-HEREDOC
13201320
<executable name='teambase_description'>
1321-
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName}</command>
1321+
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName} name:=#{_name}</command>
13221322
</executable>
13231323
<executable name='teambase_ros_ign_bridge'>
1324-
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName}</command>
1324+
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName} name:=#{_name}</command>
13251325
</executable>
13261326
HEREDOC
13271327
@@ -1384,13 +1384,15 @@
13841384
13851385
spawnStringTmp, executables = spawnX4(name, robotConfigN, robot.pos.x, robot.pos.y, robot.pos.z, robot.rot.yaw)
13861386
1387-
elsif name == "TEAMBASE" and config == "TEAMBASE"
1387+
elsif config.upcase == "TEAMBASE"
13881388
robotSpawned += 1
13891389
if !teamBaseSpawned
13901390
teamBaseSpawned = true
1391-
spawnStringTmp, executables = spawnTeamBase(posX, posY, spawnWorldZPos, spawnWorldYaw)
1391+
spawnStringTmp, executables = spawnTeamBase(name, posX, posY, spawnWorldZPos, spawnWorldYaw)
1392+
else
1393+
puts "Error: Only 1 teambase is allows. Skpping[%s]." % [name]
13921394
end
1393-
elsif config != "TEAMBASE"
1395+
else
13941396
# Try a team-submitted vehicle.
13951397
package = config.downcase
13961398
installDir = `rospack find #{package}`.chomp
@@ -1432,8 +1434,6 @@
14321434
spawnStringTmp = spawner(name, modelURI, $worldName, robot.pos.x, robot.pos.y, robot.pos.z, 0, 0, robot.rot.yaw)
14331435
executables = rosExecutables(name, $worldName)
14341436
end
1435-
else
1436-
puts "Error: Invalid Name[%s] or Config[%s]. Skpping." % [name, config]
14371437
end
14381438
14391439
if executables != nil

subt_ign/launch/cloudsim_bridge.ign

+5-5
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@
179179
"</executable>\n"
180180
end
181181
182-
def spawnTeamBase()
182+
def spawnTeamBase(_name)
183183
"<executable name='teambase_description'>\n"\
184-
" <command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName}</command>\n"\
184+
" <command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName} name:=#{_name}</command>\n"\
185185
"</executable>\n"\
186186
"<executable name='teambase_ros_ign_bridge'>\n"\
187-
" <command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName}</command>\n"\
187+
" <command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName} name:=#{_name}</command>\n"\
188188
"</executable>\n"
189189
end
190190
%>
@@ -203,11 +203,11 @@
203203
<% elsif robotConfigs[i][1] == "4" and (robotConfigN == "1" or robotConfigN == "2" or robotConfigN == "3" or robotConfigN == "4" or robotConfigN == "5") %>
204204
<%= spawnX4(robotNames[i], robotConfigs[i][-1]) %>
205205
<%
206-
elsif name == "TEAMBASE" and config == "TEAMBASE"
206+
elsif config.upcase == "TEAMBASE"
207207
if !teamBaseSpawned
208208
teamBaseSpawned = true
209209
%>
210-
<%= spawnTeamBase() %>
210+
<%= spawnTeamBase(robotNames[i]) %>
211211
<% end
212212
else
213213
# Try a team-submitted vehicle.

subt_ign/launch/cloudsim_sim.ign

+11-11
Original file line numberDiff line numberDiff line change
@@ -1324,15 +1324,15 @@
13241324
return spawn, exec
13251325
end
13261326
1327-
def spawnTeamBase(_x, _y, _z, _yaw)
1327+
def spawnTeamBase(_name, _x, _y, _z, _yaw)
13281328
spawn = <<-HEREDOC
1329-
<spawn name='TEAMBASE'>
1330-
<name>TEAMBASE</name>
1329+
<spawn name='#{_name}'>
1330+
<name>#{_name}</name>
13311331
<allow_renaming>false</allow_renaming>
13321332
<world>#{$worldName}</world>
13331333
<is_performer>false</is_performer>
13341334
<sdf version='1.6'>
1335-
<model name='TEAMBASE'>
1335+
<model name='#{_name}'>
13361336
<pose>#{_x} #{_y} #{_z} 0 0 #{_yaw}</pose>
13371337
<static>true</static>
13381338
<link name='link'>
@@ -1352,10 +1352,10 @@
13521352
13531353
exec = <<-HEREDOC
13541354
<executable name='teambase_description'>
1355-
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName}</command>
1355+
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName} name:=#{_name}</command>
13561356
</executable>
13571357
<executable name='teambase_ros_ign_bridge'>
1358-
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName}</command>
1358+
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName} name:=#{_name}</command>
13591359
</executable>
13601360
HEREDOC
13611361
@@ -1418,13 +1418,15 @@
14181418
14191419
spawnStringTmp, executables = spawnX4(name, robotConfigN, robot.pos.x, robot.pos.y, robot.pos.z, robot.rot.yaw)
14201420
1421-
elsif name == "TEAMBASE" and config == "TEAMBASE"
1421+
elsif config.upcase == "TEAMBASE"
14221422
robotSpawned += 1
14231423
if !teamBaseSpawned
14241424
teamBaseSpawned = true
1425-
spawnStringTmp, executables = spawnTeamBase(posX, posY, spawnWorldZPos, spawnWorldYaw)
1425+
spawnStringTmp, executables = spawnTeamBase(name, posX, posY, spawnWorldZPos, spawnWorldYaw)
1426+
else
1427+
puts "Error: Only 1 teambase is allows. Skpping[%s]." % [name]
14261428
end
1427-
elsif config != "TEAMBASE"
1429+
else
14281430
# Try a team-submitted vehicle.
14291431
package = config.downcase
14301432
installDir = `rospack find #{package}`.chomp
@@ -1466,8 +1468,6 @@
14661468
spawnStringTmp = spawner(name, modelURI, $worldName, robot.pos.x, robot.pos.y, robot.pos.z, 0, 0, robot.rot.yaw)
14671469
executables = rosExecutables(name, $worldName)
14681470
end
1469-
else
1470-
puts "Error: Invalid Name[%s] or Config[%s]. Skpping." % [name, config]
14711471
end
14721472
14731473
if executables != nil

subt_ign/launch/competition.ign

+11-11
Original file line numberDiff line numberDiff line change
@@ -1287,15 +1287,15 @@
12871287
return spawn, exec
12881288
end
12891289
1290-
def spawnTeamBase(_x, _y, _z, _yaw)
1290+
def spawnTeamBase(_name, _x, _y, _z, _yaw)
12911291
spawn = <<-HEREDOC
1292-
<spawn name='TEAMBASE'>
1293-
<name>TEAMBASE</name>
1292+
<spawn name='#{_name}'>
1293+
<name>#{_name}</name>
12941294
<allow_renaming>false</allow_renaming>
12951295
<world>#{$worldName}</world>
12961296
<is_performer>false</is_performer>
12971297
<sdf version='1.6'>
1298-
<model name='TEAMBASE'>
1298+
<model name='#{_name}'>
12991299
<pose>#{_x} #{_y} #{_z} 0 0 #{_yaw}</pose>
13001300
<static>true</static>
13011301
<link name='link'>
@@ -1315,10 +1315,10 @@
13151315
13161316
exec = <<-HEREDOC
13171317
<executable name='teambase_description'>
1318-
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName}</command>
1318+
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName} name:=#{_name}</command>
13191319
</executable>
13201320
<executable name='teambase_ros_ign_bridge'>
1321-
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName}</command>
1321+
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName} name:=#{_name}</command>
13221322
</executable>
13231323
HEREDOC
13241324
@@ -1381,13 +1381,15 @@
13811381
13821382
spawnStringTmp, executables = spawnX4(name, robotConfigN, robot.pos.x, robot.pos.y, robot.pos.z, robot.rot.yaw)
13831383
1384-
elsif name == "TEAMBASE" and config == "TEAMBASE"
1384+
elsif config.upcase == "TEAMBASE"
13851385
robotSpawned += 1
13861386
if !teamBaseSpawned
13871387
teamBaseSpawned = true
1388-
spawnStringTmp, executables = spawnTeamBase(posX, posY, spawnWorldZPos, spawnWorldYaw)
1388+
spawnStringTmp, executables = spawnTeamBase(name, posX, posY, spawnWorldZPos, spawnWorldYaw)
1389+
else
1390+
puts "Error: Only 1 teambase is allows. Skpping[%s]." % [name]
13891391
end
1390-
elsif config != "TEAMBASE"
1392+
else
13911393
# Try a team-submitted vehicle.
13921394
package = config.downcase
13931395
installDir = `rospack find #{package}`.chomp
@@ -1429,8 +1431,6 @@
14291431
spawnStringTmp = spawner(name, modelURI, $worldName, robot.pos.x, robot.pos.y, robot.pos.z, 0, 0, robot.rot.yaw)
14301432
executables = rosExecutables(name, $worldName)
14311433
end
1432-
else
1433-
puts "Error: Invalid Name[%s] or Config[%s]. Skpping." % [name, config]
14341434
end
14351435
14361436
if executables != nil

subt_ign/launch/tunnel_circuit_practice.ign

+11-11
Original file line numberDiff line numberDiff line change
@@ -1290,15 +1290,15 @@
12901290
return spawn, exec
12911291
end
12921292
1293-
def spawnTeamBase(_x, _y, _z, _yaw)
1293+
def spawnTeamBase(_name, _x, _y, _z, _yaw)
12941294
spawn = <<-HEREDOC
1295-
<spawn name='TEAMBASE'>
1296-
<name>TEAMBASE</name>
1295+
<spawn name='#{_name}'>
1296+
<name>#{_name}</name>
12971297
<allow_renaming>false</allow_renaming>
12981298
<world>#{$worldName}</world>
12991299
<is_performer>false</is_performer>
13001300
<sdf version='1.6'>
1301-
<model name='TEAMBASE'>
1301+
<model name='#{_name}'>
13021302
<pose>#{_x} #{_y} #{_z} 0 0 #{_yaw}</pose>
13031303
<static>true</static>
13041304
<link name='link'>
@@ -1318,10 +1318,10 @@
13181318
13191319
exec = <<-HEREDOC
13201320
<executable name='teambase_description'>
1321-
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName}</command>
1321+
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName} name:=#{_name}</command>
13221322
</executable>
13231323
<executable name='teambase_ros_ign_bridge'>
1324-
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName}</command>
1324+
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName} name:=#{_name}</command>
13251325
</executable>
13261326
HEREDOC
13271327
@@ -1384,13 +1384,15 @@
13841384
13851385
spawnStringTmp, executables = spawnX4(name, robotConfigN, robot.pos.x, robot.pos.y, robot.pos.z, robot.rot.yaw)
13861386
1387-
elsif name == "TEAMBASE" and config == "TEAMBASE"
1387+
elsif config.upcase == "TEAMBASE"
13881388
robotSpawned += 1
13891389
if !teamBaseSpawned
13901390
teamBaseSpawned = true
1391-
spawnStringTmp, executables = spawnTeamBase(posX, posY, spawnWorldZPos, spawnWorldYaw)
1391+
spawnStringTmp, executables = spawnTeamBase(name, posX, posY, spawnWorldZPos, spawnWorldYaw)
1392+
else
1393+
puts "Error: Only 1 teambase is allows. Skpping[%s]." % [name]
13921394
end
1393-
elsif config != "TEAMBASE"
1395+
else
13941396
# Try a team-submitted vehicle.
13951397
package = config.downcase
13961398
installDir = `rospack find #{package}`.chomp
@@ -1432,8 +1434,6 @@
14321434
spawnStringTmp = spawner(name, modelURI, $worldName, robot.pos.x, robot.pos.y, robot.pos.z, 0, 0, robot.rot.yaw)
14331435
executables = rosExecutables(name, $worldName)
14341436
end
1435-
else
1436-
puts "Error: Invalid Name[%s] or Config[%s]. Skpping." % [name, config]
14371437
end
14381438
14391439
if executables != nil

subt_ign/launch/urban_circuit.ign

+11-11
Original file line numberDiff line numberDiff line change
@@ -1290,15 +1290,15 @@
12901290
return spawn, exec
12911291
end
12921292
1293-
def spawnTeamBase(_x, _y, _z, _yaw)
1293+
def spawnTeamBase(_name, _x, _y, _z, _yaw)
12941294
spawn = <<-HEREDOC
1295-
<spawn name='TEAMBASE'>
1296-
<name>TEAMBASE</name>
1295+
<spawn name='#{_name}'>
1296+
<name>#{_name}</name>
12971297
<allow_renaming>false</allow_renaming>
12981298
<world>#{$worldName}</world>
12991299
<is_performer>false</is_performer>
13001300
<sdf version='1.6'>
1301-
<model name='TEAMBASE'>
1301+
<model name='#{_name}'>
13021302
<pose>#{_x} #{_y} #{_z} 0 0 #{_yaw}</pose>
13031303
<static>true</static>
13041304
<link name='link'>
@@ -1318,10 +1318,10 @@
13181318
13191319
exec = <<-HEREDOC
13201320
<executable name='teambase_description'>
1321-
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName}</command>
1321+
<command>roslaunch --wait subt_ros teambase_description.launch world_name:=#{$worldName} name:=#{_name}</command>
13221322
</executable>
13231323
<executable name='teambase_ros_ign_bridge'>
1324-
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName}</command>
1324+
<command>roslaunch --wait subt_ros teambase_topics.launch world_name:=#{$worldName} name:=#{_name}</command>
13251325
</executable>
13261326
HEREDOC
13271327
@@ -1384,13 +1384,15 @@
13841384
13851385
spawnStringTmp, executables = spawnX4(name, robotConfigN, robot.pos.x, robot.pos.y, robot.pos.z, robot.rot.yaw)
13861386
1387-
elsif name == "TEAMBASE" and config == "TEAMBASE"
1387+
elsif config.upcase == "TEAMBASE"
13881388
robotSpawned += 1
13891389
if !teamBaseSpawned
13901390
teamBaseSpawned = true
1391-
spawnStringTmp, executables = spawnTeamBase(posX, posY, spawnWorldZPos, spawnWorldYaw)
1391+
spawnStringTmp, executables = spawnTeamBase(name, posX, posY, spawnWorldZPos, spawnWorldYaw)
1392+
else
1393+
puts "Error: Only 1 teambase is allows. Skpping[%s]." % [name]
13921394
end
1393-
elsif config != "TEAMBASE"
1395+
else
13941396
# Try a team-submitted vehicle.
13951397
package = config.downcase
13961398
installDir = `rospack find #{package}`.chomp
@@ -1432,8 +1434,6 @@
14321434
spawnStringTmp = spawner(name, modelURI, $worldName, robot.pos.x, robot.pos.y, robot.pos.z, 0, 0, robot.rot.yaw)
14331435
executables = rosExecutables(name, $worldName)
14341436
end
1435-
else
1436-
puts "Error: Invalid Name[%s] or Config[%s]. Skpping." % [name, config]
14371437
end
14381438
14391439
if executables != nil
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0"?>
22
<launch>
3-
<param name="TeamBase/robot_description" command="$(find xacro)/xacro '$(find teambase_description)/urdf/teambase.xacro'"/>
3+
<arg name="name" doc="Name of TeamBase"/>
4+
<param name="$(arg name)/robot_description" command="$(find xacro)/xacro '$(find teambase_description)/urdf/teambase.xacro' name:=$(arg name)"/>
45
</launch>
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0"?>
22
<launch>
3-
<node pkg="tf2_ros" type="static_transform_publisher" name="tf_teambase_static" args="0 0 0.05 0 0 0 TeamBase TeamBase/link"/>
3+
<arg name="name" default="TEAMBASE"/>
4+
<node pkg="tf2_ros" type="static_transform_publisher" name="tf_teambase_static" args="0 0 0.05 0 0 0 $(arg name) $(arg name)/link"/>
45
</launch>

teambase_description/urdf/teambase.xacro

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version='1.0' encoding='utf-8'?>
22
<robot name="TeamBase" xmlns:xacro="http://ros.org/wiki/xacro">
3-
<xacro:property name="robot_namespace" value="TeamBase"/>
3+
<xacro:arg name="name" default="TeamBase"/>
4+
<xacro:property name="robot_namespace" value="$(arg name)"/>
45

56
<link name='${robot_namespace}/link'>
67
<visual name='visual'>

0 commit comments

Comments
 (0)