-
Notifications
You must be signed in to change notification settings - Fork 135
Generate CARLA blueprints dynamically #401
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
base: main
Are you sure you want to change the base?
Changes from all commits
e849204
a8f6fef
ebf8b8e
1ea1de6
6583ab0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,7 +44,7 @@ Global Parameters: | |||||
| import pathlib | ||||||
| from scenic.domains.driving.model import * | ||||||
|
|
||||||
| import scenic.simulators.carla.blueprints as blueprints | ||||||
| import scenic.simulators.carla.blueprints as bp | ||||||
| from scenic.simulators.carla.behaviors import * | ||||||
| from scenic.simulators.utils.colors import Color | ||||||
|
|
||||||
|
|
@@ -122,6 +122,12 @@ class CarlaActor(DrivingObject): | |||||
| carlaActor (dynamic): Set during simulations to the ``carla.Actor`` representing this | ||||||
| object. | ||||||
| blueprint (str): Identifier of the CARLA blueprint specifying the type of object. | ||||||
| defaultWidth (float): Default width to use if Scenic has no recorded dimensions for this blueprint. | ||||||
| defaultLength (float): Default length to use if Scenic has no recorded dimensions for this blueprint. | ||||||
| defaultHeight (float): Default height to use if Scenic has no recorded dimensions for this blueprint. | ||||||
| width (float): Width for this blueprint; uses Scenic's recorded dimensions when available, otherwise ``defaultWidth``. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Ditto for |
||||||
| length (float): Length for this blueprint; uses Scenic's recorded dimensions when available, otherwise ``defaultLength``. | ||||||
| height (float): Height for this blueprint; uses Scenic's recorded dimensions when available, otherwise ``defaultHeight``. | ||||||
| rolename (str): Can be used to differentiate specific actors during runtime. Default | ||||||
| value ``None``. | ||||||
| physics (bool): Whether physics is enabled for this object in CARLA. Default true. | ||||||
|
|
@@ -130,8 +136,13 @@ class CarlaActor(DrivingObject): | |||||
| """ | ||||||
| carlaActor: None | ||||||
| blueprint: None | ||||||
| defaultWidth: 1 | ||||||
| defaultLength: 1 | ||||||
| defaultHeight: 1 | ||||||
| width: bp.width(self.blueprint, self.defaultWidth) | ||||||
| length: bp.length(self.blueprint, self.defaultLength) | ||||||
| height: bp.height(self.blueprint, self.defaultHeight) | ||||||
| rolename: None | ||||||
| color: None | ||||||
| physics: True | ||||||
| snapToGround: globalParameters.snapToGroundDefault | ||||||
|
|
||||||
|
|
@@ -155,7 +166,7 @@ class CarlaActor(DrivingObject): | |||||
| else: | ||||||
| self.carlaActor.set_velocity(cvel) | ||||||
|
|
||||||
| class Vehicle(Vehicle, CarlaActor, Steers, _CarlaVehicle): | ||||||
| class Vehicle(CarlaActor, Vehicle, Steers, _CarlaVehicle): | ||||||
| """Abstract class for steerable vehicles.""" | ||||||
|
|
||||||
| def setThrottle(self, throttle): | ||||||
|
|
@@ -182,7 +193,10 @@ class Car(Vehicle): | |||||
| The default ``blueprint`` (see `CarlaActor`) is a uniform distribution over the | ||||||
| blueprints listed in :obj:`scenic.simulators.carla.blueprints.carModels`. | ||||||
| """ | ||||||
| blueprint: Uniform(*blueprints.carModels) | ||||||
| blueprint: Uniform(*bp.any_in("car")) | ||||||
| defaultWidth: 2 | ||||||
| defaultLength: 4.5 | ||||||
| defaultHeight: 1.5 | ||||||
|
|
||||||
| @property | ||||||
| def isCar(self): | ||||||
|
|
@@ -192,32 +206,45 @@ class NPCCar(Car): # no distinction between these in CARLA | |||||
| pass | ||||||
|
|
||||||
| class Bicycle(Vehicle): | ||||||
| width: 1 | ||||||
| length: 2 | ||||||
| blueprint: Uniform(*blueprints.bicycleModels) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For backwards compatibility, can we continue to define |
||||||
|
|
||||||
| blueprint: Uniform(*bp.any_in("bicycle")) | ||||||
| defaultWidth: 1 | ||||||
| defaultLength: 2 | ||||||
| defaultHeight: 1.5 | ||||||
|
|
||||||
| class Motorcycle(Vehicle): | ||||||
| width: 1 | ||||||
| length:2 | ||||||
| blueprint: Uniform(*blueprints.motorcycleModels) | ||||||
|
|
||||||
| blueprint: Uniform(*bp.any_in("motorcycle")) | ||||||
| defaultWidth: 1 | ||||||
| defaultLength: 2 | ||||||
| defaultHeight: 1.5 | ||||||
|
|
||||||
| class Truck(Vehicle): | ||||||
| width: 3 | ||||||
| length: 7 | ||||||
| blueprint: Uniform(*blueprints.truckModels) | ||||||
|
|
||||||
|
|
||||||
| class Pedestrian(Pedestrian, CarlaActor, Walks, _CarlaPedestrian): | ||||||
| blueprint: Uniform(*bp.any_in("truck")) | ||||||
| defaultWidth: 2.5 | ||||||
| defaultLength: 7.5 | ||||||
| defaultHeight: 3 | ||||||
|
|
||||||
| class Van(Vehicle): | ||||||
| blueprint: Uniform(*bp.any_in("van")) | ||||||
| defaultWidth: 2 | ||||||
| defaultLength: 5 | ||||||
| defaultHeight: 2 | ||||||
|
|
||||||
| class Bus(Vehicle): | ||||||
| blueprint: Uniform(*bp.any_in("bus")) | ||||||
| defaultWidth: 4 | ||||||
| defaultLength: 10 | ||||||
| defaultHeight: 4 | ||||||
|
|
||||||
| class Pedestrian(CarlaActor, Pedestrian, Walks, _CarlaPedestrian): | ||||||
| """A pedestrian. | ||||||
|
|
||||||
| The default ``blueprint`` (see `CarlaActor`) is a uniform distribution over the | ||||||
| blueprints listed in :obj:`scenic.simulators.carla.blueprints.walkerModels`. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to fix the docstring here, since the location of the blueprints has changed. |
||||||
| """ | ||||||
| width: 0.5 | ||||||
| length: 0.5 | ||||||
| blueprint: Uniform(*blueprints.walkerModels) | ||||||
| blueprint: Uniform(*bp.any_in("walker")) | ||||||
| defaultWidth: 0.5 | ||||||
| defaultLength: 0.5 | ||||||
| defaultHeight: 1.5 | ||||||
| carlaController: None | ||||||
|
|
||||||
| def setWalkingDirection(self, heading): | ||||||
|
|
@@ -238,100 +265,99 @@ class Prop(CarlaActor): | |||||
| regionContainedIn: road | ||||||
| position: new Point on road | ||||||
| parentOrientation: Range(0, 360) deg | ||||||
| width: 0.5 | ||||||
| length: 0.5 | ||||||
| defaultWidth: 0.5 | ||||||
| defaultLength: 0.5 | ||||||
| defaultHeight: 0.5 | ||||||
| physics: False | ||||||
|
|
||||||
| class Trash(Prop): | ||||||
| blueprint: Uniform(*blueprints.trashModels) | ||||||
| blueprint: Uniform(*bp.any_in("trash")) | ||||||
|
|
||||||
|
|
||||||
| class Cone(Prop): | ||||||
| blueprint: Uniform(*blueprints.coneModels) | ||||||
| blueprint: Uniform(*bp.any_in("cone")) | ||||||
|
|
||||||
|
|
||||||
| class Debris(Prop): | ||||||
| blueprint: Uniform(*blueprints.debrisModels) | ||||||
| blueprint: Uniform(*bp.any_in("debris")) | ||||||
|
|
||||||
|
|
||||||
| class VendingMachine(Prop): | ||||||
| blueprint: Uniform(*blueprints.vendingMachineModels) | ||||||
|
|
||||||
| blueprint: Uniform(*bp.any_in("vendingMachine")) | ||||||
|
|
||||||
| class Chair(Prop): | ||||||
| blueprint: Uniform(*blueprints.chairModels) | ||||||
|
|
||||||
| blueprint: Uniform(*bp.any_in("chair")) | ||||||
|
|
||||||
| class BusStop(Prop): | ||||||
| blueprint: Uniform(*blueprints.busStopModels) | ||||||
| blueprint: Uniform(*bp.any_in("busStop")) | ||||||
|
|
||||||
|
|
||||||
| class Advertisement(Prop): | ||||||
| blueprint: Uniform(*blueprints.advertisementModels) | ||||||
| blueprint: Uniform(*bp.any_in("advertisement")) | ||||||
|
|
||||||
|
|
||||||
| class Garbage(Prop): | ||||||
| blueprint: Uniform(*blueprints.garbageModels) | ||||||
|
|
||||||
| blueprint: Uniform(*bp.any_in("garbage")) | ||||||
|
|
||||||
| class Container(Prop): | ||||||
| blueprint: Uniform(*blueprints.containerModels) | ||||||
| blueprint: Uniform(*bp.any_in("container")) | ||||||
|
|
||||||
|
|
||||||
| class Table(Prop): | ||||||
| blueprint: Uniform(*blueprints.tableModels) | ||||||
| blueprint: Uniform(*bp.any_in("table")) | ||||||
|
|
||||||
|
|
||||||
| class Barrier(Prop): | ||||||
| blueprint: Uniform(*blueprints.barrierModels) | ||||||
| blueprint: Uniform(*bp.any_in("barrier")) | ||||||
|
|
||||||
|
|
||||||
| class PlantPot(Prop): | ||||||
| blueprint: Uniform(*blueprints.plantpotModels) | ||||||
| blueprint: Uniform(*bp.any_in("plantpot")) | ||||||
|
|
||||||
|
|
||||||
| class Mailbox(Prop): | ||||||
| blueprint: Uniform(*blueprints.mailboxModels) | ||||||
|
|
||||||
| blueprint: Uniform(*bp.any_in("mailbox")) | ||||||
|
|
||||||
| class Gnome(Prop): | ||||||
| blueprint: Uniform(*blueprints.gnomeModels) | ||||||
| blueprint: Uniform(*bp.any_in("gnome")) | ||||||
|
|
||||||
|
|
||||||
| class CreasedBox(Prop): | ||||||
| blueprint: Uniform(*blueprints.creasedboxModels) | ||||||
| blueprint: Uniform(*bp.any_in("creasedbox")) | ||||||
|
|
||||||
|
|
||||||
| class Case(Prop): | ||||||
| blueprint: Uniform(*blueprints.caseModels) | ||||||
| blueprint: Uniform(*bp.any_in("case")) | ||||||
|
|
||||||
|
|
||||||
| class Box(Prop): | ||||||
| blueprint: Uniform(*blueprints.boxModels) | ||||||
| blueprint: Uniform(*bp.any_in("box")) | ||||||
|
|
||||||
|
|
||||||
| class Bench(Prop): | ||||||
| blueprint: Uniform(*blueprints.benchModels) | ||||||
| blueprint: Uniform(*bp.any_in("bench")) | ||||||
|
|
||||||
|
|
||||||
| class Barrel(Prop): | ||||||
| blueprint: Uniform(*blueprints.barrelModels) | ||||||
| blueprint: Uniform(*bp.any_in("barrel")) | ||||||
|
|
||||||
|
|
||||||
| class ATM(Prop): | ||||||
| blueprint: Uniform(*blueprints.atmModels) | ||||||
| blueprint: Uniform(*bp.any_in("atm")) | ||||||
|
|
||||||
|
|
||||||
| class Kiosk(Prop): | ||||||
| blueprint: Uniform(*blueprints.kioskModels) | ||||||
| blueprint: Uniform(*bp.any_in("kiosk")) | ||||||
|
|
||||||
|
|
||||||
| class IronPlate(Prop): | ||||||
| blueprint: Uniform(*blueprints.ironplateModels) | ||||||
| blueprint: Uniform(*bp.any_in("ironplate")) | ||||||
|
|
||||||
|
|
||||||
| class TrafficWarning(Prop): | ||||||
| blueprint: Uniform(*blueprints.trafficwarningModels) | ||||||
| blueprint: Uniform(*bp.any_in("trafficwarning")) | ||||||
|
|
||||||
|
|
||||||
| ## Utility functions | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the old
blueprintsis more understandable.