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 }
hrp::Sensor::~Sensor
virtual ~Sensor()
Definition: hrplib/hrpModel/Sensor.cpp:64
hrp::Sensor::localR
Matrix33 localR
Definition: hrplib/hrpModel/Sensor.h:60
hrp::VisionSensor
Definition: hrplib/hrpModel/Sensor.h:135
hrp::VisionSensor::imageType
ImageType imageType
Definition: hrplib/hrpModel/Sensor.h:144
hrp::Sensor::COMMON
@ COMMON
Definition: hrplib/hrpModel/Sensor.h:32
hrp::VisionSensor::height
int height
Definition: hrplib/hrpModel/Sensor.h:142
Sensor.h
hrp::VisionSensor::near
double near
Definition: hrplib/hrpModel/Sensor.h:143
hrp::AccelSensor::AccelSensor
AccelSensor()
Definition: hrplib/hrpModel/Sensor.cpp:140
hrp::RateGyroSensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: hrplib/hrpModel/Sensor.cpp:132
hrp::Sensor::type
int type
Definition: hrplib/hrpModel/Sensor.h:57
M_PI
#define M_PI
Definition: hrplib/hrpModel/Sensor.cpp:14
hrp
Definition: ColdetModel.h:28
hrp::RangeSensor::scanAngle
double scanAngle
Definition: hrplib/hrpModel/Sensor.h:122
hrp::ForceSensor::f
Vector3 f
Definition: hrplib/hrpModel/Sensor.h:74
hrp::ForceSensor
Definition: hrplib/hrpModel/Sensor.h:68
hrp::RangeSensor::scanRate
double scanRate
Definition: hrplib/hrpModel/Sensor.h:122
hrp::Sensor::RATE_GYRO
@ RATE_GYRO
Definition: hrplib/hrpModel/Sensor.h:34
type
png_infop png_charp png_int_32 png_int_32 int * type
Definition: png.h:2330
hrp::VisionSensor::frameRate
double frameRate
Definition: hrplib/hrpModel/Sensor.h:143
hrp::ForceSensor::clear
virtual void clear()
Definition: hrplib/hrpModel/Sensor.cpp:105
hrp::ForceSensor::tau
Vector3 tau
Definition: hrplib/hrpModel/Sensor.h:75
hrp::Sensor::Sensor
Sensor()
Definition: hrplib/hrpModel/Sensor.cpp:20
hrp::Sensor::create
static Sensor * create(int type)
Definition: hrplib/hrpModel/Sensor.cpp:26
hrp::Sensor::TORQUE
@ TORQUE
Definition: hrplib/hrpModel/Sensor.h:39
hrp::Sensor::name
std::string name
Definition: hrplib/hrpModel/Sensor.h:56
hrp::Sensor::localPos
Vector3 localPos
Definition: hrplib/hrpModel/Sensor.h:61
hrp::VisionSensor::NONE
@ NONE
Definition: hrplib/hrpModel/Sensor.h:138
hrp::RangeSensor::isEnabled
bool isEnabled
Definition: hrplib/hrpModel/Sensor.h:125
hrp::RangeSensor
Definition: hrplib/hrpModel/Sensor.h:115
hrp::RateGyroSensor::clear
virtual void clear()
Definition: hrplib/hrpModel/Sensor.cpp:126
hrp::VisionSensor::far
double far
Definition: hrplib/hrpModel/Sensor.h:143
hrp::RateGyroSensor::w
Vector3 w
Definition: hrplib/hrpModel/Sensor.h:88
hrp::VisionSensor::isEnabled
bool isEnabled
Definition: hrplib/hrpModel/Sensor.h:148
hrp::AccelSensor
Definition: hrplib/hrpModel/Sensor.h:95
hrp::ForceSensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: hrplib/hrpModel/Sensor.cpp:112
hrp::Sensor::clear
virtual void clear()
Definition: hrplib/hrpModel/Sensor.cpp:86
hrp::AccelSensor::clear
virtual void clear()
Definition: hrplib/hrpModel/Sensor.cpp:147
hrp::Sensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: hrplib/hrpModel/Sensor.cpp:92
hrp::VisionSensor::VisionSensor
VisionSensor()
Definition: hrplib/hrpModel/Sensor.cpp:174
hrp::Sensor::VISION
@ VISION
Definition: hrplib/hrpModel/Sensor.h:38
hrp::Sensor::destroy
static void destroy(Sensor *sensor)
Definition: hrplib/hrpModel/Sensor.cpp:80
hrp::AccelSensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: hrplib/hrpModel/Sensor.cpp:155
hrp::RangeSensor::isUpdated
bool isUpdated
Definition: hrplib/hrpModel/Sensor.h:125
hrp::Sensor::RANGE
@ RANGE
Definition: hrplib/hrpModel/Sensor.h:40
hrp::Sensor::ACCELERATION
@ ACCELERATION
Definition: hrplib/hrpModel/Sensor.h:35
hrp::Sensor::FORCE
@ FORCE
Definition: hrplib/hrpModel/Sensor.h:33
hrp::RangeSensor::scanStep
double scanStep
Definition: hrplib/hrpModel/Sensor.h:122
hrp::RangeSensor::RangeSensor
RangeSensor()
Definition: hrplib/hrpModel/Sensor.cpp:162
hrp::VisionSensor::isUpdated
bool isUpdated
Definition: hrplib/hrpModel/Sensor.h:148
hrp::VisionSensor::nextUpdateTime
double nextUpdateTime
Definition: hrplib/hrpModel/Sensor.h:147
hrp::Sensor
Definition: hrplib/hrpModel/Sensor.h:27
hrp::Sensor::PRESSURE
@ PRESSURE
Definition: hrplib/hrpModel/Sensor.h:36
hrp::RangeSensor::maxDistance
double maxDistance
Definition: hrplib/hrpModel/Sensor.h:122
hrp::Sensor::id
int id
Definition: hrplib/hrpModel/Sensor.h:58
hrp::Sensor::PHOTO_INTERRUPTER
@ PHOTO_INTERRUPTER
Definition: hrplib/hrpModel/Sensor.h:37
hrp::ForceSensor::ForceSensor
ForceSensor()
Definition: hrplib/hrpModel/Sensor.cpp:99
hrp::RateGyroSensor::RateGyroSensor
RateGyroSensor()
Definition: hrplib/hrpModel/Sensor.cpp:120
hrp::VisionSensor::width
int width
Definition: hrplib/hrpModel/Sensor.h:142
hrp::RateGyroSensor
Definition: hrplib/hrpModel/Sensor.h:82
hrp::RangeSensor::nextUpdateTime
double nextUpdateTime
Definition: hrplib/hrpModel/Sensor.h:124
hrp::AccelSensor::dv
Vector3 dv
Definition: hrplib/hrpModel/Sensor.h:104
hrp::Sensor::operator=
virtual void operator=(const Sensor &org)
Definition: hrplib/hrpModel/Sensor.cpp:70


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Wed Sep 7 2022 02:51:04