Skip to content

Commit

Permalink
GUI Proto
Browse files Browse the repository at this point in the history
  • Loading branch information
kubasaw committed Oct 11, 2019
1 parent 84496b9 commit aef6b0c
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 72 deletions.
13 changes: 10 additions & 3 deletions car/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def getHeight(self, point):
"""
return self.__interpolantFunction(np.remainder(point, self.__trackLength))

def getTrackProfile(self):
return self.__verticalProfile

class motion:
"""Car motion class
Expand All @@ -165,6 +167,9 @@ def __init__(self, initialCondition=[0., 0., 0.]):
# Simulation control
self.__timestep = 0.1

def getSimTrackProfile(self):
return self.__track.getTrackProfile()

def getSimTime(self):
"""Returns actual simulation time
Expand Down Expand Up @@ -218,8 +223,11 @@ def setThrottle(self, throttle):
ValueError
If *throttle* is not number or outside unit interval
"""
temp = float(throttle)
if (temp < 0 or temp > 1):
try:
temp = float(throttle)
if (temp < 0 or temp > 1):
raise ValueError()
except:
raise ValueError(
"Throttle value have to be choosen from unit interval [0-1]")
self.__throttle = temp
Expand Down Expand Up @@ -291,7 +299,6 @@ def carDynamics(t, x, throttle):
if dt is not None:
self.setTimestep(dt)


t0 = self.__time
tf = self.__time+self.__timestep

