-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support new message types #12
base: master
Are you sure you want to change the base?
Changes from 4 commits
eed9c37
4d9c037
86c684d
1503c7f
121a648
7564365
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,9 @@ | |
#include <iostream> | ||
#include <QFileInfo> | ||
|
||
Player::Player() : | ||
m_referee(NULL), | ||
m_vision(NULL), | ||
m_legacyVision(NULL) | ||
Player::Player() : m_referee(NULL), | ||
m_vision(NULL), | ||
m_legacyVision(NULL) | ||
{ | ||
// create referee socket | ||
Q_ASSERT(m_referee == NULL); | ||
|
@@ -54,28 +53,33 @@ Player::~Player() | |
packets.clear(); | ||
} | ||
|
||
bool Player::load(const QString& filename, int& maxFrame, double& duration) { | ||
bool Player::load(const QString &filename, int &maxFrame, double &duration) | ||
{ | ||
QFileInfo fileInfo(filename); | ||
|
||
bool compressed = false; | ||
|
||
if (fileInfo.suffix() == "gz") { | ||
if (fileInfo.suffix() == "gz") | ||
{ | ||
compressed = true; | ||
} | ||
|
||
LogFile file(filename, compressed); | ||
|
||
if (!file.openRead()) { | ||
if (!file.openRead()) | ||
{ | ||
return false; | ||
} | ||
|
||
qDeleteAll(packets); | ||
packets.clear(); | ||
|
||
for (;;) { | ||
Frame* packet = new Frame; | ||
for (;;) | ||
{ | ||
Frame *packet = new Frame; | ||
|
||
if (!file.readMessage(packet->data, packet->time, packet->type)) { | ||
if (!file.readMessage(packet->data, packet->time, packet->type)) | ||
{ | ||
delete packet; | ||
break; | ||
} | ||
|
@@ -89,8 +93,9 @@ bool Player::load(const QString& filename, int& maxFrame, double& duration) { | |
} | ||
|
||
bool Player::start(int position) | ||
{ | ||
if (position > packets.size() - 1) { | ||
{ | ||
if (position > packets.size() - 1) | ||
{ | ||
return false; | ||
} | ||
|
||
|
@@ -113,29 +118,54 @@ bool Player::good() | |
return packets.size() > 0; | ||
} | ||
|
||
void Player::sendMessage(const Frame* packet) | ||
void Player::sendMessage(const Frame *packet) | ||
{ | ||
RoboCup2014Legacy::Wrapper::SSL_WrapperPacket legacyVisionPacket; | ||
SSL_Referee refereePacket; | ||
|
||
if (packet->type == MESSAGE_BLANK) { | ||
if (packet->type == MESSAGE_BLANK) | ||
{ | ||
// ignore | ||
} else if (packet->type == MESSAGE_UNKNOWN) { | ||
} | ||
else if (packet->type == MESSAGE_UNKNOWN) | ||
{ | ||
// OK, let's try to figure this out by parsing the message | ||
if (refereePacket.ParseFromArray(packet->data.data(), packet->data.size())) { | ||
if (refereePacket.ParseFromArray(packet->data.data(), packet->data.size())) | ||
{ | ||
m_referee->writeData(packet->data); | ||
} else if (legacyVisionPacket.ParseFromArray(packet->data.data(), packet->data.size())) { | ||
} | ||
else if (legacyVisionPacket.ParseFromArray(packet->data.data(), packet->data.size())) | ||
{ | ||
m_legacyVision->writeData(packet->data); | ||
} else { | ||
} | ||
else | ||
{ | ||
std::cout << "Error unsupported or corrupt packet found in log file!" << std::endl; | ||
} | ||
} else if (packet->type == MESSAGE_SSL_VISION_2010) { | ||
} | ||
else if (packet->type == MESSAGE_SSL_VISION_2010) | ||
{ | ||
m_legacyVision->writeData(packet->data); | ||
} else if (packet->type == MESSAGE_SSL_REFBOX_2013) { | ||
} | ||
else if (packet->type == MESSAGE_SSL_REFBOX_2013) | ||
{ | ||
m_referee->writeData(packet->data); | ||
} else if (packet->type == MESSAGE_SSL_VISION_2014) { | ||
} | ||
else if (packet->type == MESSAGE_SSL_VISION_2014) | ||
{ | ||
m_vision->writeData(packet->data); | ||
} | ||
else if (packet->type == MESSAGE_SSL_VISION_TRACKER_2020) | ||
{ | ||
m_vision->writeData(packet->data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong. Those packages should go to a different port. See https://ssl.robocup.org/league-software/#standard-network-parameters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you! It was my lack of study ... |
||
} else { | ||
} | ||
else if (packet->type == MESSAGE_SSL_INDEX_2021) | ||
{ | ||
m_index->writeData(packet->data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not useful. The index should not be send to the network. It is only useful for reading the file. |
||
} | ||
|
||
else | ||
{ | ||
std::cout << "Error unsupported message type found in log file!" << std::endl; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also improve this message?
|
||
} | ||
} | ||
|
@@ -147,12 +177,14 @@ void Player::run() | |
const qint64 startTime = Timer::systemTime(); | ||
const qint64 referenceTime = packets.at(m_currentFrame)->time; | ||
|
||
while (m_mayRun && ++m_currentFrame < packets.size() && this->isRunning()) { | ||
Frame* packet = packets.at(m_currentFrame); | ||
while (m_mayRun && ++m_currentFrame < packets.size() && this->isRunning()) | ||
{ | ||
Frame *packet = packets.at(m_currentFrame); | ||
|
||
qint64 sleepTime = ((packet->time - referenceTime) - (Timer::systemTime() - startTime)) / 1000; | ||
|
||
if (sleepTime > 0) { | ||
if (sleepTime > 0) | ||
{ | ||
QThread::currentThread()->usleep(sleepTime); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ class Player : public QThread | |
Network* m_referee; | ||
Network* m_vision; | ||
Network* m_legacyVision; | ||
Network* m_index; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. index is not sent via network. Have you mixed things up? Shouldn't there be a Network instance for visionTracker? 🤔 |
||
bool m_mayRun; | ||
int m_currentFrame; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are spaces missing ;)