00001 /*************************************************************************** 00002 * Copyright (C) 2005-2011 LpzRobots development team * 00003 * Georg Martius <georg dot martius at web dot de> * 00004 * Frank Guettler <guettler at informatik dot uni-leipzig dot de * 00005 * Frank Hesse <frank at nld dot ds dot mpg dot de> * 00006 * Ralf Der <ralfder at mis dot mpg dot de> * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program; if not, write to the * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 * * 00023 ***************************************************************************/ 00024 #ifndef __COPYWIRING_H 00025 #define __COPYWIRING_H 00026 00027 #include <selforg/abstractwiring.h> 00028 #include <selforg/matrix.h> 00029 #include <selforg/configurable.h> 00030 #include <list> 00031 #include <vector> 00032 00033 /** Implements a wiring where the motors are copied to several motors 00034 and the sensors are fusioned. 00035 */ 00036 class CopyWiring: public AbstractWiring, public Configurable { 00037 public: 00038 typedef std::vector < std::list<int> > Assignment; 00039 00040 /** constructor 00041 @param sensor_assignment for each controller sensor a list of robot sensor it is averaged over 00042 @param motor_assignment for each robot motor a list of controller motors it is averaged over 00043 @param noise NoiseGenerator that is used for adding noise to sensor values 00044 @param plotMode see AbstractWiring 00045 */ 00046 CopyWiring(const Assignment& sensor_assignment, const Assignment& motor_assignment, 00047 NoiseGenerator* noise, int plotMode=Controller|Robot, const std::string& name = "CopyWiring"); 00048 00049 /** destructor 00050 */ 00051 virtual ~CopyWiring(); 00052 00053 virtual void reset(); 00054 00055 static Assignment motorFromSensorAssignment(const Assignment& sensor_assignment); 00056 00057 protected: 00058 00059 /** initializes the number of sensors and motors on robot side, calculate 00060 number of sensors and motors on controller side 00061 */ 00062 virtual bool initIntern(); 00063 00064 /** Realizes one to one wiring from robot sensors to controller sensors. 00065 @param rsensors pointer to array of sensorvalues from robot 00066 @param rsensornumber number of sensors from robot 00067 @param csensors pointer to array of sensorvalues for controller 00068 @param csensornumber number of sensors to controller 00069 @param noise size of the noise added to the sensors 00070 */ 00071 virtual bool wireSensorsIntern(const sensor* rsensors, int rsensornumber, 00072 sensor* csensors, int csensornumber, 00073 double noise); 00074 00075 /** Realizes one to one wiring from controller motor outputs to robot motors. 00076 @param rmotors pointer to array of motorvalues for robot 00077 @param rmotornumber number of robot motors 00078 @param cmotors pointer to array of motorvalues from controller 00079 @param cmotornumber number of motorvalues from controller 00080 */ 00081 virtual bool wireMotorsIntern(motor* rmotors, int rmotornumber, 00082 const motor* cmotors, int cmotornumber); 00083 00084 00085 protected: 00086 Assignment s_assign; 00087 Assignment m_assign; 00088 }; 00089 00090 #endif