Skip to content

Commit

Permalink
Added initial support for OSCParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianoboril committed Apr 8, 2021
1 parent 468a8ac commit 1832ce4
Show file tree
Hide file tree
Showing 18 changed files with 1,669 additions and 739 deletions.
Binary file added Docs/OSCGenerator_ParameterNotExist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Docs/OSCGenerator_Parameters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Docs/OSCGenerator_Vehicles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 28 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
- [Removing Vehicles or Pedestrians](#removing-vehicles-or-pedestrians)
- [Adding Maneuvers](#adding-maneuvers)
- [Removing Maneuvers and Waypoints](#removing-maneuvers-and-waypoints)
- [Editing Parameters](#editing-parameters)
- [Editing Entity / Maneuver Parameters](#editing-entity--maneuver-parameters)
- [Adding Own Parameters](#adding-own-parameters)
- [Using Self-defined Parameters](#using-self-defined-parameters)
- [Connecting to CARLA](#connecting-to-carla)
- [Env variables](#env-variables)
- [Adding Camera](#adding-camera)
Expand Down Expand Up @@ -146,10 +148,11 @@ Infrastructure Action | ✅ | Traffic light signal control
Icon | Description
-- | --
<img src="icons/icon_weather.png" alt="Edit environment" width="50"/> | Edit environment
<img src="icons/icon_vehicle.png" alt="git commAdd vehicles" width="50"/> | Add vehicles
<img src="icons/icon_vehicle.png" alt="Add vehicles" width="50"/> | Add vehicles
<img src="icons/icon_pedestrian.png" alt="Add pedestrians" width="50"/> | Add pedestrians
<img src="icons/icon_static.png" alt="Add static objects" width="50"/> | Add static objects
<img src="icons/icon_maneuver.png" alt="Add maneuvers" width="50"/> | Add maneuvers
<img src="icons/icon_parameter.png" alt="Add parmeters" width="50"/> | Add parameters
<img src="icons/icon_endEval.png" alt="Add end evaluation KPIs" width="50"/> | Add end evaluation KPIs (Specific for Scenario Runner)
<img src="icons/icon_code.png" alt="Export OpenSCENARIO" width="50"/> | Export OpenSCENARIO file
<img src="icons/carla_logo.png" alt="Connect to CARLA instance" width="50"/> | Connect to carla instance
Expand All @@ -169,7 +172,7 @@ _Note: To change environment settings, simply adjust the parameters and press 'A
### Adding Vehicles
1. Click on 'Add vehicles' button to load dock widget.
2. Choose parameters (vehicle type, use lane heading / manually specify, initial speed)
3. Agent selection is only enabled for Ego vehicles.
3. Agent selection is only enabled for Ego vehicles. You can also specify your own agent.

![Add Vehicles Dock Widget](Docs/OSCGenerator_Vehicles.png)

Expand Down Expand Up @@ -220,7 +223,7 @@ _Note: You can toggle labels on and off by clicking on the 'Label' button_
3. Entity maneuvers
1. Choose entity to apply maneuver to, if entity is not listed, click on `Refresh entity list`.
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`.
3. If stop triggers are needed, set up stop triggers of the maneuver using the `Stop Triggers` tab by checking the 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.
Expand All @@ -236,14 +239,12 @@ _Note: You can toggle labels on and off by clicking on the 'Label' button_
4. Set up the start triggers of the maneuvers using the `Triggers` tab.
5. Click on `Insert`.

_Note: It is important to set up the start triggers first before inserting the maneuver_
_Note: It is important to set up the start/stop triggers first before inserting the maneuver_
1. Special note for Reach Position Condition
1. To set up `ReachPositionCondition`, click on `Choose position`.
2. Click on a point on the map.
3. The coordinates of the click point will be updated in the UI.

_Note: Stop triggers are currently not supported._

### Removing Maneuvers and Waypoints
1. In `Layers` right click on layer and select `Open Attribute Table`.

Expand All @@ -255,7 +256,7 @@ _Note: Stop triggers are currently not supported._
5. Click on pencil icon to disable editing.
6. When prompted to save changes, choose 'Yes'.

### Editing Parameters
### Editing Entity / Maneuver 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.
Expand All @@ -269,6 +270,25 @@ After inserting entities or maneuvers, you can edit them using the Attributes ta

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

### Adding Own Parameters
You can define you own parameters to be used inside the scenario.
1. Click on the `Add Parameters` icon.
2. Setup parameters based on requirements (name, type, value).

![Parameters Dock Widget](Docs/OSCGenerator_Parameters.png)

3. Click on `Insert`.
4. If a parameter name already exists, the plugin will prompt you if you want to replace it.

_Note: To edit existing parameters, you can edit them directly using the Attributes table, or using the same parameter name and clicking on `Insert`. The plugin will ask for confirmation to replace the existing parameter._

### Using Self-defined Parameters
Parameters can be used when creating scenarios.
1. In the text field entry, simply input the name of the parameter to be used.
2. If the parameter does not exist, and error message will appear, as shown below.

![Parameter Error Message](Docs/OSCGenerator_ParameterNotExist.png)

## Connecting to CARLA

### Env variables
Expand Down
29 changes: 28 additions & 1 deletion carla_scenario_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ def __init__(self, iface):
self._plugin_is_active_props = False
self._plugin_is_active_environment = False
self._plugin_is_active_maneuvers = False
self._plugin_is_active_parameters = False
self._dockwidget_vehicles = None
self._dockwidget_pedestrians = None
self._dockwidget_props = None
self._dockwidget_environment = None
self._dockwidget_maneuvers = None
self._dockwidget_parameters = None
self._root_layer = QgsProject.instance().layerTreeRoot()
self.ui = QGISUI(self.iface, "OSC_Generator", True)
self.action_tool = {}
Expand Down Expand Up @@ -186,6 +188,8 @@ def initGui(self):
self.static_info = "Add static objects"
self.maneuver = "icon_maneuver"
self.maneuver_info = "Add maneuvers"
self.parameter = "icon_parameter"
self.parameter_info = "Add Parameters"
self.endeval = "icon_endEval"
self.endeval_info = "End evaluation KPI's"
self.code = "icon_code"
Expand All @@ -200,6 +204,7 @@ def initGui(self):
self.__add_action__(self.pedestrians, self.pedestrians_info, self.add_pedestrians)
self.__add_action__(self.static, self.static_info, self.add_props)
self.__add_action__(self.maneuver, self.maneuver_info, self.add_maneuver)
self.__add_action__(self.parameter, self.parameter_info, self.add_parameters)
self.__add_action__(self.endeval, self.endeval_info, self.end_evaluation)
self.__add_action__(self.code, self.code_info, self.export_xosc)
self.__add_action__(self.carla, self.carla_info, self.run_scenario)
Expand Down Expand Up @@ -234,8 +239,10 @@ def onClosePlugin(self):
if self._plugin_is_active_props:
self._dockwidget_props.closingPlugin.disconnect(self.onClosePlugin)
self._plugin_is_active_props = False


if self._plugin_is_active_parameters:
self._dockwidget_parameters.closingPlugin.disconnect(self.onClosePlugin)
self._plugin_is_active_parameters = False

def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
Expand Down Expand Up @@ -365,6 +372,26 @@ def add_props(self):
self.iface.addDockWidget(Qt.BottomDockWidgetArea, self._dockwidget_props)
self._dockwidget_props.show()

def add_parameters(self):
"""
Adds "Add Parameters" dock widget.
Creates OpenSCENARIO layer group if it does not exist.
"""
# Add temporary scratch layer to QGIS (if not yet created)
if self._root_layer.findGroup("OpenSCENARIO") is None:
self._root_layer.addGroup("OpenSCENARIO")

# Load plugin
if not self._plugin_is_active_parameters:
self._plugin_is_active_parameters = True

if self._dockwidget_parameters is None:
self._dockwidget_parameters = ParameterDeclarationsDockWidget()

self._dockwidget_parameters.closingPlugin.connect(self.onClosePlugin)
self.iface.addDockWidget(Qt.BottomDockWidgetArea, self._dockwidget_parameters)
self._dockwidget_parameters.show()

def end_evaluation(self):
"""
Opens "End Evaluation" dialog.
Expand Down
Binary file added icons/icon_parameter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1832ce4

Please sign in to comment.