30 #include <boost/algorithm/string/erase.hpp> 31 #include <boost/foreach.hpp> 32 #include <boost/shared_ptr.hpp> 48 QString::fromStdString(ros::message_traits::datatype<sensor_msgs::Image>()),
49 "sensor_msgs::Image topic to subscribe to.",
this, SLOT(
updateTopic()));
59 "Advanced: set the size of the incoming message queue. Increasing this " 60 "is useful if your incoming TF data is delayed significantly from your" 61 " image data, but it can greatly increase memory usage if the messages are big.",
84 if (datatype == ros::message_traits::datatype<sensor_msgs::Image>())
91 int index = topic.lastIndexOf(
"/");
94 ROS_WARN(
"ImageDisplayBase::setTopic() Invalid topic name: %s", topic.toStdString().c_str());
97 QString transport = topic.mid(index + 1);
98 QString base_topic = topic.mid(0, index);
127 msg->header.stamp,
"", reason));
230 "image_transport",
"image_transport::SubscriberPlugin");
239 std::string transport_name = boost::erase_last_copy(lookup_name,
"_sub");
240 transport_name = transport_name.substr(lookup_name.find(
'/') + 1);
269 property->clearOptions();
271 std::vector<std::string> choices;
273 choices.push_back(
"raw");
278 ros::master::V_TopicInfo::iterator it = topics.begin();
279 ros::master::V_TopicInfo::iterator end = topics.end();
280 for (; it != end; ++it)
288 const std::string& topic_name = ti.
name;
291 if (topic_name.find(topic) == 0 && topic_name != topic && topic_name[topic.size()] ==
'/' &&
292 topic_name.find(
'/', topic.size() + 1) == std::string::npos)
294 std::string transport_type = topic_name.substr(topic.size() + 1);
300 choices.push_back(transport_type);
305 for (
size_t i = 0; i < choices.size(); i++)
307 property->addOptionStd(choices[i]);
void setStatusStd(StatusProperty::Level level, const std::string &name, const std::string &text)
Show status level and text, using a std::string. Convenience function which converts std::string to Q...
void scanForTransportSubscriberPlugins()
boost::shared_ptr< tf2_ros::MessageFilter< sensor_msgs::Image > > tf_filter_
virtual void setString(const QString &str)
std::string discoverFailureReason(const std::string &frame_id, const ros::Time &stamp, const std::string &caller_id, tf::FilterFailureReason reason)
Create a description of a transform problem.
void fillTransportOptionList(EnumProperty *property)
Fill list of available and working transport options.
DisplayContext * context_
This DisplayContext pointer is the main connection a Display has into the rest of rviz...
void failedMessage(const sensor_msgs::Image::ConstPtr &msg, tf2_ros::FilterFailureReason reason)
Callback for messages, whose frame_id cannot resolved.
boost::shared_ptr< T > createInstance(const std::string &lookup_name)
void emitTimeSignal(ros::Time time)
Emit a time signal that other Displays can synchronize to.
ros::NodeHandle update_nh_
A NodeHandle whose CallbackQueue is run from the main GUI thread (the "update" thread).
ROSCPP_DECL bool getTopics(V_TopicInfo &topics)
virtual void unsubscribe()
std::vector< TopicInfo > V_TopicInfo
std::string getTopicStd() const
void reset() override
Reset display.
Property specialized to provide max/min enforcement for integers.
ImageDisplayBase()
Constructor.
std::string getStdString()
virtual void removeByID(uint64_t owner_id)=0
QString fixed_frame_
A convenience variable equal to context_->getFixedFrame().
BoolProperty * unreliable_property_
virtual void processMessage(const sensor_msgs::Image::ConstPtr &msg)=0
Implement this to process the contents of a message.
IntProperty * queue_size_property_
TransportHints & unreliable()
virtual void subscribe()
ROS topic management.
uint32_t messages_received_
virtual void reset()
Called to tell the display to clear its state.
std::vector< std::string > getDeclaredClasses()
virtual void updateQueueSize()
Update queue size of tf filter.
virtual FrameManager * getFrameManager() const =0
Return the FrameManager instance.
CallbackQueueInterface * getCallbackQueue() const
void fixedFrameChanged() override
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
void onInitialize() override
Override this function to do subclass-specific initialization.
virtual int getInt() const
Return the internal property value as an integer.
BoolProperty(const QString &name=QString(), bool default_value=false, const QString &description=QString(), Property *parent=nullptr, const char *changed_slot=nullptr, QObject *receiver=nullptr)
virtual std::shared_ptr< tf2_ros::Buffer > getTF2BufferPtr() const =0
Convenience function: returns getFrameManager()->getTF2BufferPtr().
virtual void queueRender()=0
Queues a render. Multiple calls before a render happens will only cause a single render.
bool isEnabled() const
Return true if this Display is enabled, false if not.
EnumProperty * transport_property_
RosTopicProperty * topic_property_
virtual void updateTopic()
Update topic and resubscribe.
std::set< std::string > transport_plugin_types_
void incomingMessage(const sensor_msgs::Image::ConstPtr &msg)
Incoming message callback. Checks if the message pointer is valid, increments messages_received_, then calls processMessage().
void setTopic(const QString &topic, const QString &datatype) override
Set the ROS topic to listen to for this display.
boost::shared_ptr< image_transport::SubscriberFilter > sub_
virtual bool getBool() const
bool setStdString(const std::string &std_str)
virtual void setString(const QString &str)
Set the value of this property to the given string. Does not force the value to be one of the list of...
boost::scoped_ptr< image_transport::ImageTransport > it_
virtual void setStatus(StatusProperty::Level level, const QString &name, const QString &text)
Show status level and text. This is thread-safe.
~ImageDisplayBase() override