Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into release-0-9-0
Browse files Browse the repository at this point in the history
# Conflicts:
#	crdesigner/map_conversion/map_conversion_interface.py
#	crdesigner/map_conversion/sumo_map/sumo2cr.py
#	crdesigner/ui/gui/utilities/sumo_settings.py
  • Loading branch information
smaierhofer committed Nov 26, 2024
2 parents 9ce5ffd + b9d5355 commit b293bfb
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Command line interface: Providing no input path
- Scenario fails to be opened, if any of the dynamic obstacles does not contain a prediction
- GUI: wrong usage of button
- Check for qt6 so that map conversions work under Ubuntu 20.04

## [0.8.2] - 2024-07-22

Expand Down
29 changes: 19 additions & 10 deletions crdesigner/common/config/config_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@

import yaml
from PyQt6.QtCore import QObject, pyqtSignal
from PyQt6.QtWidgets import QMessageBox

try:
# required for Ubuntu 20.04 since there a system library is too old for pyqt6 and the import fails
# when not importing this, one can still use the map conversion
from PyQt6.QtWidgets import QMessageBox

pyqt_available = True
except (ImportError, RuntimeError):
pyqt_available = False

from crdesigner.ui.gui.utilities.custom_yaml import add_custom_interval_interpreter

Expand Down Expand Up @@ -136,15 +144,16 @@ def restore_last_value(self):
self.value = copy.deepcopy(self.last_saved)

def _warning_wrong_setting(self):
warning_dialog = QMessageBox()
warning_dialog.warning(
None,
"Warning",
f"Setting {self.display_name} contains invalid value!",
QMessageBox.StandardButton.Ok,
QMessageBox.StandardButton.Ok,
)
warning_dialog.close()
if pyqt_available:
warning_dialog = QMessageBox()
warning_dialog.warning(
None,
"Warning",
f"Setting {self.display_name} contains invalid value!",
QMessageBox.StandardButton.Ok,
QMessageBox.StandardButton.Ok,
)
warning_dialog.close()
self.reset()


Expand Down
17 changes: 17 additions & 0 deletions crdesigner/common/sumo_available.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from crdesigner.common import logging

try:
from sumocr.interface.sumo_simulation import SumoSimulation # noqa: F401

from crdesigner.map_conversion.sumo_map.config import SumoConfig # noqa: F401
from crdesigner.map_conversion.sumo_map.cr2sumo.converter import ( # noqa: F401
CR2SumoMapConverter,
)

SUMO_AVAILABLE = True
except ImportError:
logging.warning(
"Cannot import SUMO. SUMO simulation will not be offered in Scenario Designer GUI. "
"The GUI and other map conversions should work."
)
SUMO_AVAILABLE = False
1 change: 1 addition & 0 deletions crdesigner/map_conversion/map_conversion_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from crdesigner.common.config.lanelet2_config import lanelet2_config
from crdesigner.common.config.opendrive_config import open_drive_config
from crdesigner.common.file_reader import CRDesignerFileReader
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.map_conversion.lanelet2.cr2lanelet import CR2LaneletConverter
from crdesigner.map_conversion.lanelet2.lanelet2_parser import Lanelet2Parser
from crdesigner.map_conversion.lanelet2.lanelet2cr import Lanelet2CRConverter
Expand Down
12 changes: 10 additions & 2 deletions crdesigner/map_conversion/sumo_map/sumo2cr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

from commonroad.scenario.scenario import Scenario
from lxml import etree
from PyQt6.QtWidgets import QMessageBox

try:
# required for Ubuntu 20.04 since there a system library is too old for pyqt6 and the import fails
# when not importing this, one can still use the map conversion
from PyQt6.QtWidgets import QMessageBox

pyqt_available = True
except (ImportError, RuntimeError):
pyqt_available = False

