Input / Output

enum class motion3d::M3DIOStatus

Status return type for M3DWriter and M3DReader.

Values:

enumerator kSuccess

no errors

enumerator kFileNotFound

the given file does not exist

enumerator kFileOpenError

could not open file

enumerator kFileLockError

could not lock file

enumerator kFilePermissionsError

could not set file permissions

enumerator kUnsupportedFileType

the file type is not supported

enumerator kNoTransformType

input has no transform type

enumerator kInvalidTransformType

given transform type does not exist

enumerator kNoTransforms

transforms are uninitialized or empty

enumerator kInvalidBinarySize

binary data does not result in complete transformations

enumerator kInvalidTransform

number of values does not match the advertised number

enumerator kMoreTransforms

input has more transforms than advertised

enumerator kLessTransforms

input has fewer transforms than advertised

enumerator kInvalidFrame

input has an invalid FRAME value

enumerator kInvalidType

input has an invalid TYPE value

enumerator kInvalidStamps

input has an invalid STAMPS value

enumerator kInvalidPoses

input has an invalid POSES value

enumerator kInvalidSize

input has an invalid SIZE value

enum class motion3d::M3DFileType

M3D File type.

Values:

enumerator kASCII

human-readable ascii

enumerator kBinary

binary-encoded

class MotionData

Storage class for motion data.

Public Functions

explicit MotionData(std::string frame_id = "")

Constructs motion data without initializing the transform type or the transforms.

MotionData(const TransformType &type, const TransformContainer::ConstPtr &transforms, std::string frame_id = "")

Constructs motion data and initializes the transform type and the transforms.

MotionData(const TransformType &type, const TransformContainer::ConstPtr &transforms, const TransformInterface::ConstPtr &origin, std::string frame_id = "")

Constructs motion data and initializes the transform type, the transforms and the origin.

inline const std::string &getFrameId() const
inline std::shared_ptr<const TransformType> getTransformType() const
inline TransformInterface::ConstPtr getOrigin() const
inline TransformContainer::ConstPtr getTransforms() const
inline void setFrameId(const std::string &frame_id)
inline void setTransformType(const TransformType &type)
inline void setOrigin(const TransformInterface::ConstPtr &origin)
inline void setTransforms(const TransformContainer::ConstPtr &transforms)
inline std::string desc() const
Returns:

a description of *this.

Private Members

std::shared_ptr<TransformType> transform_type_

Transform type used for exporting the transforms.

TransformInterface::Ptr origin_

Coordinate frame origin.

TransformContainer::Ptr transforms_

Container with all transforms.

std::string frame_id_

Coordinate frame identifier.

Friends

friend class M3DReader
friend class M3DWriter
friend std::ostream &operator<<(std::ostream &os, const MotionData &data)

Inserts a description of *this.

class M3DReader

Motion3d (M3D) file format reader.

Note

The implementation is based on pcl::PCDReader: https://pointclouds.org/documentation/classpcl_1_1_p_c_d_reader.html

Public Functions

M3DReader() = delete

Public Static Functions

static M3DIOStatus readHeader(std::istream &fs, MotionData &motion, unsigned int &data_size, M3DFileType &file_type, unsigned int &data_idx, bool unsafe = false)

Reads a motion data header from a M3D-formatted, binary istream.

Load only the meta information (number of transforms, their types, etc), and not the transforms themselves, from a given M3D stream. Useful for fast evaluation of the underlying data structure.

Parameters:
  • fs[in] a std::istream with openmode set to std::ios::binary

  • motion[out] the resultant motion data (only the header data will be filled)

  • data_size[out] the number of transforms

  • file_type[out] the type of data

  • data_idx[out] the offset of transform data within the file

  • unsafe[in] read origin transform as unsafe (optional parameter)

Returns:

status

static M3DIOStatus readHeader(const std::string &file_name, MotionData &motion, unsigned int &data_size, M3DFileType &file_type, unsigned int &data_idx, bool unsafe = false, int offset = 0)

Reads a motion data header from a M3D file.

Load only the meta information (number of transforms, their types, etc), and not the transforms themselves, from a given M3D stream. Useful for fast evaluation of the underlying data structure.

