Template Struct NodeletWithSharedTfBuffer

Inheritance Relationships

Base Types

Derived Type

Struct Documentation

template<typename NodeletType = ::nodelet::Nodelet>
struct NodeletWithSharedTfBuffer : public virtual nodelet::Nodelet, public cras::NodeletWithSharedTfBufferInterface, protected cras::TimeJumpResettable

A nodelet mixin that allows to use a tf2_ros::Buffer provided by the nodelet manager (which should save some computations). If this nodelet has also the StatefulNodelet mixin, the automatically created non-shared buffer is nodelet-aware (you can also pass a NodeletAwareTfBuffer to setBuffer()). That means any TF lookups done via this->getBuffer() will be able to correctly end when the nodelet is being unloaded (which normally hangs: https://github.com/ros/geometry2/issues/381).

Template Parameters:

NodeletType – Type of the base nodelet.

Subclassed by cras::NodeletBase<::nodelet::Nodelet >

Public Functions

NodeletWithSharedTfBuffer()
~NodeletWithSharedTfBuffer() override
virtual void setBuffer(const ::std::shared_ptr<::tf2_ros::Buffer> &buffer) override

Set the TF buffer to be used by the nodelet. If this method is not called, a standalone buffer is created.

Parameters:

buffer[in] The buffer to use.

virtual ::cras::NodeletAwareTFBuffer &getBuffer() const override

Get the TF buffer used by the nodelet. If none has been set by setBuffer(), a buffer is automatically created.

Note

This buffer only offers the timeouting versions of canTransform() and lookupTransform(). It does not offer setTransform() and many other functions. User getRawBuffer() on the returned instance to get a tf2::BufferCore that offers the missing non-time-aware functionality.

Returns:

The buffer.

::std::shared_ptr<::cras::NodeletAwareTFBuffer> getBufferPtr() const
virtual bool usesSharedBuffer() const override

Whether the buffer set using setBuffer() is used or a standalone buffer has been automatically created.

Returns:

Whether the buffer set using setBuffer() is used or a standalone buffer has been automatically created.

virtual void onInit()
virtual void reset() override

Reset the TF buffer. If a shared buffer is used, it is not reset by this call and its owner is responsible.