Skip to content

Commit

Permalink
Added spawn for ns and no-ns
Browse files Browse the repository at this point in the history
  • Loading branch information
ana-GT committed Jun 6, 2024
1 parent 0515af6 commit 7cbb0fa
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions simulation/launch/spawn_astrobee.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,35 @@ def read_pose(context, *args, **kwargs):
DeclareLaunchArgument('Y', default_value=pose[5]),
]

def generate_launch_description():
return LaunchDescription([
DeclareLaunchArgument("ns", default_value=""), # Robot namespace
DeclareLaunchArgument("pose"), # Robot pose
OpaqueFunction(function=read_pose),
DeclareLaunchArgument("robot_description"), # Robot description
def launch_setup(context, *args, **kwargs):
ns = str( (LaunchConfiguration('ns').perform(context)) )

topic = "/robot_description"
entity = "bsharp"

Node(
if ns:
topic = "/" + ns + topic
entity = ns

spawn_entity = Node(
package='gazebo_ros',
executable='spawn_entity.py',
name='spawn_astrobee',
output='screen',
arguments=["-entity", "bsharp", "-timeout", "30.0",
arguments=["-topic", topic, "-entity", entity, "-timeout", "30.0",
"-x", LaunchConfiguration("x"), "-y", LaunchConfiguration("y"), "-z", LaunchConfiguration("z"),
"-R", LaunchConfiguration("R"), "-P", LaunchConfiguration("P"), "-Y", LaunchConfiguration("Y"),
"-stdin", LaunchConfiguration("robot_description")],
"-R", LaunchConfiguration("R"), "-P", LaunchConfiguration("P"), "-Y", LaunchConfiguration("Y")],
condition=LaunchConfigurationEquals("ns", "")
),
Node(
package='gazebo_ros',
executable='spawn_entity.py',
name='spawn_astrobee',
output='screen',
arguments=["-entity", LaunchConfiguration("ns"), "-timeout", "30.0",
"-x", LaunchConfiguration("x"), "-y", LaunchConfiguration("y"), "-z", LaunchConfiguration("z"),
"-R", LaunchConfiguration("R"), "-P", LaunchConfiguration("P"), "-Y", LaunchConfiguration("Y"),
"-stdin", LaunchConfiguration("robot_description")],
condition=LaunchConfigurationNotEquals("ns", "")
)

return [spawn_entity]

def generate_launch_description():

return LaunchDescription([
DeclareLaunchArgument("ns", default_value=""), # Robot namespace
DeclareLaunchArgument("pose"), # Robot pose
OpaqueFunction(function=read_pose),
DeclareLaunchArgument("robot_description"), # Robot description
OpaqueFunction(function=launch_setup)
])

0 comments on commit 7cbb0fa

Please sign in to comment.