EtherCAT Client Library Code 0.0.1
EtherCAT Client library that uses different communication protocols with EtherCAT Master server.
Loading...
Searching...
No Matches
ec_repl_cmd.h
1#ifndef __EC_REPL_CMD__
2#define __EC_REPL_CMD__
3
4#include "mechanism/zmq/ec_zmq_context.h"
5
6enum EC_REPL_CMD_STATUS : int {
7
8 TIMEOUT= 0,
9 NACK= 1,
10 WRONG_COMPOSITION= 2,
11 WRONG_CMD_TYPE= 3,
12 WRONG_FB_MSG= 4, //FB=feedback
13 OK= 5
14
15};
16
17inline const char* get_cmd_type(iit::advr::CmdType type)
18{
19 switch (type)
20 {
21 case iit::advr::CmdType::TRJ_CMD: return "TRJ_CMD";
22 case iit::advr::CmdType::CTRL_CMD: return "CTRL_CMD";
23 case iit::advr::CmdType::FLASH_CMD: return "FLASH_CMD";
24 case iit::advr::CmdType::ECAT_MASTER_CMD: return "ECAT_MASTER_CMD";
25 case iit::advr::CmdType::FOE_MASTER: return "FOE_MASTER";
26 case iit::advr::CmdType::TRJ_QUEUE_CMD: return "TRJ_QUEUE_CMD";
27 case iit::advr::CmdType::SLAVE_SDO_CMD: return "SLAVE_SDO_CMD";
28 case iit::advr::CmdType::SLAVE_SDO_INFO: return "SLAVE_SDO_INFO";
29 case iit::advr::CmdType::MOTOR_PDO_CMD: return "MOTOR_PDO_CMD";
30 case iit::advr::CmdType::PDO_AUX_CMD: return "PDO_AUX_CMD";
31 default: return("UNKNOWN COMMAND");
32 }
33}
34
35
37{
38public:
39
46
47 };
48
54
55 };
56
62 void set_zmq_cmd(std::string zmq_cmd){
63 _zmq_cmd=zmq_cmd;
64 };
65
66
72 void set_type(int type){
73 _type=type;
74 };
75
76
82 void set_info(std::string info){
83 _info=info;
84 };
85
86
92 void set_recovery_info(std::string recovery_info){
93 _recovery_info=recovery_info;
94 };
95
96
102 std::string get_zmq_cmd(){
103 return _zmq_cmd;
104 };
105
106
112 int get_type(){
113 return _type;
114 };
115
116
122 std::string get_info(){
123 return _info;
124 };
125
126
132 std::string get_recovery_info(){
133 return _recovery_info;
134 };
135
136private:
137 int _type;
138 std::string _info;
139 std::string _recovery_info;
140 std::string _zmq_cmd;
141};
142
143
145{
146public:
147
148 typedef std::shared_ptr<EcReplCmd> Ptr;
149
151
152 std::vector<float> x;
153
154 };
155
157
158 float freq;
159 float ampl;
160 float teta;
161 float secs;
162
163 };
164
166
167 std::vector<float> x;
168 std::vector<float> y;
169
170 };
171
173
174 iit::advr::PDOs_aux_cmd_Aux_cmd_Type type;
175 long int board_id;
176
177 };
178
179 using m_ref_t = std::tuple<int32_t, //ctrl_type
180 float, float, float, // pos_ref, vel_ref, tor_ref
181 float, float, float, float, float, // gains
182 uint32_t, uint32_t, float>; // op, idx, aux
183
184 using motors_ref_map = std::map<int32_t,m_ref_t>;
185
186
194 EcReplCmd(std::string zmq_uri,int timeout);
195
201
202
212 EcReplFault Ecat_Master_cmd(iit::advr::Ecat_Master_cmd_Type type,
213 std::map<std::string,std::string> args,
214 std::string &msg);
215
216
228 EcReplFault FOE_Master(std::string filename,
229 unsigned long int password,
230 std::string mcu_type,
231 long int slave_pos,
232 long int board_id,
233 std::string &msg);
234
243 EcReplFault Slave_SDO_info(iit::advr::Slave_SDO_info_Type type,
244 long int board_id,
245 std::string &msg);
246
259 EcReplFault Slave_SDO_cmd(long int board_id,
260 std::vector<std::string> rd_sdo,
261 std::map<std::string ,std::string> wr_sdo,
262 std::string &msg);
263
272 EcReplFault Flash_cmd(iit::advr::Flash_cmd_Type type,
273 long int board_id,
274 std::string &msg);
275
276
287 EcReplFault Ctrl_cmd(iit::advr::Ctrl_cmd_Type type,
288 long int board_id,
289 float value,
290 std::vector<float> gains,
291 std::string &msg);
292
305 EcReplFault Trajectory_Cmd(iit::advr::Trajectory_cmd_Type type,
306 std::string name,
307 long int board_id,
308 homing_par_t homing_par,
309 period_par_t period_par,
310 smooth_par_t smooth_par,
311 std::string &msg);
312
321 EcReplFault Trj_queue_cmd(iit::advr::Trj_queue_cmd_Type type,
322 std::vector<std::string> trj_names,
323 std::string &msg);
324
332 EcReplFault PDOs_aux_cmd(std::vector<aux_cmd_message_t> aux_cmds,
333 std::string &msg);
334
341 EcReplFault Motors_PDO_cmd(motors_ref_map motors_references);
342
343
349 std::string get_zmq_uri();
350
357
363 void set_zmq_timeout(int timeout);
364
365 void set_motor_type_map(std::map<int32_t,std::string> motor_type_map);
366
367private:
368
369 std::string _zmq_uri;
370 int _timeout;
371 std::map<int32_t,std::string> _advrf_motor_map;
372 void check_advrf_motor_gains(iit::advr::Gains_Type ctrl_type,std::vector<float> &gains);
373
374
382
383 void zmq_do_cmd(iit::advr::Repl_cmd pb_cmd,
384 std::string& msg,
385 int timeout,
386 EcReplFault &fault);
387
388
389 void zmq_cmd_recv(std::string& msg,
390 iit::advr::CmdType cmd_sent,
391 zmq::socket_t& socket,
392 EcReplFault &fault);
393
394
395
396 bool zmq_cmd_send(iit::advr::Repl_cmd pb_cmd,
397 zmq::socket_t& socket,
398 EcReplFault &fault
399 );
400};
401
402#endif
403
EcReplFault FOE_Master(std::string filename, unsigned long int password, std::string mcu_type, long int slave_pos, long int board_id, std::string &msg)
FOE Master command for flash a new firmare for a specific slave.
EcReplFault Ctrl_cmd(iit::advr::Ctrl_cmd_Type type, long int board_id, float value, std::vector< float > gains, std::string &msg)
Control command is used to control the motors or start the auto-calibration mechanisms.
EcReplFault Ecat_Master_cmd(iit::advr::Ecat_Master_cmd_Type type, std::map< std::string, std::string > args, std::string &msg)
EtherCAT Master command for stopping, starting the EtherCAT Master Server and GET EtherCAT informatio...
void set_zmq_timeout(int timeout)
set timeout of ZMQ communication.
EcReplCmd(std::string zmq_uri, int timeout)
Constructor of EcReplCmd Class. It needs of zmq uri (TCP/UDP) and of a timeout.
EcReplFault Slave_SDO_cmd(long int board_id, std::vector< std::string > rd_sdo, std::map< std::string, std::string > wr_sdo, std::string &msg)
The slave SDO command is typical used to read the values of SDO of specific slave in pre-operational ...
EcReplFault Trajectory_Cmd(iit::advr::Trajectory_cmd_Type type, std::string name, long int board_id, homing_par_t homing_par, period_par_t period_par, smooth_par_t smooth_par, std::string &msg)
Command to send a trajectory to the slave.
std::string get_zmq_uri()
Return ZMQ URI for the ZMQ communication.
EcReplFault Flash_cmd(iit::advr::Flash_cmd_Type type, long int board_id, std::string &msg)
Flash command for save, load and load default sdo of the FLASH.
EcReplFault PDOs_aux_cmd(std::vector< aux_cmd_message_t > aux_cmds, std::string &msg)
Command to release or engage motors brake.
void zmq_do_cmd(iit::advr::Repl_cmd pb_cmd, std::string &msg, int timeout, EcReplFault &fault)
This method is responsible to perform the ZMQ commad to EtherCAT Server.
EcReplFault Motors_PDO_cmd(motors_ref_map motors_references)
Command to send references.
int get_zmq_timeout()
Return timeout of ZMQ communication.
EcReplFault Slave_SDO_info(iit::advr::Slave_SDO_info_Type type, long int board_id, std::string &msg)
Slave SDO Information is a command to get the SDO datas of a specific slave.
EcReplFault Trj_queue_cmd(iit::advr::Trj_queue_cmd_Type type, std::vector< std::string > trj_names, std::string &msg)
Command to start or clear a trajectoy using its name.
~EcReplCmd()
Destructor of EcReplCmd Class-.
Definition ec_repl_cmd.h:37
std::string get_recovery_info()
method to set the information related on ZMQ Command fault.
Definition ec_repl_cmd.h:132
std::string get_zmq_cmd()
method to get the ZMQ Command type
Definition ec_repl_cmd.h:102
~EcReplFault()
Destructor of EcReplCmd Fault Class.
Definition ec_repl_cmd.h:53
void set_type(int type)
method to set the type of ZMQ Command fault.
Definition ec_repl_cmd.h:72
std::string get_info()
method to get the recovery for the ZMQ Command.
Definition ec_repl_cmd.h:122
EcReplFault()
Constructor of EcReplCmd Fault Class. This class is responsible to manage the fault coming from ZMQ c...
Definition ec_repl_cmd.h:45
int get_type()
method to get the type of ZMQ Command fault.
Definition ec_repl_cmd.h:112
void set_info(std::string info)
method to set the information related on ZMQ Command fault.
Definition ec_repl_cmd.h:82
void set_recovery_info(std::string recovery_info)
method to se the recovery for the ZMQ Command.
Definition ec_repl_cmd.h:92
void set_zmq_cmd(std::string zmq_cmd)
method to set the ZMQ Command type.
Definition ec_repl_cmd.h:62
Definition ec_repl_cmd.h:172
Definition ec_repl_cmd.h:150
Definition ec_repl_cmd.h:156
Definition ec_repl_cmd.h:165