Skip to content

Commit

Permalink
cras_cpp_common: nodelet_utils: Allowed accessing the shared_ptr of t…
Browse files Browse the repository at this point in the history
…he shared TF buffer.
  • Loading branch information
peci1 committed Dec 12, 2024
1 parent 301864f commit eb7ea6d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#pragma once

// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: Czech Technical University in Prague

/**
* \file
* \brief NodeletWithSharedTfBuffer allows you to use a tf2_ros::Buffer provided by the nodelet manager (private
* implementation details, do not include this directly).
* \author Martin Pecka
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-FileCopyrightText: Czech Technical University in Prague
*/

#include "../nodelet_with_shared_tf_buffer.hpp"
Expand Down Expand Up @@ -91,6 +92,14 @@ ::cras::NodeletAwareTFBuffer& NodeletWithSharedTfBuffer<NodeletType>::getBuffer(
return *this->data->buffer;
}

template <typename NodeletType>
::std::shared_ptr<::cras::NodeletAwareTFBuffer>
NodeletWithSharedTfBuffer<NodeletType>::getBufferPtr() const
{
this->getBuffer();
return this->data->buffer;
}

template <typename NodeletType>
bool NodeletWithSharedTfBuffer<NodeletType>::usesSharedBuffer() const
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#pragma once

// SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: Czech Technical University in Prague

/**
* \file
* \brief NodeletWithSharedTfBuffer allows you to use a tf2_ros::Buffer provided by the nodelet manager.
* \author Martin Pecka
* SPDX-License-Identifier: BSD-3-Clause
* SPDX-FileCopyrightText: Czech Technical University in Prague
*/

#include <memory>
Expand Down Expand Up @@ -45,7 +46,7 @@ struct NodeletWithSharedTfBufferInterface
* \brief Get the TF buffer used by the nodelet. If none has been set by `setBuffer()`, a buffer is automatically
* created.
* \return The buffer.
* \note This buffer is only offers the timeouting versions of canTransform() and lookupTransform().
* \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.
*/
Expand Down Expand Up @@ -77,10 +78,11 @@ struct NodeletWithSharedTfBuffer : public virtual NodeletType, public ::cras::No
{
public:
NodeletWithSharedTfBuffer();
virtual ~NodeletWithSharedTfBuffer();
~NodeletWithSharedTfBuffer() override;

void setBuffer(const ::std::shared_ptr<::tf2_ros::Buffer>& buffer) override;
::cras::NodeletAwareTFBuffer& getBuffer() const override;
::std::shared_ptr<::cras::NodeletAwareTFBuffer> getBufferPtr() const;
bool usesSharedBuffer() const override;

virtual void onInit();
Expand Down

0 comments on commit eb7ea6d

Please sign in to comment.