本文整理汇总了C++中Registry::receiveMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ Registry::receiveMessage方法的具体用法?C++ Registry::receiveMessage怎么用?C++ Registry::receiveMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::receiveMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
mainLoop( Registry & registry, PosePlanner & planner,
double offsetX, double offsetY )
{
while ( !quit )
{
try
{
Message msg = registry.receiveMessage( 1 );
if ( msg.name() == "planner_plan_message" )
{
Structure & data = msg.data();
planner_plan_message & planMessage =
* reinterpret_cast<planner_plan_message *>( data.buffer() );
Logger::spam( "Plan request message has been received:" + data.toString(),
"path_planner" );
double planStart = seconds();
PosePlanner::Path path = planner.plan (
planMessage.start.x + offsetX,
planMessage.start.y + offsetY,
planMessage.start.theta,
planMessage.goal.x + offsetX,
planMessage.goal.y + offsetY,
planMessage.goal.theta
);
cout << "Generated path of length " << path.size() << " in " <<
seconds() - planStart << "s" << endl;
if ( path.size() > 0 )
{
Rotor::Structure pathMessage = registry.newStructure("path_message");
pathMessage["point_count"] = static_cast<int>( path.size() );
pathMessage.adjust();
size_t i = 0;
for ( PosePlanner::Path::const_iterator it = path.begin();
it != path.end(); ++it, ++i )
{
const Pose & pose = *it;
pathMessage["x"][i] = pose.x() - offsetX;
pathMessage["y"][i] = pose.y() - offsetY;
pathMessage["theta"][i] = pose.theta();
}
pathMessage["timestamp"] = Rotor::seconds();
pathMessage["host"] = const_cast<char*>( Rotor::hostName().c_str() );
registry.sendStructure( "path_message", pathMessage );
Logger::spam( "Path message has been sent:" + pathMessage.toString(),
"path_planner" );
} else {
Rotor::Structure stopMessage = registry.newStructure("path_stop_message");
stopMessage["timestamp"] = Rotor::seconds();
stopMessage["host"] = const_cast<char*>( Rotor::hostName().c_str() );
registry.sendStructure( "path_stop_message", stopMessage );
Logger::spam( "Stop message has been sent:" + stopMessage.toString(),
"path_planner" );
}
}
} catch( MessagingTimeout ) {
Logger::spam( "Timeout waiting for message", "path_planner" );
}
}
}