Skip to content

Commit

Permalink
Pad AABB to detect axis aligned collision (#1889)
Browse files Browse the repository at this point in the history
* Pad AABB

* Bump up from ground.
  • Loading branch information
Gamenot authored Mar 1, 2023
1 parent 4ac842d commit a331b9e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Copy and pasting the git commit messages is __NOT__ enough.
- Missing neighborhood vehicle ids are now added to the `highway-v1` formatted observations.
- Stopped agent providers from removing social agents when they have no actor.
- Using `trip` in sstudio traffic generation no longer causes a durouter error.
- Chassis collision AABB first pass now has an additional `0.05m` tolerance to identify axis aligned collisions that would previously be missed.
- Agent to mission padding warning now occurs when there are less missions than agents rather than when there are the same number of agents as missions.
### Removed
### Security

Expand Down
11 changes: 8 additions & 3 deletions smarts/core/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,27 @@

def _query_bullet_contact_points(bullet_client, bullet_id, link_index):
contact_objects = set()
# Give 0.05 meter leeway
LEEWAY = 0.05

# `getContactPoints` does not pick up collisions well so we cast a fast box check on the physics
min_, max_ = bullet_client.getAABB(bullet_id, link_index)
# note that getAABB returns a box around the link_index link only,
# which means it's offset from the ground (min_ has a positive z)
# if link_index=0 (the chassis link) is used.
overlapping_objects = bullet_client.getOverlappingObjects(min_, max_)
overlapping_objects = bullet_client.getOverlappingObjects(
tuple(map(sum, zip(min_, (-LEEWAY, -LEEWAY, 0)))),
tuple(map(sum, zip(max_, (LEEWAY, LEEWAY, LEEWAY)))),
)
# the pairs returned by getOverlappingObjects() appear to be in the form (body_id, link_idx)
if overlapping_objects is not None:
contact_objects = set(oo for oo, _ in overlapping_objects if oo != bullet_id)

contact_points = []
for contact_object in contact_objects:
# Give 0.05 meter leeway

contact_points.extend(
bullet_client.getClosestPoints(bullet_id, contact_object, distance=0.05)
bullet_client.getClosestPoints(bullet_id, contact_object, distance=LEEWAY)
)

return contact_points
Expand Down
2 changes: 1 addition & 1 deletion smarts/core/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def variations_for_all_scenario_roots(
# `or [None]` so that product(...) will not return an empty result
# but insted a [(..., `None`), ...].
agent_missions = agent_missions or [None]
if len(agents_to_be_briefed) == len(agent_missions):
if len(agents_to_be_briefed) > len(agent_missions):
warnings.warn(
f"Scenario `{scenario_root}` has {len(agent_missions)} missions and"
f" but there are {len(agents_to_be_briefed)} agents to assign"
Expand Down

0 comments on commit a331b9e

Please sign in to comment.