Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tf2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ find_package(rosidl_runtime_cpp REQUIRED)
# export user definitions

#CPP Libraries
add_library(tf2 src/cache.cpp src/buffer_core.cpp src/static_cache.cpp src/time.cpp)
add_library(tf2
src/cache.cpp
src/buffer_core.cpp
src/convert.cpp
src/exceptions.cpp
src/static_cache.cpp
src/time.cpp)
target_include_directories(tf2 PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
Expand Down
27 changes: 7 additions & 20 deletions tf2/include/tf2/buffer_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ class BufferCore : public BufferCoreInterface
// Tell the buffer that there are multiple threads servicing it.
// This is useful for derived classes to know if they can block or not.
TF2_PUBLIC
void setUsingDedicatedThread(bool value) {using_dedicated_thread_ = value;}
void setUsingDedicatedThread(bool value);
// Get the state of using_dedicated_thread_
TF2_PUBLIC
bool isUsingDedicatedThread() const {return using_dedicated_thread_;}
bool isUsingDedicatedThread() const;


/* Backwards compatibility section for tf::Transformer you should not use these
Expand All @@ -292,36 +292,23 @@ class BufferCore : public BufferCoreInterface


TF2_PUBLIC
CompactFrameID _lookupFrameNumber(const std::string & frameid_str) const
{
return lookupFrameNumber(frameid_str);
}
CompactFrameID _lookupFrameNumber(const std::string & frameid_str) const;
TF2_PUBLIC
CompactFrameID _lookupOrInsertFrameNumber(const std::string & frameid_str)
{
return lookupOrInsertFrameNumber(frameid_str);
}
CompactFrameID _lookupOrInsertFrameNumber(const std::string & frameid_str);

TF2_PUBLIC
tf2::TF2Error _getLatestCommonTime(
CompactFrameID target_frame, CompactFrameID source_frame,
TimePoint & time, std::string * error_string) const
{
std::unique_lock<std::mutex> lock(frame_mutex_);
return getLatestCommonTime(target_frame, source_frame, time, error_string);
}
TimePoint & time, std::string * error_string) const;

TF2_PUBLIC
CompactFrameID _validateFrameId(
const char * function_name_arg,
const std::string & frame_id) const
{
return validateFrameId(function_name_arg, frame_id);
}
const std::string & frame_id) const;

/**@brief Get the duration over which this transformer will cache */
TF2_PUBLIC
tf2::Duration getCacheLength() {return cache_time_;}
tf2::Duration getCacheLength();

/** \brief Backwards compatibilityA way to see what frames have been cached
* Useful for debugging
Expand Down
29 changes: 4 additions & 25 deletions tf2/include/tf2/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#ifndef TF2__CONVERT_HPP_
#define TF2__CONVERT_HPP_

#include <algorithm>
#include <array>
#include <string>

Expand Down Expand Up @@ -166,38 +165,18 @@ void convert(const A & a1, A & a2)
* \param row_major A row-major array of 36 covariance values.
* \return A nested array representation of 6x6 covariance values.
*/
inline
TF2_PUBLIC
std::array<std::array<double, 6>, 6> covarianceRowMajorToNested(
const std::array<double, 36> & row_major)
{
std::array<std::array<double, 6>, 6> nested_array;
std::array<double, 36>::const_iterator ss = row_major.begin();
for (std::array<double, 6> & dd : nested_array) {
std::copy_n(ss, dd.size(), dd.begin());
ss += dd.size();
}
return nested_array;
}
const std::array<double, 36> & row_major);

/**\brief Function that converts from a nested array representation of a 6x6
* covariance matrix to a row-major representation.
* \param nested_array A nested array representation of 6x6 covariance values.
* \return A row-major array of 36 covariance values.
*/
inline
TF2_PUBLIC
std::array<double, 36> covarianceNestedToRowMajor(
const std::array<std::array<double, 6>, 6> & nested_array)
{
std::array<double, 36> row_major = {};
size_t counter = 0;
for (const auto & arr : nested_array) {
for (const double & val : arr) {
row_major[counter] = val;
counter++;
}
}
return row_major;
}
const std::array<std::array<double, 6>, 6> & nested_array);
} // namespace tf2

#endif // TF2__CONVERT_HPP_
43 changes: 9 additions & 34 deletions tf2/include/tf2/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ class TransformException : public std::runtime_error
{
public:
TF2_PUBLIC
explicit TransformException(const std::string errorDescription)
: std::runtime_error(errorDescription)
{
}
explicit TransformException(const std::string errorDescription);
};


Expand All @@ -82,10 +79,7 @@ class ConnectivityException : public TransformException
{
public:
TF2_PUBLIC
explicit ConnectivityException(const std::string errorDescription)
: tf2::TransformException(errorDescription)
{
}
explicit ConnectivityException(const std::string errorDescription);
};


Expand All @@ -101,10 +95,7 @@ class LookupException : public TransformException
{
public:
TF2_PUBLIC
explicit LookupException(const std::string errorDescription)
: tf2::TransformException(errorDescription)
{
}
explicit LookupException(const std::string errorDescription);
};

