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

Commit 510453b

Browse files
haoyuanyingjdsika
authored andcommitted
new release osi-visualizer (#23)
* add field of view and fmu communicate support * upgrade to osi-3.0 * rm fmu hard code; change default messasge save threshold; display receive message time stamp; add scroll bar for the config info. * segmentation fault. add trafficsign/trafficlight/roadmarking/laneboundary possibility * bug fix: refresh old buffer when playback restart * keep the data type consistant through the whole program; update support data type to: SensorData and SensorView; update README.md * Fixed JModelica link error * add submodule osi-sensor-model-packaging * remove osi-sensor-model-packing submodule, reason: open-simulation-interface recursively included, logically, referencing to osi-sensor-model-packing IMHO is incorrect. * cmath fix for M_PI * cmath fix +1 * Fixed FMILib in CMake for local building
1 parent b56445c commit 510453b

34 files changed

+4059
-1750
lines changed

.gitmodules

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
[submodule "open-simulation-interface"]
22
path = open-simulation-interface
33
url = https://github.com/OpenSimulationInterface/open-simulation-interface.git
4+
5+
[submodule "osi-sensor-model-packaging"]
6+
path = osi-sensor-model-packaging
7+
url = https://github.com/OpenSimulationInterface/osi-sensor-model-packaging.git
8+
[submodule "osi-sensor-model-packaging/examples"]
9+
path = osi-sensor-model-packaging/examples
10+
url = http://www.github.com/OpenSimulationInterface/osi-sensor-model-packaging.git

CMakeLists.txt

+27-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ set(CMAKE_AUTOUIC ON)
1010

1111
find_package(Qt5 COMPONENTS Core Gui OpenGL Widgets Xml Network REQUIRED)
1212

13+
find_path(
14+
FMILIB_INCLUDE_DIRS
15+
fmilib.h
16+
HINTS /usr/include/fmi-library /usr/include /usr/local/include/fmi-library /usr/local/include
17+
)
18+
19+
find_library(
20+
FMILIB_LIBRARY
21+
fmilib_shared
22+
HINTS /usr/lib/fmi-library /usr/lib /usr/local/lib/fmi-library /usr/local/lib
23+
)
24+
1325
set(SOURCES
1426
src/main.cpp
1527
src/mainwindow.cpp
@@ -31,6 +43,9 @@ set(SOURCES
3143
src/gltrafficsign.cpp
3244
src/qrc_resources.cpp
3345
src/osiparser.cpp
46+
src/glfieldofview.cpp
47+
src/fmureceiver.cpp
48+
src/utils.cpp
3449
)
3550

3651
set(HEADERS
@@ -55,9 +70,17 @@ set(HEADERS
5570
include/glpoint.h
5671
include/gltrafficsign.h
5772
include/osiparser.h
73+
include/glfieldofview.h
74+
include/fmureceiver.h
75+
include/utils.h
76+
)
77+
78+
79+
include_directories(
80+
${CMAKE_CURRENT_LIST_DIR}/include
81+
${FMILIB_INCLUDE_DIRS}
5882
)
5983

60-
include_directories(include)
6184

6285
add_executable(${PROJECT_NAME}
6386
${HEADERS}
@@ -72,7 +95,9 @@ target_link_libraries(${PROJECT_NAME}
7295
Qt5::OpenGL
7396
Qt5::Network
7497

75-
open_simulation_interface_pic
98+
open_simulation_interface
99+
${FMILIB_LIBRARY}
76100
protobuf
77101
zmq
78102
)
103+

Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
FROM ubuntu:latest
22

33
RUN mkdir -p /project
4-
RUN apt-get update && apt-get install -y git vim unzip zip cmake gcc g++ qtbase5-dev libprotobuf-dev protobuf-compiler libzmq3-dev
4+
RUN apt-get update && apt-get install -y git vim unzip zip cmake gcc g++ qtbase5-dev libprotobuf-dev protobuf-compiler libzmq3-dev wget
5+
RUN mkdir -p /build
6+
WORKDIR /build
7+
RUN wget https://jmodelica.org/fmil/FMILibrary-2.0.3-src.zip && unzip FMILibrary-2.0.3-src.zip && mkdir build-fmil && cd build-fmil && cmake -DFMILIB_INSTALL_PREFIX=/usr/local ../FMILibrary-2.0.3 && make install
58

69
VOLUME [ "/project"]
710
WORKDIR /project

README.md

+19-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
Visualization tool for OSI messages. This software serves as visualization tool for the current implementation of the [OSI (Open Simulation Interface)](https://github.com/OpenSimulationInterface/open-simulation-interface) mesages.The osi-visualizer supports to visualize the OSI GroundTruth and SensorData messages. It supports two independent visual channels with two different input types (file and network stream).
44

5-
![alt text](https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Over_View.png "Over View")
5+
<div align="center">
6+
<img src="https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Over_View.png"><br><br>
7+
</div>
68

79
## General Information
810

@@ -38,7 +40,9 @@ Open New Project -> CMakeLists.txt
3840
### Connection:
3941
The channel receives osi message from the network with specific IP address and Port number, and shows up different data types.
4042

41-
![alt text](https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Connection.png "Connection Setting")
43+
<div align="center">
44+
<img src="https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Connection.png"><br><br>
45+
</div>
4246

4347
### Playback:
4448
The channel receives osi message from the loaded file. The tool will check a header file of same name with a extension: .txth. If it doesn't exist, the tool will create one automatically for the first time.
@@ -48,7 +52,16 @@ Example: set it to 10 ms, each message will have 10 ms more delay for playing.
4852

4953
Besides the tool provides sending out osi message to network with specific port number.
5054

51-
![alt text](https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Playback.png "Playback Setting")
55+
<div align="center">
56+
<img src="https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Playback.png"><br><br>
57+
</div>
58+
59+
### Show Field of View:
60+
Show field of view for sensors, like Lidar, on the grid. User can set minimum range, maximum range, azimuth positive angle and azimuth negative angle.
61+
62+
<div align="center">
63+
<img src="https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/FOV.png"><br><br>
64+
</div>
5265

5366
### Save OSI Message:
5467
Log or cut out part of the osi message stream and save it to another file. By default the threshold is 1000 osi messages. User can change this threshold in the config file.
@@ -79,7 +92,9 @@ When playing large osi files, try to adapt the Delta Delay. Then the tool render
7992
Channel 1 plays an osi input file and sends out the osi message to port 5564 at the same time.
8093
Channel 2 receives osi message from port 5564 and shows up on the canvas.
8194

82-
![alt text](https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Demo.png "Run time screen shot")
95+
<div align="center">
96+
<img src="https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Demo.png"><br><br>
97+
</div>
8398

8499

85100

Resources/Images/Connection.png

1.04 KB
Loading

Resources/Images/Demo.png

16.8 KB
Loading

Resources/Images/FOV.png

8.58 KB
Loading

Resources/Images/Playback.png

3.43 KB
Loading

include/appconfig.h

+19
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,39 @@ class AppConfig
2121
QString ch1IPAddress_;
2222
QString ch1PortNum_;
2323
DataType ch1DataType_;
24+
bool ch1FMURxCheck_;
25+
QString ch1LoadFMURx_;
2426
QString ch1LoadFile_;
2527
DataType ch1PlaybackDataType_;
2628
int ch1DeltaDelay_;
2729
bool ch1EnableSendOut_;
2830
QString ch1SendOutPortNum_;
31+
bool ch1FMUTxCheck_;
32+
QString ch1LoadFMUTx_;
33+
bool ch1ShowFOV_;
34+
float ch1MinRadius_;
35+
float ch1MaxRadius_;
36+
float ch1AzimuthPos_;
37+
float ch1AzimuthNeg_;
38+
2939

3040
QString ch2IPAddress_;
3141
QString ch2PortNum_;
3242
DataType ch2DataType_;
43+
bool ch2FMURxCheck_;
44+
QString ch2LoadFMURx_;
3345
QString ch2LoadFile_;
3446
DataType ch2PlaybackDataType_;
3547
int ch2DeltaDelay_;
3648
bool ch2EnableSendOut_;
3749
QString ch2SendOutPortNum_;
50+
bool ch2FMUTxCheck_;
51+
QString ch2LoadFMUTx_;
52+
bool ch2ShowFOV_;
53+
float ch2MinRadius_;
54+
float ch2MaxRadius_;
55+
float ch2AzimuthPos_;
56+
float ch2AzimuthNeg_;
3857

3958
bool combineChannel_;
4059
bool showGrid_;

include/fmureceiver.h

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
///
2+
/// @file
3+
/// @copyright Copyright (C) 2017, Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
4+
///
5+
/// @brief
6+
///
7+
8+
9+
10+
#pragma once
11+
12+
#include <QtConcurrent/QtConcurrent>
13+
14+
#include <string>
15+
16+
#include "osi_sensordata.pb.h"
17+
#include "imessagesource.h"
18+
#include "types.h"
19+
20+
21+
extern "C" {
22+
#include <JM/jm_portability.h>
23+
#include <fmilib.h>
24+
}
25+
26+
/* The following names come from FMU modelDescription.in.xml */
27+
#define FMI_SENDER_NAME "sender"
28+
#define FMI_RECEIVER_NAME "receiver"
29+
#define FMI_ADDRESS_NAME "address"
30+
#define FMI_PORT_NAME "port"
31+
32+
#define FMI_DATA_OUT_BASELO_NAME "OSMPSensorDataOut.base.lo"
33+
#define FMI_DATA_OUT_BASEHI_NAME "OSMPSensorDataOut.base.hi"
34+
#define FMI_DATA_OUT_SIZE_NAME "OSMPSensorDataOut.size"
35+
36+
/* local index defines */
37+
#define FMI_INTEGER_SENSORDATA_OUT_BASELO_IDX 0 // correspond to FMI_DATA_OUT_BASELO_NAME
38+
#define FMI_INTEGER_SENSORDATA_OUT_BASEHI_IDX 1 // correspond to FMI_DATA_OUT_BASEHI_NAME
39+
#define FMI_INTEGER_SENSORDATA_OUT_SIZE_IDX 2 // correspond to FMI_DATA_OUT_SIZE_NAME
40+
#define FMI_INTEGER_LAST_OUT_IDX FMI_INTEGER_SENSORDATA_OUT_SIZE_IDX
41+
#define FMI_INTEGER_OUT_VARS (FMI_INTEGER_LAST_OUT_IDX + 1)
42+
43+
class FMUReceiver: public QObject, public IMessageSource
44+
{
45+
Q_OBJECT
46+
47+
public:
48+
FMUReceiver();
49+
50+
signals:
51+
void Connected(DataType dataType);
52+
void Disconnected(const QString& message = "");
53+
void UpdateSliderTime(int sliderValue);
54+
void MessageSDReceived(const osi3::SensorData& sd);
55+
void MessageSVReceived(const osi3::SensorView& sv);
56+
57+
public slots:
58+
void DisconnectRequested();
59+
void ConnectRequested(const QString& ipAddress,
60+
const QString& port,
61+
const QString& fmuPath,
62+
DataType dataType);
63+
64+
private:
65+
66+
void ReceiveLoop();
67+
68+
bool isRunning_;
69+
bool isThreadTerminated_;
70+
DataType currentDataType_;
71+
72+
73+
// FMU interface
74+
fmi2_import_t* fmu_;
75+
fmi2_callback_functions_t callBackFunctions_;
76+
jm_callbacks callbacks_;
77+
fmi_import_context_t* context_;
78+
79+
jm_status_enu_t jmStatus_;
80+
fmi2_status_t fmiStatus_;
81+
82+
fmi2_real_t tStart_;
83+
fmi2_real_t tEnd_;
84+
fmi2_real_t tCurrent_;
85+
fmi2_real_t hStep_;
86+
87+
std::string ip_;
88+
std::string port_;
89+
std::string FMUPath_;
90+
std::string tmpPath_;
91+
enum class LogLevel
92+
{
93+
Warn,
94+
Debug
95+
};
96+
LogLevel logLevel_;
97+
std::string currentBuffer_;
98+
fmi2_value_reference_t vr_[FMI_INTEGER_OUT_VARS];
99+
100+
// initialize fmu wrapper specific logger, create fmi import context and check fmi version
101+
bool initializeFMUWrapper();
102+
// import fmu binary file
103+
bool importFMU();
104+
// setup and initialize FMU
105+
bool initializeFMU();
106+
// protobuf accessors
107+
template<typename T> bool get_fmi_sensor_data_in(T& data);
108+
};
109+
110+

include/glfieldofview.h

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
3+
4+
5+
#pragma once
6+
#include "globject.h"
7+
8+
class GLFieldOfView : public GLObject
9+
{
10+
public:
11+
GLFieldOfView(QOpenGLFunctions_4_3_Core* functions,
12+
const float minRadius,
13+
const float maxRadius,
14+
const float azimuthPosAngle,
15+
const float azimuthNegAngle);
16+
17+
void UpdateParameter(const float minRadius,
18+
const float maxRadius,
19+
const float azimuthPosAngle,
20+
const float azimuthNegAngle);
21+
};
22+
23+

include/glvehicle.h

+7
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ class GLVehicle : public GLObject
1212
{
1313
public:
1414
GLVehicle(QOpenGLFunctions_4_3_Core* functions, QString id, float xExtend, float zExtend);
15+
16+
GLVehicle(QOpenGLFunctions_4_3_Core* functions,
17+
QString id,
18+
QVector3D v0,
19+
QVector3D v1,
20+
QVector3D v2,
21+
QVector3D v3);
1522
};

include/glwidget.h

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "lane.h"
1515
#include "imessagesource.h"
1616

17+
#include "glfieldofview.h"
18+
1719
#include <QOpenGLWidget>
1820
#include <QTreeWidgetItem>
1921
#include <QOpenGLFunctions>
@@ -35,6 +37,13 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Core
3537

3638
void UpdateIMessageSource(IMessageSource* msgSource);
3739

40+
void UpdateFOVPaint(const bool showFOV);
41+
42+
void UpdateFOVParam(const float minRadius,
43+
const float maxRadius,
44+
const float azimuthPosAngle,
45+
const float azimuthNegAngle);
46+
3847
signals:
3948
void DisplayObjectInformation(GLObject* object);
4049
void SetTrackingEnabled(bool enable);
@@ -87,4 +96,7 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Core
8796
QOpenGLShaderProgram shaderProgram_;
8897
QMap<ObjectType, QTreeWidgetItem*>& treeNodes_;
8998

99+
bool showFOV_;
100+
GLFieldOfView* objFOV_;
101+
90102
};

0 commit comments

Comments
 (0)