|
3 | 3 | # |
4 | 4 | # SPDX-License-Identifier: BSD-3-Clause |
5 | 5 |
|
6 | | -from dataclasses import MISSING |
| 6 | +import os |
7 | 7 |
|
8 | 8 | import torch |
9 | 9 |
|
10 | 10 | from isaacsim.core.prims import SingleArticulation |
11 | 11 |
|
12 | 12 | # enable motion generation extensions |
13 | | -from isaacsim.core.utils.extensions import enable_extension |
| 13 | +from isaacsim.core.utils.extensions import enable_extension, get_extension_path_from_name |
14 | 14 |
|
15 | 15 | enable_extension("isaacsim.robot_motion.lula") |
16 | 16 | enable_extension("isaacsim.robot_motion.motion_generation") |
|
19 | 19 | from isaacsim.robot_motion.motion_generation.lula.motion_policies import RmpFlow, RmpFlowSmoothed |
20 | 20 |
|
21 | 21 | import isaaclab.sim as sim_utils |
22 | | -from isaaclab.utils import configclass |
23 | 22 | from isaaclab.utils.assets import retrieve_file_path |
24 | 23 |
|
| 24 | +from .rmp_flow_cfg import RmpFlowControllerCfg # noqa: F401 |
25 | 25 |
|
26 | | -@configclass |
27 | | -class RmpFlowControllerCfg: |
28 | | - """Configuration for RMP-Flow controller (provided through LULA library).""" |
| 26 | +_RMPFLOW_EXT_PREFIX = "rmpflow_ext:" |
| 27 | +_RMPFLOW_EXT_NAME = "isaacsim.robot_motion.motion_generation" |
29 | 28 |
|
30 | | - name: str = "rmp_flow" |
31 | | - """Name of the controller. Supported: "rmp_flow", "rmp_flow_smoothed". Defaults to "rmp_flow".""" |
32 | | - config_file: str = MISSING |
33 | | - """Path to the configuration file for the controller.""" |
34 | | - urdf_file: str = MISSING |
35 | | - """Path to the URDF model of the robot.""" |
36 | | - collision_file: str = MISSING |
37 | | - """Path to collision model description of the robot.""" |
38 | | - frame_name: str = MISSING |
39 | | - """Name of the robot frame for task space (must be present in the URDF).""" |
40 | | - evaluations_per_frame: float = MISSING |
41 | | - """Number of substeps during Euler integration inside LULA world model.""" |
42 | | - ignore_robot_state_updates: bool = False |
43 | | - """If true, then state of the world model inside controller is rolled out. Defaults to False.""" |
| 29 | + |
| 30 | +def _resolve_rmpflow_path(path: str) -> str: |
| 31 | + """Resolve a sentinel ``rmpflow_ext:`` path to an absolute filesystem path. |
| 32 | +
|
| 33 | + Paths stored in :class:`~isaaclab.controllers.rmp_flow_cfg.RmpFlowControllerCfg` |
| 34 | + that begin with ``"rmpflow_ext:"`` are relative to the |
| 35 | + ``isaacsim.robot_motion.motion_generation`` extension directory. This avoids |
| 36 | + importing ``isaacsim`` in the cfg file (which is loaded without Kit). |
| 37 | + """ |
| 38 | + if path.startswith(_RMPFLOW_EXT_PREFIX): |
| 39 | + rel = path[len(_RMPFLOW_EXT_PREFIX) :] |
| 40 | + ext_dir = get_extension_path_from_name(_RMPFLOW_EXT_NAME) |
| 41 | + return os.path.join(ext_dir, rel) |
| 42 | + return path |
44 | 43 |
|
45 | 44 |
|
46 | 45 | class RmpFlowController: |
@@ -98,9 +97,11 @@ def initialize(self, prim_paths_expr: str): |
98 | 97 | robot.initialize() |
99 | 98 | # download files if they are not local |
100 | 99 |
|
101 | | - local_urdf_file = retrieve_file_path(self.cfg.urdf_file, force_download=True) |
102 | | - local_collision_file = retrieve_file_path(self.cfg.collision_file, force_download=True) |
103 | | - local_config_file = retrieve_file_path(self.cfg.config_file, force_download=True) |
| 100 | + local_urdf_file = retrieve_file_path(_resolve_rmpflow_path(self.cfg.urdf_file), force_download=True) |
| 101 | + local_collision_file = retrieve_file_path( |
| 102 | + _resolve_rmpflow_path(self.cfg.collision_file), force_download=True |
| 103 | + ) |
| 104 | + local_config_file = retrieve_file_path(_resolve_rmpflow_path(self.cfg.config_file), force_download=True) |
104 | 105 |
|
105 | 106 | # add controller |
106 | 107 | rmpflow = controller_cls( |
|
0 commit comments