本文整理汇总了C++中imc::Message类的典型用法代码示例。如果您正苦于以下问题:C++ Message类的具体用法?C++ Message怎么用?C++ Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dispatchReply
//! Dispatch message to the message bus in reply to another
//! message.
//! @param[in] original original message.
//! @param[in] msg message reference.
//! @param[in] flags bitfield with flags (see Tasks::DispatchFlags).
void
dispatchReply(const IMC::Message& original, IMC::Message& msg, unsigned int flags = 0)
{
msg.setDestination(original.getSource());
msg.setDestinationEntity(original.getSourceEntity());
dispatch(msg, flags);
}
示例2:
static void
sendMsg(IMC::Message& msg, UDPSocket& sock, Address& dest, int port)
{
DUNE::Utils::ByteBuffer bb;
msg.setTimeStamp();
IMC::Packet::serialize(&msg, bb);
sock.write((const uint8_t*)bb.getBuffer(), msg.getSerializationSize(), dest, port);
msg.toText(std::cout);
}
示例3: l
void
MessageMonitor::updateMessage(const IMC::Message* msg)
{
ScopedMutex l(m_mutex);
IMC::Message* tmsg = msg->clone();
unsigned key = tmsg->getId() << 24 | tmsg->getSubId() << 8 | tmsg->getSourceEntity();
if (m_msgs[key])
delete m_msgs[key];
m_msgs[key] = tmsg;
}
示例4: sizeof
void
sendMessage(IMC::Message& msg)
{
uint16_t rv = IMC::Packet::serialize(&msg, (uint8_t*)g_buffer, sizeof(g_buffer));
g_sock.write(g_buffer, rv, g_addr, g_port);
msg.toText(std::cerr);
}
示例5: l
void
MessageMonitor::updateMessage(const IMC::Message* msg)
{
ScopedMutex l(m_mutex);
if (msg->getId() == DUNE_IMC_POWERCHANNELSTATE)
updatePowerChannel(static_cast<const IMC::PowerChannelState*>(msg));
IMC::Message* tmsg = msg->clone();
unsigned key = tmsg->getId() << 24 | tmsg->getSubId() << 8 | tmsg->getSourceEntity();
if (m_msgs[key])
delete m_msgs[key];
m_msgs[key] = tmsg;
}
示例6: if
void
GraphicsScene::handleInputData(void)
{
while (m_sock->hasPendingDatagrams())
{
m_dgram.resize(m_sock->pendingDatagramSize());
m_sock->readDatagram(m_dgram.data(), m_dgram.size());
IMC::Message* msg = IMC::Packet::deserialize((uint8_t*)m_dgram.data(), m_dgram.size());
if (msg == 0)
continue;
if (msg->getId() == DUNE_IMC_COMPRESSEDIMAGE)
{
++m_fps;
IMC::CompressedImage* img = static_cast<IMC::CompressedImage*>(msg);
QPixmap pix;
pix.loadFromData((uchar*)img->data.data(), img->data.size(), "JPEG");
QTransform t;
pix = pix.transformed(t.rotate(m_rotate));
m_item.setPixmap(pix);
setMinimumSize(pix.width() + c_pad, pix.height() + c_pad);
if (m_grid)
{
m_vline->setLine(0, pix.height() / 2, pix.width(), pix.height() / 2);
m_hline->setLine(pix.width() / 2, 0, pix.width() / 2, pix.height());
}
}
else if (msg->getId() == DUNE_IMC_EULERANGLES)
{
IMC::EulerAngles* ang = static_cast<IMC::EulerAngles*>(msg);
// QString str("Roll: %0.2f | Pitch: %0.2f");
// m_text.setText(str.arg(Angles::degrees(ang->roll), Angles::degrees(ang->pitch)));
}
}
}
示例7: dest
int
main(int argc, char** argv)
{
if (argc < 4)
{
fprintf(stderr, "Usage: %s <destination host> <destination port> <abbrev> [arguments]\n", argv[0]);
return 1;
}
Address dest(argv[1]);
// Parse port.
unsigned port = 0;
if (!castLexical(argv[2], port))
{
fprintf(stderr, "ERROR: invalid port '%s'\n", argv[2]);
return 1;
}
if (port > 65535)
{
fprintf(stderr, "ERROR: invalid port '%s'\n", argv[2]);
return 1;
}
IMC::Message* msg = NULL;
if (strcmp(argv[3], "Heartbeat") == 0)
{
IMC::Heartbeat* tmsg = new IMC::Heartbeat;
msg = tmsg;
}
if (strcmp(argv[3], "RestartSystem") == 0)
{
IMC::RestartSystem* tmsg = new IMC::RestartSystem;
msg = tmsg;
}
else if (strcmp(argv[3], "Sms") == 0)
{
IMC::Sms* tmsg = new IMC::Sms;
tmsg->number = argv[4];
tmsg->timeout = atoi(argv[5]);
tmsg->contents = argv[6];
msg = tmsg;
}
else if (strcmp(argv[3], "EntityState") == 0)
{
IMC::EntityState* tmsg = new IMC::EntityState;
msg = tmsg;
tmsg->setSourceEntity(atoi(argv[4]));
tmsg->state = atoi(argv[5]);
}
else if (strcmp(argv[3], "EntityActivationState") == 0)
{
IMC::EntityActivationState* tmsg = new IMC::EntityActivationState;
msg = tmsg;
tmsg->setSourceEntity(atoi(argv[4]));
tmsg->state = IMC::EntityActivationState::EAS_ACTIVE;
}
else if (strcmp(argv[3], "MagneticField") == 0)
{
IMC::MagneticField* tmsg = new IMC::MagneticField;
msg = tmsg;
tmsg->setSourceEntity(atoi(argv[4]));
tmsg->x = atof(argv[5]);
tmsg->y = atof(argv[6]);
tmsg->z = atof(argv[7]);
}
else if (strcmp(argv[3], "DataSanity") == 0)
{
IMC::DataSanity* tmsg = new IMC::DataSanity;
msg = tmsg;
tmsg->setSourceEntity(atoi(argv[4]));
tmsg->sane = atoi(argv[5]);
}
else if (strcmp(argv[3], "MonitorEntityState") == 0)
{
IMC::MonitorEntityState* tmsg = new IMC::MonitorEntityState;
msg = tmsg;
tmsg->command = atoi(argv[4]);
if (argc >= 6)
tmsg->entities = argv[5];
}
else if (strcmp(argv[3], "Abort") == 0)
{
msg = new IMC::Abort;
}
else if (strcmp(argv[3], "LoggingControl") == 0)
{
IMC::LoggingControl* tmsg = new IMC::LoggingControl;
msg = tmsg;
tmsg->op = atoi(argv[4]);
tmsg->name = argv[5];
}
else if (strcmp(argv[3], "CacheControl") == 0)
{
IMC::CacheControl* tmsg = new IMC::CacheControl;
msg = tmsg;
tmsg->op = atoi(argv[4]);
}
//.........这里部分代码省略.........
示例8: extractPosition
Duration::ManeuverDuration::const_iterator
Duration::parse(const std::vector<IMC::PlanManeuver*>& nodes,
const IMC::EstimatedState* state)
{
Position pos;
extractPosition(state, pos);
std::vector<IMC::PlanManeuver*>::const_iterator itr = nodes.begin();
for (; itr != nodes.end(); ++itr)
{
if ((*itr)->data.isNull())
return m_durations.end();
IMC::Message* msg = (*itr)->data.get();
float last_duration = -1.0;
if (m_accum_dur != NULL)
{
if (m_accum_dur->size())
last_duration = m_accum_dur->getLastDuration();
}
Memory::clear(m_accum_dur);
m_accum_dur = new AccumulatedDurations(last_duration);
bool parsed = false;
switch (msg->getId())
{
case DUNE_IMC_GOTO:
parsed = parse(static_cast<IMC::Goto*>(msg), pos);
break;
case DUNE_IMC_STATIONKEEPING:
parsed = parse(static_cast<IMC::StationKeeping*>(msg), pos);
break;
case DUNE_IMC_LOITER:
parsed = parse(static_cast<IMC::Loiter*>(msg), pos);
break;
case DUNE_IMC_FOLLOWPATH:
parsed = parse(static_cast<IMC::FollowPath*>(msg), pos);
break;
case DUNE_IMC_ROWS:
parsed = parse(static_cast<IMC::Rows*>(msg), pos);
break;
case DUNE_IMC_YOYO:
parsed = parse(static_cast<IMC::YoYo*>(msg), pos);
break;
case DUNE_IMC_ELEVATOR:
parsed = parse(static_cast<IMC::Elevator*>(msg), pos);
break;
case DUNE_IMC_POPUP:
parsed = parse(static_cast<IMC::PopUp*>(msg), pos);
break;
case DUNE_IMC_COMPASSCALIBRATION:
parsed = parse(static_cast<IMC::CompassCalibration*>(msg), pos);
break;
default:
parsed = false;
break;
}
if (!parsed)
{
if (m_durations.empty() || itr == nodes.begin())
return m_durations.end();
// return the duration from the previously computed maneuver
ManeuverDuration::const_iterator dtr;
dtr = m_durations.find((*(--itr))->maneuver_id);
if (dtr->second.empty())
return m_durations.end();
return dtr;
}
std::pair<std::string, std::vector<float> > ent((*itr)->maneuver_id,
m_accum_dur->vec);
m_durations.insert(ent);
}
Memory::clear(m_accum_dur);
return m_durations.find(nodes.back()->maneuver_id);
}
示例9: lsf
int
main(int32_t argc, char** argv)
{
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " <abbrev of imc message 1>,<abbrev of imc message 2>,..,"
<< "<abbrev of imc message n> Data.lsf[.gz] .. Data.lsf[.gz]"
<< std::endl;
std::cerr << argv[0] << " accepts multiple IMC messages comma separated and "
<< "multiple Data.lsf files space separated." << std::endl;
std::cerr << "This program does not sort the input Data.lsf files." << std::endl;
return 1;
}
ByteBuffer buffer;
std::ofstream lsf("FilteredData.lsf", std::ios::binary);
IMC::Message* msg;
uint32_t accum = 0;
bool done_first = false;
std::set<uint32_t> ids;
std::vector<std::string> msgs;
Utils::String::split(argv[1], ",", msgs);
for (unsigned k = 0; k < msgs.size(); ++k)
{
uint32_t got = IMC::Factory::getIdFromAbbrev(Utils::String::trim(msgs[k]));
ids.insert(got);
}
for (uint32_t j = 2; j < (uint32_t)argc; ++j)
{
std::istream* is = 0;
Compression::Methods method = Compression::Factory::detect(argv[j]);
if (method == METHOD_UNKNOWN)
is = new std::ifstream(argv[j], std::ios::binary);
else
is = new Compression::FileInput(argv[j], method);
uint32_t i = 0;
try
{
while ((msg = IMC::Packet::deserialize(*is)) != 0)
{
if (!done_first)
{
// place an empty estimatedstate message in the log
IMC::EstimatedState state;
state.setTimeStamp(msg->getTimeStamp());
IMC::Packet::serialize(&state, buffer);
lsf.write(buffer.getBufferSigned(), buffer.getSize());
done_first = true;
}
std::set<uint32_t>::const_iterator it;
it = ids.find(msg->getId());
if (it != ids.end())
{
IMC::Packet::serialize(msg, buffer);
lsf.write(buffer.getBufferSigned(), buffer.getSize());
++i;
}
delete msg;
}
}
catch (std::runtime_error& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
return -1;
}
std::cerr << i << " messages in " << argv[j] << std::endl;
accum += i;
delete is;
}
lsf.close();
std::cerr << "Total of " << accum << " " << argv[1] << " messages." << std::endl;
return 0;
}
示例10: csv
int
main(int32_t argc, char** argv)
{
if (argc <= 1)
{
std::cerr << "Usage: " << argv[0] << " [options] <path_to_log_1/Data.lsf[.gz]> ... <path_to_log_n/Data.lsf[.gz]>"
<< std::endl
<< "Options:" << std::endl
<< "-i Process idles. Idle logs are ignored by default."
<< std::endl;
return 1;
}
std::ofstream csv("AllData.csv");
csv << "timestamp (s), latitude (deg), longitude (deg), conductivity (S/m), temperature (ºC), depth (m)" << std::endl;
for (int32_t i = 1; i < argc; ++i)
{
std::istream* is = 0;
Compression::Methods method = Compression::Factory::detect(argv[i]);
if (method == METHOD_UNKNOWN)
is = new std::ifstream(argv[i], std::ios::binary);
else
is = new Compression::FileInput(argv[i], method);
IMC::Message* msg = NULL;
bool got_name = false;
std::string log_name = "unknown";
bool got_ent = false;
unsigned ctd_ent = 0;
bool ignore = false;
RData rdata;
rdata.clearData();
std::stringstream ss_data;
try
{
while ((msg = IMC::Packet::deserialize(*is)) != 0)
{
if (msg->getId() == DUNE_IMC_LOGGINGCONTROL)
{
IMC::LoggingControl* ptr = dynamic_cast<IMC::LoggingControl*>(msg);
if (ptr->op == IMC::LoggingControl::COP_STARTED)
{
log_name = ptr->name;
got_name = true;
}
}
else if (msg->getId() == DUNE_IMC_ENTITYINFO)
{
IMC::EntityInfo *ptr = dynamic_cast<IMC::EntityInfo*>(msg);
if (ptr->label.compare(c_ctd_label) == 0)
{
ctd_ent = ptr->id;
got_ent = true;
}
}
else if (msg->getId() == DUNE_IMC_ESTIMATEDSTATE)
{
IMC::EstimatedState* ptr = dynamic_cast<IMC::EstimatedState*>(msg);
Coordinates::toWGS84(*ptr, rdata.lat, rdata.lon);
rdata.timestamp = ptr->getTimeStamp();
rdata.cnt |= GOT_STATE;
}
else if (rdata.gotState() && got_ent)
{
if (msg->getId() == DUNE_IMC_CONDUCTIVITY)
{
IMC::Conductivity* ptr = dynamic_cast<IMC::Conductivity*>(msg);
if (ptr->getSourceEntity() == ctd_ent)
{
rdata.cond = ptr->value;
rdata.cnt |= GOT_COND;
}
}
else if (msg->getId() == DUNE_IMC_TEMPERATURE)
{
IMC::Temperature* ptr = dynamic_cast<IMC::Temperature*>(msg);
if (ptr->getSourceEntity() == ctd_ent)
{
rdata.temp = ptr->value;
rdata.cnt |= GOT_TEMP;
}
}
else if (msg->getId() == DUNE_IMC_DEPTH)
{
IMC::Depth* ptr = dynamic_cast<IMC::Depth*>(msg);
if (ptr->getSourceEntity() == ctd_ent)
{
rdata.depth = ptr->value;
rdata.cnt |= GOT_DEPTH;
}
//.........这里部分代码省略.........
示例11: lsf
int
main(int32_t argc, char** argv)
{
if (argc <= 1)
{
std::cerr << "Usage: " << argv[0] << " <path_to_log/Data.lsf[.gz]>"
<< std::endl;
return 1;
}
std::istream* is = 0;
Compression::Methods method = Compression::Factory::detect(argv[1]);
if (method == METHOD_UNKNOWN)
is = new std::ifstream(argv[1], std::ios::binary);
else
is = new Compression::FileInput(argv[1], method);
IMC::Message* msg = NULL;
std::ofstream lsf("Data.lsf", std::ios::binary);
DUNE::Utils::ByteBuffer buffer;
float bottom_follow_depth = -1.0;
float vertical_ref = -1.0;
// Control parcel for debug
IMC::ControlParcel parcel;
// Last EstimatedState
IMC::EstimatedState last_state;
bool got_state = false;
// Coarse altitude control
DUNE::Control::CoarseAltitude::Arguments args;
createCA(&args);
DUNE::Control::CoarseAltitude ca(&args);
try
{
while ((msg = IMC::Packet::deserialize(*is)) != 0)
{
if (msg->getId() == DUNE_IMC_ESTIMATEDSTATE)
{
IMC::EstimatedState* state = dynamic_cast<IMC::EstimatedState*>(msg);
if (!got_state)
{
last_state = *state;
got_state = true;
}
else
{
IMC::Packet::serialize(state, buffer);
lsf.write(buffer.getBufferSigned(), buffer.getSize());
buffer.resetBuffer();
if (bottom_follow_depth > 0.0)
{
bottom_follow_depth = state->depth + (state->alt - vertical_ref);
parcel.p = bottom_follow_depth;
parcel.i = ca.update(state->getTimeStamp() - last_state.getTimeStamp(),
state->depth, bottom_follow_depth);
parcel.d = state->depth - bottom_follow_depth;
// parcel.a = state->depth - parcel.i;
parcel.a = ca.getCorridor();
parcel.setTimeStamp(state->getTimeStamp());
IMC::Packet::serialize(&parcel, buffer);
lsf.write(buffer.getBufferSigned(), buffer.getSize());
buffer.resetBuffer();
}
last_state = *state;
}
}
else if (msg->getId() == DUNE_IMC_DESIREDZ)
{
IMC::DesiredZ* ptr = dynamic_cast<IMC::DesiredZ*>(msg);
if (ptr->z_units == IMC::Z_ALTITUDE)
{
vertical_ref = ptr->value;
bottom_follow_depth = last_state.depth;
}
IMC::Packet::serialize(ptr, buffer);
lsf.write(buffer.getBufferSigned(), buffer.getSize());
buffer.resetBuffer();
}
else if (msg->getId() == DUNE_IMC_LOGGINGCONTROL)
{
IMC::LoggingControl* ptr = dynamic_cast<IMC::LoggingControl*>(msg);
IMC::Packet::serialize(ptr, buffer);
lsf.write(buffer.getBufferSigned(), buffer.getSize());
buffer.resetBuffer();
}
delete msg;
//.........这里部分代码省略.........
示例12: dest
//.........这里部分代码省略.........
UDPSocket sock;
Address dest(argv[0]);
uint16_t port = std::atoi(argv[1]);
argv += 2;
std::cout << std::fixed << std::setprecision(4);
for (; *argv != 0; argv++)
{
Path file(*argv);
std::istream* is;
if (file.isDirectory())
{
file = file / "Data.lsf";
if (!file.isFile())
file += ".gz";
}
if (!file.isFile())
{
std::cerr << file << " does not exist\n";
return 1;
}
Compression::Methods method = Compression::Factory::detect(file.c_str());
if (method == METHOD_UNKNOWN)
is = new std::ifstream(file.c_str(), std::ios::binary);
else
is = new Compression::FileInput(file.c_str(), method);
IMC::Message* m;
m = IMC::Packet::deserialize(*is);
if (!m)
{
std::cerr << file << " contains no messages\n";
delete is;
continue;
}
DUNE::Utils::ByteBuffer bb;
double time_origin = m->getTimeStamp();
if (begin >= 0)
{
do
{
if (m->getTimeStamp() - time_origin >= begin)
break;
delete m;
m = IMC::Packet::deserialize(*is);
}
while (m);
if (!m)
{
std::cerr << "no messages for specified time range" << std::endl;
return 1;
}
}
else
begin = 0;
示例13: if
int
main(int32_t argc, char** argv)
{
if (argc <= 1)
{
std::cerr << "Usage: " << argv[0] << " <path_to_log_1/Data.lsf[.gz]> ... <path_to_log_n/Data.lsf[.gz]>"
<< std::endl;
return 1;
}
double total_accum = 0;
for (int32_t i = 1; i < argc; ++i)
{
std::istream* is = 0;
Compression::Methods method = Compression::Factory::detect(argv[i]);
if (method == METHOD_UNKNOWN)
is = new std::ifstream(argv[i], std::ios::binary);
else
is = new Compression::FileInput(argv[i], method);
IMC::Message* msg = NULL;
uint16_t curr_rpm = 0;
bool got_state = false;
IMC::EstimatedState estate;
double last_lat;
double last_lon;
// Accumulated travelled distance
double accum = 0;
bool got_name = false;
std::string log_name = "unknown";
bool ignore = false;
try
{
while ((msg = IMC::Packet::deserialize(*is)) != 0)
{
if (msg->getId() == DUNE_IMC_LOGGINGCONTROL)
{
if (!got_name)
{
IMC::LoggingControl* ptr = dynamic_cast<IMC::LoggingControl*>(msg);
if (ptr->op == IMC::LoggingControl::COP_STARTED)
{
log_name = ptr->name;
got_name = true;
}
}
}
else if (msg->getId() == DUNE_IMC_ESTIMATEDSTATE)
{
if (msg->getTimeStamp() - estate.getTimeStamp() > c_timestep)
{
IMC::EstimatedState* ptr = dynamic_cast<IMC::EstimatedState*>(msg);
if (!got_state)
{
estate = *ptr;
Coordinates::toWGS84(*ptr, last_lat, last_lon);
got_state = true;
}
else if (curr_rpm > c_min_rpm)
{
double lat, lon;
Coordinates::toWGS84(*ptr, lat, lon);
double dist = Coordinates::WGS84::distance(last_lat, last_lon, 0.0,
lat, lon, 0.0);
// Not faster than maximum considered speed
if (dist / (ptr->getTimeStamp() - estate.getTimeStamp()) < c_max_speed)
accum += dist;
estate = *ptr;
Coordinates::toWGS84(*ptr, last_lat, last_lon);
}
}
}
else if (msg->getId() == DUNE_IMC_RPM)
{
IMC::Rpm* ptr = dynamic_cast<IMC::Rpm*>(msg);
curr_rpm = ptr->value;
}
else if (msg->getId() == DUNE_IMC_SIMULATEDSTATE)
{
// since it has simulated state let us ignore this log
ignore = true;
delete msg;
std::cerr << "this is a simulated log";
break;
}
//.........这里部分代码省略.........
示例14: extractPosition
void
TimeProfile::parse(const std::vector<IMC::PlanManeuver*>& nodes,
const IMC::EstimatedState* state)
{
if (!m_valid_model)
{
m_last_valid.clear();
return;
}
Position pos;
extractPosition(state, pos);
std::vector<IMC::PlanManeuver*>::const_iterator itr = nodes.begin();
for (; itr != nodes.end(); ++itr)
{
if ((*itr)->data.isNull())
return;
IMC::Message* msg = (*itr)->data.get();
float last_duration = -1.0;
if (m_accum_dur != NULL)
{
if (m_accum_dur->size())
last_duration = m_accum_dur->getLastDuration();
}
Memory::clear(m_accum_dur);
m_accum_dur = new TimeProfile::AccumulatedDurations(last_duration);
Memory::clear(m_speed_vec);
m_speed_vec = new std::vector<SpeedProfile>();
bool parsed = false;
switch (msg->getId())
{
case DUNE_IMC_GOTO:
parsed = parse(static_cast<IMC::Goto*>(msg), pos);
break;
case DUNE_IMC_STATIONKEEPING:
parsed = parse(static_cast<IMC::StationKeeping*>(msg), pos);
break;
case DUNE_IMC_LOITER:
parsed = parse(static_cast<IMC::Loiter*>(msg), pos);
break;
case DUNE_IMC_FOLLOWPATH:
parsed = parse(static_cast<IMC::FollowPath*>(msg), pos);
break;
case DUNE_IMC_ROWS:
parsed = parse(static_cast<IMC::Rows*>(msg), pos);
break;
case DUNE_IMC_YOYO:
parsed = parse(static_cast<IMC::YoYo*>(msg), pos);
break;
case DUNE_IMC_ELEVATOR:
parsed = parse(static_cast<IMC::Elevator*>(msg), pos);
break;
case DUNE_IMC_POPUP:
parsed = parse(static_cast<IMC::PopUp*>(msg), pos);
break;
case DUNE_IMC_COMPASSCALIBRATION:
parsed = parse(static_cast<IMC::CompassCalibration*>(msg), pos);
break;
default:
parsed = false;
break;
}
if (!parsed)
{
if (m_profiles.empty() || itr == nodes.begin())
return;
// return the duration from the previously computed maneuver
const_iterator dtr;
dtr = m_profiles.find((*(--itr))->maneuver_id);
if (dtr->second.durations.empty())
return;
m_last_valid = dtr->first;
return;
}
// Update speeds and durations
Profile prof;
prof.durations = m_accum_dur->vec;
prof.speeds = *m_speed_vec;
//.........这里部分代码省略.........
示例15: if
int
main(int32_t argc, char** argv)
{
if (argc <= 1)
{
std::cerr << "Usage: " << argv[0] << " <path_to_log_1/Data.lsf[.gz]> ... <path_to_log_n/Data.lsf[.gz]>"
<< std::endl;
return 1;
}
std::map<std::string, Vehicle> vehicles;
for (int32_t i = 1; i < argc; ++i)
{
std::istream* is = 0;
Compression::Methods method = Compression::Factory::detect(argv[i]);
if (method == METHOD_UNKNOWN)
is = new std::ifstream(argv[i], std::ios::binary);
else
is = new Compression::FileInput(argv[i], method);
IMC::Message* msg = NULL;
uint16_t curr_rpm = 0;
bool got_state = false;
IMC::EstimatedState estate;
double last_lat;
double last_lon;
// Accumulated travelled distance
double distance = 0.0;
// Accumulated travelled time
double duration = 0.0;
bool got_name = false;
std::string log_name = "unknown";
bool ignore = false;
uint16_t sys_id = 0xffff;
std::string sys_name;
try
{
while ((msg = IMC::Packet::deserialize(*is)) != 0)
{
if (msg->getId() == DUNE_IMC_ANNOUNCE)
{
IMC::Announce* ptr = static_cast<IMC::Announce*>(msg);
if (sys_id == ptr->getSource())
{
sys_name = ptr->sys_name;
}
}
else if (msg->getId() == DUNE_IMC_LOGGINGCONTROL)
{
if (!got_name)
{
IMC::LoggingControl* ptr = static_cast<IMC::LoggingControl*>(msg);
if (ptr->op == IMC::LoggingControl::COP_STARTED)
{
sys_id = ptr->getSource();
log_name = ptr->name;
got_name = true;
}
}
}
else if (msg->getId() == DUNE_IMC_ESTIMATEDSTATE)
{
if (msg->getTimeStamp() - estate.getTimeStamp() > c_timestep)
{
IMC::EstimatedState* ptr = static_cast<IMC::EstimatedState*>(msg);
if (!got_state)
{
estate = *ptr;
Coordinates::toWGS84(*ptr, last_lat, last_lon);
got_state = true;
}
else if (curr_rpm > c_min_rpm)
{
double lat, lon;
Coordinates::toWGS84(*ptr, lat, lon);
double dist = Coordinates::WGS84::distance(last_lat, last_lon, 0.0,
lat, lon, 0.0);
// Not faster than maximum considered speed
if (dist / (ptr->getTimeStamp() - estate.getTimeStamp()) < c_max_speed)
{
distance += dist;
duration += msg->getTimeStamp() - estate.getTimeStamp();
}
estate = *ptr;
last_lat = lat;
last_lon = lon;
}
//.........这里部分代码省略.........