@@ -138,19 +138,28 @@ def main():
138
138
settings ["parameter_blackboard" ]["ros__parameters" ] = ros_parameters
139
139
140
140
options = provide_config (OPTIONS_PATH )
141
+
142
+ # As a special case, we try to get the robot_id from the hostname as a default value
143
+ # Because the robots often play with theirs fixed numbers
144
+ try :
145
+ robot_id = int (os .uname ()[1 ][- 1 ]) # We assume the the hostname is in the form 'nucX'
146
+ ros_parameters ["bot_id" ] = robot_id
147
+ except ValueError :
148
+ pass
149
+
141
150
while not is_config_correct :
142
- for key in options .keys ():
143
- entry_value_type = locate (options [ key ] ["type" ])
144
- entry_options = options [ key ] .get ("options" , None )
145
- entry_explanation = options [ key ] ["explanation" ]
146
-
147
- if key in ros_parameters .keys ():
148
- ros_parameters [key ] = ask_for_config_option (
149
- key , entry_value_type , ros_parameters [key ], entry_options , entry_explanation
151
+ for param_name , param_template in options .items ():
152
+ entry_value_type = locate (param_template ["type" ])
153
+ entry_options = param_template .get ("options" , None )
154
+ entry_explanation = param_template ["explanation" ]
155
+
156
+ if param_name in ros_parameters .keys ():
157
+ ros_parameters [param_name ] = ask_for_config_option (
158
+ param_name , entry_value_type , ros_parameters [param_name ], entry_options , entry_explanation
150
159
)
151
160
else :
152
- value = ask_for_config_option (key , entry_value_type , None , entry_options , entry_explanation )
153
- ros_parameters .update ({key : value })
161
+ value = ask_for_config_option (param_name , entry_value_type , None , entry_options , entry_explanation )
162
+ ros_parameters .update ({param_name : value })
154
163
155
164
settings_string = yaml .safe_dump (settings )
156
165
print ("=============== Current Settings ===============" )
0 commit comments