54 #ifndef _GAMS_POSE_REFERENCE_FRAME_FWD_H_
55 #define _GAMS_POSE_REFERENCE_FRAME_FWD_H_
59 #include "madara/knowledge/KnowledgeBase.h"
63 namespace gams {
namespace pose {
65 class ReferenceFrameArena;
66 class ReferenceFrameIdentity;
67 class ReferenceFrameVersion;
68 struct ReferenceFrameType;
75 (x.transform_to(std::declval<ReferenceFrame>())));
88 using Base = madara::knowledge::EvalSettings;
101 :
Base(std::move(base)),
102 prefix_(std::make_shared<std::string>(std::move(prefix))) {}
122 std::lock_guard<std::mutex> guard(defaults_lock_);
123 return default_prefix_;
132 std::lock_guard<std::mutex> guard(defaults_lock_);
133 default_prefix_ = new_prefix;
143 return default_prefix();
151 prefix_ = std::make_shared<std::string>(std::move(prefix));
201 std::shared_ptr<ReferenceFrameVersion>
impl_;
204 static const uint64_t ETERNAL = 0UL - 1;
205 static const uint64_t TEMP = 0UL - 2;
225 impl_(std::move(impl)) {}
237 typename std::enable_if<
238 supports_transform_to<P>::value,
void*>::type =
nullptr>
241 uint64_t timestamp = ETERNAL)
243 std::forward<P>(origin), timestamp)) {}
257 typename std::enable_if<
258 supports_transform_to<P>::value,
void*>::type =
nullptr>
262 uint64_t timestamp = ETERNAL)
264 type, std::forward<P>(origin), timestamp)) {}
277 typename std::enable_if<
278 supports_transform_to<P>::value,
void*>::type =
nullptr>
282 uint64_t timestamp = ETERNAL)
284 id, std::forward<P>(origin), timestamp)) {}
298 typename std::enable_if<
299 supports_transform_to<P>::value,
void*>::type =
nullptr>
304 uint64_t timestamp = ETERNAL)
306 type, id, std::forward<P>(origin), timestamp)) {}
314 bool valid()
const {
return (
bool)impl_; }
402 return impl_ < other.
impl_;
407 return impl_ <= other.
impl_;
412 return impl_ > other.
impl_;
417 return impl_ >= other.
impl_;
431 const std::string &
id()
const;
472 uint64_t
expiry(uint64_t age = ETERNAL)
const;
525 void save(madara::knowledge::KnowledgeBase &kb,
537 void save(madara::knowledge::KnowledgeBase &kb,
553 madara::knowledge::KnowledgeBase &kb,
554 const std::string &
id,
555 uint64_t timestamp = ETERNAL,
574 template<
typename InputIterator>
576 madara::knowledge::KnowledgeBase &kb,
579 uint64_t timestamp = ETERNAL,
599 template<
typename Container>
601 madara::knowledge::KnowledgeBase &kb,
602 const Container &ids,
603 uint64_t timestamp = ETERNAL,
621 madara::knowledge::KnowledgeBase &kb,
622 const std::initializer_list<const char *> &ids,
623 uint64_t timestamp = ETERNAL,
635 madara::knowledge::KnowledgeBase &kb,
636 const std::string &key,
647 void save_as(madara::knowledge::KnowledgeBase &kb,
648 const std::string &key, uint64_t expiry,
669 std::vector<const ReferenceFrame *> *to_stack);
689 void (*transform_linear_to_origin)(
692 double ox,
double oy,
double oz,
693 double orx,
double ory,
double orz,
694 double &x,
double &y,
double &z,
697 void (*transform_linear_from_origin)(
700 double ox,
double oy,
double oz,
701 double orx,
double ory,
double orz,
702 double &x,
double &y,
double &z,
705 void (*normalize_linear)(
707 double &x,
double &y,
double &z);
709 double (*calc_distance)(
711 double x1,
double y1,
double z1,
712 double x2,
double y2,
double z2);
717 double orx,
double ory,
double orz,
718 double &rx,
double &ry,
double &rz);
723 double orx,
double ory,
double orz,
724 double &rx,
double &ry,
double &rz);
726 void (*normalize_angular)(
728 double &rx,
double &ry,
double &rz);
732 double rx1,
double ry1,
double rz1,
733 double rx2,
double ry2,
double rz2);
738 double ox,
double oy,
double oz,
739 double orx,
double ory,
double orz,
740 double &x,
double &y,
double &z,
741 double &rx,
double &ry,
double &rz,
747 double ox,
double oy,
double oz,
748 double orx,
double ory,
double orz,
749 double &x,
double &y,
double &z,
750 double &rx,
double &ry,
double &rz,
753 void (*normalize_pose)(
755 double &x,
double &y,
double &z,
756 double &rx,
double &ry,
double &rz);
Settings class for saving/loading reference frames.
const std::string & prefix() const
Get prefix set for this settings object.
FrameEvalSettings(std::string prefix, Base base=Base{true})
Custom prefix constructor.
static std::string default_prefix_
static const FrameEvalSettings DEFAULT
void prefix(std::string prefix)
Set prefix set for this settings object.
std::shared_ptr< std::string > prefix_
static std::mutex defaults_lock_
FrameEvalSettings(Base base=Base{true})
Default constructor.
FrameEvalSettings(const char *prefix, Base base=Base{true})
Custom prefix constructor.
static void set_default_prefix(std::string new_prefix)
Set default prefix for all FrameEvalSettings that don't have another prefix set.
FrameEvalSettings(std::nullptr_t, Base base=Base{true})
Explicit default prefix constructor.
madara::knowledge::EvalSettings Base
static const std::string & default_prefix()
Get default prefix for all FrameEvalSettings that don't have another prefix set.
Provides Reference Frame (i.e., coordinate systemm) transforms.
ReferenceFrame orient(const Orientation &new_origin, uint64_t timestamp) const
Creates a new ReferenceFrame with modified origin and timestamp.
uint64_t timestamp() const
Get the timestamp assigned to this frame.
bool operator>(const ReferenceFrame &other) const
bool operator==(const ReferenceFrame &other) const
Equality operator.
ReferenceFrame(std::string id, P &&origin, uint64_t timestamp=ETERNAL)
Constructor from a id, an origin, and optional timestamp.
ReferenceFrame timestamp(uint64_t) const
Clone the this frame, but with new timestamp.
bool operator<(const ReferenceFrame &other) const
static ReferenceFrame load(madara::knowledge::KnowledgeBase &kb, const std::string &id, uint64_t timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT)
Load a single ReferenceFrame, by ID.
void save(madara::knowledge::KnowledgeBase &kb, uint64_t expiry, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
Save this ReferenceFrame to the knowledge base, The saved frames will be marked with their timestamp ...
bool operator>=(const ReferenceFrame &other) const
bool interpolated() const
Test if frame is interpolated.
uint64_t expiry() const
Return the current expiry for frames of this ID.
bool operator!=(const ReferenceFrame &other) const
Inequality operator.
ReferenceFrame(P &&origin, uint64_t timestamp=ETERNAL)
Constructor from an origin, and optional timestamp.
void save_as(madara::knowledge::KnowledgeBase &kb, const std::string &key, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
Save this ReferenceFrame to the knowledge base, with a specific key value.
ReferenceFrame move(const Position &new_origin, uint64_t timestamp) const
Creates a new ReferenceFrame with modified origin and timestamp.
std::shared_ptr< ReferenceFrameVersion > impl_
ReferenceFrame move(const Position &new_origin) const
Creates a new ReferenceFrame with modified origin.
ReferenceFrame interpolate(const ReferenceFrame &other, ReferenceFrame parent, uint64_t time) const
Interpolate a frame between the given frame; use the given parent.
static std::vector< ReferenceFrame > load_tree(madara::knowledge::KnowledgeBase &kb, const std::initializer_list< const char * > &ids, uint64_t timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT, ReferenceFrameArena *arena=nullptr)
Load ReferenceFrames, by ID, and their common ancestors.
bool valid() const
Test whether this frame is valid.
ReferenceFrame origin_frame() const
Gets the parent frame (the one the origin is within).
uint64_t expiry(uint64_t age=ETERNAL) const
Sets configuration for all frames of this frames ID.
ReferenceFrame pose(const Pose &new_origin, uint64_t timestamp) const
Creates a new ReferenceFrame with modified origin and timestamp.
ReferenceFrame orient(const Orientation &new_origin) const
Creates a new ReferenceFrame with modified origin.
void save(madara::knowledge::KnowledgeBase &kb, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
Save this ReferenceFrame to the knowledge base, The saved frames will be marked with their timestamp ...
ReferenceFrame(const ReferenceFrameType *type, std::string id, P &&origin, uint64_t timestamp=ETERNAL)
Constructor from a type, id, an origin, and optional timestamp.
void save_as(madara::knowledge::KnowledgeBase &kb, const std::string &key, uint64_t expiry, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
Save this ReferenceFrame to the knowledge base, with a specific key value.
static std::vector< ReferenceFrame > load_tree(madara::knowledge::KnowledgeBase &kb, InputIterator begin, InputIterator end, uint64_t timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT, ReferenceFrameArena *arena=nullptr)
Load ReferenceFrames, by ID, and their common ancestors.
const std::string & id() const
Get the ID string of this frame.
bool operator<=(const ReferenceFrame &other) const
friend GAMS_EXPORT const ReferenceFrame * find_common_frame(const ReferenceFrame *from, const ReferenceFrame *to, std::vector< const ReferenceFrame * > *to_stack)
Helper function to find the common frame between two frames.
static const std::string & default_prefix()
Return the default prefix for load/save operations.
ReferenceFrame(std::shared_ptr< ReferenceFrameVersion > impl)
Construct from an existing ReferenceFrameVersion object.
ReferenceFrame()
Default constructor.
static uint64_t default_expiry(uint64_t age)
Set the default expiry value for new frames IDs.
const ReferenceFrameType * type() const
Retrieve the frame type object for this frame.
const Pose & origin() const
Gets the origin of this Frame.
static uint64_t default_expiry()
Return the default expiry for new frame IDs.
ReferenceFrame pose(const Pose &new_origin) const
Creates a new ReferenceFrame with modified origin.
bool temp() const
Returns true if this frame is a temporary; one invented to serve as root of a frame tree.
static std::vector< ReferenceFrame > load_tree(madara::knowledge::KnowledgeBase &kb, const Container &ids, uint64_t timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT, ReferenceFrameArena *arena=nullptr)
Load ReferenceFrames, by ID, and their common ancestors.
ReferenceFrame(const ReferenceFrameType *type, P &&origin, uint64_t timestamp=ETERNAL)
Constructor from a type, an origin, and optional timestamp.
std::string name() const
Returns a human-readable name for the reference frame type.
double calc_angle(const ReferenceFrameType *self, double rx1, double ry1, double rz1, double rx2, double ry2, double rz2)
Calculates smallest angle between two AngularVectors.
void transform_angular_to_origin(const ReferenceFrameType *origin, const ReferenceFrameType *self, double orx, double ory, double orz, double &rx, double &ry, double &rz)
Transform AngularVector in-place into its origin frame from this frame.
void transform_pose_to_origin(const ReferenceFrameType *origin, const ReferenceFrameType *self, double ox, double oy, double oz, double orx, double ory, double orz, double &x, double &y, double &z, double &rx, double &ry, double &rz, bool fixed)
Transform pose in-place into its origin frame from this frame.
void transform_angular_from_origin(const ReferenceFrameType *origin, const ReferenceFrameType *self, double orx, double ory, double orz, double &rx, double &ry, double &rz)
Transform AngularVector in-place from its origin frame.
void transform_pose_from_origin(const ReferenceFrameType *origin, const ReferenceFrameType *self, double ox, double oy, double oz, double orx, double ory, double orz, double &x, double &y, double &z, double &rx, double &ry, double &rz, bool fixed)
Transform pose in-place from its origin frame Simply applies linear and angular transforms independan...
GAMS_EXPORT const ReferenceFrame & default_frame(void)
Default frame.
MADARA_MAKE_VAL_SUPPORT_TEST(nano_timestamp, x,(x.nanos(), x.nanos(0UL)))
Type trait to detect stamped types.
gams::pose::Orientation Orientation
Represents a orientation or orientation within a reference frame.
gams::pose::ReferenceFrame ReferenceFrame
Base class for Reference Frames.
gams::pose::Pose Pose
Represents a combination of Location and Orientation within a single reference frame.
Contains all GAMS-related tools, classes and code.
const char * name
A human-readable name for reference frame types.
int type_id
The type's ID.