Control Libraries 7.4.0
Loading...
Searching...
No Matches
encoders.hpp
1#pragma once
2
3#include <google/protobuf/repeated_field.h>
4
5#include <state_representation/State.hpp>
6#include <state_representation/AnalogIOState.hpp>
7#include <state_representation/DigitalIOState.hpp>
8#include <state_representation/space/SpatialState.hpp>
9#include <state_representation/space/cartesian/CartesianState.hpp>
10#include <state_representation/space/Jacobian.hpp>
11#include <state_representation/space/joint/JointState.hpp>
12#include <state_representation/parameters/Parameter.hpp>
13
14#include "clproto.hpp"
15#include "state_representation/state_message.pb.h"
16
17namespace clproto {
18
26template<typename ParamT>
27state_representation::proto::Parameter
28encoder(state_representation::proto::Parameter& message, const state_representation::Parameter<ParamT>& parameter);
29
36template<typename ParamT>
37state_representation::proto::Parameter encoder(const state_representation::Parameter<ParamT>& parameter);
38
46template<typename FieldT>
47google::protobuf::RepeatedField<FieldT> encoder(const std::vector<FieldT>& data);
48
55google::protobuf::RepeatedField<double> matrix_encoder(const Eigen::MatrixXd& matrix);
56
57/*
58 * Declarations for encoding helpers
59 */
60state_representation::proto::State encoder(const state_representation::State& state);
61state_representation::proto::SpatialState encoder(const state_representation::SpatialState& spatial_state);
62state_representation::proto::Vector3d encoder(const Eigen::Vector3d& vector);
63state_representation::proto::Quaterniond encoder(const Eigen::Quaterniond& quaternion);
64state_representation::proto::CartesianState encoder(const state_representation::CartesianState& cartesian_state);
65state_representation::proto::Jacobian encoder(const state_representation::Jacobian& jacobian);
66state_representation::proto::JointState encoder(const state_representation::JointState& joint_state);
67state_representation::proto::AnalogIOState encoder(const state_representation::AnalogIOState& analog_io_state);
68state_representation::proto::DigitalIOState encoder(const state_representation::DigitalIOState& digital_io_state);
69
70/*
71 * Definitions for templated RepeatedField methods
72 */
73template<typename FieldT>
74google::protobuf::RepeatedField<FieldT> encoder(const std::vector<FieldT>& data) {
75 return google::protobuf::RepeatedField<FieldT>({data.begin(), data.end()});
76}
77
78template<typename ParamT>
79inline state_representation::proto::Parameter encoder(const state_representation::Parameter<ParamT>& parameter) {
80 state_representation::proto::Parameter message;
81 *message.mutable_state() = encoder(static_cast<state_representation::State>(parameter));
82 return encoder<ParamT>(message, parameter);
83}
84}
Class to represent a state in Cartesian space.
Class to define a robot Jacobian matrix.
Definition Jacobian.hpp:21
Class to define a state in joint space.
Class to represent name-value pairs of different types.
Definition Parameter.hpp:18
Abstract class to represent a state.
Definition State.hpp:25
Bindings to encode and decode state objects into serialised binary message.
google::protobuf::RepeatedField< double > matrix_encoder(const Eigen::MatrixXd &matrix)
Encoding helper method for Eigen data into a RepeatedField message type.
Definition encoders.cpp:7
std::string encode(const T &obj)
Encode a control libraries object into a serialized binary string representation (wire format).
state_representation::proto::Parameter encoder(state_representation::proto::Parameter &message, const state_representation::Parameter< ParamT > &parameter)
Encoding helper method for the Parameter type.