当前位置: 首页>>代码示例>>C++>>正文


C++ Registry::sendStructure方法代码示例

本文整理汇总了C++中Registry::sendStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ Registry::sendStructure方法的具体用法?C++ Registry::sendStructure怎么用?C++ Registry::sendStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Registry的用法示例。


在下文中一共展示了Registry::sendStructure方法的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" );
    }
  }
}
开发者ID:kralf,项目名称:rotor-smartter,代码行数:72,代码来源:path_planner.cpp


注:本文中的Registry::sendStructure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。