google-deepmind / google-deepmind/dm_control

Attachment frames's inertial property

Đang mở
#477 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
4.7k
Fork
764
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hello,

I am trying to attach a body to another one, similar to your example [here](https://github.com/google-deepmind/dm_control/blob/ed424509c0a0e8ddf7a43824924de483026ad9cc/dm_control/mjcf/README.md#attachment-frames) of `child` and `parent`.

However, my `child` body does have inertial-properties. Attaching the following `child` body
```
class Camera:
#===================#
# C O N S T A N T #
#===================#
_com_pos = (0, 0, 0.015)
_dclass = 'wam\\viz'
_mass = 0.095
_mesh_name = 'intel_realsense_l515'
_name = '\\rgb'
_quat = (0, 0, 1, 0)
#===============================#
# I N I T I A L I Z A T I O N #
#===============================#
def __init__(self, name, fovy):
# Make a MujoCo Root
self.mjcf_model = mjcf.RootElement()
# Add a body element: No need to add position info, as that will be added based on which `site` this body is going to be attached (https://github.com/google-deepmind/dm_control/blob/main/dm_control/mjcf/README.md#attachment-frames)
self.camera_body = self.mjcf_model.worldbody.add('body',
name = name)
# Add Inertial properties
self.camera_body.add('inertial',
pos = self._com_pos,
mass = self._mass)
# Add the Geometry (https://github.com/google-deepmind/dm_control/blob/ed424509c0a0e8ddf7a43824924de483026ad9cc/dm_control/locomotion/soccer/humanoid.py#L50)
self.camera_body.add('geom',
mesh = self._mesh_name,
dclass = self._dclass)
# Add camera sensor
self.camera_body.add('camera',
name = name+self._name,
pos = (0, 0, 0),
quat = self._quat,
fovy = fovy)
```
as such in the `parent` body
```
# Add camera locations
# An empty array to hold camera-sites
camera_site = []
for x in range(len(self._camera_pos)):
camera_site.append(self.summit_body.add('site',
pos = self._camera_pos[x],
quat = self._camera_quat[x],
dclass = self._site_name))
# Create camera
# Initialize empty list of camera
cameras = []
for x in range(len(self._camera_pos)):
cameras.append(Camera(name = self._name_summit+'_'+prefix+self._camera_name[x],
fovy = self._camera_fovy[x]))
# Attach the cameras
for x in range(len(self._camera_pos)):
camera_site[x].attach(cameras[x].mjcf_model)
```
causes the generated file to introduce an unnecessary body called `unnamed_model`, which is derived from the name of the `worldbody` (which, in this case, was initialized without a name).
```









```
What I am aiming for is a representation similar to your example [here](https://github.com/google-deepmind/dm_control/blob/ed424509c0a0e8ddf7a43824924de483026ad9cc/dm_control/mjcf/README.md#attachment-frames), such that I should have:
```







```
but I am not allowed to do this because `AttributeError: is not a valid child of `.

Question;
How can I get such a clean representation while introducing `inertial` properties for attached-bodies?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.