Open DevinQiao opened 1 week ago
For MJCF I am not completely sure if it will work 100% correctly. I am currently importing the robocasa dataset and found a few bugs in the MJCF loader as a result
For URDF it should work fine. How did you retrieve the bboxes in code?
I use the following code to create each articulation
in the scene
, then use get_first_collision_mesh()
to obtain its mesh
. Using mesh.bounds
, I get min_bbox
and max_bbox
, and then subtract min_bbox
from max_bbox
to obtain bbox
. However, I think the values of max_bbox and min_bbox are not quite correct. I think their values should be close to position + bbox/2
and position - bbox/2
, respectively.
for art in arts:
urdf_path = osp.join('data/dataset', str(art['path']), 'mobility.urdf')
rot = np.array(art["rotation"])
angles_radians = np.radians(rot)
quat = euler2quat(angles_radians[0], angles_radians[1], angles_radians[2] - np.pi / 2)
pos = art["position"]
if rot[2] == 180:
offset = np.array([-art["offset"][1], -art["offset"][0], art["offset"][2]])
elif rot[2] == 270:
offset = np.array([-art["offset"][0], -art["offset"][1], art["offset"][2]])
elif rot[2] == 0:
offset = np.array([art["offset"][1], art["offset"][0], art["offset"][2]])
else:
offset = np.array(art["offset"])
pos -= offset
urdf_loader = self.scene.create_urdf_loader()
urdf_loader.name = art["id"]
urdf_loader.scale = art["scale"]
articulation = urdf_loader.load(urdf_path)
articulation.set_pose(sapien.Pose(pos, quat))
mesh = articulation.get_first_collision_mesh()
min_bbox, max_bbox = mesh.bounds
bbox = max_bbox - min_bbox
center = (max_bbox + min_bbox) / 2
print(f"{urdf_loader.name=}")
print(f"{pos=}")
print(f"{max_bbox=}")
print(f"{min_bbox=}")
print(f"{bbox=}")
print(f"{center=}")
Perhaps you can load /data/dataset/47391/mobility.urdf
in partnet_mobility
. The related info I used is as follows.
loader = self.scene.create_urdf_loader()
loader.scale = 0.743
articulation = loader.load(fp)
articulation.set_pose(sapien.Pose([5.121, 5.41 , 2.47], [1, 0, 0, 0]))
mesh = articulation.get_first_collision_mesh()
min_bbox, max_bbox = mesh.bounds
bbox = max_bbox - min_bbox
center = (max_bbox + min_bbox) / 2
print(f"{max_bbox=}")
print(f"{min_bbox=}")
print(f"{bbox=}")
print(f"{center=}")
And it outputs:
max_bbox=array([10.42297376, 11.41342718, 5.3782044 ])
min_bbox=array([10.00989236, 10.20651197, 4.51612149])
bbox=array([0.4130814 , 1.20691521, 0.86208291])
center=array([10.21643306, 10.80996957, 4.94716294])
The max_bbox
and min_bbox
and larger than the pos
.
Is the code you shared in the def _load_scene
function? And you are testing in the GPU sim?
If it is the GPU sim, the bounding box info generated in the load_scene function will likely not be centered at the right place since we initialize the GPU poses based on the articulation initial pose.
I want to load some URDF or MJCF models in ManiSkill, and the positions of these models are calculated. In my calculations, I assumed the position of the model is the center of its bounding box (bbox), but when loading the model, it doesn't appear in the desired position. I printed some information using the code below.
For the scene "ReplicaCAD", output is below:
So, if I want the URDF model to appear in the desired location, how should I set it up? How can I calculate their offset?