55 "Marker Topic",
"visualization_marker",
56 QString::fromStdString(ros::message_traits::datatype<visualization_msgs::Marker>()),
57 "visualization_msgs::Marker topic to subscribe to. <topic>_array will also" 58 " automatically be subscribed with type visualization_msgs::MarkerArray.",
63 "Advanced: set the size of the incoming Marker message queue. Increasing this is" 64 " useful if your incoming TF data is delayed significantly from your Marker data, " 65 "but it can greatly increase memory usage if the messages are big.",
76 #pragma GCC diagnostic push 77 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 83 #pragma GCC diagnostic pop 114 QString key = iter.currentKey();
115 const Config& child = iter.currentChild();
162 if (!marker_topic.empty())
195 M_IDToMarker::iterator it =
markers_.find(
id);
206 std::vector<MarkerID> to_delete;
209 M_IDToMarker::iterator marker_it =
markers_.begin();
210 M_IDToMarker::iterator marker_end =
markers_.end();
211 for (; marker_it != marker_end; ++marker_it)
213 if (marker_it->first.first == ns)
215 to_delete.push_back(marker_it->first);
220 std::vector<MarkerID>::iterator it = to_delete.begin();
221 std::vector<MarkerID>::iterator end = to_delete.end();
222 for (; it != end; ++it)
231 std::vector<MarkerID> to_delete;
232 M_IDToMarker::iterator marker_it =
markers_.begin();
233 for (; marker_it !=
markers_.end(); ++marker_it)
235 to_delete.push_back(marker_it->first);
238 for (std::vector<MarkerID>::iterator it = to_delete.begin(); it != to_delete.end(); ++it)
246 std::stringstream ss;
247 ss <<
id.first <<
"/" <<
id.second;
248 std::string marker_name = ss.str();
254 std::stringstream ss;
255 ss <<
id.first <<
"/" <<
id.second;
256 std::string marker_name = ss.str();
263 for (
const visualization_msgs::Marker& marker : array->markers)
265 tf_filter_->
add(visualization_msgs::Marker::Ptr(
new visualization_msgs::Marker(marker)));
278 visualization_msgs::Marker::ConstPtr marker = marker_evt.
getConstMessage();
279 if (marker->action == visualization_msgs::Marker::DELETE ||
280 marker->action == visualization_msgs::Marker::DELETEALL)
287 #pragma GCC diagnostic push 288 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 292 marker->header.frame_id, marker->header.stamp, authority, reason);
295 #pragma GCC diagnostic pop 302 switch (message->action)
304 case visualization_msgs::Marker::ADD:
312 case visualization_msgs::Marker::DELETE:
316 case visualization_msgs::Marker::DELETEALL:
321 ROS_ERROR(
"Unknown marker action: %d\n", message->action);
327 QString namespace_name = QString::fromStdString(message->ns);
328 M_Namespace::iterator ns_it =
namespaces_.find(namespace_name);
338 ns_it.value()->setValue(
false);
342 if (!ns_it.value()->isEnabled())
350 M_IDToMarker::iterator it =
markers_.find(
MarkerID(message->ns, message->id));
355 if (message->type == marker->getMessage()->type)
370 markers_.insert(std::make_pair(
MarkerID(message->ns, message->id), marker));
376 marker->setMessage(message);
378 if (message->lifetime.toSec() > 0.0001f)
383 if (message->frame_locked)
409 if (!local_queue.empty())
411 V_MarkerMessage::iterator message_it = local_queue.begin();
412 V_MarkerMessage::iterator message_end = local_queue.end();
413 for (; message_it != message_end; ++message_it)
415 visualization_msgs::Marker::ConstPtr& marker = *message_it;
427 if (marker->expired())
442 for (; it != end; ++it)
445 marker->updateFrameLocked();
472 :
BoolProperty(name, true,
"Enable/disable all markers in this namespace.", parent_property)
const boost::shared_ptr< ConstMessage > & getConstMessage() const
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 processMessage(const visualization_msgs::Marker::ConstPtr &message)
Processes a marker message.
void deleteStatusStd(const std::string &name)
Delete the status entry with the given std::string name. This is thread-safe.
virtual void setString(const QString &str)
void processAdd(const visualization_msgs::Marker::ConstPtr &message)
Processes an "Add" marker message.
void onDisable() override
Derived classes override this to do the actual work of disabling themselves.
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 processDelete(const visualization_msgs::Marker::ConstPtr &message)
Processes a "Delete" marker message.
S_MarkerBase frame_locked_markers_
void setMarkerStatus(MarkerID id, StatusLevel level, const std::string &text)
RosTopicProperty * marker_topic_property_
virtual tf::TransformListener * getTFClient() const =0
Convenience function: returns getFrameManager()->getTFClient().
MarkerNamespace(const QString &name, Property *parent_property, MarkerDisplay *owner)
QVariant getValue() const
If this config object is valid and is a Value type, this returns its value. Otherwise it returns an i...
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
DisplayContext * context_
This DisplayContext pointer is the main connection a Display has into the rest of rviz...
void changed()
Emitted by setValue() just after the value has changed.
void add(const MEvent &evt)
std::vector< visualization_msgs::Marker::ConstPtr > V_MarkerMessage
ros::NodeHandle update_nh_
A NodeHandle whose CallbackQueue is run from the main GUI thread (the "update" thread).
A single element of a property tree, with a name, value, description, and possibly children...
IntProperty * queue_size_property_
boost::mutex queue_mutex_
void reset() override
Called to tell the display to clear its state.
void incomingMarker(const visualization_msgs::Marker::ConstPtr &marker)
ROS callback notifying us of a new marker.
bool checkMarkerMsg(const visualization_msgs::Marker &marker, MarkerDisplay *owner)
void load(const Config &config) override
Load the settings for this display from the given Config node, which must be a map.
bool isValid()
Return true if the iterator currently points to a valid entry, false if not.
Config mapGetChild(const QString &key) const
If the referenced Node is a Map and it has a child with the given key, return a reference to the chil...
void deleteMarkerInternal(MarkerID id)
virtual void unsubscribe()
Unsubscribes from the "visualization_marker" "visualization_marker_array" topics. ...
std::string getTopicStd() const
Property specialized to provide max/min enforcement for integers.
Ogre::SceneNode * scene_node_
The Ogre::SceneNode to hold all 3D scene elements shown by this Display.
M_EnabledState namespace_config_enabled_state_
void deleteMarker(MarkerID id)
Configuration data storage class.
Property * namespaces_category_
void incomingMarkerArray(const visualization_msgs::MarkerArray::ConstPtr &array)
Process a MarkerArray message.
QString fixed_frame_
A convenience variable equal to context_->getFixedFrame().
virtual void setQueueSize(uint32_t new_queue_size)
MarkerBase * createMarker(int marker_type, MarkerDisplay *owner, DisplayContext *context, Ogre::SceneNode *parent_node)
void deleteMarkersInNamespace(const std::string &ns)
Delete all the markers within the given namespace.
std::pair< std::string, int32_t > MarkerID
void update(float wall_dt, float ros_dt) override
Called periodically by the visualization manager.
bool checkMarkerArrayMsg(const visualization_msgs::MarkerArray &array, MarkerDisplay *owner)
M_IDToMarker markers_
Map of marker id to the marker info structure.
virtual void removeChildren(int start_index=0, int count=-1)
Remove and delete some or all child Properties. Does not change the value of this Property...
virtual void reset()
Called to tell the display to clear its state.
V_MarkerMessage message_queue_
in our update() function
void deleteMarkerStatus(MarkerID id)
virtual QString getName() const
Return the name of this Property as a QString.
Iterator class for looping over all entries in a Map type Config Node.
message_filters::Connection registerFailureCallback(const FailureCallback &callback)
virtual FrameManager * getFrameManager() const =0
Return the FrameManager instance.
Property(const QString &name=QString(), const QVariant default_value=QVariant(), const QString &description=QString(), Property *parent=nullptr, const char *changed_slot=nullptr, QObject *receiver=nullptr)
Constructor.
void onInitialize() override
Override this function to do subclass-specific initialization.
ros::Subscriber array_sub_
message_filters::Subscriber< visualization_msgs::Marker > sub_
void setTopic(const QString &topic, const QString &datatype) override
Set the ROS topic to listen to for this display.
~MarkerDisplay() override
friend class MarkerNamespace
tf::MessageFilter< visualization_msgs::Marker > * tf_filter_
void fixedFrameChanged() override
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
void failedMarker(const ros::MessageEvent< visualization_msgs::Marker > &marker_evt, tf::FilterFailureReason reason)
void onEnable() override
Derived classes override this to do the actual work of enabling themselves.
S_MarkerBase markers_with_expiration_
virtual int getInt() const
Return the internal property value as an integer.
virtual void subscribe()
Subscribes to the "visualization_marker" and "visualization_marker_array" topics. ...
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.
void load(const Config &config) override
Load the value of this property and/or its children from the given Config reference.
void deleteAllMarkers()
Delete all known markers to this plugin, regardless of id or namespace.
void subscribe(ros::NodeHandle &nh, const std::string &topic, uint32_t queue_size, const ros::TransportHints &transport_hints=ros::TransportHints(), ros::CallbackQueueInterface *callback_queue=0)
Property specialized to provide getter for booleans.
void setTargetFrame(const std::string &target_frame)
MapIterator mapIterator() const
Return a new iterator for looping over key/value pairs.
bool initialized() const
Returns true if the display has been initialized.
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
Displays "markers" sent in by other ROS nodes on the "visualization_marker" topic.
void clearMarkers()
Removes all the markers.
const std::string & getPublisherName() const
virtual void setStatus(StatusProperty::Level level, const QString &name, const QString &text)
Show status level and text. This is thread-safe.
Connection registerCallback(const C &callback)