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:
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;
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
WorldOpScalar::WorldOpScalar
WorldOpScalar()
Definition: WorldOp.h:90
WORLD_OP_GRAB
@ WORLD_OP_GRAB
Definition: WorldOp.h:33
WorldOp::show
void show() const
Definition: WorldOp.cpp:72
WorldOpDatum::WorldOpDatum
WorldOpDatum()
Definition: WorldOp.h:44
WorldOpIndex
Definition: WorldOp.h:75
WorldOpName::WorldOpName
WorldOpName()
Definition: WorldOp.h:55
WorldOp::index
WorldOpIndex index
Definition: WorldOp.h:119
WorldOpFlag
Definition: WorldOp.h:64
WorldResult::success
bool success
Definition: WorldOp.h:140
WORLD_OP_COL
@ WORLD_OP_COL
Definition: WorldOp.h:36
WorldResult::location
WorldOpTriplet location
Definition: WorldOp.h:142
WorldResult::path
WorldOpName path
Definition: WorldOp.h:145
WorldOpFlag::get
bool get() const
Definition: WorldOp.h:72
z
z
Definition: show_eyes_axes.m:22
offset
degrees offset
Definition: sine.m:4
WorldResult::rotation
WorldOpTriplet rotation
Definition: WorldOp.h:143
WORLD_OP_DEL
@ WORLD_OP_DEL
Definition: WorldOp.h:35
WorldOpTriplet::WorldOpTriplet
WorldOpTriplet(double x, double y, double z)
Definition: WorldOp.h:103
WorldOpFlag::WorldOpFlag
WorldOpFlag(bool setting)
Definition: WorldOp.h:70
WorldOpScalar
Definition: WorldOp.h:86
WorldOpDatum::isValid
bool isValid() const
Definition: WorldOp.h:46
WorldOpFlag::setting
bool setting
Definition: WorldOp.h:66
WorldOpDatum::valid
bool valid
Definition: WorldOp.h:42
WorldOpScalar::WorldOpScalar
WorldOpScalar(double val)
Definition: WorldOp.h:92
WorldOp::rotation
WorldOpTriplet rotation
Definition: WorldOp.h:123
WorldOp::active
WorldOpFlag active
Definition: WorldOp.h:126
WorldOp::modelTexture
WorldOpName modelTexture
Definition: WorldOp.h:131
WORLD_OP_NULL
@ WORLD_OP_NULL
Definition: WorldOp.h:29
WorldOp::dynamic
WorldOpFlag dynamic
Definition: WorldOp.h:127
WorldOpScalar::val
double val
Definition: WorldOp.h:88
WorldResult::WorldResult
WorldResult()
Definition: WorldOp.h:148
WORLD_OP_GET
@ WORLD_OP_GET
Definition: WorldOp.h:30
WORLD_OP
WORLD_OP
Definition: WorldOp.h:28
WorldResult::show
void show()
Definition: WorldOp.cpp:109
WorldOpTriplet::get
double get(int offset) const
Definition: WorldOp.h:110
WorldResult::count
WorldOpIndex count
Definition: WorldOp.h:146
WorldOpScalar::get
double get() const
Definition: WorldOp.h:94
WorldOp::cmd
WORLD_OP cmd
Definition: WorldOp.h:116
WorldOpName::WorldOpName
WorldOpName(const char *name)
Definition: WorldOp.h:59
WorldResult::msg
std::string msg
Definition: WorldOp.h:141
y
y
Definition: show_eyes_axes.m:21
WorldOp::radius
WorldOpScalar radius
Definition: WorldOp.h:124
WorldOpFlag::WorldOpFlag
WorldOpFlag()
Definition: WorldOp.h:68
WorldOpIndex::get
int get() const
Definition: WorldOp.h:83
WorldOpName
Definition: WorldOp.h:51
WorldOp::location
WorldOpTriplet location
Definition: WorldOp.h:120
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
WorldOp::color
WorldOpTriplet color
Definition: WorldOp.h:122
WorldOpIndex::WorldOpIndex
WorldOpIndex()
Definition: WorldOp.h:79
WORLD_OP_MK
@ WORLD_OP_MK
Definition: WorldOp.h:32
WORLD_OP_ROT
@ WORLD_OP_ROT
Definition: WorldOp.h:34
WorldOpName::get
std::string get() const
Definition: WorldOp.h:61
WorldOpTriplet::WorldOpTriplet
WorldOpTriplet()
Definition: WorldOp.h:101
WORLD_OP_SET
@ WORLD_OP_SET
Definition: WorldOp.h:31
WorldOpName::name
std::string name
Definition: WorldOp.h:53
WorldResult::color
WorldOpTriplet color
Definition: WorldOp.h:144
WorldOp::rightHanded
WorldOpFlag rightHanded
Definition: WorldOp.h:128
WorldOp::kind
WorldOpName kind
Definition: WorldOp.h:117
WorldOp
Definition: WorldOp.h:114
WorldOp::modelName
WorldOpName modelName
Definition: WorldOp.h:130
WORLD_OP_NUM
@ WORLD_OP_NUM
Definition: WorldOp.h:37
WorldOpTriplet
Definition: WorldOp.h:97
WorldResult
Definition: WorldOp.h:138
WorldOpName::WorldOpName
WorldOpName(const std::string &name)
Definition: WorldOp.h:57
WorldResult::setFail
void setFail(const char *msg)
Definition: WorldOp.h:158
WorldOp::parameter
WorldOpFlag parameter
Definition: WorldOp.h:129
WorldOpIndex::index
int index
Definition: WorldOp.h:77
WorldOp::length
WorldOpScalar length
Definition: WorldOp.h:125
WorldOpIndex::WorldOpIndex
WorldOpIndex(int index)
Definition: WorldOp.h:81
WorldOp::collide
WorldOpFlag collide
Definition: WorldOp.h:132
WorldOp::name
WorldOpName name
Definition: WorldOp.h:118
WorldResult::setOk
void setOk()
Definition: WorldOp.h:153
WorldOpTriplet::x
double x[3]
Definition: WorldOp.h:99
WorldOpDatum
Definition: WorldOp.h:40
WorldOp::size
WorldOpTriplet size
Definition: WorldOp.h:121