refactor and extend runtime configuration handling
- **Scene configuration:** - Replaced `bishop` object with `hole` and added a new `peg` object. - Enhanced object properties with new attributes like `randomize`, `relative_to`, `static`, and `texture`. - Updated `robot` joint positions in the default scene configuration. - **Launch file updates:** - Added handling for MoveIt SRDF file processing, including semantic descriptions. - Refactored unused parameters (`gripper_name`, `hardware`) and streamlined arguments. - Extended `robot_type` choices in the `generate_launch_description` method. - **Runtime initialization:** - Introduced `object_factory` to handle dynamic object instantiation based on type (`box`, `cylinder`, `mesh`, or `model`). - Enhanced `scene_config_loader` to process and instantiate objects using the factory function.
This commit is contained in:
parent
b71a2bdf55
commit
fbddca1b8b
3 changed files with 91 additions and 27 deletions
|
@ -4,6 +4,24 @@ import yaml
|
|||
from dacite import from_dict
|
||||
from env_manager.models.configs import SceneData
|
||||
|
||||
from typing import Dict, Any
|
||||
from env_manager.models.configs import (
|
||||
BoxObjectData, CylinderObjectData, MeshData, ModelData, ObjectData
|
||||
)
|
||||
|
||||
def object_factory(obj_data: Dict[str, Any]) -> ObjectData:
|
||||
obj_type = obj_data.get('type', '')
|
||||
|
||||
if obj_type == 'box':
|
||||
return BoxObjectData(**obj_data)
|
||||
elif obj_type == 'cylinder':
|
||||
return CylinderObjectData(**obj_data)
|
||||
elif obj_type == 'mesh':
|
||||
return MeshData(**obj_data)
|
||||
elif obj_type == 'model':
|
||||
return ModelData(**obj_data)
|
||||
else:
|
||||
return ObjectData(**obj_data)
|
||||
|
||||
def scene_config_loader(file: str | Path) -> SceneData:
|
||||
def tuple_constructor(loader, node):
|
||||
|
@ -15,4 +33,8 @@ def scene_config_loader(file: str | Path) -> SceneData:
|
|||
|
||||
scene_data = from_dict(data_class=SceneData, data=scene_cfg)
|
||||
|
||||
scene_data.objects = [object_factory(obj) for obj in scene_cfg.get('objects', [])]
|
||||
|
||||
print(scene_data)
|
||||
|
||||
return scene_data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue