Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

New branch of visualizer for osi-2.2.1 maintenance #20

Open
wants to merge 11 commits into
base: maintenance/v-for-osi2.2.1
Choose a base branch
from
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ set(SOURCES
src/gltrafficsign.cpp
src/qrc_resources.cpp
src/osiparser.cpp
src/glfieldofview.cpp
src/fmureceiver.cpp
)

set(HEADERS
Expand All @@ -55,9 +57,20 @@ set(HEADERS
include/glpoint.h
include/gltrafficsign.h
include/osiparser.h
include/glfieldofview.h
include/fmureceiver.h
)


include_directories(
/usr/local/include/fmi-library
${CMAKE_CURRENT_LIST_DIR}/include
)

link_directories(
/usr/local/lib/fmi-library
)

include_directories(include)

add_executable(${PROJECT_NAME}
${HEADERS}
Expand All @@ -72,7 +85,9 @@ target_link_libraries(${PROJECT_NAME}
Qt5::OpenGL
Qt5::Network

open_simulation_interface_pic
open_simulation_interface
fmilib_shared
protobuf
zmq
)

19 changes: 19 additions & 0 deletions include/appconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,39 @@ class AppConfig
QString ch1IPAddress_;
QString ch1PortNum_;
DataType ch1DataType_;
bool ch1FMURxCheck_;
QString ch1LoadFMURx_;
QString ch1LoadFile_;
DataType ch1PlaybackDataType_;
int ch1DeltaDelay_;
bool ch1EnableSendOut_;
QString ch1SendOutPortNum_;
bool ch1FMUTxCheck_;
QString ch1LoadFMUTx_;
bool ch1ShowFOV_;
float ch1MinRadius_;
float ch1MaxRadius_;
float ch1AzimuthPos_;
float ch1AzimuthNeg_;


QString ch2IPAddress_;
QString ch2PortNum_;
DataType ch2DataType_;
bool ch2FMURxCheck_;
QString ch2LoadFMURx_;
QString ch2LoadFile_;
DataType ch2PlaybackDataType_;
int ch2DeltaDelay_;
bool ch2EnableSendOut_;
QString ch2SendOutPortNum_;
bool ch2FMUTxCheck_;
QString ch2LoadFMUTx_;
bool ch2ShowFOV_;
float ch2MinRadius_;
float ch2MaxRadius_;
float ch2AzimuthPos_;
float ch2AzimuthNeg_;

bool combineChannel_;
bool showGrid_;
Expand Down
108 changes: 108 additions & 0 deletions include/fmureceiver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
///
/// @file
/// @copyright Copyright (C) 2017, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
///
/// @brief
///



#pragma once

#include <QtConcurrent/QtConcurrent>

#include <string>

#include "osi_sensordata.pb.h"
#include "imessagesource.h"
#include "types.h"


extern "C" {
#include <JM/jm_portability.h>
#include <fmilib.h>
}

#define FMI_INTEGER_SENSORDATA_IN_BASELO_IDX 0
#define FMI_INTEGER_SENSORDATA_IN_BASEHI_IDX 1
#define FMI_INTEGER_SENSORDATA_IN_SIZE_IDX 2
#define FMI_INTEGER_SENSORDATA_OUT_BASELO_IDX 3
#define FMI_INTEGER_SENSORDATA_OUT_BASEHI_IDX 4
#define FMI_INTEGER_SENSORDATA_OUT_SIZE_IDX 5
#define FMI_INTEGER_LAST_IDX FMI_INTEGER_SENSORDATA_OUT_SIZE_IDX
#define FMI_INTEGER_VARS (FMI_INTEGER_LAST_IDX + 1)




class FMUReceiver: public QObject, public IMessageSource
{
Q_OBJECT

public:
FMUReceiver();

signals:
void Connected(DataType dataType);
void Disconnected(const QString& message = "");
void MessageReceived(const osi::SensorData& sensorData,
const DataType datatype);

public slots:
void DisconnectRequested();
void ConnectRequested(const QString& ipAddress,
const QString& port,
const QString& fmuPath,
DataType dataType);

private:

void ReceiveLoop();


bool isRunning_;
bool isThreadTerminated_;
DataType currentDataType_;


// FMU interface
fmi2_import_t* fmu_;
fmi2_callback_functions_t callBackFunctions_;
jm_callbacks callbacks_;
fmi_import_context_t* context_;

jm_status_enu_t jmStatus_;
fmi2_status_t fmiStatus_;

fmi2_real_t tStart_;
fmi2_real_t tEnd_;
fmi2_real_t tCurrent_;
fmi2_real_t hStep_;

std::string ip_;
std::string port_;
std::string FMUPath_;
std::string tmpPath_;
enum class LogLevel
{
Warn,
Debug
};
LogLevel logLevel_;

std::string currentBuffer_;

fmi2_value_reference_t vr_[FMI_INTEGER_VARS];
fmi2_integer_t integerVars_[FMI_INTEGER_VARS];

// initialize fmu wrapper specific logger, create fmi import context and check fmi version
bool initializeFMUWrapper();
// import fmu binary file
bool importFMU();
// setup and initialize FMU
bool initializeFMU();
// protobuf accessors
bool get_fmi_sensor_data_in(osi::SensorData& data);
};


23 changes: 23 additions & 0 deletions include/glfieldofview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@




#pragma once
#include "globject.h"

class GLFieldOfView : public GLObject
{
public:
GLFieldOfView(QOpenGLFunctions_4_3_Core* functions,
const float minRadius,
const float maxRadius,
const float azimuthPosAngle,
const float azimuthNegAngle);

void UpdateParameter(const float minRadius,
const float maxRadius,
const float azimuthPosAngle,
const float azimuthNegAngle);
};


7 changes: 7 additions & 0 deletions include/glvehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,11 @@ class GLVehicle : public GLObject
{
public:
GLVehicle(QOpenGLFunctions_4_3_Core* functions, QString id, float xExtend, float zExtend);

GLVehicle(QOpenGLFunctions_4_3_Core* functions,
QString id,
QVector3D v0,
QVector3D v1,
QVector3D v2,
QVector3D v3);
};
12 changes: 12 additions & 0 deletions include/glwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "lane.h"
#include "imessagesource.h"

#include "glfieldofview.h"

#include <QOpenGLWidget>
#include <QTreeWidgetItem>
#include <QOpenGLFunctions>
Expand All @@ -35,6 +37,13 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Core

void UpdateIMessageSource(IMessageSource* msgSource);

void UpdateFOVPaint(const bool showFOV);

void UpdateFOVParam(const float minRadius,
const float maxRadius,
const float azimuthPosAngle,
const float azimuthNegAngle);

signals:
void DisplayObjectInformation(GLObject* object);
void SetTrackingEnabled(bool enable);
Expand Down Expand Up @@ -87,4 +96,7 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Core
QOpenGLShaderProgram shaderProgram_;
QMap<ObjectType, QTreeWidgetItem*>& treeNodes_;

bool showFOV_;
GLFieldOfView* objFOV_;

};
53 changes: 48 additions & 5 deletions include/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class GLWidget;
class TCPReceiver;
class FMUReceiver;
class AppConfig;
class OsiParser;
class OsiReader;
Expand All @@ -35,6 +36,8 @@ class MainWindow : public QMainWindow
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();

void LocalUpdate();

signals:
void UpdateGrid();
void UpdateLane();
Expand All @@ -47,11 +50,23 @@ class MainWindow : public QMainWindow
const QString& port,
const DataType dataType);

void FMUConnectRequested(const QString& ipAddress,
const QString& port,
const QString& fmuPath,
const DataType dataType);

void FMUConnectRequested2(const QString& ipAddress,
const QString& port,
const QString& fmuPath,
const DataType dataType);

void StartPlaybackRequested(const QString& fileName,
const DataType dataType);
const DataType dataType,
const QString& fmuPath);

void StartPlaybackRequested2(const QString& fileName,
const DataType dataType);
const DataType dataType,
const QString& fmuPath);

public slots:
void EnableExport(bool enable);
Expand Down Expand Up @@ -91,9 +106,29 @@ class MainWindow : public QMainWindow
void RBPlayback();
void RBPlayback2();

void CBDataTypeCon(int index);
void CBDataTypePlay(int index);
void CBDataTypeCon2(int index);
void CBDataTypePlay2(int index);
void ToggleShowFOV();
void ToggleShowFOV2();

void CheckBoxFMURx();
void CheckBoxFMURx2();
void LoadFMURxEdited(const QString& text);
void LoadFMURxBrowse();
void LoadFMURxEdited2(const QString& text);
void LoadFMURxBrowse2();

void CheckBoxFMUTx();
void CheckBoxFMUTx2();
void LoadFMUTxEdited(const QString& text);
void LoadFMUTxBrowse();
void LoadFMUTxEdited2(const QString& text);
void LoadFMUTxBrowse2();

void LoadFileEdited(const QString& text);
void LoadFileBrowse();

void LoadFileEdited2(const QString& text);
void LoadFileBrowse2();

Expand All @@ -112,6 +147,9 @@ class MainWindow : public QMainWindow

void CombineChannels();

void ShowFOV();
void ShowFOV2();


private:

Expand Down Expand Up @@ -184,6 +222,9 @@ class MainWindow : public QMainWindow

void ShowErrorMessage(const QString& errMsg);

void EnableShowFOV(const bool enable);
void EnableShowFOV2(const bool enable);


// Configurations
AppConfig config_;
Expand Down Expand Up @@ -211,12 +252,14 @@ class MainWindow : public QMainWindow
Ui::MainWindow *ui_;

GLWidget* glWidget_;
TCPReceiver* receiver_;
TCPReceiver* tcpReceiver_;
FMUReceiver* fmuReceiver_;
OsiReader* reader_;
OsiParser* osiparser_;

GLWidget* glWidget2_;
TCPReceiver* receiver2_;
TCPReceiver* tcpReceiver2_;
FMUReceiver* fmuReceiver2_;
OsiReader* reader2_;
OsiParser* osiparser2_;

Expand Down
Loading