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


C++ Publisher::getTopic方法代码示例

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


在下文中一共展示了Publisher::getTopic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shutdown

 void shutdown()
 {
   if (pub_.getTopic() != "")
   {
     pub_.shutdown();
   }
 }
开发者ID:lucasw,项目名称:rviz_camera_stream,代码行数:7,代码来源:camera_display.cpp

示例2: publishFrame

  // bool publishFrame(Ogre::RenderWindow * render_object, const std::string frame_id)
  bool publishFrame(Ogre::RenderTexture * render_object, const std::string frame_id)
  {
    if (pub_.getTopic() == "")
    {
      return false;
    }
    if (frame_id == "")
    {
      return false;
    }
    // RenderTarget::writeContentsToFile() used as example
    int height = render_object->getHeight();
    int width = render_object->getWidth();
    // the results of pixel format have to be used to determine
    // image.encoding
    Ogre::PixelFormat pf = render_object->suggestPixelFormat();
    uint pixelsize = Ogre::PixelUtil::getNumElemBytes(pf);
    uint datasize = width * height * pixelsize;

    // 1.05 multiplier is to avoid crash when the window is resized.
    // There should be a better solution.
    uchar *data = OGRE_ALLOC_T(uchar, datasize * 1.05, Ogre::MEMCATEGORY_RENDERSYS);
    Ogre::PixelBox pb(width, height, 1, pf, data);
    render_object->copyContentsToMemory(pb, Ogre::RenderTarget::FB_AUTO);

    sensor_msgs::Image image;
    image.header.stamp = ros::Time::now();
    image.header.seq = image_id_++;
    image.header.frame_id = frame_id;
    image.height = height;
    image.width = width;
    image.step = pixelsize * width;
    if (pixelsize == 3)
      image.encoding = sensor_msgs::image_encodings::RGB8;  // would break if pf changes
    else if (pixelsize == 4)
      image.encoding = sensor_msgs::image_encodings::RGBA8;  // would break if pf changes
    else
    {
      ROS_ERROR_STREAM("unknown pixe format " << pixelsize << " " << pf);
    }
    image.is_bigendian = (OGRE_ENDIAN == OGRE_ENDIAN_BIG);
    image.data.resize(datasize);
    memcpy(&image.data[0], data, datasize);
    pub_.publish(image);

    OGRE_FREE(data, Ogre::MEMCATEGORY_RENDERSYS);
  }
开发者ID:lucasw,项目名称:rviz_camera_stream,代码行数:48,代码来源:camera_display.cpp

示例3: is_active

 bool is_active()
 {
   return !pub_.getTopic().empty();
 }
开发者ID:lucasw,项目名称:rviz_camera_stream,代码行数:4,代码来源:camera_display.cpp

示例4: get_topic

 std::string get_topic()
 {
   return pub_.getTopic();
 }
开发者ID:lucasw,项目名称:rviz_camera_stream,代码行数:4,代码来源:camera_display.cpp


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