5#include "mechanism/pipe/ec_pipe_pdo.h"
6#include "mechanism/zmq/ec_zmq_pdo.h"
9 static const std::vector<std::string>name = {
"encoder_position",
"force",
"pressure1",
"pressure2",
"current",
"temperature",
10 "fault",
"rtt",
"op_idx_ack",
"aux",
11 "current_ref_fb",
"position_ref_fb",
"force_ref_fb"};
12 static const int pdo_size=13;
13 using pdo_t=std::tuple<float, float, float, float, float, float,uint16_t,uint16_t,uint16_t,float,float,float,float>;
15 inline bool make_vector_from_tuple(
const pdo_t &pdo_tuple,std::vector<T> &pdo_vector){
16 if(pdo_vector.size()!=pdo_size){
19 pdo_vector[0]=
static_cast<T
>(std::get<0>(pdo_tuple));
20 pdo_vector[1]=
static_cast<T
>(std::get<1>(pdo_tuple));
21 pdo_vector[2]=
static_cast<T
>(std::get<2>(pdo_tuple));
22 pdo_vector[3]=
static_cast<T
>(std::get<3>(pdo_tuple));
23 pdo_vector[4]=
static_cast<T
>(std::get<4>(pdo_tuple));
24 pdo_vector[5]=
static_cast<T
>(std::get<5>(pdo_tuple));
25 pdo_vector[6]=
static_cast<T
>(std::get<6>(pdo_tuple));
26 pdo_vector[7]=
static_cast<T
>(std::get<7>(pdo_tuple));
27 pdo_vector[8]=
static_cast<T
>(std::get<8>(pdo_tuple));
28 pdo_vector[9]=
static_cast<T
>(std::get<9>(pdo_tuple));
29 pdo_vector[10]=
static_cast<T
>(std::get<10>(pdo_tuple));
30 pdo_vector[11]=
static_cast<T
>(std::get<11>(pdo_tuple));
31 pdo_vector[12]=
static_cast<T
>(std::get<12>(pdo_tuple));
37 static const std::vector<std::string>name = {
"current_ref",
"position_ref",
"force_ref",
38 "gain_0",
"gain_1",
"gain_2",
"gain_3",
"gain_4",
39 "fault_ack",
"ts",
"op_idx_aux",
"aux"};
40 static const int pdo_size=12;
41 using pdo_t=std::tuple<float, float, float,float,float,float,float,float,uint16_t, uint16_t,uint16_t,float>;
43 inline bool make_vector_from_tuple(
const pdo_t &pdo_tuple,std::vector<T> &pdo_vector){
44 if(pdo_vector.size()!=pdo_size){
47 pdo_vector[0]=
static_cast<T
>(std::get<0>(pdo_tuple));
48 pdo_vector[1]=
static_cast<T
>(std::get<1>(pdo_tuple));
49 pdo_vector[2]=
static_cast<T
>(std::get<2>(pdo_tuple));
50 pdo_vector[3]=
static_cast<T
>(std::get<3>(pdo_tuple));
51 pdo_vector[4]=
static_cast<T
>(std::get<4>(pdo_tuple));
52 pdo_vector[5]=
static_cast<T
>(std::get<5>(pdo_tuple));
53 pdo_vector[6]=
static_cast<T
>(std::get<6>(pdo_tuple));
54 pdo_vector[7]=
static_cast<T
>(std::get<7>(pdo_tuple));
55 pdo_vector[8]=
static_cast<T
>(std::get<8>(pdo_tuple));
56 pdo_vector[9]=
static_cast<T
>(std::get<9>(pdo_tuple));
57 pdo_vector[10]=
static_cast<T
>(std::get<10>(pdo_tuple));
58 pdo_vector[11]=
static_cast<T
>(std::get<11>(pdo_tuple));
64class ValvePdo:
public T{
68 ValvePdo(
const std::string value,int32_t
id, uint32_t type);
75 ValvePdoRx::pdo_t rx_pdo{};
76 ValvePdoTx::pdo_t tx_pdo{};
77 bool init_rx_pdo=
false;
83inline void ValvePdo<T>::init_pb()
85 uint8_t pb_buf[MAX_PB_SIZE];
89 msg_size = T::pb_tx_pdos.ByteSizeLong();
90 T::pb_tx_pdos.SerializeToArray( (
void*)(pb_buf+
sizeof(msg_size)), msg_size);
94inline ValvePdo<T>::ValvePdo(
const std::string value,int32_t
id, uint32_t type):
103inline ValvePdo<T>::~ValvePdo()
110inline void ValvePdo<T>::get_from_pb()
112 std::get<0>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->encoder_position();
113 std::get<1>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->force();
114 std::get<2>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->pressure_1();
115 std::get<3>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->pressure_2();
116 std::get<4>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->current();
117 std::get<5>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->temperature();
118 std::get<6>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->fault();
119 std::get<7>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->rtt();
120 std::get<8>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->op_idx_ack();
121 std::get<9>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->aux();
122 std::get<10>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->current_ref_fb();
123 std::get<11>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->position_ref_fb();
124 std::get<12>(rx_pdo) = T::pb_rx_pdos.mutable_hyqknee_rx_pdo()->force_ref_fb();
132inline void ValvePdo<T>::set_to_pb()
134 set_pbHeader(T::pb_tx_pdos.mutable_header(), T::name, 0);
136 T::pb_tx_pdos.set_type(iit::advr::Ec_slave_pdo::TX_HYQ_KNEE);
138 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_current_ref(std::get<0>(tx_pdo));
139 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_position_ref(std::get<1>(tx_pdo));
140 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_force_ref(std::get<2>(tx_pdo));
141 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_gain_0(std::get<3>(tx_pdo));
142 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_gain_1(std::get<4>(tx_pdo));
143 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_gain_2(std::get<5>(tx_pdo));
144 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_gain_3(std::get<6>(tx_pdo));
145 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_gain_4(std::get<7>(tx_pdo));
146 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_fault_ack(std::get<8>(tx_pdo));
147 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_ts(std::get<9>(tx_pdo));
148 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_op_idx_aux(std::get<10>(tx_pdo));
149 T::pb_tx_pdos.mutable_hyqknee_tx_pdo()->set_aux(std::get<11>(tx_pdo));
Definition valve_pdo.h:64