Skip to content

File pose_base.hpp

File List > data_format > poses > pose_base.hpp

Go to the documentation of this file

#pragma once

#include 
#ifdef USING_OPENXR
#    ifdef ENABLE_MONADO
#        include "xrt/xrt_defines.h"
#        define POSE_DATA_TYPE xrt_pose
#    else
#        include "openxr_defines.hpp"

#        include 
#        define POSE_DATA_TYPE XrPosef
#    endif
#else
#    if __has_include()
#        include 
#    else // __has_include()
#        include 
#        include 
#    endif // __has_include()
#endif     // USING_OPENXR

namespace ILLIXR::data_format::pose {
enum side : int { LEFT = 0, RIGHT = 1 };

[[maybe_unused]] inline side non_primary(const side sd) {
    if (sd == LEFT)
        return RIGHT;
    return LEFT;
}

#ifdef USING_OPENXR
struct pose_base : POSE_DATA_TYPE {
#else
struct pose_base {
    Eigen::Vector3f    position;    
    Eigen::Quaternionf orientation; 
    float              confidence;  
    bool               valid;       
#endif

#ifdef USING_OPENXR
    pose_base()
        : POSE_DATA_TYPE{} { }

    explicit pose_base(POSE_DATA_TYPE pose)
        : POSE_DATA_TYPE{pose} { }

    pose_base(const pose_base& base)
        : POSE_DATA_TYPE{} {
        position    = base.position;
        orientation = base.orientation;
    }

#else
    pose_base()
        : position{0.f, 0.f, 0.f}
        , orientation{1.f, 0.f, 0.f, 0.f}
        , confidence{0.f}
        , valid{false} { }

    pose_base(Eigen::Vector3f position_, Eigen::Quaternionf orientation_, float confidence_ = 0.f, bool valid_ = true)
        : position{std::move(position_)}
        , orientation{std::move(orientation_)}
        , confidence{confidence_}
        , valid{valid_} { }
#endif

#ifdef USING_OPENXR

    void update(POSE_DATA_TYPE pose) {
        position    = pose.position;
        orientation = pose.orientation;
    }
#else
    void update(Eigen::Vector3f position_, Eigen::Quaternionf orientation_) {
        position    = std::move(position_);
        orientation = std::move(orientation_);
    }
#endif
};

[[maybe_unused]] typedef std::map<side, pose_base> multi_pose_map;

} // namespace ILLIXR::data_format::pose