2021-08-20 11:34:26 -04:00
|
|
|
/*
|
|
|
|
otp/transform.h
|
|
|
|
|
|
|
|
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "pdu.h"
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
namespace OTP::Transform {
|
|
|
|
|
|
|
|
using Timestamp = std::chrono::time_point<std::chrono::system_clock>;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Point {
|
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
|
|
|
* @brief The address struct
|
|
|
|
*/
|
2021-08-20 11:34:26 -04:00
|
|
|
struct address
|
|
|
|
: PDU::pdu_stream_object
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
uint8_t system; //!< system referance number
|
|
|
|
uint16_t group; //!< group referance number
|
|
|
|
uint32_t point; //!< point referance number
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override { return 7; }
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
namespace Module {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Figure 16-1: Module Identifier Structure
|
|
|
|
*/
|
|
|
|
struct module_id
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
uint16_t manufacturer; //!< ESTA manufacturer ID
|
|
|
|
uint16_t number; //!< manurfactuer assigned model number
|
2021-08-20 11:34:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Table 16-1: Standard Module Types
|
|
|
|
static const uint16_t Position = 0x0001; //!< the current position of a Point in all three linear directions.
|
|
|
|
static const uint16_t Position_VA = 0x0002; //!< the positional velocity and acceleration of a Point.
|
|
|
|
static const uint16_t Rotation = 0x0003; //!< the current rotation of the Point using intrinsic Euler rotation
|
|
|
|
static const uint16_t Rotation_VA = 0x0004; //!< the rotational velocity and acceleration of the Point
|
|
|
|
static const uint16_t Scale = 0x0005; //!< the unitless, absolute scale of the Point
|
|
|
|
static const uint16_t Reference_Frame = 0x0006; //!< the Address of the Reference Frame of the Point.
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The OTP::Transform::Point::Module::pdu class
|
|
|
|
*/
|
|
|
|
class pdu
|
|
|
|
: public OTP::PDU::pdu
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct module : PDU::pdu_stream_object {};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The position_module struct
|
|
|
|
*/
|
|
|
|
struct position_module
|
|
|
|
: module
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
uint8_t options;
|
|
|
|
struct {
|
|
|
|
uint8_t o_reserved : 7;
|
|
|
|
bool scaling : 1;
|
|
|
|
};
|
|
|
|
};
|
2021-08-25 17:20:33 -04:00
|
|
|
int32_t x; //!< x-axis position
|
|
|
|
int32_t y; //!< y-axis position
|
|
|
|
int32_t z; //!< z-axis position
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override { return 13; }
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The position_va_module struct
|
|
|
|
*/
|
|
|
|
struct position_va_module
|
|
|
|
: module
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
int32_t Vx; //!< x-axis velocity
|
|
|
|
int32_t Vy; //!< y-axis velocity
|
|
|
|
int32_t Vz; //!< z-axis velocity
|
|
|
|
int32_t Ax; //!< x-axis acceleration
|
|
|
|
int32_t Ay; //!< y-axis acceleration
|
|
|
|
int32_t Az; //!< z-axis acceleration
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override { return 24; }
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The rotation_module struct
|
|
|
|
*/
|
|
|
|
struct rotation_module
|
|
|
|
: module
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
int32_t Rx; //!< x-axis rotation
|
|
|
|
int32_t Ry; //!< y-axis rotation
|
|
|
|
int32_t Rz; //!< z-axis rotation
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override { return 12; }
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The rotation_va_module struct
|
|
|
|
*/
|
|
|
|
struct rotation_va_module
|
|
|
|
: module
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
int32_t Vrx; //!< x-axis rotational velocity
|
|
|
|
int32_t Vry; //!< y-axis rotational velocity
|
|
|
|
int32_t Vrz; //!< z-axis rotational velocity
|
|
|
|
int32_t Arx; //!< x-axis rotational acceleration
|
|
|
|
int32_t Ary; //!< y-axis rotational acceleration
|
|
|
|
int32_t Arz; //!< z-axis rotational acceleration
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override { return 24; }
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The scale_module struct
|
|
|
|
*/
|
|
|
|
struct scale_module
|
|
|
|
: module
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
int32_t scale_x; //!< x-axis scale
|
|
|
|
int32_t scale_y; //!< y-axis scale
|
|
|
|
int32_t scale_z; //!< z-axis scale
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override { return 12; }
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The reference_frame_module struct
|
|
|
|
*/
|
|
|
|
struct reference_frame_module
|
|
|
|
: module
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
address point; //!< referance point
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override { return point.streamSize(); }
|
2021-08-25 17:20:33 -04:00
|
|
|
void iStream(PDU::Stream s) override;
|
|
|
|
void oStream(PDU::Stream s) const override;
|
2021-08-20 11:34:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
|
|
|
* @brief The module_data struct
|
|
|
|
*/
|
2021-08-20 11:34:26 -04:00
|
|
|
struct module_data
|
|
|
|
: OTP::PDU::pdu_data
|
|
|
|
{
|
|
|
|
~module_data();
|
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
uint16_t number; //!< module number
|
|
|
|
module * mod = nullptr; //!< module object
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override;
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Module
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The OTP::Transform::Point::pdu class
|
|
|
|
*/
|
|
|
|
class pdu
|
|
|
|
: public OTP::PDU::pdu
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
|
|
|
* @brief The point_data struct
|
|
|
|
*/
|
2021-08-20 11:34:26 -04:00
|
|
|
struct point_data
|
|
|
|
: OTP::PDU::pdu_data
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
uint8_t priority = 100; //!< priority, between 0 and 200
|
|
|
|
uint16_t group; //!< group number
|
|
|
|
uint32_t point; //!< point number
|
|
|
|
Timestamp timestamp; //!< timestamp
|
2021-08-20 11:34:26 -04:00
|
|
|
union {
|
|
|
|
uint8_t options;
|
|
|
|
struct {
|
|
|
|
uint8_t f_reserved : 8;
|
|
|
|
};
|
|
|
|
};
|
2021-08-25 17:20:33 -04:00
|
|
|
uint32_t reserved; //!< reserved
|
|
|
|
PDU::Block<Module::pdu> modules; //!< block of module PDU
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override;
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Point
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The OTP::Transform::pdu class
|
|
|
|
*/
|
|
|
|
class pdu
|
|
|
|
: public OTP::PDU::pdu
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
};
|
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The transform_data struct
|
|
|
|
*/
|
2021-08-20 11:34:26 -04:00
|
|
|
struct transform_data
|
|
|
|
: OTP::PDU::pdu_data
|
|
|
|
{
|
2021-08-25 17:20:33 -04:00
|
|
|
uint8_t system; //!< system number
|
|
|
|
Timestamp timestamp; //!< timestamp
|
2021-08-20 11:34:26 -04:00
|
|
|
union {
|
|
|
|
uint8_t options;
|
|
|
|
struct {
|
|
|
|
uint8_t f_reserved : 7;
|
|
|
|
bool full_set : 1;
|
|
|
|
};
|
|
|
|
};
|
2021-08-25 17:20:33 -04:00
|
|
|
uint32_t reserved; //!< reserved
|
|
|
|
PDU::Block<Point::pdu> points; //!< block of Point PDU
|
2021-08-20 11:34:26 -04:00
|
|
|
|
|
|
|
size_t streamSize() const override;
|
|
|
|
void iStream(PDU::Stream) override;
|
|
|
|
void oStream(PDU::Stream) const override;
|
|
|
|
};
|
|
|
|
|
|
|
|
ACN::PDU::pdu_stream& operator>>(ACN::PDU::pdu_stream&, OTP::Transform::Timestamp&);
|
|
|
|
ACN::PDU::pdu_stream& operator<<(ACN::PDU::pdu_stream&, const OTP::Transform::Timestamp&);
|
|
|
|
|
|
|
|
} // namespace OTP::Transform
|