Expand Down
1 change: 1 addition & 0 deletions gui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .mainWindow import Ui_MainWindow
149 changes: 149 additions & 0 deletions gui/mainWindow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'mainWindow.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(714, 433)
MainWindow.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedKingdom))
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedKingdom))
self.centralwidget.setObjectName("centralwidget")
self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.tabWidget.setGeometry(QtCore.QRect(10, 10, 671, 341))
self.tabWidget.setToolTipDuration(0)
self.tabWidget.setObjectName("tabWidget")
self.Simulation = QtWidgets.QWidget()
self.Simulation.setObjectName("Simulation")
self.gridLayoutWidget = QtWidgets.QWidget(self.Simulation)
self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 10, 317, 71))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.positionLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.positionLabel.setAlignment(QtCore.Qt.AlignCenter)
self.positionLabel.setObjectName("positionLabel")
self.gridLayout.addWidget(self.positionLabel, 0, 1, 1, 1)
self.engineField = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.engineField.setObjectName("engineField")
self.gridLayout.addWidget(self.engineField, 1, 4, 1, 1)
self.positionField = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.positionField.setReadOnly(True)
self.positionField.setObjectName("positionField")
self.gridLayout.addWidget(self.positionField, 1, 1, 1, 1)
self.speedField = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.speedField.setReadOnly(True)
self.speedField.setObjectName("speedField")
self.gridLayout.addWidget(self.speedField, 1, 2, 1, 1)
self.fuelField = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.fuelField.setReadOnly(True)
self.fuelField.setObjectName("fuelField")
self.gridLayout.addWidget(self.fuelField, 1, 3, 1, 1)
self.fuelLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.fuelLabel.setAlignment(QtCore.Qt.AlignCenter)
self.fuelLabel.setObjectName("fuelLabel")
self.gridLayout.addWidget(self.fuelLabel, 0, 3, 1, 1)
self.speedLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.speedLabel.setAlignment(QtCore.Qt.AlignCenter)
self.speedLabel.setObjectName("speedLabel")
self.gridLayout.addWidget(self.speedLabel, 0, 2, 1, 1)
self.timeLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.timeLabel.setAlignment(QtCore.Qt.AlignCenter)
self.timeLabel.setObjectName("timeLabel")
self.gridLayout.addWidget(self.timeLabel, 0, 0, 1, 1)
self.timeField = QtWidgets.QLineEdit(self.gridLayoutWidget)
self.timeField.setReadOnly(True)
self.timeField.setObjectName("timeField")
self.gridLayout.addWidget(self.timeField, 1, 0, 1, 1)
self.makeStepButton = QtWidgets.QPushButton(self.gridLayoutWidget)
self.makeStepButton.setObjectName("makeStepButton")
self.gridLayout.addWidget(self.makeStepButton, 2, 0, 1, 5)
self.engineLabel = QtWidgets.QLabel(self.gridLayoutWidget)
self.engineLabel.setAlignment(QtCore.Qt.AlignCenter)
self.engineLabel.setObjectName("engineLabel")
self.gridLayout.addWidget(self.engineLabel, 0, 4, 1, 1)
self.tabWidget.addTab(self.Simulation, "")
self.Car = QtWidgets.QWidget()
self.Car.setObjectName("Car")
self.tabWidget.addTab(self.Car, "")
self.Track = QtWidgets.QWidget()
self.Track.setObjectName("Track")
self.trackVerticalProfileField = QtWidgets.QPlainTextEdit(self.Track)
self.trackVerticalProfileField.setGeometry(QtCore.QRect(10, 30, 651, 281))
self.trackVerticalProfileField.setObjectName("trackVerticalProfileField")
self.trackVerticalProfileLabel = QtWidgets.QLabel(self.Track)
self.trackVerticalProfileLabel.setGeometry(QtCore.QRect(10, 10, 151, 16))
self.trackVerticalProfileLabel.setObjectName("trackVerticalProfileLabel")
self.tabWidget.addTab(self.Track, "")
MainWindow.setCentralWidget(self.centralwidget)
self.menuBar = QtWidgets.QMenuBar(MainWindow)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 714, 21))
self.menuBar.setObjectName("menuBar")
self.menuMain = QtWidgets.QMenu(self.menuBar)
self.menuMain.setObjectName("menuMain")
self.menuAbout = QtWidgets.QMenu(self.menuBar)
self.menuAbout.setObjectName("menuAbout")
MainWindow.setMenuBar(self.menuBar)
self.statusBar = QtWidgets.QStatusBar(MainWindow)
self.statusBar.setObjectName("statusBar")
MainWindow.setStatusBar(self.statusBar)
self.actionClose = QtWidgets.QAction(MainWindow)
self.actionClose.setObjectName("actionClose")
self.actionAbout = QtWidgets.QAction(MainWindow)
self.actionAbout.setObjectName("actionAbout")
self.actionImport_Settings = QtWidgets.QAction(MainWindow)
self.actionImport_Settings.setObjectName("actionImport_Settings")
self.actionExport_Settings = QtWidgets.QAction(MainWindow)
self.actionExport_Settings.setObjectName("actionExport_Settings")
self.menuMain.addAction(self.actionImport_Settings)
self.menuMain.addAction(self.actionExport_Settings)
self.menuMain.addSeparator()
self.menuMain.addAction(self.actionClose)
self.menuAbout.addAction(self.actionAbout)
self.menuBar.addAction(self.menuMain.menuAction())
self.menuBar.addAction(self.menuAbout.menuAction())

self.retranslateUi(MainWindow)
self.tabWidget.setCurrentIndex(0)
self.actionClose.triggered.connect(MainWindow.close)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Simulator"))
self.positionLabel.setText(_translate("MainWindow", "Position"))
self.fuelLabel.setText(_translate("MainWindow", "Fuel"))
self.speedLabel.setText(_translate("MainWindow", "Speed"))
self.timeLabel.setText(_translate("MainWindow", "Time"))
self.makeStepButton.setText(_translate("MainWindow", "Make Simulation &Step!"))
self.engineLabel.setText(_translate("MainWindow", "Engine"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Simulation), _translate("MainWindow", "Simulation"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Car), _translate("MainWindow", "Car"))
self.trackVerticalProfileLabel.setText(_translate("MainWindow", "Track Profile (Python format)"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.Track), _translate("MainWindow", "Track"))
self.menuMain.setTitle(_translate("MainWindow", "Main"))
self.menuAbout.setTitle(_translate("MainWindow", "About"))
self.actionClose.setText(_translate("MainWindow", "Close"))
self.actionAbout.setText(_translate("MainWindow", "About"))
self.actionImport_Settings.setText(_translate("MainWindow", "Import Settings"))
self.actionExport_Settings.setText(_translate("MainWindow", "Export Settings"))


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Loading

0 comments on commit aef6b0c

Please sign in to comment.