Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup tests and tests utilities (#43)
- Loading branch information
1 parent
4d85ef0
commit 37b4a3d
Showing
35 changed files
with
2,318 additions
and
1,064 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Schema for S.I.M.P.L.E. Homogeneous Transformation | ||
|
||
namespace simple_msgs; | ||
|
||
table TransformFbs { | ||
point:[ubyte]; | ||
matrix:[ubyte]; | ||
} | ||
|
||
root_type TransformFbs; | ||
file_identifier "TRAN"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Schema for S.I.M.P.L.E. Stamped Homogeneous Transformation | ||
|
||
namespace simple_msgs; | ||
|
||
table TransformStampedFbs { | ||
transform:[ubyte]; | ||
header:[ubyte]; | ||
} | ||
|
||
root_type TransformStampedFbs; | ||
file_identifier "TRST"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/** | ||
* S.I.M.P.L.E. - Smart Intuitive Messaging Platform with Less Effort | ||
* Copyright (C) 2018 Salvatore Virga - salvo.virga@tum.de, Fernanda Levy | ||
* Langsch - fernanda.langsch@tum.de | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef SIMPLE_MSGS_TRANSFORM_H | ||
#define SIMPLE_MSGS_TRANSFORM_H | ||
|
||
#include <array> | ||
#include <ostream> | ||
|
||
#include "generated/transform_generated.h" | ||
#include "point.h" | ||
#include "rotation_matrix.h" | ||
|
||
namespace simple_msgs { | ||
/** | ||
* @class Transform transform.h. | ||
* @brief Wrapper for a Flatbuffers Transform message. | ||
* It represents a 4x4 homogeneous transformation, stored in <b>row-major</b> order. | ||
*/ | ||
class Transform : public GenericMessage { | ||
public: | ||
Transform() = default; | ||
|
||
/** | ||
* @brief Construct a Transform message give its translation and its rotation part. | ||
*/ | ||
Transform(const Point&, const RotationMatrix&); | ||
|
||
/** | ||
* @brief Construct a Transform message give its translation and its rotation part. | ||
*/ | ||
Transform(Point&&, RotationMatrix&&); | ||
|
||
/** | ||
* @brief Construct a Transform message give a vector of 16 elements. | ||
* The vector is expected to be in <b>row-major</b> order. | ||
*/ | ||
Transform(const std::array<double, 16>&); | ||
|
||
/** | ||
* @brief Construct a Transform message give a vector of 16 elements. | ||
* The vector is expected to be in <b>row-major</b> order. | ||
*/ | ||
Transform(std::array<double, 16>&&) noexcept; | ||
|
||
/** | ||
* @brief Construct a Transform message using a raw memory coming from network. | ||
*/ | ||
Transform(const void*); | ||
|
||
/** | ||
* @brief Copy constructor. | ||
*/ | ||
Transform(const Transform&); | ||
|
||
/** | ||
* @brief Move constructor. | ||
*/ | ||
Transform(Transform&&) noexcept; | ||
|
||
/** | ||
* @brief Copy assignment operator. | ||
*/ | ||
Transform& operator=(const Transform&); | ||
|
||
/** | ||
* @brief Move assignment operator. | ||
*/ | ||
Transform& operator=(Transform&&) noexcept; | ||
|
||
/** | ||
* @brief Copy assignment operator that uses raw memory coming from the network. | ||
*/ | ||
Transform& operator=(std::shared_ptr<void*>); | ||
|
||
/** | ||
* @brief Returns true if lhs is equal to rhs, false otherwise. | ||
*/ | ||
inline bool operator==(const Transform& rhs) const { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return (point_ == rhs.point_ && matrix_ == rhs.matrix_); | ||
} | ||
|
||
/** | ||
* @brief Returns true if lhs is not equal to rhs, false otherwise. | ||
*/ | ||
inline bool operator!=(const Transform& rhs) const { return !(*this == rhs); } | ||
|
||
/** | ||
* @brief Stream extraction operator. | ||
*/ | ||
friend std::ostream& operator<<(std::ostream&, const Transform&); | ||
|
||
/** | ||
* @brief Builds and returns the buffer accordingly to the values currently stored. | ||
*/ | ||
std::shared_ptr<flatbuffers::DetachedBuffer> getBufferData() const override; | ||
|
||
/** | ||
* @brief Returns the rotational part of the homogeneous transformation. | ||
*/ | ||
inline RotationMatrix& getRotation() { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return matrix_; | ||
} | ||
|
||
/** | ||
* @brief Returns the rotational part of the homogeneous transformation. | ||
*/ | ||
inline const RotationMatrix& getRotation() const { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return matrix_; | ||
} | ||
|
||
/** | ||
* @brief Returns the translational part of the homogeneous transformation. | ||
*/ | ||
inline Point& getTranslation() { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return point_; | ||
} | ||
|
||
/** | ||
* @brief Returns the translational part of the homogeneous transformation. | ||
*/ | ||
inline const Point& getTranslation() const { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return point_; | ||
} | ||
|
||
/** | ||
* @brief Modifies the translational part of the Pose. | ||
*/ | ||
void setTranslation(const Point&); | ||
|
||
/** | ||
* @brief Modifies the rotational part of the Pose. | ||
*/ | ||
void setRotation(const RotationMatrix&); | ||
|
||
/** | ||
* @brief Returns an identifier of the message type generated by the flatbuffers. | ||
*/ | ||
static inline std::string getTopic() { return TransformFbsIdentifier(); } | ||
|
||
private: | ||
//! Thread safe copy and move constructors. | ||
Transform(const Transform& other, const std::lock_guard<std::mutex>&); | ||
Transform(Transform&& other, const std::lock_guard<std::mutex>&) noexcept; | ||
|
||
mutable std::mutex mutex_{}; | ||
Point point_{}; //! The translational part of the homogeneous transformation. | ||
RotationMatrix matrix_{}; //! The rotational part of the homogeneous transformation. | ||
}; | ||
} // Namespace simple_msgs. | ||
|
||
#endif // SIMPLE_MSGS_TRANSFORM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
/** | ||
* S.I.M.P.L.E. - Smart Intuitive Messaging Platform with Less Effort | ||
* Copyright (C) 2018 Salvatore Virga - salvo.virga@tum.de, Fernanda Levy | ||
* Langsch - fernanda.langsch@tum.de | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef SIMPLE_MSGS_TRANSFORM_STAMPED_H | ||
#define SIMPLE_MSGS_TRANSFORM_STAMPED_H | ||
|
||
#include <array> | ||
#include <ostream> | ||
|
||
#include "generated/transform_stamped_generated.h" | ||
#include "header.h" | ||
#include "transform.h" | ||
|
||
namespace simple_msgs { | ||
/** | ||
* @class TransformStamped transform_stamped.h. | ||
* @brief Thread-safe wrapper for a Flatbuffers TransformStamped message. | ||
* It contains a Transform and a Header message. | ||
*/ | ||
class TransformStamped : public GenericMessage { | ||
public: | ||
TransformStamped() = default; | ||
|
||
/** | ||
* @brief Construct a TransformStamped message given its Header and Transform. | ||
*/ | ||
TransformStamped(const Header&, const Transform&); | ||
|
||
/** | ||
* @brief Construct a TransformStamped message given its Header and Transform. | ||
*/ | ||
TransformStamped(Header&&, Transform&&); | ||
|
||
/** | ||
* @brief Construct a TransformStamped message using a raw memory coming from network. | ||
*/ | ||
TransformStamped(const void*); | ||
|
||
/** | ||
* @brief Copy constructor. | ||
*/ | ||
TransformStamped(const TransformStamped&); | ||
|
||
/** | ||
* @brief Move constructor. | ||
*/ | ||
TransformStamped(TransformStamped&&) noexcept; | ||
|
||
/** | ||
* @brief Copy assignment operator. | ||
*/ | ||
TransformStamped& operator=(const TransformStamped&); | ||
|
||
/** | ||
* @brief Move assignment operator. | ||
*/ | ||
TransformStamped& operator=(TransformStamped&&) noexcept; | ||
|
||
/** | ||
* @brief Copy assignment operator that uses raw memory coming from the network. | ||
*/ | ||
TransformStamped& operator=(std::shared_ptr<void*>); | ||
|
||
/** | ||
* @brief Returns true if lhs is equal to rhs, false otherwise. | ||
*/ | ||
inline bool operator==(const TransformStamped& rhs) const { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return (transform_ == rhs.transform_ && header_ == rhs.header_); | ||
} | ||
|
||
/** | ||
* @brief Returns true if lhs is not equal to rhs, false otherwise. | ||
*/ | ||
inline bool operator!=(const TransformStamped& rhs) const { return !(*this == rhs); } | ||
|
||
/** | ||
* @brief Stream extraction operator. | ||
*/ | ||
friend std::ostream& operator<<(std::ostream&, const TransformStamped&); | ||
|
||
/** | ||
* @brief Builds and returns the buffer accordingly to the values currently stored. | ||
*/ | ||
std::shared_ptr<flatbuffers::DetachedBuffer> getBufferData() const override; | ||
|
||
/** | ||
* @brief Returns the message Header. | ||
*/ | ||
inline Header& getHeader() { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return header_; | ||
} | ||
|
||
/** | ||
* @brief Returns the message Header. | ||
*/ | ||
inline const Header& getHeader() const { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return header_; | ||
} | ||
|
||
/** | ||
* @brief Returns the message Transform. | ||
*/ | ||
inline Transform& getTransform() { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return transform_; | ||
} | ||
|
||
/** | ||
* @brief Returns the message Transform. | ||
*/ | ||
inline const Transform& getTransform() const { | ||
std::lock_guard<std::mutex> lock{mutex_}; | ||
return transform_; | ||
} | ||
|
||
/** | ||
* @brief Modifies the message header. | ||
*/ | ||
void setHeader(const Header&); | ||
|
||
/** | ||
* @brief Modifies the message Transform. | ||
*/ | ||
void setTransform(const Transform&); | ||
|
||
/** | ||
* @brief Returns an identifier of the message type generated by the flatbuffers. | ||
*/ | ||
static inline std::string getTopic() { return TransformStampedFbsIdentifier(); } | ||
|
||
private: | ||
//! Thread safe copy and move constructors. | ||
TransformStamped(const TransformStamped& other, const std::lock_guard<std::mutex>&); | ||
TransformStamped(TransformStamped&& other, const std::lock_guard<std::mutex>&) noexcept; | ||
|
||
mutable std::mutex mutex_{}; | ||
Header header_{}; | ||
Transform transform_{}; | ||
}; | ||
} // Namespace simple_msgs. | ||
|
||
#endif // SIMPLE_MSGS_TRANSFORM_STAMPED_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.