from crdesigner.map_conversion.opendrive.odr2cr.opendrive_conversion.network import (
Network,
Expand All @@ -22,7 +30,7 @@ def convert_net_to_cr(net_file: str, verbose: bool = False) -> Scenario:
:return: CommonRoad map file
"""
if net_file is None:
if net_file is None and pyqt_available:
QMessageBox.warning(None, "Warning", "No file selected.", QMessageBox.StandardButton.Ok)
return
assert isinstance(net_file, str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from PyQt6.QtWidgets import QFileDialog, QMessageBox

from crdesigner.common.config.gui_config import gui_config
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.ui.gui.controller.animated_viewer.dynamic_canvas_controller import (
DynamicCanvasController,
)
from crdesigner.ui.gui.model.planning_problem_set_model import PlanningProblemSetModel
from crdesigner.ui.gui.utilities.gui_sumo_simulation import SUMO_AVAILABLE
from crdesigner.ui.gui.utilities.helper import draw_lanelet_polygon

if SUMO_AVAILABLE:
Expand Down
2 changes: 1 addition & 1 deletion crdesigner/ui/gui/controller/mwindow_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from crdesigner.common.config.gui_config import gui_config
from crdesigner.common.logging import logger
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.ui.gui.autosaves.autosaves_setup import DIR_AUTOSAVE
from crdesigner.ui.gui.controller.animated_viewer.animated_viewer_wrapper_controller import (
AnimatedViewerWrapperController,
Expand All @@ -32,7 +33,6 @@
from crdesigner.ui.gui.model.planning_problem_set_model import PlanningProblemSetModel
from crdesigner.ui.gui.model.scenario_model import ScenarioModel
from crdesigner.ui.gui.utilities.file_actions import open_commonroad_file
from crdesigner.ui.gui.utilities.gui_sumo_simulation import SUMO_AVAILABLE
from crdesigner.ui.gui.utilities.util import (
find_invalid_lanelet_polygons,
find_invalid_ref_of_traffic_lights,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from crdesigner.common.config.osm_config import osm_config
from crdesigner.common.logging import logger
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.map_conversion.lanelet2.cr2lanelet import CR2LaneletConverter
from crdesigner.map_conversion.lanelet2.lanelet2_parser import Lanelet2Parser
from crdesigner.map_conversion.lanelet2.lanelet2cr import Lanelet2CRConverter
Expand All @@ -32,7 +33,6 @@
download_around_map,
)
from crdesigner.ui.gui.model.scenario_model import ScenarioModel
from crdesigner.ui.gui.utilities.gui_sumo_simulation import SUMO_AVAILABLE
from crdesigner.ui.gui.utilities.util import select_local_file
from crdesigner.ui.gui.utilities.waitingspinnerwidget import QtWaitingSpinner
from crdesigner.ui.gui.view.toolboxes.converter_toolbox.converter_toolbox_ui import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@
from commonroad.scenario.scenario import Scenario
from pyproj import CRS, Transformer
from PyQt6.QtCore import Q_ARG, QMetaObject, QRunnable, Qt, QThreadPool
from PyQt6.QtWidgets import QMessageBox

try:
# required for Ubuntu 20.04 since there a system library is too old for pyqt6 and the import fails
# when not importing this, one can still use the map conversion
from PyQt6.QtWidgets import QMessageBox

pyqt_available = True
except (ImportError, RuntimeError):
pyqt_available = False

from crdesigner.common.config.gui_config import gui_config as config_settings
from crdesigner.common.config.gui_config import lanelet2_default
Expand Down Expand Up @@ -163,7 +171,7 @@ def show_aerial_image(self, current_position: bool = False):
return

if self.road_network_toolbox_ui.bing_selection.isChecked():
if config_settings.BING_MAPS_KEY == "":
if config_settings.BING_MAPS_KEY == "" and pyqt_available:
print("_Warning__: No Bing Maps key specified. Go to settings and set password.")
warning_dialog = QMessageBox()
warning_dialog.warning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
)

from crdesigner.common.logging import logger
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.ui.gui.model.scenario_model import ScenarioModel
from crdesigner.ui.gui.utilities.gui_sumo_simulation import SUMO_AVAILABLE
from crdesigner.ui.gui.view.toolboxes.road_network_toolbox.road_network_toolbox_ui.road_network_toolbox_ui import (
RoadNetworkToolboxUI,
)
Expand Down
2 changes: 0 additions & 2 deletions crdesigner/ui/gui/utilities/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
""" """

from PyQt6.QtWidgets import QMessageBox, QWidget


Expand Down
13 changes: 2 additions & 11 deletions crdesigner/ui/gui/utilities/gui_sumo_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,15 @@

from commonroad.scenario.scenario import Scenario

from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.ui.gui.utilities.errors import error
from crdesigner.ui.gui.utilities.util import Observable

# try to import sumo functionality
try:
if SUMO_AVAILABLE:
from sumocr.interface.sumo_simulation import SumoSimulation

from crdesigner.map_conversion.sumo_map.config import SumoConfig
from crdesigner.map_conversion.sumo_map.cr2sumo.converter import CR2SumoMapConverter

SUMO_AVAILABLE = True
except ImportError:
logging.warning(
"Cannot import SUMO. SUMO simulation will not be offered in Scenario Designer GUI. "
"The GUI and other map conversions should work."
)
SUMO_AVAILABLE = False

from PyQt6 import QtWidgets
from PyQt6.QtCore import QThread
from PyQt6.QtWidgets import QFrame, QMessageBox
Expand Down
15 changes: 12 additions & 3 deletions crdesigner/ui/gui/utilities/sumo_settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from commonroad.common.util import Interval
from commonroad.scenario.obstacle import ObstacleType
from PyQt6.QtWidgets import QMessageBox

try:
# required for Ubuntu 20.04 since there a system library is too old for pyqt6 and the import fails
# when not importing this, one can still use the map conversion
from PyQt6.QtWidgets import QMessageBox

pyqt_available = True
except (ImportError, RuntimeError):
pyqt_available = False

from crdesigner.map_conversion.sumo_map.config import SumoConfig
from crdesigner.ui.gui.utilities.util import Observable
Expand Down Expand Up @@ -162,5 +170,6 @@ def restore_defaults(self):
self.update_ui_values()

def warn(self, msg):
messbox = QMessageBox()
messbox.warning(None, "Warning", msg, QMessageBox.StandardButton.Ok, QMessageBox.StandardButton.Ok)
if pyqt_available:
messbox = QMessageBox()
messbox.warning(None, "Warning", msg, QMessageBox.StandardButton.Ok, QMessageBox.StandardButton.Ok)
2 changes: 1 addition & 1 deletion crdesigner/ui/gui/view/mwindow_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from PyQt6.QtWidgets import QApplication, QMainWindow, QMessageBox

from crdesigner.common.config.gui_config import ColorSchema, gui_config
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.ui.gui.resources.MainWindow import Ui_mainWindow
from crdesigner.ui.gui.utilities.gui_sumo_simulation import SUMO_AVAILABLE

if SUMO_AVAILABLE:
pass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from crdesigner.common.file_reader import CRDesignerFileReader
from crdesigner.common.file_writer import CRDesignerFileWriter, OverwriteExistingFile
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.map_conversion.map_conversion_interface import commonroad_to_sumo
from crdesigner.ui.gui.utilities.gui_sumo_simulation import SUMO_AVAILABLE

if SUMO_AVAILABLE:
from sumocr.interface.sumo_simulation import SumoSimulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from commonroad.scenario.scenario import Tag

from crdesigner.common.file_writer import CRDesignerFileWriter, OverwriteExistingFile
from crdesigner.common.sumo_available import SUMO_AVAILABLE
from crdesigner.map_conversion.map_conversion_interface import sumo_to_commonroad
from crdesigner.ui.gui.utilities.gui_sumo_simulation import SUMO_AVAILABLE

if SUMO_AVAILABLE:
from crdesigner.map_conversion.sumo_map.sumo2cr import convert_net_to_cr
Expand Down

0 comments on commit b293bfb

Please sign in to comment.