Skip to content

Commit cb173eb

Browse files
Add manipulator mount for add base (#770)
* Add manipulator mount for add base * Format
1 parent cb25aae commit cb173eb

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

robosuite/models/robots/robot_model.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from robosuite.models.base import MujocoXMLModel
88
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
1010
from robosuite.utils.transform_utils import euler2mat, mat2quat
1111

1212
REGISTERED_ROBOTS = {}
@@ -202,14 +202,21 @@ def add_mobile_base(self, mobile_base: MobileBaseModel):
202202
mount_support = find_elements(
203203
root=self.worldbody, tags="body", attribs={"name": mobile_base.correct_naming("support")}, return_first=True
204204
)
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
207211
for child in all_root_children:
208212
# Skip inertial elements to avoid duplicates with mobile base's own inertial
209213
# Skip freejoints since they can only be used at top level
210214
if child.tag not in ["inertial", "freejoint"]:
211-
mount_support.append(deepcopy(child))
215+
manipulator_mount.append(deepcopy(child))
212216
root.remove(child)
217+
218+
# Attach the manipulator_mount body to the mobile base support
219+
mount_support.append(manipulator_mount)
213220
self.merge_assets(mobile_base)
214221
for one_actuator in mobile_base.actuator:
215222
self.actuator.append(one_actuator)

0 commit comments

Comments
 (0)