/** \brief An exception class to notify that the requested value would have required extrapolation beyond current limits.
Expand All @@ -114,10 +105,7 @@ class ExtrapolationException : public TransformException
{
public:
TF2_PUBLIC
explicit ExtrapolationException(const std::string errorDescription)
: tf2::TransformException(errorDescription)
{
}
explicit ExtrapolationException(const std::string errorDescription);
};

/** \brief An exception class to notify that the requested value would have required extrapolation in the past.
Expand All @@ -127,10 +115,7 @@ class BackwardExtrapolationException : public ExtrapolationException
{
public:
TF2_PUBLIC
explicit BackwardExtrapolationException(const std::string errorDescription)
: ExtrapolationException(errorDescription)
{
}
explicit BackwardExtrapolationException(const std::string errorDescription);
};

/** \brief An exception class to notify that the requested value would have required extrapolation in the future.
Expand All @@ -140,10 +125,7 @@ class ForwardExtrapolationException : public ExtrapolationException
{
public:
TF2_PUBLIC
explicit ForwardExtrapolationException(const std::string errorDescription)
: ExtrapolationException(errorDescription)
{
}
explicit ForwardExtrapolationException(const std::string errorDescription);
};

/** \brief An exception class to notify that the requested value would have required extrapolation, but only zero or one data is available, so not enough for extrapolation.
Expand All @@ -153,10 +135,7 @@ class NoDataForExtrapolationException : public ExtrapolationException
{
public:
TF2_PUBLIC
explicit NoDataForExtrapolationException(const std::string errorDescription)
: ExtrapolationException(errorDescription)
{
}
explicit NoDataForExtrapolationException(const std::string errorDescription);
};

/** \brief An exception class to notify that one of the arguments is invalid
Expand All @@ -168,8 +147,7 @@ class InvalidArgumentException : public TransformException
{
public:
TF2_PUBLIC
explicit InvalidArgumentException(const std::string errorDescription)
: tf2::TransformException(errorDescription) {}
explicit InvalidArgumentException(const std::string errorDescription);
};

/** \brief An exception class to notify that a timeout has occurred
Expand All @@ -180,10 +158,7 @@ class TimeoutException : public TransformException
{
public:
TF2_PUBLIC
explicit TimeoutException(const std::string errorDescription)
: tf2::TransformException(errorDescription)
{
}
explicit TimeoutException(const std::string errorDescription);
};
} // namespace tf2
#endif // TF2__EXCEPTIONS_HPP_
29 changes: 4 additions & 25 deletions tf2/include/tf2/transform_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,16 @@ class TransformStorage
CompactFrameID child_frame_id);

TF2_PUBLIC
TransformStorage(const TransformStorage & rhs)
{
*this = rhs;
}
TransformStorage(const TransformStorage & rhs);

TF2_PUBLIC
TransformStorage & operator=(const TransformStorage & rhs)
{
rotation_ = rhs.rotation_;
translation_ = rhs.translation_;
stamp_ = rhs.stamp_;
frame_id_ = rhs.frame_id_;
child_frame_id_ = rhs.child_frame_id_;
return *this;
}
TransformStorage & operator=(const TransformStorage & rhs);

TF2_PUBLIC
bool operator==(const TransformStorage & rhs) const
{
return (this->rotation_ == rhs.rotation_) &&
(this->translation_ == rhs.translation_) &&
(this->stamp_ == rhs.stamp_) &&
(this->frame_id_ == rhs.frame_id_) &&
(this->child_frame_id_ == rhs.child_frame_id_);
}
bool operator==(const TransformStorage & rhs) const;

TF2_PUBLIC
bool operator!=(const TransformStorage & rhs) const
{
return !(*this == rhs);
}
bool operator!=(const TransformStorage & rhs) const;

tf2::Quaternion rotation_;
tf2::Vector3 translation_;
Expand Down
40 changes: 40 additions & 0 deletions tf2/src/buffer_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,46 @@ void BufferCore::cancelTransformableRequest(TransformableRequestHandle handle)
transformable_requests_.erase(remove_it, transformable_requests_.end());
}

void BufferCore::setUsingDedicatedThread(bool value)
{
using_dedicated_thread_ = value;
}

bool BufferCore::isUsingDedicatedThread() const
{
return using_dedicated_thread_;
}

CompactFrameID BufferCore::_lookupFrameNumber(const std::string & frameid_str) const
{
return lookupFrameNumber(frameid_str);
}

CompactFrameID BufferCore::_lookupOrInsertFrameNumber(const std::string & frameid_str)
{
return lookupOrInsertFrameNumber(frameid_str);
}

tf2::TF2Error BufferCore::_getLatestCommonTime(
CompactFrameID target_frame, CompactFrameID source_frame,
TimePoint & time, std::string * error_string) const
{
std::unique_lock<std::mutex> lock(frame_mutex_);
return getLatestCommonTime(target_frame, source_frame, time, error_string);
}

CompactFrameID BufferCore::_validateFrameId(
const char * function_name_arg,
const std::string & frame_id) const
{
return validateFrameId(function_name_arg, frame_id);
}

tf2::Duration BufferCore::getCacheLength()
{
return cache_time_;
}

// backwards compatibility for tf methods
bool BufferCore::_frameExists(const std::string & frame_id_str) const
{
Expand Down
29 changes: 29 additions & 0 deletions tf2/src/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,35 @@ TransformStorage::TransformStorage(
{
}

TransformStorage::TransformStorage(const TransformStorage & rhs)
{
*this = rhs;
}

TransformStorage & TransformStorage::operator=(const TransformStorage & rhs)
{
rotation_ = rhs.rotation_;
translation_ = rhs.translation_;
stamp_ = rhs.stamp_;
frame_id_ = rhs.frame_id_;
child_frame_id_ = rhs.child_frame_id_;
return *this;
}

bool TransformStorage::operator==(const TransformStorage & rhs) const
{
return (this->rotation_ == rhs.rotation_) &&
(this->translation_ == rhs.translation_) &&
(this->stamp_ == rhs.stamp_) &&
(this->frame_id_ == rhs.frame_id_) &&
(this->child_frame_id_ == rhs.child_frame_id_);
}

bool TransformStorage::operator!=(const TransformStorage & rhs) const
{
return !(*this == rhs);
}

TimeCache::TimeCache(tf2::Duration max_storage_time)
: max_storage_time_(max_storage_time)
{}
Expand Down
Loading