|
6 | 6 |
|
7 | 7 | from robosuite.models.base import MujocoXMLModel |
8 | 8 | from robosuite.models.bases import LegBaseModel, MobileBaseModel, MountModel, NullBaseModel, RobotBaseModel |
9 | | -from robosuite.utils.mjcf_utils import ROBOT_COLLISION_COLOR, array_to_string, find_elements, find_parent |
| 9 | +from robosuite.utils.mjcf_utils import ROBOT_COLLISION_COLOR, array_to_string, find_elements, find_parent, new_element |
10 | 10 | from robosuite.utils.transform_utils import euler2mat, mat2quat |
11 | 11 |
|
12 | 12 | REGISTERED_ROBOTS = {} |
@@ -202,14 +202,21 @@ def add_mobile_base(self, mobile_base: MobileBaseModel): |
202 | 202 | mount_support = find_elements( |
203 | 203 | root=self.worldbody, tags="body", attribs={"name": mobile_base.correct_naming("support")}, return_first=True |
204 | 204 | ) |
205 | | - # Move content from robot0_base to the mobile base support (arms, geoms), but skip inertial |
206 | | - # elements and freejoints to avoid conflicts and MuJoCo constraints |
| 205 | + |
| 206 | + # Create an intermediate body to act as what robot0_base previously was |
| 207 | + manipulator_mount = new_element("body", "manipulator_mount") |
| 208 | + |
| 209 | + # Move content from robot0_base to the intermediate manipulator_mount body (arms, geoms), |
| 210 | + # but skip inertial elements and freejoints to avoid conflicts and MuJoCo constraints |
207 | 211 | for child in all_root_children: |
208 | 212 | # Skip inertial elements to avoid duplicates with mobile base's own inertial |
209 | 213 | # Skip freejoints since they can only be used at top level |
210 | 214 | if child.tag not in ["inertial", "freejoint"]: |
211 | | - mount_support.append(deepcopy(child)) |
| 215 | + manipulator_mount.append(deepcopy(child)) |
212 | 216 | root.remove(child) |
| 217 | + |
| 218 | + # Attach the manipulator_mount body to the mobile base support |
| 219 | + mount_support.append(manipulator_mount) |
213 | 220 | self.merge_assets(mobile_base) |
214 | 221 | for one_actuator in mobile_base.actuator: |
215 | 222 | self.actuator.append(one_actuator) |
|
0 commit comments