Robot Simulator of the Robotics Group for Self-Organization of Control: plotoption.h Source File

# plotoption.h

Go to the documentation of this file.

    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
    00025
    00026 #ifndef PLOTOPTION_H_
    00027 #define PLOTOPTION_H_
    00028
    00029 #include <stdio.h>
    00030 #include <list>
    00031 #include <utility>
    00032 #include <string>
    00033
    00034 class Configurable;
    00035 class Inspectable;
    00036
    00037 /** Output mode for agent.
    00038  */
    00039 enum PlotMode {
    00040   /// dummy (does nothing) is there for compatibility, might be removed later
    00041   NoPlot,
    00042   /// write into file
    00043   File,
    00044   /// plotting with guilogger (gnuplot)
    00045   GuiLogger,
    00046   /// plotting with guiscreen (gnuplot) in file logging mode
    00047   GuiLogger_File,
    00048   /// plotting with matrixVisualizer
    00049   MatrixViz,
    00050
    00051   /// Acustic output of robotic values via external SoundMan
    00052   SoundMan,
    00053
    00054   /// gui for ECBRobots (see lpzrobots/ecbrobots), should be usable with OdeRobots, too
    00055   ECBRobotGUI,
    00056
    00057   /// dummy used for upper bound of plotmode type
    00058   LastPlot
    00059 };
    00060
    00061
    00062 /** This class contains options for the use of an external plot utility like guilogger or neuronviz
    00063     or just simply file output
    00064  */
    00065 class PlotOption {
    00066 public:
    00067   friend class WiredController;
    00068   friend class PlotOptionEngine;
    00069
    00070   PlotOption(){ mode=NoPlot; interval=1; pipe=0; parameter="";}
    00071   /**
    00072      creates a new plotting object
    00073      @param mode output type @see PlotMode
    00074      @param interval every i-th step is plotted
    00075      @param parameter free parameters for plotting tool
    00076      Note: the argument whichSensor is removed. You can adjust this in the wirings now.
    00077    */
    00078   PlotOption( PlotMode mode, int interval = 1, std::string parameter="")
    00079     : interval(interval), mode(mode), parameter(parameter)
    00080   {
    00081     pipe=0;
    00082   }
    00083
    00084   virtual ~PlotOption(){}
    00085
    00086   virtual PlotMode getPlotOptionMode() const { return mode; }
    00087   // flushes pipe (depending on mode)
    00088   virtual void flush(long step);
    00089
    00090   /// nice predicate function for finding by mode
    00091   struct matchMode : public std::unary_function<const PlotOption&, bool> {
    00092     matchMode(PlotMode mode) : mode(mode) {}
    00093     int mode;
    00094     bool operator()(const PlotOption& m) { return (m.mode == mode); }
    00095
    00096   };
    00097
    00098   void addConfigurable(const Configurable*);
    00099   void setName(const std::string& name) { this->name = name;}
    00100   const std::string& getName() const { return name; }
    00101
    00102   bool open(); ///< opens the connections to the plot tool
    00103   void close();///< closes the connections to the plot tool
    00104
    00105   FILE* pipe;
    00106   long t;
    00107   int interval;
    00108   std::string name;
    00109
    00110 private:
    00111
    00112   PlotMode mode;
    00113   std::string parameter; ///< additional parameter for external command
    00114 };
    00115
    00116 #endif /* PLOTOPTION_H_ */