54 #ifndef _GAMS_POSE_REFERENCE_FRAME_H_
55 #define _GAMS_POSE_REFERENCE_FRAME_H_
71 #include "madara/knowledge/EvalSettings.h"
74 namespace gams {
namespace pose {
76 class ReferenceFrameVersion;
77 class ReferenceFrameIdentity;
83 std::weak_ptr<ReferenceFrameIdentity>>
idents_;
86 std::shared_ptr<ReferenceFrameIdentity>
lookup(std::string
id);
88 std::shared_ptr<ReferenceFrameIdentity>
find(std::string
id)
const;
90 std::shared_ptr<ReferenceFrameIdentity>
make_guid();
122 mutable std::map<uint64_t, std::weak_ptr<ReferenceFrameVersion>>
125 mutable uint64_t expiry_ = ETERNAL;
132 : id_(std::move(id)), expiry_(expiry) {}
134 static std::shared_ptr<ReferenceFrameIdentity>
lookup(std::string
id)
136 std::lock_guard<std::recursive_mutex> guard(idents_lock_);
138 return arena_.
lookup(std::move(
id));
141 static std::shared_ptr<ReferenceFrameIdentity>
find(std::string
id)
143 std::lock_guard<std::recursive_mutex> guard(idents_lock_);
145 return arena_.
find(std::move(
id));
148 static std::shared_ptr<ReferenceFrameIdentity>
make_guid()
150 std::lock_guard<std::recursive_mutex> guard(idents_lock_);
156 std::shared_ptr<ReferenceFrameVersion> ver)
const
158 std::lock_guard<std::recursive_mutex> guard(versions_lock_);
160 std::weak_ptr<ReferenceFrameVersion> weak(std::move(ver));
161 versions_[timestamp] = ver;
164 std::shared_ptr<ReferenceFrameVersion>
get_version(uint64_t timestamp)
const
166 std::lock_guard<std::recursive_mutex> guard(versions_lock_);
168 auto find = versions_.find(timestamp);
170 if (find == versions_.end()) {
174 return find->second.lock();
177 const std::string &
id()
const {
return id_; }
197 std::lock_guard<std::recursive_mutex> guard(idents_lock_);
199 uint64_t ret = default_expiry_;
200 default_expiry_ = age;
206 std::lock_guard<std::recursive_mutex> guard(idents_lock_);
207 return default_expiry_;
225 std::lock_guard<std::recursive_mutex> guard(versions_lock_);
227 uint64_t ret = expiry_;
234 std::lock_guard<std::recursive_mutex> guard(versions_lock_);
242 std::lock_guard<std::recursive_mutex> guard(idents_lock_);
252 std::lock_guard<std::recursive_mutex> guard(idents_lock_);
264 const std::string &
id)
266 prefix.reserve(prefix.capacity() + 1 +
id.size());
275 std::string &prefix, uint64_t timestamp)
282 std::ostringstream oss;
285 oss << std::hex << timestamp;
295 const std::string &
id, uint64_t timestamp)
305 (x.nanos(), x.nanos(0UL)));
314 template<
typename T,
typename... Args>
316 typename std::enable_if<supports_nano_timestamp<T>::value, uint64_t>::type
322 template<
typename T,
typename... Args>
324 typename std::enable_if<!supports_nano_timestamp<T>::value, uint64_t>::type
336 public std::enable_shared_from_this<ReferenceFrameVersion>
339 mutable std::shared_ptr<ReferenceFrameIdentity>
ident_;
341 uint64_t timestamp_ = ETERNAL;
343 mutable bool interpolated_ =
false;
350 if (given == ETERNAL) {
371 typename std::enable_if<
372 supports_transform_to<P>::value,
void*>::type =
nullptr>
375 uint64_t timestamp = ETERNAL,
378 std::forward<P>(origin),
393 typename std::enable_if<
394 supports_transform_to<P>::value,
void*>::type =
nullptr>
398 uint64_t timestamp = ETERNAL,
401 std::forward<P>(origin), timestamp, temp) {}
414 typename std::enable_if<
415 supports_transform_to<P>::value,
void*>::type =
nullptr>
419 uint64_t timestamp = ETERNAL,
423 std::forward<P>(origin), timestamp, temp) {}
437 typename std::enable_if<
438 supports_transform_to<P>::value,
void*>::type =
nullptr>
443 uint64_t timestamp = ETERNAL,
447 std::forward<P>(origin), timestamp, temp) {}
462 typename std::enable_if<
463 supports_transform_to<P>::value,
void*>::type =
nullptr>
465 std::shared_ptr<ReferenceFrameIdentity> ident,
468 uint64_t timestamp = ETERNAL,
470 : ident_(std::move(ident)),
472 timestamp_(init_timestamp(timestamp, origin)),
473 origin_(std::forward<P>(origin)),
489 typename std::enable_if<
490 supports_transform_to<P>::value,
void*>::type =
nullptr>
492 std::shared_ptr<ReferenceFrameIdentity> ident,
494 uint64_t timestamp = ETERNAL,
497 std::forward<P>(origin), timestamp, temp) {}
548 return pose(new_origin, timestamp_);
558 return move(new_origin, timestamp_);
568 return orient(new_origin, timestamp_);
580 ident_, type(), new_origin, timestamp));
591 uint64_t timestamp)
const {
603 uint64_t timestamp)
const {
604 return pose(
Pose(
Position(origin_), new_origin), timestamp);
612 return origin_.
frame();
665 const std::string &
id()
const {
689 return has_id() ? nullptr : &id();
706 ident_, type(), origin(), timestamp));
715 return interpolated_;
734 std::string prefix = settings.prefix();
748 void save(madara::knowledge::KnowledgeBase &kb,
751 std::string key = this->key(settings);
752 save_as(kb, std::move(key), expiry, settings);
763 void save(madara::knowledge::KnowledgeBase &kb,
765 std::string key = this->key(settings);
766 save_as(kb, std::move(key), settings);
784 madara::knowledge::KnowledgeBase &kb,
785 const std::string &
id,
786 uint64_t timestamp = ETERNAL,
787 uint64_t parent_timestamp = ETERNAL,
789 bool throw_on_errors =
true,
808 madara::knowledge::KnowledgeBase &kb,
809 const std::string &
id,
810 uint64_t timestamp = ETERNAL,
811 uint64_t parent_timestamp = ETERNAL,
813 bool throw_on_errors =
true,
830 madara::knowledge::KnowledgeBase &kb,
831 const std::string &
id,
832 uint64_t timestamp = ETERNAL,
834 bool throw_on_errors =
true,
848 madara::knowledge::KnowledgeBase &kb,
849 const std::string &
id,
857 madara::knowledge::KnowledgeBase &kb,
const std::string &
id,
861 madara::knowledge::KnowledgeBase &kb,
866 const std::vector<ancestor_vec> &stamps);
882 template<
typename InputIterator>
884 madara::knowledge::KnowledgeBase &kb,
893 std::vector<ancestor_vec> stamps;
896 typename std::iterator_traits<InputIterator>::iterator_category,
897 std::random_access_iterator_tag>::value) {
898 size_t count = std::distance(begin, end);
901 madara::knowledge::ContextGuard guard(kb);
903 return find_nearest_neighbors(kb, *begin, -1, settings).first;
906 stamps.reserve(count);
910 madara::knowledge::ContextGuard guard(kb);
912 InputIterator cur = begin;
914 stamps.emplace_back(get_ancestry(kb, *cur, settings));
919 return find_common_timestamp_to_first_ancestor(stamps);
934 template<
typename Container>
936 madara::knowledge::KnowledgeBase &kb,
937 const Container &ids,
940 madara::knowledge::ContextGuard guard(kb);
942 return latest_common_timestamp(kb, ids.cbegin(), ids.cend(),
962 template<
typename ForwardIterator>
964 madara::knowledge::KnowledgeBase &kb,
965 ForwardIterator begin,
967 uint64_t timestamp = ETERNAL,
971 std::vector<ReferenceFrame> ret;
973 typename std::iterator_traits<ForwardIterator>::iterator_category,
974 std::random_access_iterator_tag>::value) {
975 size_t count = std::distance(begin, end);
979 madara::knowledge::ContextGuard guard(kb);
981 if (timestamp == ETERNAL) {
982 timestamp = latest_common_timestamp(kb, begin, end, settings);
986 if (arena ==
nullptr) {
987 arena = &local_arena;
990 while (begin != end) {
991 ReferenceFrame frame = load(kb, *begin, timestamp, settings, arena);
992 if (!frame.
valid()) {
993 std::stringstream msg;
994 msg <<
"ReferenceFrame::load_tree: could not find frame \"" <<
995 *begin <<
"\" at timestamp " << timestamp << std::endl;
998 ret.push_back(frame);
1001 throw_if_not_connected(ret);
1024 template<
typename Container>
1026 madara::knowledge::KnowledgeBase &kb,
const Container &ids,
1027 uint64_t timestamp = ETERNAL,
1031 return load_tree(kb, ids.begin(), ids.end(),
1032 timestamp, std::move(settings), arena);
1043 void save_as(madara::knowledge::KnowledgeBase &kb,
1044 std::string key, uint64_t expiry,
1053 void save_as(madara::knowledge::KnowledgeBase &kb,
1057 save_as(kb, key, ident().expiry(), settings);
1075 auto ret = ident().get_version(time);
1080 double fraction = (time - timestamp()) / (
double)(other.
timestamp() - timestamp());
1082 Pose interp = origin();
1085 interp.
frame(std::move(parent));
1087 interp.x((fraction * (opose.x() - interp.x())) + interp.x());
1088 interp.y((fraction * (opose.y() - interp.y())) + interp.y());
1089 interp.z((fraction * (opose.z() - interp.z())) + interp.z());
1091 Quaternion iq(origin().as_orientation_vec());
1099 auto ret = std::make_shared<ReferenceFrameVersion>(
1100 ident_, type(), std::move(interp), time);
1103 ident().register_version(time, ret);
1106 ret->interpolated_ =
true;
1110 template<
typename CoordType>
1130 mutable madara::knowledge::KnowledgeBase
kb_;
1148 : kb_(std::move(kb)), settings_(std::move(settings)), expiry_(expiry) {}
1158 :
FrameStore(std::move(kb), std::move(settings),
1191 const madara::knowledge::KnowledgeBase &
kb()
const {
return kb_; }
1202 return frame.
save(kb_, expiry_, settings_);
1236 template<
typename InputIterator>
1238 InputIterator begin,
1240 uint64_t timestamp = ETERNAL)
const {
1260 template<
typename Container>
1262 const Container &ids,
1263 uint64_t timestamp = ETERNAL)
const {
1279 std::vector<const ReferenceFrame *> *to_stack =
nullptr);
1328 bool is_child_to_parent,
1329 bool unsupported_angular =
false);
1334 bool is_child_to_parent;
1335 bool unsupported_angular;
1346 namespace simple_rotate {
1359 double &x,
double &y,
double &z,
1360 double rx,
double ry,
double rz,
1361 bool reverse =
false);
1378 double orx,
double ory,
double orz,
1379 double &rx,
double &ry,
double &rz);
1396 double orx,
double ory,
double orz,
1397 double &rx,
double &ry,
double &rz);
1418 double ox,
double oy,
double oz,
1419 double orx,
double ory,
double orz,
1420 double &x,
double &y,
double &z,
1421 double &rx,
double &ry,
double &rz,
1446 double ox,
double oy,
double oz,
1447 double orx,
double ory,
double orz,
1448 double &x,
double &y,
double &z,
1449 double &rx,
double &ry,
double &rz,
1466 double rx1,
double ry1,
double rz1,
1467 double rx2,
double ry2,
double rz2);
1475 double &,
double &,
double &) {}
1482 double &,
double &,
double &) {}
1498 double &x,
double &y,
double &z,
1499 double &rx,
double &ry,
double &rz)
1501 self->normalize_linear(
self, x, y, z);
1502 self->normalize_angular(
self, rx, ry, rz);
1507 #include "ReferenceFrame.inl"
An exception class for ReferenceFrame errors subclassed from GamsException.
OrientationVector & as_orientation_vec()
Gets a reference to this object's Orientation part.
Settings class for saving/loading reference frames.
static const FrameEvalSettings DEFAULT
static const std::string & default_prefix()
Get default prefix for all FrameEvalSettings that don't have another prefix set.
Class for storing and loading frames in a given KnowledgeBase, using given settings,...
FrameStore(madara::knowledge::KnowledgeBase kb, FrameEvalSettings settings)
Constructor for FrameStore Uses ReferenceFrame::default_expiry() for expiration.
FrameStore(madara::knowledge::KnowledgeBase kb)
Constructor for FrameStore Uses default FrameEvalSettings Uses ReferenceFrame::default_expiry() for e...
const FrameEvalSettings & settings() const
Return the current settings for frames saved/loaded with this FrameStore.
madara::knowledge::KnowledgeBase kb_
uint64_t expiry() const
Return the current expiry for all frames saved with this FrameStore See ReferenceFrame::expiry(uint64...
std::vector< ReferenceFrame > load_tree(InputIterator begin, InputIterator end, uint64_t timestamp=ETERNAL) const
Load ReferenceFrames, by ID, and their common ancestors.
void save(const ReferenceFrame &frame) const
Save a ReferenceFrame to the knowledge base, The saved frames will be marked with their timestamp for...
std::vector< ReferenceFrame > load_tree(const Container &ids, uint64_t timestamp=ETERNAL) const
Load ReferenceFrames, by ID, and their common ancestors.
FrameStore(madara::knowledge::KnowledgeBase kb, uint64_t expiry)
Constructor for FrameStore Uses default FrameEvalSettings.
const madara::knowledge::KnowledgeBase & kb() const
Return the KnowledgeBase to load/save with this FrameStore.
FrameStore(madara::knowledge::KnowledgeBase kb, FrameEvalSettings settings, uint64_t expiry)
Primary constructor for FrameStore.
ReferenceFrame load(const std::string &id, uint64_t timestamp=ETERNAL)
Load a single ReferenceFrame, by ID.
const ReferenceFrame & frame() const
Getter for the ReferenceFrame this Coordinate belongs to.
Used internally to implement angle operations.
void to_angular_vector(double &rx, double &ry, double &rz) const
void slerp_this(const Quaternion &o, double t)
If *this and o are unit quaternions, interpolate a quaternion that is partially between them,...
std::shared_ptr< ReferenceFrameIdentity > find(std::string id) const
std::shared_ptr< ReferenceFrameIdentity > lookup(std::string id)
std::map< std::string, std::weak_ptr< ReferenceFrameIdentity > > idents_
void gc()
Old versions of frames can remain loaded in memory after they are no longer needed.
std::shared_ptr< ReferenceFrameIdentity > make_guid()
static uint64_t default_expiry(uint64_t age)
Set the default expiry value for new frames IDs.
static ReferenceFrameArena arena_
uint64_t expiry() const
Return the current expiry.
static uint64_t default_expiry_
static std::shared_ptr< ReferenceFrameIdentity > find(std::string id)
static void gc()
Old versions of frames can remain loaded in memory after they are no longer needed.
uint64_t expiry(uint64_t age) const
If a frame newer than this time is saved, expire saved frames of the same ID older than this duration...
static std::shared_ptr< ReferenceFrameIdentity > make_guid()
void expire_older_than(madara::knowledge::KnowledgeBase &kb, uint64_t time, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
static std::recursive_mutex idents_lock_
static const uint64_t ETERNAL
static std::shared_ptr< ReferenceFrameIdentity > lookup(std::string id)
static const uint64_t TEMP
static const std::string & default_prefix()
std::map< uint64_t, std::weak_ptr< ReferenceFrameVersion > > versions_
std::recursive_mutex versions_lock_
static uint64_t default_expiry()
Return the default expiry for new frame IDs.
const std::string & id() const
void register_version(uint64_t timestamp, std::shared_ptr< ReferenceFrameVersion > ver) const
std::shared_ptr< ReferenceFrameVersion > get_version(uint64_t timestamp) const
ReferenceFrameIdentity(std::string id, uint64_t expiry)
Public by necessity. Use lookup instead.
bool interpolated() const
Returns true if this frame was interpolated from two stored frames.
ReferenceFrameVersion(const ReferenceFrameType *type, P &&origin, uint64_t timestamp=ETERNAL, bool temp=false)
Constructor from a type, an origin, and optional timestamp.
static uint64_t latest_common_timestamp(madara::knowledge::KnowledgeBase &kb, const Container &ids, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT)
Get the latest available timestamp in the knowledge base common to all the given ids.
std::shared_ptr< ReferenceFrameIdentity > ident_
ReferenceFrame origin_frame() const
Gets the parent frame (the one the origin is within).
ReferenceFrameVersion(std::shared_ptr< ReferenceFrameIdentity > ident, P &&origin, uint64_t timestamp=ETERNAL, bool temp=false)
Constructor from an existing ReferenceFrameIdentity, an origin, and optional timestamp.
bool check_consistent() const
ReferenceFrame orient(const Orientation &new_origin, uint64_t timestamp) const
Creates a new ReferenceFrame with modified origin and timestamp.
static std::pair< uint64_t, uint64_t > find_nearest_neighbors(madara::knowledge::KnowledgeBase &kb, const std::string &id, uint64_t timestamp, const FrameEvalSettings &settings)
const std::string & id() const
Get the ID string of this frame.
bool operator==(const ReferenceFrameVersion &other) const
Equality operator.
static uint64_t find_common_timestamp_to_first_ancestor(const std::vector< ancestor_vec > &stamps)
ReferenceFrameVersion(const ReferenceFrameType *type, std::string name, P &&origin, uint64_t timestamp=ETERNAL, bool temp=false)
Constructor from a type, id, an origin, and optional timestamp.
const ReferenceFrameType * type_
ReferenceFrame move(const Position &new_origin, uint64_t timestamp) const
Creates a new ReferenceFrame with modified origin and timestamp.
ReferenceFrame orient(Orientation new_origin) const
Creates a new ReferenceFrame with modified origin.
static ReferenceFrame load_exact_internal(madara::knowledge::KnowledgeBase &kb, const std::string &id, uint64_t timestamp=ETERNAL, uint64_t parent_timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT, bool throw_on_errors=true, ReferenceFrameArena *arena=nullptr)
Load a single ReferenceFrame, by ID and timestamp.
static ReferenceFrame load(madara::knowledge::KnowledgeBase &kb, const std::string &id, uint64_t timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT, bool throw_on_errors=true, ReferenceFrameArena *arena=nullptr)
Load a single ReferenceFrame, by ID and timestamp, interpolated if applicable.
static std::vector< ReferenceFrame > load_tree(madara::knowledge::KnowledgeBase &kb, ForwardIterator begin, ForwardIterator end, uint64_t timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT, ReferenceFrameArena *arena=nullptr)
Load ReferenceFrames, by ID, and their common ancestors.
ReferenceFrame timestamp(uint64_t timestamp) const
Clone the this frame, but with new timestamp.
std::string key(const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
Returns the key that save() will use to store this frame.
static void throw_if_not_connected(const std::vector< ReferenceFrame > &frames)
bool operator!=(const ReferenceFrame &other) const
Inequality operator.
std::pair< std::string, uint64_t > ancestor_elem
bool operator==(const ReferenceFrame &other) const
Equality operator.
static const std::string & default_prefix()
static bool check_is_connected(const std::vector< ReferenceFrame > &frames)
std::vector< ancestor_elem > ancestor_vec
ReferenceFrame move(Position new_origin) const
Creates a new ReferenceFrame with modified origin.
uint64_t timestamp() const
Get the timestamp assigned to this frame.
ReferenceFrameVersion(std::string name, P &&origin, uint64_t timestamp=ETERNAL, bool temp=false)
Constructor from a id, an origin, and optional timestamp.
static ancestor_vec get_ancestry(madara::knowledge::KnowledgeBase &kb, std::string name, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT)
ReferenceFrame pose(Pose new_origin) const
Creates a new ReferenceFrame with modified origin.
ReferenceFrameVersion(P &&origin, uint64_t timestamp=ETERNAL, bool temp=false)
Constructor from an origin, and optional timestamp.
ReferenceFrame interpolate(const ReferenceFrame &other, ReferenceFrame parent, uint64_t time) const
Interpolate a frame between the given frame; use the given parent.
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 ...
ReferenceFrameVersion(std::shared_ptr< ReferenceFrameIdentity > ident, const ReferenceFrameType *type, P &&origin, uint64_t timestamp=ETERNAL, bool temp=false)
Constructor from an existing ReferenceFrameIdentity, an origin, and optional timestamp.
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 ...
Pose & mut_origin()
Gets the origin of this Frame.
const Pose & origin() const
Gets the origin of this Frame.
const ReferenceFrameType * type() const
Retrieve the frame type object for this frame.
bool operator!=(const ReferenceFrameVersion &other) const
Inequality operator.
static uint64_t latest_common_timestamp(madara::knowledge::KnowledgeBase &kb, InputIterator begin, InputIterator end, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT)
Get the latest available timestamp in the knowledge base common to all the given ids.
const char * name() const
Returns a human-readable name for the reference frame type.
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.
const std::string * id_ptr() const
Get the ID string of this frame.
static ReferenceFrame load_exact(madara::knowledge::KnowledgeBase &kb, const std::string &id, uint64_t timestamp=ETERNAL, uint64_t parent_timestamp=ETERNAL, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT, bool throw_on_errors=true, ReferenceFrameArena *arena=nullptr)
Load a single ReferenceFrame, by ID and timestamp.
ReferenceFrame pose(const Pose &new_origin, uint64_t timestamp) const
Creates a new ReferenceFrame with modified origin and timestamp.
static uint64_t latest_timestamp(madara::knowledge::KnowledgeBase &kb, const std::string &id, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT)
Get the latest available timestamp in the knowledge base for the given id.
void save_as(madara::knowledge::KnowledgeBase &kb, std::string key, uint64_t expiry, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
Save this ReferenceFrame to the knowledge base, with a specific key value.
const ReferenceFrameIdentity & ident() const
Get the ReferenceFrameIdentity object associated with this frame, creating one with random ID if none...
bool has_id() const
Does this frame have an ID? Frames gain an ID either at construction, or lazily as needed (by having ...
bool temp() const
Returns true if this frame is a temporary; one invented to serve as root of a frame tree.
void save_as(madara::knowledge::KnowledgeBase &kb, std::string key, const FrameEvalSettings &settings=FrameEvalSettings::DEFAULT) const
Save this ReferenceFrame to the knowledge base, with a specific key value.
static uint64_t init_timestamp(uint64_t given, const T &p)
Provides Reference Frame (i.e., coordinate systemm) transforms.
uint64_t timestamp() const
Get the timestamp assigned to this frame.
static const uint64_t ETERNAL
static const uint64_t TEMP
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.
bool valid() const
Test whether this frame is valid.
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 ...
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 Pose & origin() const
Gets the origin of this Frame.
static std::string & make_kb_key(std::string &prefix, const std::string &id)
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 orient_linear_vec(double &x, double &y, double &z, double rx, double ry, double rz, bool reverse=false)
Rotates a LinearVector according to a AngularVector.
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 * find_common_frame(const ReferenceFrame *from, const ReferenceFrame *to, std::vector< const ReferenceFrame * > *to_stack=nullptr)
Helper function to find the common frame between two frames.
void default_normalize_linear(const ReferenceFrameType *, double &, double &, double &)
Returns a default normalized positional.
GAMS_EXPORT const ReferenceFrameType * Cartesian
ReferenceFrameType struct for Cartesian frames.
void default_normalize_angular(const ReferenceFrameType *, double &, double &, double &)
Returns a default normalized angular.
void default_normalize_pose(const ReferenceFrameType *self, double &x, double &y, double &z, double &rx, double &ry, double &rz)
Returns a default normalized pose.
MADARA_MAKE_VAL_SUPPORT_TEST(nano_timestamp, x,(x.nanos(), x.nanos(0UL)))
Type trait to detect stamped types.
uint64_t try_get_nano_time(uint64_t def)
Base case: return default.
gams::pose::Orientation Orientation
Represents a orientation or orientation within a reference frame.
gams::pose::ReferenceFrame ReferenceFrame
Base class for Reference Frames.
gams::pose::Coordinate< CoordType > Coordinate
New coordinate types which are frame-dependant can inherit from this class.
gams::pose::Pose Pose
Represents a combination of Location and Orientation within a single reference frame.
Contains all GAMS-related tools, classes and code.
Copyright (c) 2015 Carnegie Mellon University.
Copyright (c) 2015 Carnegie Mellon University.
Copyright (c) 2015 Carnegie Mellon University.