@@ -301,7 +301,7 @@ def _resolve_common_term_cfg(self, term_name: str, term_cfg: ManagerTermBaseCfg,
301301 Usually, called by the :meth:`_prepare_terms` method to resolve common attributes of the term
302302 configuration. These include:
303303
304- * Resolving the term function and checking if it is callable .
304+ * Resolving callable references throughout the term configuration and checking the term function .
305305 * Checking if the term function's arguments are matched by the parameters.
306306 * Resolving special attributes of the term configuration like ``asset_cfg``, ``sensor_cfg``, etc.
307307 * Initializing the term if it is a class.
@@ -334,8 +334,8 @@ def _resolve_common_term_cfg(self, term_name: str, term_cfg: ManagerTermBaseCfg,
334334 )
335335
336336 # get the corresponding function or functional class
337- if isinstance ( term_cfg .func , str ):
338- term_cfg . func = string_to_callable ( term_cfg . func )
337+ term_cfg .func = self . _resolve_param_value ( term_name , "func" , term_cfg . func )
338+
339339 # check if function is callable
340340 if not callable (term_cfg .func ):
341341 raise AttributeError (f"The term '{ term_name } ' is not callable. Received: { term_cfg .func } " )
@@ -381,7 +381,7 @@ def _process_term_cfg_at_play(self, term_name: str, term_cfg: ManagerTermBaseCfg
381381 This function is called when the simulation starts playing. It is used to process the term
382382 configuration at runtime. This includes:
383383
384- * Resolving the scene entity configuration for the term.
384+ * Resolving callable references and scene entity configurations throughout the term configuration .
385385 * Initializing the term if it is a class.
386386
387387 Since the above steps rely on PhysX to parse over the simulation scene, they are deferred
@@ -391,17 +391,17 @@ def _process_term_cfg_at_play(self, term_name: str, term_cfg: ManagerTermBaseCfg
391391 term_name: The name of the term.
392392 term_cfg: The term configuration.
393393 """
394- for key , value in term_cfg .params .items ():
395- self ._resolve_param_value (term_name , key , value )
394+ for key , value in term_cfg .__dict__ .items ():
395+ setattr ( term_cfg , key , self ._resolve_param_value (term_name , key , value ) )
396396
397- # resolve string func references then initialize class-based terms
398- if isinstance (term_cfg .func , str ):
399- term_cfg .func = string_to_callable (term_cfg .func )
397+ # initialize class-based terms
400398 if inspect .isclass (term_cfg .func ):
401399 term_cfg .func = term_cfg .func (cfg = term_cfg , env = self ._env )
402400
403- def _resolve_param_value (self , term_name : str , key : str | int , value : Any ):
404- """Recursively resolve a single param value (SceneEntityCfg, nested term cfgs, dicts, lists)."""
401+ def _resolve_param_value (self , term_name : str , key : str | int , value : Any ) -> Any :
402+ """Recursively resolve a value in a manager term configuration."""
403+ if key == "func" and isinstance (value , str ):
404+ return string_to_callable (value )
405405 if isinstance (value , SceneEntityCfg ):
406406 try :
407407 value .resolve (self ._env .scene )
@@ -411,7 +411,11 @@ def _resolve_param_value(self, term_name: str, key: str | int, value: Any):
411411 self ._process_term_cfg_at_play (f"{ term_name } .{ key } " , value )
412412 elif isinstance (value , dict ):
413413 for sub_key , sub_value in value .items ():
414- self ._resolve_param_value (f"{ term_name } .{ key } " , sub_key , sub_value )
414+ value [ sub_key ] = self ._resolve_param_value (f"{ term_name } .{ key } " , sub_key , sub_value )
415415 elif isinstance (value , (list , tuple )):
416416 for i , item in enumerate (value ):
417417 self ._resolve_param_value (f"{ term_name } .{ key } " , i , item )
418+ elif not isinstance (value , type ) and hasattr (value , "__dataclass_fields__" ) and hasattr (value , "__dict__" ):
419+ for sub_key , sub_value in value .__dict__ .items ():
420+ setattr (value , sub_key , self ._resolve_param_value (f"{ term_name } .{ key } " , sub_key , sub_value ))
421+ return value
0 commit comments