server/UtDynamicsSimulator/Sensor.cpp
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
2 /*
3  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
4  * All rights reserved. This program is made available under the terms of the
5  * Eclipse Public License v1.0 which accompanies this distribution, and is
6  * available at http://www.eclipse.org/legal/epl-v10.html
7  * Contributors:
8  * The University of Tokyo
9  * National Institute of Advanced Industrial Science and Technology (AIST)
10  * General Robotix Inc.
11  */
12 
17 #include "Sensor.h"
18 
20 {
21  type = COMMON;
22 }
23 
24 
26 {
27  Sensor* sensor;
28 
29  switch(type){
30 
31  case FORCE:
32  sensor = new ForceSensor();
33  break;
34 
35  case RATE_GYRO:
36  sensor = new RateGyroSensor();
37  break;
38 
39  case ACCELERATION:
40  sensor = new AccelSensor();
41  break;
42 
43  case PRESSURE:
44  case PHOTO_INTERRUPTER:
45  case VISION:
46  case TORQUE:
47  sensor = new Sensor();
48  break;
49  default:
50  sensor = 0;
51  }
52 
53  return sensor;
54 }
55 
56 
58 {
59 
60 }
61 
62 
63 void Sensor::operator=(const Sensor& org)
64 {
65  name = org.name;
66  type = org.type;
67  id = org.id;
68  localR = org.localR;
69  localPos = org.localPos;
70 }
71 
72 
73 void Sensor::destroy(Sensor* sensor)
74 {
75  delete sensor;
76 }
77 
78 
80 {
81 
82 }
83 
84 
85 void Sensor::putInformation(std::ostream &os)
86 {
87  os << "name = " << name << ", id = " << id << "\n";
88  os << "localAttitude = " << localR << ", localPos = " << localPos << std::endl;
89 }
90 
91 
93 {
94  type = FORCE;
95 }
96 
97 
99 {
100  f = 0.0;
101  tau = 0.0;
102 }
103 
104 
105 void ForceSensor::putInformation(std::ostream& os)
106 {
107  os << "Force Sensor\n";
109  os << "f = " << f << "tau = " << tau << std::endl;
110 }
111 
112 
114 {
115  type = RATE_GYRO;
116 }
117 
118 
120 {
121  w = 0.0;
122 }
123 
124 
125 void RateGyroSensor::putInformation(std::ostream& os)
126 {
127  os << "Gyro\n";
129  os << "omega = " << w << std::endl;
130 }
131 
132 
134 {
135  type = ACCELERATION;
136  clear();
137 }
138 
139 
141 {
142  dv(0) = 0.0;
143  dv(1) = 0.0;
144  dv(2) = 0.0;
145 }
146 
147 
148 void AccelSensor::putInformation(std::ostream& os)
149 {
150  os << "Acceleration Sensor\n";
152  os << "dv = " << dv << std::endl;
153 }
Sensor::Sensor
Sensor()
Definition: server/UtDynamicsSimulator/Sensor.cpp:19
Sensor.h
Sensor::TORQUE
@ TORQUE
Definition: server/UtDynamicsSimulator/Sensor.h:36
ForceSensor::ForceSensor
ForceSensor()
Definition: server/UtDynamicsSimulator/Sensor.cpp:92
AccelSensor::dv
fVec3 dv
Definition: server/UtDynamicsSimulator/Sensor.h:98
Sensor::ACCELERATION
@ ACCELERATION
Definition: server/UtDynamicsSimulator/Sensor.h:32
Sensor
Definition: server/UtDynamicsSimulator/Sensor.h:24
Sensor::VISION
@ VISION
Definition: server/UtDynamicsSimulator/Sensor.h:35
Sensor::FORCE
@ FORCE
Definition: server/UtDynamicsSimulator/Sensor.h:30
ForceSensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: server/UtDynamicsSimulator/Sensor.cpp:105
Sensor::type
int type
Definition: server/UtDynamicsSimulator/Sensor.h:53
Sensor::COMMON
@ COMMON
Definition: server/UtDynamicsSimulator/Sensor.h:29
ForceSensor
Definition: server/UtDynamicsSimulator/Sensor.h:64
Sensor::destroy
static void destroy(Sensor *sensor)
Definition: server/UtDynamicsSimulator/Sensor.cpp:73
ForceSensor::tau
fVec3 tau
Definition: server/UtDynamicsSimulator/Sensor.h:71
RateGyroSensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: server/UtDynamicsSimulator/Sensor.cpp:125
Sensor::RATE_GYRO
@ RATE_GYRO
Definition: server/UtDynamicsSimulator/Sensor.h:31
AccelSensor::AccelSensor
AccelSensor()
Definition: server/UtDynamicsSimulator/Sensor.cpp:133
Sensor::localPos
fVec3 localPos
Definition: server/UtDynamicsSimulator/Sensor.h:57
type
png_infop png_charp png_int_32 png_int_32 int * type
Definition: png.h:2330
RateGyroSensor
Definition: server/UtDynamicsSimulator/Sensor.h:78
Sensor::name
std::string name
Definition: server/UtDynamicsSimulator/Sensor.h:52
RateGyroSensor::w
fVec3 w
Definition: server/UtDynamicsSimulator/Sensor.h:84
ForceSensor::clear
virtual void clear()
Definition: server/UtDynamicsSimulator/Sensor.cpp:98
Sensor::~Sensor
virtual ~Sensor()
Definition: server/UtDynamicsSimulator/Sensor.cpp:57
Sensor::id
int id
Definition: server/UtDynamicsSimulator/Sensor.h:54
Sensor::operator=
virtual void operator=(const Sensor &org)
Definition: server/UtDynamicsSimulator/Sensor.cpp:63
RateGyroSensor::RateGyroSensor
RateGyroSensor()
Definition: server/UtDynamicsSimulator/Sensor.cpp:113
Sensor::clear
virtual void clear()
Definition: server/UtDynamicsSimulator/Sensor.cpp:79
Sensor::localR
fMat33 localR
Definition: server/UtDynamicsSimulator/Sensor.h:56
Sensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: server/UtDynamicsSimulator/Sensor.cpp:85
ForceSensor::f
fVec3 f
Definition: server/UtDynamicsSimulator/Sensor.h:70
Sensor::PRESSURE
@ PRESSURE
Definition: server/UtDynamicsSimulator/Sensor.h:33
AccelSensor::clear
virtual void clear()
Definition: server/UtDynamicsSimulator/Sensor.cpp:140
RateGyroSensor::clear
virtual void clear()
Definition: server/UtDynamicsSimulator/Sensor.cpp:119
AccelSensor::putInformation
virtual void putInformation(std::ostream &os)
Definition: server/UtDynamicsSimulator/Sensor.cpp:148
Sensor::create
static Sensor * create(int type)
Definition: server/UtDynamicsSimulator/Sensor.cpp:25
Sensor::PHOTO_INTERRUPTER
@ PHOTO_INTERRUPTER
Definition: server/UtDynamicsSimulator/Sensor.h:34
AccelSensor
Definition: server/UtDynamicsSimulator/Sensor.h:91


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