Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pad AABB to detect axis aligned collision #1889

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Copy and pasting the git commit messages is __NOT__ enough.
### Fixed
- Missing neighborhood vehicle ids are now added to the `highway-v1` formatted observations.
- 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