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  protected:
49  MBSim::Frame * frame;
50  fmatvec::Mat direction;
51  std::string frameString;
52  };
53 
59  public:
60  AbsolutePositionSensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
61  std::string getType() const { return "AbsolutePositionSensor"; }
62  fmatvec::VecV getSignal();
63  };
64 
70  public:
71  AbsoluteVelocitySensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
72  std::string getType() const { return "AbsoluteVelocitySensor"; }
73  fmatvec::VecV getSignal();
74  };
75 
81  public:
82  AbsoluteAngularPositionSensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
83  std::string getType() const { return "AbsoluteAngularPositionSensor"; }
84  fmatvec::VecV getSignal();
85 
86  void calcxSize() {xSize=direction.cols(); }
87  void init(InitStage stage) {
88  if (stage==resize) {
89  AbsolutCoordinateSensor::init(stage);
90  g.resize(direction.cols());
91  gd.resize(direction.cols());
92  x.resize(direction.cols());
93  }
94  else
95  AbsolutCoordinateSensor::init(stage);
96  }
97  void updateg(double t) {g=x; }
98  void updategd(double t);
99  void updatexd(double t) {xd=gd; }
100  void updatedx(double t, double dt) {xd=gd*dt; }
101  };
102 
108  public:
109  AbsoluteAngularVelocitySensor(const std::string &name="") : AbsolutCoordinateSensor(name) {}
110  std::string getType() const { return "AbsoluteAngularVelocitySensor"; }
111  fmatvec::VecV getSignal();
112  };
113 
114 
120  public:
121  RelativeCoordinateSensor(const std::string &name) : Sensor(name), refFrame(NULL), relFrame(NULL), direction(), refFrameString(""), relFrameString("") {}
122  std::string getType() const { return "RelativeCoordinateSensor"; }
123  void initializeUsingXML(xercesc::DOMElement *element);
124  void init(InitStage stage);
125  void setReferenceFrame(MBSim::Frame * refFrame_) {refFrame=refFrame_; }
126  void setRelativeFrame(MBSim::Frame * relFrame_) {relFrame=relFrame_; }
127  void setDirection(fmatvec::Mat direction_) {
128  direction=direction_;
129  for (int i=0; i<direction_.cols(); i++)
130  direction.col(i)=direction.col(i)/nrm2(direction.col(i));
131  assert(direction.rows()==3);
132  }
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  fmatvec::VecV getSignal();
149  };
150 
156  public:
157  RelativeVelocitySensor(const std::string &name="") : RelativeCoordinateSensor(name) {}
158  std::string getType() const { return "RelativeVelocitySensor"; }
159  fmatvec::VecV getSignal();
160  };
161 
167  public:
168  RelativeAngularPositionSensor(const std::string &name="") : RelativeCoordinateSensor(name) {}
169  std::string getType() const { return "RelativeAngularPositionSensor"; }
170  fmatvec::VecV getSignal();
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 updateg(double t) {g=x; }
184  void updategd(double t);
185  void updatexd(double t) {xd=gd; }
186  void updatedx(double t, double dt) {xd=gd*dt; }
187  };
188 
194  public:
195  RelativeAngularVelocitySensor(const std::string &name="") : RelativeCoordinateSensor(name) {}
196  std::string getType() const { return "RelativeAngularVelocitySensor"; }
197  fmatvec::VecV getSignal();
198  };
199 
200 }
201 
202 #endif /* _FRAME_SENSORS_H_ */
RelativeVelocitySensor.
Definition: frame_sensors.h:155
AbsoluteAngularVelocitySensor.
Definition: frame_sensors.h:107
AbsoluteVelocitySensor.
Definition: frame_sensors.h:69
AbsolutePositionSensor.
Definition: frame_sensors.h:58
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:193
AbsoluteAngularPositionSensor.
Definition: frame_sensors.h:80
RelativeCoordinateSensor.
Definition: frame_sensors.h:119
RelativePositionSensor.
Definition: frame_sensors.h:144

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML