Repository navigation
Conversation
545a2a1 to
9a9f549
Compare
| default = sphere | ||
|
|
||
|
|
||
| from crazyflow.sim.sim import Sim # noqa: E402 (sim.py imports CollisionType from this package) |
There was a problem hiding this comment.
Should this rather be in crazyflow/sim/collision.py then?
| self.viewer = None | ||
| self.spec.numeric("max_geom_pairs").data = [self.max_geom_pairs] | ||
| self.mj_model, self.mj_data, self.mjx_model, self.mjx_data = self.build_mjx_model(self.spec) | ||
| core = self.data.core.replace(mjx_synced=jnp.zeros_like(self.data.core.mjx_synced)) |
There was a problem hiding this comment.
| core = self.data.core.replace(mjx_synced=jnp.zeros_like(self.data.core.mjx_synced)) | |
| core = self.data.core.replace(mjx_synced=False) |
This should work
| collision_type: ``sphere`` (default) is a bounding sphere, ``box`` an oriented bounding box | ||
| and ``hull`` the convex hull of the drone mesh, limited to 32 vertices. The selected | ||
| geometry is in geom group 3, which the viewer hides by default (toggle with key 3). |
There was a problem hiding this comment.
| collision_type: ``sphere`` (default) is a bounding sphere, ``box`` an oriented bounding box | |
| and ``hull`` the convex hull of the drone mesh, limited to 32 vertices. The selected | |
| geometry is in geom group 3, which the viewer hides by default (toggle with key 3). | |
| collision_type: ``sphere`` (default) is a bounding sphere, ``box`` an oriented bounding box | |
| and ``hull`` the convex hull of the drone mesh, limited to 32 vertices. |
| """Fly the outer drones back and forth through a hovering drone and check for contacts. | ||
|
|
||
| The crossing is repeated with every collision type. Each type reports contacts for a different | ||
| fraction of the crossing, from the loose sphere to the tight convex hull. A disc above each | ||
| drone turns red while the drone is in contact. Press 3 in the viewer to show the collision | ||
| geometry. | ||
| """ |
There was a problem hiding this comment.
| """Fly the outer drones back and forth through a hovering drone and check for contacts. | |
| The crossing is repeated with every collision type. Each type reports contacts for a different | |
| fraction of the crossing, from the loose sphere to the tight convex hull. A disc above each | |
| drone turns red while the drone is in contact. Press 3 in the viewer to show the collision | |
| geometry. | |
| """ | |
| """Fly the outer drones back and forth through a hovering drone and check for contacts. | |
| The crossing is repeated with every collision type. Each type reports contacts for a different | |
| fraction of the crossing. A disc above each drone turns red while the drone is in contact. | |
| Press 3 in the viewer to show the collision geometry. | |
| """ |
| dynamics=Dynamics.so_rpy, | ||
| device="cpu", |
There was a problem hiding this comment.
| dynamics=Dynamics.so_rpy, | |
| device="cpu", |
We initially added different options per example to show how these things can be changed on the side. Now that we have a dedicated example for almost all of them, we should remove them to focus on the stuff the example is actually about. We can probably clean these up as we edit examples (like this one here)
|
This PR is currently blocked by the raycasting pipeline. Our depth renderer wraps mjx.ray, which picks geoms only by geom group and ignores contype/conaffinity. It does skip invisible geoms (alpha 0), but only after computing all intersections, because geom_rgba is a traced array in MJX. The new col_hull geoms sit in group 3 with the other collision geoms and reference the full drone mesh (85k faces for cf21B_fused). So even while disabled, every ray is tested against every face: 200×200 rays × 85k faces ≈ 123 GB. Upstream MJX main behaves the same. Possible fixes:
Neither option is great. The second is the better one though. I'll come back to this later. |
So far, we only had sphere and box collision types. We can also use a more approximate check based on the mesh. This is already built into MuJoCo, which simply takes a convex hull, limited by the maxhullvert. I set this to 32 to not slow down the sim too much. On the GPU, this is essentially free. On the CPU,
contacts()is significantly slower for larger swarms. I've added a warning for that case.Here is some short benchmark