d4c
d4c_helpers.h
1 /*
2  * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia
3  * Authors: Ilaria Gori, Ugo Pattacini
4  * email: ilaria.gori@iit.it, ugo.pattacini@iit.it
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * http://www.robotcub.org/icub/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
18 #ifndef __D4C_HELPERS_H__
19 #define __D4C_HELPERS_H__
20 
21 #include <string>
22 
23 #include <yarp/os/all.h>
24 #include <yarp/sig/all.h>
25 
26 #define D4C_VOCAB_CMD_PING VOCAB4('p','i','n','g')
27 #define D4C_VOCAB_CMD_ADD VOCAB3('a','d','d')
28 #define D4C_VOCAB_CMD_DEL VOCAB3('d','e','l')
29 #define D4C_VOCAB_CMD_SET VOCAB3('s','e','t')
30 #define D4C_VOCAB_CMD_GET VOCAB3('g','e','t')
31 #define D4C_VOCAB_CMD_LIST VOCAB4('l','i','s','t')
32 #define D4C_VOCAB_CMD_CLEAR VOCAB4('c','l','e','a')
33 #define D4C_VOCAB_CMD_ENFIELD VOCAB4('f','e','n','a')
34 #define D4C_VOCAB_CMD_DISFIELD VOCAB4('f','d','i','s')
35 #define D4C_VOCAB_CMD_STATFIELD VOCAB4('f','s','t','a')
36 #define D4C_VOCAB_CMD_ENCTRL VOCAB4('c','e','n','a')
37 #define D4C_VOCAB_CMD_DISCTRL VOCAB4('c','d','i','s')
38 #define D4C_VOCAB_CMD_STATCTRL VOCAB4('c','s','t','a')
39 #define D4C_VOCAB_CMD_ENSIM VOCAB4('m','e','n','a')
40 #define D4C_VOCAB_CMD_DISSIM VOCAB4('m','d','i','s')
41 #define D4C_VOCAB_CMD_STATSIM VOCAB4('m','s','t','a')
42 #define D4C_VOCAB_CMD_SETPER VOCAB4('s','p','e','r')
43 #define D4C_VOCAB_CMD_GETPER VOCAB4('g','p','e','r')
44 #define D4C_VOCAB_CMD_SETACTIF VOCAB4('s','a','i','f')
45 #define D4C_VOCAB_CMD_GETACTIF VOCAB4('g','a','i','f')
46 #define D4C_VOCAB_CMD_GETTRAJ VOCAB4('g','t','r','j')
47 #define D4C_VOCAB_CMD_EXECTRAJ VOCAB4('e','t','r','j')
48 #define D4C_VOCAB_CMD_SETSTATETOTOOL VOCAB4('s','s','t','t')
49 #define D4C_VOCAB_CMD_SETSTATE VOCAB4('s','s','t','a')
50 #define D4C_VOCAB_CMD_SETORIEN VOCAB4('s','o','r','i')
51 #define D4C_VOCAB_CMD_GETSTATE VOCAB4('g','s','t','a')
52 #define D4C_VOCAB_CMD_ATTACHTOOLFRAME VOCAB4('t','a','t','f')
53 #define D4C_VOCAB_CMD_GETTOOLFRAME VOCAB4('t','g','e','f')
54 #define D4C_VOCAB_CMD_REMOVETOOLFRAME VOCAB4('t','r','e','f')
55 #define D4C_VOCAB_CMD_GETTOOL VOCAB4('t','g','e','t')
56 #define D4C_VOCAB_CMD_ACK VOCAB3('a','c','k')
57 #define D4C_VOCAB_CMD_NACK VOCAB4('n','a','c','k')
58 
59 #define extractProperty(value) (Property(value.asList()->toString().c_str()))
60 
61 
62 namespace iCub
63 {
64 
65 namespace d4c
66 {
67 
68 namespace log
69 {
70  enum { no_info, info, warning, error };
71 }
72 
73 inline yarp::sig::Vector getVectorPos(const yarp::sig::Vector &x)
74 {
75  return x.subVector(0,2);
76 }
77 
78 inline yarp::sig::Vector getVectorOrien(const yarp::sig::Vector &x)
79 {
80  return x.subVector(3,6);
81 }
82 
83 bool copyVectorData(const yarp::sig::Vector &src, yarp::sig::Vector &dest);
84 
85 bool extractVector(const yarp::os::Property &prop, const std::string &option,
86  yarp::sig::Vector &res);
87 
88 }
89 
90 }
91 
92 #endif
93 
94 
Definition: d4c.h:43