hrplib/hrpModel/Sensor.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * National Institute of Advanced Industrial Science and Technology (AIST)
8  */
9 
10 
11 #include "Sensor.h"
12 
13 #ifndef M_PI
14 #define M_PI 3.14159265358979323846
15 #endif
16 
17 using namespace hrp;
18 
19 
21 {
22  type = COMMON;
23 }
24 
25 
27 {
28  Sensor* sensor;
29 
30  switch(type){
31 
32  case FORCE:
33  sensor = new ForceSensor();
34  break;
35 
36  case RATE_GYRO:
37  sensor = new RateGyroSensor();
38  break;
39 
40  case ACCELERATION:
41  sensor = new AccelSensor();
42  break;
43 
44  case RANGE:
45  sensor = new RangeSensor();
46  break;
47  case VISION:
48  sensor = new VisionSensor();
49  break;
50 
51  case PRESSURE:
52  case PHOTO_INTERRUPTER:
53  case TORQUE:
54  sensor = new Sensor();
55  break;
56  default:
57  sensor = 0;
58  }
59 
60  return sensor;
61 }
62 
63 
65 {
66 
67 }
68 
69 
70 void Sensor::operator=(const Sensor& org)
71 {
72  name = org.name;
73  type = org.type;
74  id = org.id;
75  localR = org.localR;
76  localPos = org.localPos;
77 }
78 
79 
80 void Sensor::destroy(Sensor* sensor)
81 {
82  delete sensor;
83 }
84 
85 
87 {
88 
89 }
90 
91 
92 void Sensor::putInformation(std::ostream &os)
93 {
94  os << "name = " << name << ", id = " << id << "\n";
95  os << "localAttitude = " << localR << ", localPos = " << localPos << std::endl;
96 }
97 
98 
100 {
101  type = FORCE;
102 }
103 
104 
106 {
107  f.setZero();
108  tau.setZero();
109 }
110 
111 
112 void ForceSensor::putInformation(std::ostream& os)
113 {
114  os << "Force Sensor\n";
116  os << "f = " << f << "tau = " << tau << std::endl;
117 }
118 
119 
121 {
122  type = RATE_GYRO;
123 }
124 
125 
127 {
128  w.setZero();
129 }
130 
131 
132 void RateGyroSensor::putInformation(std::ostream& os)
133 {
134  os << "Gyro\n";
136  os << "omega = " << w << std::endl;
137 }
138 
139 
141 {
142  type = ACCELERATION;
143  clear();
144 }
145 
146 
148 {
149  dv(0) = 0.0;
150  dv(1) = 0.0;
151  dv(2) = 9.8;
152 }
153 
154 
155 void AccelSensor::putInformation(std::ostream& os)
156 {
157  os << "Acceleration Sensor\n";
159  os << "dv = " << dv << std::endl;
160 }
161 
163 {
164  type = RANGE;
165  scanAngle = M_PI;
166  scanStep = 0.1;
167  scanRate = 10;
168  maxDistance = 10;
169  nextUpdateTime = 0;
170  isUpdated = false;
171  isEnabled = false;
172 }
173 
175 {
176  type = VISION;
177  near = 0.01;
178  far = 10.0;
179  width = 320;
180  height = 240;
181  imageType = NONE;
182  frameRate = 30.0;
183  nextUpdateTime = 0;
184  isUpdated = false;
185  isEnabled = false;
186 }
static void destroy(Sensor *sensor)
virtual void putInformation(std::ostream &os)
virtual void putInformation(std::ostream &os)
w
virtual void operator=(const Sensor &org)
png_infop png_uint_32 * width
Definition: png.h:2309
virtual void clear()
png_infop png_uint_32 png_uint_32 * height
Definition: png.h:2309
static Sensor * create(int type)
#define M_PI
virtual void putInformation(std::ostream &os)
virtual void putInformation(std::ostream &os)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05