Sensor.cpp
Go to the documentation of this file.
00001 // -*- mode: c++; indent-tabs-mode: t; tab-width: 4; c-basic-offset: 4; -*-
00002 /*
00003  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00004  * All rights reserved. This program is made available under the terms of the
00005  * Eclipse Public License v1.0 which accompanies this distribution, and is
00006  * available at http://www.eclipse.org/legal/epl-v10.html
00007  * Contributors:
00008  * The University of Tokyo
00009  * National Institute of Advanced Industrial Science and Technology (AIST)
00010  * General Robotix Inc. 
00011  */
00012 
00017 #include "Sensor.h"
00018 
00019 Sensor::Sensor()
00020 {
00021         type = COMMON;
00022 }
00023 
00024 
00025 Sensor* Sensor::create(int type)
00026 {
00027     Sensor* sensor;
00028 
00029     switch(type){
00030         
00031     case FORCE:
00032                 sensor = new ForceSensor();
00033                 break;
00034                 
00035     case RATE_GYRO:
00036                 sensor = new RateGyroSensor();
00037                 break;
00038                 
00039     case ACCELERATION:
00040                 sensor = new AccelSensor();
00041                 break;
00042                 
00043     case PRESSURE:
00044     case PHOTO_INTERRUPTER:
00045     case VISION:
00046     case TORQUE:
00047                 sensor = new Sensor();
00048                 break;
00049     default:
00050                 sensor = 0;
00051     }
00052         
00053     return sensor;
00054 }
00055 
00056 
00057 Sensor:: ~Sensor()
00058 {
00059         
00060 }
00061 
00062 
00063 void Sensor::operator=(const Sensor& org)
00064 {
00065         name            = org.name;
00066         type            = org.type;
00067         id                      = org.id;
00068         localR          = org.localR;
00069         localPos        = org.localPos;
00070 }
00071         
00072 
00073 void Sensor::destroy(Sensor* sensor)
00074 {
00075     delete sensor;
00076 }
00077 
00078 
00079 void Sensor::clear()
00080 {
00081 
00082 }
00083 
00084 
00085 void Sensor::putInformation(std::ostream &os)
00086 {
00087         os << "name = " << name << ", id = " << id << "\n";
00088     os << "localAttitude = " << localR << ", localPos = " << localPos << std::endl;
00089 }
00090 
00091 
00092 ForceSensor::ForceSensor()
00093 {
00094         type = FORCE;
00095 }
00096 
00097 
00098 void ForceSensor::clear()
00099 {
00100     f = 0.0;
00101     tau = 0.0;
00102 }
00103 
00104 
00105 void ForceSensor::putInformation(std::ostream& os)
00106 {
00107         os << "Force Sensor\n";
00108         Sensor::putInformation(os);
00109         os << "f = " << f << "tau = " << tau << std::endl;
00110 }
00111 
00112 
00113 RateGyroSensor::RateGyroSensor()
00114 {
00115         type = RATE_GYRO;
00116 }
00117 
00118 
00119 void RateGyroSensor::clear()
00120 {
00121     w = 0.0;
00122 }
00123 
00124 
00125 void RateGyroSensor::putInformation(std::ostream& os)
00126 {
00127         os << "Gyro\n";
00128         Sensor::putInformation(os);
00129         os << "omega = " << w << std::endl;
00130 }
00131 
00132 
00133 AccelSensor::AccelSensor()
00134 {
00135         type = ACCELERATION;
00136         clear();
00137 }
00138 
00139 
00140 void AccelSensor::clear()
00141 {
00142     dv(0) = 0.0;
00143     dv(1) = 0.0;
00144     dv(2) = 0.0;
00145 }
00146 
00147 
00148 void AccelSensor::putInformation(std::ostream& os)
00149 {
00150         os << "Acceleration Sensor\n";
00151         Sensor::putInformation(os);
00152         os << "dv = " << dv << std::endl;
00153 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:19