11#!/usr/bin/env python3
2- # Copyright 2023 PAL Robotics S.L.
2+ # Copyright 2023 Stogl Robotics Consulting UG (haftungsbeschränkt)
33#
44# Licensed under the Apache License, Version 2.0 (the "License");
55# you may not use this file except in compliance with the License.
@@ -157,7 +157,6 @@ def main(args=None):
157157 "hardware_component_name" ,
158158 help = "The name of the hardware component which should be activated." ,
159159 )
160-
161160 parser .add_argument (
162161 "-c" ,
163162 "--controller-manager" ,
@@ -173,13 +172,13 @@ def main(args=None):
173172 type = int ,
174173 )
175174
175+ # add arguments which are mutually exclusive
176176 activate_or_confiigure_grp .add_argument (
177177 "--activate" ,
178178 help = "Activates the given components. Note: Components are by default configured before activated. " ,
179179 action = "store_true" ,
180180 required = False ,
181181 )
182-
183182 activate_or_confiigure_grp .add_argument (
184183 "--configure" ,
185184 help = "Configures the given components." ,
@@ -195,15 +194,14 @@ def main(args=None):
195194 activate = args .activate
196195 configure = args .configure
197196
198- print (type (hardware_component ))
199-
200197 node = Node ("hardware_spawner" )
201198 if not controller_manager_name .startswith ("/" ):
202199 spawner_namespace = node .get_namespace ()
203200 if spawner_namespace != "/" :
204201 controller_manager_name = f"{ spawner_namespace } /{ controller_manager_name } "
205202 else :
206203 controller_manager_name = f"/{ controller_manager_name } "
204+
207205 try :
208206 if not wait_for_controller_manager (
209207 node , controller_manager_name , controller_manager_timeout
@@ -216,10 +214,11 @@ def main(args=None):
216214 elif configure :
217215 configure_components (node , controller_manager_name , hardware_component )
218216 else :
219- node .get_logger ().warn ("Something went wrong." )
217+ node .get_logger ().error (
218+ 'You need to either specify if the hardware component should be activated with the "--activate" flag or configured with the "--configure" flag'
219+ )
220220 parser .print_help ()
221221 return 0
222-
223222 finally :
224223 rclpy .shutdown ()
225224
0 commit comments