本文整理汇总了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();
}
}
示例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);
}
示例3: is_active
bool is_active()
{
return !pub_.getTopic().empty();
}
示例4: get_topic
std::string get_topic()
{
return pub_.getTopic();
}