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

Commit b56445c

Browse files
authored
Merge pull request #14 from Yang-Wu-Altran/master
1. Update README.md; 2. some coding improvement; 3. add lanes in sensor data visualization
2 parents e66f95a + 56d737d commit b56445c

14 files changed

+114
-104
lines changed

README.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
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")
6+
57
## General Information
68

79
Some software library dependencies are needed to run the osi-visualizer:
@@ -12,7 +14,7 @@ Some software library dependencies are needed to run the osi-visualizer:
1214
The osi-visualizer needs to use ZeroMQ libraries to complete the socket communication between different sensor / traffic / scenario simulators. Note that the C++ Bindings are required as well.
1315
* protobuf 2.6.1: https://github.com/google/protobuf
1416

15-
The required version of Open Simulation Interface (https://github.com/OpenSimulationInterface/open-simulation-interface.git) is referenced as a git submodule, so be sure to run git submodule init && git submodule update after cloning the osi-visualizer repository.
17+
The required version of [Open Simulation Interface](https://github.com/OpenSimulationInterface/open-simulation-interface.git) is referenced as a git submodule, so be sure to run `git submodule init` && `git submodule update` after cloning the osi-visualizer repository.
1618

1719
If the CMake build process does not automatically locate the required libraries, please use the usual CMake options to set the relevant CMake variables to the proper paths.
1820

@@ -32,10 +34,11 @@ Currently we strongly recommend users to use the osi-visualizer under Ubuntu Lin
3234
### From QtCreator:
3335
Open New Project -> CMakeLists.txt
3436

35-
3637
## Usage
3738
### Connection:
38-
The channel receives osi message from the network with specific IP address, Port number and data type.
39+
The channel receives osi message from the network with specific IP address and Port number, and shows up different data types.
40+
41+
![alt text](https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Connection.png "Connection Setting")
3942

4043
### Playback:
4144
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.
@@ -45,24 +48,38 @@ Example: set it to 10 ms, each message will have 10 ms more delay for playing.
4548

4649
Besides the tool provides sending out osi message to network with specific port number.
4750

51+
![alt text](https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Playback.png "Playback Setting")
52+
4853
### Save OSI Message:
49-
Log or cut out part of the osi message stream. Current the threshold is 100 osi messages. It can be saved to another osi file.
54+
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.
5055

5156

5257
## Menu options
5358
### File Menu:
54-
"Play" -> play/pause Channel 1;
59+
`Play` -> play/pause Channel 1 by default.
60+
61+
`Python Compare` -> A standalone compare tool to compare two osi message file directly. By default, it takes the playback file from these two channels. It supports flexible selecting random file as well. Just put the python scripts into folder: ./Resources/Python/ before start this tool. Then all the scripts will be shown up in the "Python Scripts" select menu. The compare script should take the two osi files' full path as arguments. The compare result can be exported to a text file by clicking the "Export" button.
5562

56-
"Python Compare" -> A standalone compare tool to compare two osi message file directly. By default, it takes the playback file from these two channels. It supports flexible selecting random file as well. Just put the python scripts into folder: ./Resources/Python/ before start this tool. Then all the scripts will be shown up in the "Python Scripts" select menu. The compare script should take the two osi files' full path as arguments. The compare result can be exported to a text file by clicking the "Export" button.
63+
`Quit` -> Quit the visualizer.
5764

5865
### View Menu:
59-
"Combine Channels" -> Config two channels' "Play/Pause' button act simultaneously, or not. It can only be checked when the channels are at the same status: both "Play" or "Pause". By default, it is unchecked.
66+
`Combine Channels` -> Config two channels' "Play/Pause" simultaneously, or not. It can only be checked when the channels are at the same status: both "Play" or "Pause". By default, it is unchecked.
6067

61-
"Show Grid" -> Show up the grid in the canvas. By default, it is checked.
68+
`Show Grid` -> Show up the grid in the canvas. By default, it is checked.
6269

63-
"Show Object details" -> Select object from the Objects Overview tree. Show up the selected object's position, velocity and acceleration in another independent dialog. By default, it is checked.
70+
`Show Object details` -> Select object from the Objects Overview tree. Show up the selected object's position, velocity and acceleration in another independent dialog. By default, it is checked.
6471

6572
The others are self-explaining.
6673

6774
## Notice
6875
When playing large osi files, try to adapt the Delta Delay. Then the tool renders smoothly.
76+
77+
78+
## Run time screen shot
79+
Channel 1 plays an osi input file and sends out the osi message to port 5564 at the same time.
80+
Channel 2 receives osi message from port 5564 and shows up on the canvas.
81+
82+
![alt text](https://github.com/OpenSimulationInterface/osi-visualizer/tree/master/Resources/Images/Demo.png "Run time screen shot")
83+
84+
85+

Resources/Images/Connection.png

8.09 KB
Loading

Resources/Images/Demo.png

298 KB
Loading

Resources/Images/Over_View.png

201 KB
Loading

Resources/Images/Playback.png

13.7 KB
Loading
File renamed without changes.
File renamed without changes.

include/glwidget.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class GLWidget : public QOpenGLWidget, protected QOpenGLFunctions_4_3_Core
5858
bool eventFilter(QObject* obj, QEvent* event);
5959

6060
private:
61-
// void Zoom(float zoom);
61+
6262
void ResetObjectTextOrientations();
6363
void RenderObject(GLObject* object);
6464
void MouseWheel(QWheelEvent* event);

include/osiparser.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class OsiParser : public QObject
3838

3939
private:
4040

41-
void ParseGroundtruth(Message& objectMessage,
42-
LaneMessage& laneMessage);
41+
void ParseGroundtruth(Message& objectMessage, LaneMessage& laneMessage);
4342

4443
void ParseGroundtruthMovingObject(Message& objectMessage,
4544
const osi::BaseMoving& baseObject,

include/osireader.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class OsiReader: public QObject, public IMessageSource
6060

6161
void SendMessageLoop();
6262

63-
void ZMQSendOutMessage(const osi::SensorData& sd);
63+
void ZMQSendOutMessage(const std::string& message);
6464

6565

6666

src/appconfig.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ AppConfig::AppConfig(QString fileName)
3232
, laneType_(LaneType::BoundaryLanes)
3333
, typeColors_()
3434

35-
, osiMsgSaveThreshold_(200)
35+
, osiMsgSaveThreshold_(1000)
3636
, srcPath_("./")
3737

3838
, configFileName_(fileName)
@@ -81,6 +81,8 @@ AppConfig::Load()
8181
lockCamera_ = root.elementsByTagName("LockCamera").at(0).toElement().text() == "1" ? true : false;
8282
laneType_ = root.elementsByTagName("LaneType").at(0).toElement().text() == "0" ? LaneType::BoundaryLanes : LaneType::CenterLanes;
8383

84+
osiMsgSaveThreshold_ = root.elementsByTagName("OSIMsgSaveThreshold").at(0).toElement().text().toInt();
85+
8486
QList<ObjectType> types = Global::GetAllObjectTypes();
8587
foreach (ObjectType type, types)
8688
{
@@ -135,6 +137,8 @@ AppConfig::Save()
135137
writer.writeTextElement("LockCamera", QString::number(lockCamera_));
136138
writer.writeTextElement("LaneType", QString::number(static_cast<int>(laneType_)));
137139

140+
writer.writeTextElement("OSIMsgSaveThreshold", QString::number(static_cast<int>(osiMsgSaveThreshold_)));
141+
138142
foreach (ObjectType key, typeColors_.keys())
139143
{
140144
writer.writeTextElement(Global::GetObjectTypeName(key), typeColors_.value(key).name());

src/glwidget.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -665,25 +665,6 @@ GLWidget::TreeItemClicked(QTreeWidgetItem* item, int column)
665665
this->update();
666666
}
667667

668-
//void
669-
//GLWidget::ZoomPlus()
670-
//{
671-
// Zoom(-20);
672-
//}
673-
//
674-
//void
675-
//GLWidget::ZoomMinus()
676-
//{
677-
// Zoom(20);
678-
//}
679-
//
680-
//void
681-
//GLWidget::Zoom(float zoom)
682-
//{
683-
// camera_->Translate(0, zoom, 0);
684-
// this->update();
685-
//}
686-
687668
void
688669
GLWidget::Connected(DataType dataType)
689670
{

src/osiparser.cpp

+77-67
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ OsiParser::ParseGroundtruth(Message& objectMessage,
162162
centerLines.append(QVector3D(-centerLine.x(), 0, centerLine.y()));
163163
}
164164

165-
QVector<QVector<QVector3D> > dummyVector;
166-
dummyVector.append(centerLines);
167-
168-
tmpLane.centerLanes= dummyVector;
165+
tmpLane.centerLanes.append(centerLines);
169166
}
170167

171168
// DRAW_LANE_BOUNDARIES
@@ -291,7 +288,8 @@ OsiParser::ParseSensorData(Message& objectMessage,
291288
for (int i = 0; i < currentSensorData_.object_size(); ++i)
292289
{
293290
osi::DetectedObject sensorDataObject = currentSensorData_.object(i);
294-
if(sensorDataObject.model_internal_object().is_seen()){
291+
if(sensorDataObject.model_internal_object().is_seen())
292+
{
295293

296294
ObjectType objectType = GetObjectTypeFromHighestProbability(sensorDataObject.class_probability());
297295

@@ -306,82 +304,94 @@ OsiParser::ParseSensorData(Message& objectMessage,
306304
}
307305
}
308306

309-
310-
//TODO: expand SENSORDATA visualization to display lanes and signs and stuff
311-
312-
/*for (int i = 0; i < sensorData.traffic_sign_size(); ++i)
313-
{
314-
osi::DetectedTrafficSign sensorDataSign = sensorData.traffic_sign(i);
315-
osi::TrafficSign signToDisplay;
316-
317-
double highestProbCandidate = -1.0f;
318-
int signToDisplayID;
319-
320-
for(int j = 0; j < sensorDataSign.candidate_sign_size(); ++i)
307+
// for (int i = 0; i < currentSensorData_.traffic_sign_size(); ++i)
308+
// {
309+
// osi::DetectedTrafficSign sensorDataSign = currentSensorData_.traffic_sign(i);
310+
// osi::TrafficSign signToDisplay;
311+
//
312+
// double highestProbCandidate = -1.0f;
313+
// int signToDisplayID;
314+
//
315+
// for(int j = 0; j < sensorDataSign.candidate_sign_size(); ++j)
316+
// {
317+
//
318+
// if(sensorDataSign.candidate_sign(j).candidate_probability() > highestProbCandidate)
319+
// {
320+
// signToDisplayID = j;
321+
// }
322+
// }
323+
//
324+
// signToDisplay = sensorDataSign.mutable_candidate_sign(signToDisplayID)->sign();
325+
//
326+
// QString idStr = QString::number(signToDisplay.id().value());
327+
//
328+
// ParseSensorDataStationaryObject(objectMessage, signToDisplay.base(), ObjectType::TrafficSign, idStr);
329+
// }
330+
331+
for (int i = 0; i < currentSensorData_.lane_size(); ++i)
332+
{
333+
osi::DetectedLane lane = currentSensorData_.lane(i);
334+
if(lane.existence_probability() == 1)
321335
{
336+
LaneStruct tmpLane;
337+
tmpLane.id = lane.lane().id().value();
322338

323-
if(sensorDataSign.candidate_sign(j).candidate_probability() > highestProbCandidate)
339+
// DRAW_CENTER_LINES
324340
{
325-
signToDisplayID = j;
326-
}
327-
}
328-
329-
signToDisplay = sensorDataSign.mutable_candidate_sign(signToDisplayID)->sign();
330-
331-
QString idStr = QString::number(signToDisplay.id().value());
332-
333-
ParseSensorDataStationaryObject(objectMessage, signToDisplay.base(), TrafficSign, idStr);
334-
335-
}
336-
337-
for (int i = 0; i < sensorData.lane_size(); ++i)
338-
{
339-
osi::Lane lane = sensorData.lane(i).lane();
340-
laneMessage->ids.append(lane.id().value());
341-
341+
// lane <dummyVector <centerLines <position> > >
342+
QVector<QVector3D> centerLines;
343+
for (int a = 0; a < lane.lane().center_line_size(); ++a)
344+
{
345+
osi::Vector3d centerLine = lane.lane().center_line(a);
346+
if(centerLine.x() != 0 || centerLine.y() != 0 || centerLine.z() != 0)
347+
{
348+
centerLines.append(QVector3D(centerLine.x(), 0, -centerLine.y()));
349+
}
350+
else
351+
{
352+
tmpLane.centerLanes.append(centerLines);
353+
centerLine.Clear();
354+
}
355+
}
342356

343-
if (DRAW_CENTER_LINES)
344-
{
345-
// lane <dummyVector <centerLines <position> > >
346-
QVector<QVector3D> centerLines;
347-
for (int a = 0; a < lane.center_line_size(); a++)
348-
{
349-
osi::Vector3d centerLine = lane.center_line(a);
350-
//necessary because of differences between coordinate frames of OSI and graphical representation
351-
centerLines.append(QVector3D(centerLine.x(), 0, -centerLine.y()));
357+
tmpLane.centerLanes.append(centerLines);
352358
}
353359

354-
QVector<QVector<QVector3D> > dummyVector;
355-
dummyVector.append(centerLines);
356-
357-
laneMessage->lanes.append(dummyVector);
358-
}
359-
360-
if (DRAW_LANE_BOUNDARIES)
361-
{
362-
// lanes <laneBoundaries <boundaryLines <position> > >
363-
QVector<QVector<QVector3D>> laneBoundaries;
364-
365-
for (int b = 0; b < lane.lane_boundary_size(); b++)
360+
// DRAW_LANE_BOUNDARIES
366361
{
367-
osi::LaneBoundary laneBoundary = lane.lane_boundary(b);
368-
QVector<QVector3D> boundaryLines;
362+
// lanes <laneBoundaries <boundaryLines <position> > >
363+
QVector<QVector<QVector3D>> laneBoundaries;
369364

370-
for (int c = 0; c < laneBoundary.boundary_line_size(); c++)
365+
for (int b = 0; b < lane.lane().lane_boundary_size(); ++b)
371366
{
372-
osi::BoundaryPoint boundaryLine = laneBoundary.boundary_line(c);
373-
osi::Vector3d position = boundaryLine.position();
374-
375-
//necessary because of differences between coordinate frames of OSI and graphical representation
376-
boundaryLines.append(QVector3D(position.x(), 0, -position.y()));
367+
osi::LaneBoundary laneBoundary = lane.lane().lane_boundary(b);
368+
QVector<QVector3D> boundaryLines;
369+
370+
for (int c = 0; c < laneBoundary.boundary_line_size(); ++c)
371+
{
372+
osi::BoundaryPoint boundaryLine = laneBoundary.boundary_line(c);
373+
osi::Vector3d position = boundaryLine.position();
374+
375+
if(position.x() != 0 || position.y() != 0 || position.z() != 0)
376+
{
377+
boundaryLines.append(QVector3D(position.x(), 0, -position.y()));
378+
}
379+
else
380+
{
381+
laneBoundaries.append(boundaryLines);
382+
boundaryLines.clear();
383+
}
384+
}
385+
386+
laneBoundaries.append(boundaryLines);
377387
}
378388

379-
laneBoundaries.append(boundaryLines);
389+
tmpLane.boundaryLanes= laneBoundaries;
380390
}
381391

382-
laneMessage->lanes.append(laneBoundaries);
392+
laneMessage.append(tmpLane);
383393
}
384-
}*/
394+
}
385395
}
386396

387397

src/osireader.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ OsiReader::SliderValueChanged(int newValue)
168168
{
169169
uint64_t curStamp = GetTimeStampInNanoSecond(osiSD);
170170
MessageSendout(osiSD, defaultDatatype_);
171-
ZMQSendOutMessage(osiSD);
171+
ZMQSendOutMessage(str_line);
172172
// update slider value in millisecond level
173173
int sliderValue = curStamp / 1000000;
174174
UpdateSliderValue(sliderValue);
@@ -369,7 +369,7 @@ OsiReader::SendMessageLoop()
369369
preTimeStamp = curStamp;
370370

371371
MessageSendout(osiSD, defaultDatatype_);
372-
ZMQSendOutMessage(osiSD);
372+
ZMQSendOutMessage(str_line);
373373
// update slider value in millisecond level
374374
int sliderValue = (curStamp - firstTimeStamp) / 1000000;
375375
UpdateSliderValue(sliderValue);
@@ -413,11 +413,10 @@ OsiReader::SendMessageLoop()
413413
}
414414

415415
void
416-
OsiReader::ZMQSendOutMessage(const osi::SensorData& sd)
416+
OsiReader::ZMQSendOutMessage(const std::string& message)
417417
{
418418
if(enableSendOut_ && zmqPublisher_.connected())
419419
{
420-
std::string message = sd.SerializeAsString();
421420
zmq::message_t zmqMessage(message.size());
422421
memcpy(zmqMessage.data(), message.data(), message.size());
423422
zmqPublisher_.send(zmqMessage);

0 commit comments

Comments
 (0)