iCub-main
WorldOp.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4 * Copyright (C) 2010 RobotCub Consortium, European Commission FP6 Project IST-004370
5 * Author: Paul Fitzpatrick, Vadim Tikhanoff
6 * email: paulfitz@alum.mit.edu, vadim.tikhanoff@iit.it
7 * website: www.robotcub.org
8 * Permission is granted to copy, distribute, and/or modify this program
9 * under the terms of the GNU General Public License, version 2 or any
10 * later version published by the Free Software Foundation.
11 *
12 * A copy of the license can be found at
13 * http://www.robotcub.org/icub/license/gpl.txt
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
18 * Public License for more details
19 */
20 
21 #ifndef ICUBSIMULATION_WORLDOP_INC
22 #define ICUBSIMULATION_WORLDOP_INC
23 
24 #include <yarp/os/Vocab.h>
25 
26 #include <string>
27 
28 enum WORLD_OP {
30  WORLD_OP_GET = yarp::os::createVocab32('g','e','t'),
31  WORLD_OP_SET = yarp::os::createVocab32('s','e','t'),
32  WORLD_OP_MK = yarp::os::createVocab32('m','k'),
33  WORLD_OP_GRAB = yarp::os::createVocab32('g','r','a','b'),
34  WORLD_OP_ROT = yarp::os::createVocab32('r','o','t'),
35  WORLD_OP_DEL = yarp::os::createVocab32('d','e','l'),
36  WORLD_OP_COL = yarp::os::createVocab32('c','o','l'),
37  WORLD_OP_NUM = yarp::os::createVocab32('n','u','m'),
38 };
39 
40 class WorldOpDatum {
41 public:
42  bool valid;
43 
44  WorldOpDatum() { valid = false; }
45 
46  bool isValid() const {
47  return valid;
48  }
49 };
50 
51 class WorldOpName : public WorldOpDatum {
52 public:
53  std::string name;
54 
56 
57  WorldOpName(const std::string& name) : name(name) { valid = true; }
58 
59  WorldOpName(const char *name) : name(name) { valid = true; }
60 
61  std::string get() const { return name; }
62 };
63 
64 class WorldOpFlag : public WorldOpDatum {
65 public:
66  bool setting;
67 
68  WorldOpFlag() { setting=false; }
69 
70  WorldOpFlag(bool setting) : setting(setting) { valid = true; }
71 
72  bool get() const { return setting; }
73 };
74 
75 class WorldOpIndex : public WorldOpDatum {
76 public:
77  int index;
78 
79  WorldOpIndex() { index = 0; }
80 
81  WorldOpIndex(int index) : index(index) { valid = true; }
82 
83  int get() const { return index; }
84 };
85 
86 class WorldOpScalar : public WorldOpDatum {
87 public:
88  double val;
89 
90  WorldOpScalar() { val = 0; }
91 
92  WorldOpScalar(double val) : val(val) { valid = true; }
93 
94  double get() const { return val; }
95 };
96 
97 class WorldOpTriplet : public WorldOpDatum {
98 public:
99  double x[3];
100 
101  WorldOpTriplet() { x[0] = x[1] = x[2] = 0; }
102 
103  WorldOpTriplet(double x, double y, double z) {
104  valid = true;
105  this->x[0] = x;
106  this->x[1] = y;
107  this->x[2] = z;
108  }
109 
110  double get(int offset) const { return x[offset]; }
111 
112 };
113 
114 class WorldOp {
115 public:
133 
134  // for debugging
135  void show() const;
136 };
137 
138 class WorldResult {
139 public:
140  bool success;
141  std::string msg;
147 
149  success = false;
150  msg = "";
151  }
152 
153  void setOk() {
154  success = true;
155  msg = "";
156  }
157 
158  void setFail(const char *msg) {
159  success = false;
160  this->msg = msg;
161  }
162 
163  void show();
164 };
165 
166 #endif
WORLD_OP
Definition: WorldOp.h:28
@ WORLD_OP_NULL
Definition: WorldOp.h:29
@ WORLD_OP_ROT
Definition: WorldOp.h:34
@ WORLD_OP_GRAB
Definition: WorldOp.h:33
@ WORLD_OP_DEL
Definition: WorldOp.h:35
@ WORLD_OP_MK
Definition: WorldOp.h:32
@ WORLD_OP_SET
Definition: WorldOp.h:31
@ WORLD_OP_GET
Definition: WorldOp.h:30
@ WORLD_OP_COL
Definition: WorldOp.h:36
@ WORLD_OP_NUM
Definition: WorldOp.h:37
bool isValid() const
Definition: WorldOp.h:46
WorldOpDatum()
Definition: WorldOp.h:44
bool valid
Definition: WorldOp.h:42
WorldOpFlag()
Definition: WorldOp.h:68
WorldOpFlag(bool setting)
Definition: WorldOp.h:70
bool setting
Definition: WorldOp.h:66
bool get() const
Definition: WorldOp.h:72
WorldOpIndex(int index)
Definition: WorldOp.h:81
int get() const
Definition: WorldOp.h:83
int index
Definition: WorldOp.h:77
WorldOpIndex()
Definition: WorldOp.h:79
std::string get() const
Definition: WorldOp.h:61
std::string name
Definition: WorldOp.h:53
WorldOpName(const std::string &name)
Definition: WorldOp.h:57
WorldOpName()
Definition: WorldOp.h:55
WorldOpName(const char *name)
Definition: WorldOp.h:59
double get() const
Definition: WorldOp.h:94
WorldOpScalar()
Definition: WorldOp.h:90
double val
Definition: WorldOp.h:88
WorldOpScalar(double val)
Definition: WorldOp.h:92
double get(int offset) const
Definition: WorldOp.h:110
WorldOpTriplet(double x, double y, double z)
Definition: WorldOp.h:103
double x[3]
Definition: WorldOp.h:99
WorldOpTriplet color
Definition: WorldOp.h:122
WorldOpIndex index
Definition: WorldOp.h:119
WORLD_OP cmd
Definition: WorldOp.h:116
WorldOpFlag active
Definition: WorldOp.h:126
WorldOpName kind
Definition: WorldOp.h:117
WorldOpName name
Definition: WorldOp.h:118
WorldOpFlag dynamic
Definition: WorldOp.h:127
WorldOpName modelName
Definition: WorldOp.h:130
void show() const
Definition: WorldOp.cpp:72
WorldOpTriplet location
Definition: WorldOp.h:120
WorldOpFlag rightHanded
Definition: WorldOp.h:128
WorldOpName modelTexture
Definition: WorldOp.h:131
WorldOpTriplet size
Definition: WorldOp.h:121
WorldOpFlag collide
Definition: WorldOp.h:132
WorldOpScalar radius
Definition: WorldOp.h:124
WorldOpFlag parameter
Definition: WorldOp.h:129
WorldOpScalar length
Definition: WorldOp.h:125
WorldOpTriplet rotation
Definition: WorldOp.h:123
std::string msg
Definition: WorldOp.h:141
WorldOpIndex count
Definition: WorldOp.h:146
void setOk()
Definition: WorldOp.h:153
void setFail(const char *msg)
Definition: WorldOp.h:158
WorldOpTriplet location
Definition: WorldOp.h:142
bool success
Definition: WorldOp.h:140
WorldOpName path
Definition: WorldOp.h:145
WorldOpTriplet rotation
Definition: WorldOp.h:143
void show()
Definition: WorldOp.cpp:109
WorldOpTriplet color
Definition: WorldOp.h:144
WorldResult()
Definition: WorldOp.h:148
degrees offset
Definition: sine.m:4