Skip to content

3d driving#382

Open
ethan10mak wants to merge 128 commits into
mainfrom
3d-driving
Open

3d driving#382
ethan10mak wants to merge 128 commits into
mainfrom
3d-driving

Conversation

@ethan10mak

@ethan10mak ethan10mak commented Sep 5, 2025

Copy link
Copy Markdown

Description

This PR adds support for 3D mode.

  • Elevation parsed from Open Drive files
  • Added mesh generation through the Trimesh library
  • Tested driving simulations through CARLA
  • Updated older test cases to generate in 2D mode

Issue Link

N/A

Checklist

  • I have tested the changes locally via pytest and/or other means
  • I have added or updated relevant documentation
  • I have autoformatted the code with black and isort
  • I have added test cases (if applicable)

Additional Notes

N/A

Made comments to file
Started writing code to parse elevationProfile and lateralProfile elements.
Trying to take 3 dimensional vectors and display them, currently displays visual window, but doesn't show anything
Doesn't quite work yet, but I have differentiated functions such as calc_geometry_for_type() to calculate different things for 2D and 3D
Doesn't work yet, currently facing an error where PolylineRegion and PathRegion are not compatible.
Made sure that all PathRegions created are created through points
Updated the FollowLaneBehavior function to deal with 2d and 3d points
@lola831 lola831 requested a review from Eric-Vin February 25, 2026 17:47
lola831 added 5 commits April 15, 2026 17:25
Handle MeshSurfaceRegion/MeshVolumeRegion intersections through a custom sampler instead of the generic intersection fallback. The sampler filters surface triangles using bounding-box overlap with the volume, then samples from the reduced surface and checks points against the volume exactly.

This improves 3D sampling enough to go back to using the same basic.scenic CARLA test scenario instead of needing a separate 3D-specific case.

Also add core region tests covering sampler wiring and sampling behavior for surface-volume intersections.
Update test_car_clipping_3D to generate a scene instead of only compiling, and allow either InvalidScenarioError or RejectionException. With dynamic CARLA blueprints, default car dimensions depend on the sampled blueprint, so overlapping cars will not be rejected during the early static validation pass and instead will fail during scene generation.
@lola831

lola831 commented May 11, 2026

Copy link
Copy Markdown
Collaborator

The test suite was passing except for the two CARLA tests in tests/simulators/carla/test_basic.py that use basic.scenic (test_basic[False] and test_car_created[False]).

The new surface-volume sampler, sampleSurfaceInVolume, helped, but those 3D cases can still occasionally require more iterations to generate a scene, so I increased the iteration limit for those tests from 1000 to 2000.

@lola831 lola831 requested a review from dfremont May 11, 2026 19:13
numpy.linalg.norm(b - a, axis=1), (len(a), 1)
)

def intersects(self, other, triedReversed=False):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation here is not correct: it ignores the Z coordinates. Using Shapely isn't a bad idea (it's probably faster than trying to compute intersections ourselves), but you'd have to check that at least one of the 2D intersections it finds is actually an intersection in 3D. For intersection points, that's easy; for segments, I think it's enough to check each of the endpoints.

regionContainedIn: roadOrShoulder
position: new Point on road
regionContainedIn: roadOrShoulder.boundingPolygon # Change region to bounding polygon region
position: centerOnSurface(road, self.baseOffset, self.contactTolerance)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see why we need this now, but with a mechanism for default specifiers, this would be equivalent to simply on road, I think.

Comment on lines +149 to +160
startDir = None
endDir = None
if isinstance(connecting.centerline, PathRegion):
startDir = (
connecting.centerline.vertices[0] - connecting.centerline.vertices[1]
)
endDir = (
connecting.centerline.vertices[-2] - connecting.centerline.vertices[-1]
)
else:
startDir = connecting.centerline[1] - connecting.centerline[0]
endDir = connecting.centerline[-1] - connecting.centerline[-2]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can revert this change since PathRegion.__getitem__ was added above. (Also the indices look backwards for the PathRegion case -- better double-check this!)

polygon=self.polygon, orientation=self.orientation, name=self.name
)
if isinstance(self.region, MeshSurfaceRegion):
self.region.__init__(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't call __init__ again: the region is already initialized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants