Skip to content

Commit

Permalink
Added StopTriggers and extended README
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianoboril committed Mar 12, 2021
1 parent daa3bcf commit 468a8ac
Show file tree
Hide file tree
Showing 6 changed files with 984 additions and 104 deletions.
Binary file added Docs/OSCGenerator_EditAttributes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Python Packages](#python-packages)
- [Installation](#installation)
- [Features](#features)
- [Known Issues](#known-issues)
- [OpenSCENARIO Support List](#openscenario-support-list)
- [Environment](#environment)
- [Actors](#actors)
Expand All @@ -23,7 +24,8 @@
- [Removing Vehicles or Pedestrians](#removing-vehicles-or-pedestrians)
- [Adding Maneuvers](#adding-maneuvers)
- [Removing Maneuvers and Waypoints](#removing-maneuvers-and-waypoints)
- [Connecting to CARLA](#connecting-to-carla)
- [Editing Parameters](#editing-parameters)
- [Connecting to CARLA](#connecting-to-carla)
- [Env variables](#env-variables)
- [Adding Camera](#adding-camera)
- [Place Camera Manually:](#place-camera-manually)
Expand Down Expand Up @@ -62,11 +64,16 @@ pip3 install --user -r /path/to/requirements.txt

## Features
- Place entiites onto loaded OpenDRIVE map (through AD Map plugin)
- Specity start and stop triggers for maneuvers
- Add maneuvers to entities
- Add global maneuvers
- Current support for traffic light actions only
- Set initial environment variables (cloud state, time of day, precipitation)

## Known Issues
- Non CARLA maps are not fully supported
- Entity spawn z coordinates need to be manually adjusted

## OpenSCENARIO Support List

✅ - Supported
Expand Down Expand Up @@ -212,8 +219,9 @@ _Note: You can toggle labels on and off by clicking on the 'Label' button_
2. Choose either to add entity maneuvers or global actions under `Maneuver Type`.
3. Entity maneuvers
1. Choose entity to apply maneuver to, if entity is not listed, click on `Refresh entity list`.
2. Set up the start triggers of the maneuvers using the `Triggers` tab.
3. Choose type of maneuver (waypoints, longitudinal, lateral)
2. Set up start triggers of the maneuver using the `Start Triggers` tab.
3. Set up stop triggers of the maneuver using the `Stop Triggers` tab. If stop triggers are not needed, uncheck the check box beside `Stop Triggers`.
4. Choose type of maneuver (waypoints, longitudinal, lateral)
1. Waypoint Maneuvers
1. Choose waypoint strategy and whether to use lane heading or user-defined heading.
2. Click on `Insert`, and click on the map to spawn as many waypoints as intended.
Expand Down Expand Up @@ -247,7 +255,21 @@ _Note: Stop triggers are currently not supported._
5. Click on pencil icon to disable editing.
6. When prompted to save changes, choose 'Yes'.

### Connecting to CARLA
### Editing Parameters
After inserting entities or maneuvers, you can edit them using the Attributes table.
1. In `Layers`, right click on layer and select `Open Attribute Table`.
2. Click on the pencil icon on top left to enable editing.
3. Double click on cell to edit.

![Editing Parameters](Docs/OSCGenerator_EditAttributes.png)

4. Change the cell value.
5. When desired changes are complete, click on pencil icon to disable editing.
6. When promted to save changes, choose 'Yes'.

_Note: Changing the positions (X, Y, heading) in the attributes table does not update the positions seen in the map._

## Connecting to CARLA

### Env variables

Expand Down
116 changes: 89 additions & 27 deletions osc_generator/add_maneuvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def layer_setup(self):
self._waypoint_layer.setLabeling(QgsVectorLayerSimpleLabeling(label_settings))
self._waypoint_layer.setLabelsEnabled(True)

# Maneuvers + Start Triggers
# Maneuvers + Start Triggers + Stop Triggers
if not QgsProject.instance().mapLayersByName("Maneuvers"):
maneuver_layer = QgsVectorLayer("None", "Maneuvers", "memory")
QgsProject.instance().addMapLayer(maneuver_layer, False)
Expand All @@ -116,33 +116,60 @@ def layer_setup(self):
QgsField("Entity", QVariant.String),
QgsField("Entity: Maneuver Type", QVariant.String),
QgsField("Start Trigger", QVariant.String),
QgsField("Entity: Condition", QVariant.String),
QgsField("Entity: Ref Entity", QVariant.String),
QgsField("Entity: Duration", QVariant.Double),
QgsField("Entity: Value", QVariant.Double),
QgsField("Entity: Rule", QVariant.String),
QgsField("Entity: RelDistType", QVariant.String),
QgsField("Entity: Freespace", QVariant.Bool),
QgsField("Entity: Along Route", QVariant.Bool),
QgsField("Value: Condition", QVariant.String),
QgsField("Value: Param Ref", QVariant.String),
QgsField("Value: Name", QVariant.String),
QgsField("Value: DateTime", QVariant.String),
QgsField("Value: Value", QVariant.Double),
QgsField("Value: Rule", QVariant.String),
QgsField("Value: State", QVariant.String),
QgsField("Value: Sboard Type", QVariant.String),
QgsField("Value: Sboard Element", QVariant.String),
QgsField("Value: Sboard State", QVariant.String),
QgsField("Value: TController Ref", QVariant.String),
QgsField("Value: TController Phase", QVariant.String),
QgsField("Start - Entity: Condition", QVariant.String),
QgsField("Start - Entity: Ref Entity", QVariant.String),
QgsField("Start - Entity: Duration", QVariant.Double),
QgsField("Start - Entity: Value", QVariant.Double),
QgsField("Start - Entity: Rule", QVariant.String),
QgsField("Start - Entity: RelDistType", QVariant.String),
QgsField("Start - Entity: Freespace", QVariant.Bool),
QgsField("Start - Entity: Along Route", QVariant.Bool),
QgsField("Start - Value: Condition", QVariant.String),
QgsField("Start - Value: Param Ref", QVariant.String),
QgsField("Start - Value: Name", QVariant.String),
QgsField("Start - Value: DateTime", QVariant.String),
QgsField("Start - Value: Value", QVariant.Double),
QgsField("Start - Value: Rule", QVariant.String),
QgsField("Start - Value: State", QVariant.String),
QgsField("Start - Value: Sboard Type", QVariant.String),
QgsField("Start - Value: Sboard Element", QVariant.String),
QgsField("Start - Value: Sboard State", QVariant.String),
QgsField("Start - Value: TController Ref", QVariant.String),
QgsField("Start - Value: TController Phase", QVariant.String),
QgsField("Global: Act Type", QVariant.String),
QgsField("Infra: Traffic Light ID", QVariant.Int),
QgsField("Infra: Traffic Light State", QVariant.String),
QgsField("WorldPos: Tolerance", QVariant.Double),
QgsField("WorldPos: X", QVariant.Double),
QgsField("WorldPos: Y", QVariant.Double),
QgsField("WorldPos: Heading", QVariant.Double)]
QgsField("Start - WorldPos: Tolerance", QVariant.Double),
QgsField("Start - WorldPos: X", QVariant.Double),
QgsField("Start - WorldPos: Y", QVariant.Double),
QgsField("Start - WorldPos: Heading", QVariant.Double),
# Stop Triggers
QgsField("Stop Trigger Enabled", QVariant.Bool),
QgsField("Stop Trigger", QVariant.String),
QgsField("Stop - Entity: Condition", QVariant.String),
QgsField("Stop - Entity: Ref Entity", QVariant.String),
QgsField("Stop - Entity: Duration", QVariant.Double),
QgsField("Stop - Entity: Value", QVariant.Double),
QgsField("Stop - Entity: Rule", QVariant.String),
QgsField("Stop - Entity: RelDistType", QVariant.String),
QgsField("Stop - Entity: Freespace", QVariant.Bool),
QgsField("Stop - Entity: Along Route", QVariant.Bool),
QgsField("Stop - Value: Condition", QVariant.String),
QgsField("Stop - Value: Param Ref", QVariant.String),
QgsField("Stop - Value: Name", QVariant.String),
QgsField("Stop - Value: DateTime", QVariant.String),
QgsField("Stop - Value: Value", QVariant.Double),
QgsField("Stop - Value: Rule", QVariant.String),
QgsField("Stop - Value: State", QVariant.String),
QgsField("Stop - Value: Sboard Type", QVariant.String),
QgsField("Stop - Value: Sboard Element", QVariant.String),
QgsField("Stop - Value: Sboard State", QVariant.String),
QgsField("Stop - Value: TController Ref", QVariant.String),
QgsField("Stop - Value: TController Phase", QVariant.String),
QgsField("Stop - WorldPos: Tolerance", QVariant.Double),
QgsField("Stop - WorldPos: X", QVariant.Double),
QgsField("Stop - WorldPos: Y", QVariant.Double),
QgsField("Stop - WorldPos: Heading", QVariant.Double)]
data_input = maneuver_layer.dataProvider()
data_input.addAttributes(data_attributes)
maneuver_layer.updateFields()
Expand Down Expand Up @@ -231,6 +258,8 @@ def refresh_entity(self):
self.entityTrig_RefEntity.clear()
self.lateral_RefEntity.clear()
self.long_RefEntity.clear()
self.stop_Entity_RefEntity.clear()

entities = []
if QgsProject.instance().mapLayersByName("Vehicles - Ego"):
layer = QgsProject.instance().mapLayersByName("Vehicles - Ego")[0]
Expand All @@ -254,16 +283,21 @@ def refresh_entity(self):
self.entityTrig_RefEntity.addItems(entities)
self.lateral_RefEntity.addItems(entities)
self.long_RefEntity.addItems(entities)
self.stop_Entity_RefEntity.addItems(entities)

def update_ref_entity(self):
"""
Updates start trigger reference entity to match selected entity by default.
"""
selected_entity = self.entitySelection.currentText()
# Trigger
# Start Trigger (Ref Entity)
index = self.entityTrig_RefEntity.findText(selected_entity)
self.entityTrig_RefEntity.setCurrentIndex(index)

# Stop Trigger (Ref Entity)
index = self.stop_Entity_RefEntity.findText(selected_entity)
self.stop_Entity_RefEntity.setCurrentIndex(index)

# Lateral reference entity
index = self.lateral_RefEntity.findText(selected_entity)
self.lateral_RefEntity.setCurrentIndex(index)
Expand Down Expand Up @@ -357,6 +391,7 @@ def add_maneuvers(self):
elif self.entityManeuverType.currentText() == "Lateral":
self.save_lateral_attributes()
elif self.maneuverType.currentText() == "Global Actions":
# Infrastructure actions are saved inside Maneuvers layer
pass

self.save_maneuver_attributes()
Expand Down Expand Up @@ -663,7 +698,34 @@ def save_maneuver_attributes(self):
float(self.entityTolerance.text()),
float(self.entityPositionX.text()),
float(self.entityPositionY.text()),
float(self.entityHeading.text())])
float(self.entityHeading.text()),
# Stop Triggers
self.stopTriggersGroup.isChecked(),
self.stop_ConditionType.currentText(),
self.stop_Entity_Cond.currentText(),
self.stop_Entity_RefEntity.currentText(),
self.stop_Entity_Duration.text(),
self.stop_Entity_Value.text(),
self.stop_Entity_Rule.currentText(),
self.stop_Entity_RelDistType.currentText(),
self.stop_Entity_Freespace.isChecked(),
self.stop_Entity_AlongRoute.isChecked(),
self.stop_Value_Cond.currentText(),
self.stop_Value_ParamRef.text(),
self.stop_Value_Name.text(),
self.stop_Value_DateTime.dateTime().toString("yyyy-MM-ddThh:mm:ss"),
float(self.stop_Value_Value.text()),
self.stop_Value_Rule.currentText(),
self.stop_Value_State.text(),
self.stop_Storyboard_Type.currentText(),
self.stop_Storyboard_Element.text(),
self.stop_Storyboard_State.currentText(),
self.stop_TrafficSignal_ControllerRef.text(),
self.stop_TrafficSignal_Phase.text(),
float(self.stop_Entity_Tolerance.text()),
float(self.stop_Entity_PositionX.text()),
float(self.stop_Entity_PositionY.text()),
float(self.stop_Entity_Heading.text())])
self._maneuver_layer.dataProvider().addFeature(feature)

def save_longitudinal_attributes(self):
Expand Down
Loading

0 comments on commit 468a8ac

Please sign in to comment.