Parameters:
  • file_name[in] the name of the file to load

  • motion[out] the resultant motion data (only the header data will be filled)

  • data_size[out] the number of transforms

  • file_type[out] the type of data

  • data_idx[out] the offset of transform data within the file

  • unsafe[in] read origin transform as unsafe (optional parameter)

  • offset[in] the offset of where to expect the M3D Header in the file (optional parameter)

Returns:

status

static M3DIOStatus readBodyASCII(std::istream &fs, MotionData &motion, unsigned int data_size, bool unsafe = false)

Reads the ASCII motion data body from a M3D stream.

Reads the transforms from a text-formatted stream. For use after readHeader(), when the resulting file_type is ASCII.

Attention

This assumes the stream has been seeked to the position indicated by the data_idx result of readHeader().

Parameters:
  • fs[in] the stream from which to read the body

  • motion[out] the resultant motion data to be filled

  • data_size[out] the number of transforms

  • unsafe[in] read transform as unsafe (optional parameter)

Returns:

status

static M3DIOStatus readBodyBinary(std::istream &fs, MotionData &motion, unsigned int data_size, bool unsafe = false)

Reads the binary motion data body from a M3D stream.

Reads the transforms from a binary-formatted memory block. For use after readHeader(), when the resulting file_type is binary.

Attention

This assumes the stream has been seeked to the position indicated by the data_idx result of readHeader().

Parameters:
  • fs[in] the stream from which to read the body

  • motion[out] the resultant motion data to be filled

  • data_size[out] the number of transforms

  • unsafe[in] read transform as unsafe (optional parameter)

Returns:

status

static M3DIOStatus read(const std::string &file_name, MotionData &motion, bool unsafe = false, int offset = 0)

Reads motion data from a M3D file.

Parameters:
  • file_name[in] the name of the file to load

  • motion[out] the resultant motion data to be filled

  • unsafe[in] read transforms as unsafe (optional parameter)

  • offset[in] the offset of where to expect the M3D Header in the file (optional parameter)

Returns:

status

static std::optional<MotionData> read(const std::string &file_name, M3DIOStatus &result, bool unsafe = false, int offset = 0)

Reads motion data from a M3D file.

Parameters:
  • file_name[in] the name of the file to load

  • result[out] the read status

  • unsafe[in] read transforms as unsafe (optional parameter)

  • offset[in] the offset of where to expect the M3D Header in the file (optional parameter)

Returns:

an std::optional with the resultant motion data in case of success.

static std::optional<MotionData> read(const std::string &file_name, bool unsafe = false, int offset = 0)

Reads motion data from a M3D file.

Parameters:
  • file_name[in] the name of the file to load

  • unsafe[in] read transforms as unsafe (optional parameter)

  • offset[in] the offset of where to expect the M3D Header in the file (optional parameter)

Returns:

an std::optional with the resultant motion data in case of success.

class M3DWriter

Motion3d (M3D) file format writer.

Note

The implementation is based on pcl::PCDWriter: https://pointclouds.org/documentation/classpcl_1_1_p_c_d_writer.html

Public Functions

M3DWriter() = delete

Public Static Functions

static std::string generateHeader(const MotionData &motion, bool binary)

Generates the header of a M3D file format.

Parameters:
  • motion[in] the motion data

  • binary[in] generate binary header without origin scalars

Returns:

the header as string.

static M3DIOStatus write(const std::string &file_name, const MotionData &motion, const M3DFileType &file_type, int precision = kDefaultASCIIPrecision)

Saves motion data to a M3D file in either ASCII or binary format.

Parameters:
  • file_name[in] the output file name

  • motion[in] the motion data

  • file_type[in] output file type

  • precision[in] the specified output numeric stream precision (optional parameter)

Returns:

status

static M3DIOStatus writeASCII(const std::string &file_name, const MotionData &motion, int precision = kDefaultASCIIPrecision)

Saves motion data to a M3D file in ASCII format.

Parameters:
  • file_name[in] the output file name

  • motion[in] the motion data

  • precision[in] the specified output numeric stream precision (optional parameter)

Returns:

status

static M3DIOStatus writeBinary(const std::string &file_name, const MotionData &motion)

Saves motion data to a M3D file in binary format.

Parameters:
  • file_name[in] the output file name

  • motion[in] the motion data

Returns:

status

Public Static Attributes

static constexpr int kDefaultASCIIPrecision = 16