All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
frame_sensors.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: markus.ms.schneider@gmail.com
18  */
19 
20 #ifndef _FRAME_SENSORS_H_
21 #define _FRAME_SENSORS_H_
22 
23 #include "mbsimControl/sensor.h"
24 
25 namespace MBSim {
26  class Frame;
27 }
28 
29 namespace MBSimControl {
30 
36  public:
37  AbsolutCoordinateSensor(const std::string &name) : Sensor(name), frame(NULL), direction(), frameString("") {}
38  std::string getType() const { return "AbsolutCoordinateSensor"; }
39  void initializeUsingXML(xercesc::DOMElement *element);
40  void init(InitStage stage);
41  void setFrame(MBSim::Frame * frame_) {frame=frame_; }
42  void setDirection(fmatvec::Mat direction_) {
43  direction=direction_;
44  for (int i=0; i<direction_.cols(); i++)
45  direction.col(i)=direction.col(i)/nrm2(direction.col(i));
46  assert(direction.rows()==3);
47  }
48  int getSignalSize() const { return direction.cols(); }
49  protected:
50  MBSim::Frame * frame;
51  fmatvec::Mat direction;
52  std::string frameString;
53  };
54 
60  public:
61  AbsolutePositionSensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
62  std::string getType() const { return "AbsolutePositionSensor"; }
63  void updateSignal();
64  };
65 
71  public:
72  AbsoluteVelocitySensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
73  std::string getType() const { return "AbsoluteVelocitySensor"; }
74  void updateSignal();
75  };
76 
82  public:
83  AbsoluteAngularPositionSensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
84  std::string getType() const { return "AbsoluteAngularPositionSensor"; }
85  void updateSignal();
86 
87  void calcxSize() {xSize=direction.cols(); }
88  void init(InitStage stage) {
89  if (stage==resize) {
90  AbsolutCoordinateSensor::init(stage);
91  g.resize(direction.cols());
92  gd.resize(direction.cols());
93  x.resize(direction.cols());
94  }
95  else
96  AbsolutCoordinateSensor::init(stage);
97  }
98  void updatexd();
99  void updatedx();
100  };
101 
107  public:
108  AbsoluteAngularVelocitySensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
109  std::string getType() const { return "AbsoluteAngularVelocitySensor"; }
110  void updateSignal();
111  };
112 
113 
119  public:
120  RelativeCoordinateSensor(const std::string &name) : Sensor(name), refFrame(NULL), relFrame(NULL), direction(), refFrameString(""), relFrameString("") {}
121  std::string getType() const { return "RelativeCoordinateSensor"; }
122  void initializeUsingXML(xercesc::DOMElement *element);
123  void init(InitStage stage);
124  void setReferenceFrame(MBSim::Frame * refFrame_) {refFrame=refFrame_; }
125  void setRelativeFrame(MBSim::Frame * relFrame_) {relFrame=relFrame_; }
126  void setDirection(fmatvec::Mat direction_) {
127  direction=direction_;
128  for (int i=0; i<direction_.cols(); i++)
129  direction.col(i)=direction.col(i)/nrm2(direction.col(i));
130  assert(direction.rows()==3);
131  }
132  int getSignalSize() const { return direction.cols(); }
133  protected:
134  MBSim::Frame * refFrame;
135  MBSim::Frame * relFrame;
136  fmatvec::Mat direction;
137  std::string refFrameString, relFrameString;
138  };
139 
145  public:
146  RelativePositionSensor(const std::string &name="") : RelativeCoordinateSensor(name) {}
147  std::string getType() const { return "RelativePositionSensor"; }
148  void updateSignal();
149  };
150 
156  public:
157  RelativeVelocitySensor(const std::string &name="") : RelativeCoordinateSensor(name) {}
158  std::string getType() const { return "RelativeVelocitySensor"; }
159  void updateSignal();
160  };
161 
167  public:
168  RelativeAngularPositionSensor(const std::string &name="") : RelativeCoordinateSensor(name) {}
169  std::string getType() const { return "RelativeAngularPositionSensor"; }
170  void updateSignal();
171 
172  void calcxSize() {xSize=direction.cols(); }
173  void init(InitStage stage) {
174  if (stage==resize) {
175  RelativeCoordinateSensor::init(stage);
176  g.resize(direction.cols());
177  gd.resize(direction.cols());
178  x.resize(direction.cols());
179  }
180  else
181  RelativeCoordinateSensor::init(stage);
182  }
183  void updatexd();
184  void updatedx();
185  };
186 
192  public:
193  RelativeAngularVelocitySensor(const std::string &name="") : RelativeCoordinateSensor(name) {}
194  std::string getType() const { return "RelativeAngularVelocitySensor"; }
195  void updateSignal();
196  };
197 
198 }
199 
200 #endif /* _FRAME_SENSORS_H_ */
RelativeVelocitySensor.
Definition: frame_sensors.h:155
AbsoluteAngularVelocitySensor.
Definition: frame_sensors.h:106
AbsoluteVelocitySensor.
Definition: frame_sensors.h:70
AbsolutePositionSensor.
Definition: frame_sensors.h:59
RelativeAngularPositionSensor.
Definition: frame_sensors.h:166
AbsolutCoordinateSensor.
Definition: frame_sensors.h:35
int rows() const
int cols() const
Sensor.
Definition: sensor.h:31
RelativeAngularVelocitySensor.
Definition: frame_sensors.h:191
AbsoluteAngularPositionSensor.
Definition: frame_sensors.h:81
RelativeCoordinateSensor.
Definition: frame_sensors.h:118
RelativePositionSensor.
Definition: frame_sensors.h:144

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML