Libbarrett  1.2.4
include/barrett/systems/ramp.h
00001 /*
00002         Copyright 2009, 2010 Barrett Technology <support@barrett.com>
00003 
00004         This file is part of libbarrett.
00005 
00006         This version of libbarrett is free software: you can redistribute it
00007         and/or modify it under the terms of the GNU General Public License as
00008         published by the Free Software Foundation, either version 3 of the
00009         License, or (at your option) any later version.
00010 
00011         This version of libbarrett is distributed in the hope that it will be
00012         useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00013         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014         GNU General Public License for more details.
00015 
00016         You should have received a copy of the GNU General Public License along
00017         with this version of libbarrett.  If not, see
00018         <http://www.gnu.org/licenses/>.
00019 
00020         Further, non-binding information about licensing is available at:
00021         <http://wiki.barrett.com/libbarrett/wiki/LicenseNotes>
00022 */
00023 
00024 /*
00025  * ramp.h
00026  *
00027  *  Created on: Jan 5, 2010
00028  *      Author: dc
00029  */
00030 
00031 #ifndef BARRETT_SYSTEMS_RAMP_H_
00032 #define BARRETT_SYSTEMS_RAMP_H_
00033 
00034 
00035 #include <barrett/detail/ca_macro.h>
00036 #include <barrett/thread/abstract/mutex.h>
00037 #include <barrett/systems/abstract/system.h>
00038 #include <barrett/systems/abstract/single_io.h>
00039 
00040 
00041 namespace barrett {
00042 namespace systems {
00043 
00044 
00045 // TODO(dc): add a configuration file interface
00046 
00047 
00048 class Ramp : public System, public SingleOutput<double> {
00049 public:
00050         explicit Ramp(ExecutionManager* em, double slope = 1.0,
00051                         const std::string& sysName = "Ramp");
00052         virtual ~Ramp();
00053 
00054         bool isRunning();
00055 
00056         void start();
00057         void stop();
00058         void setSlope(double slope);
00059 
00060         void reset();
00061         void setOutput(double newOutput);
00062 
00063         void smoothStart(double transitionDuration);
00064         void smoothStop(double transitionDuration);
00065         void smoothSetSlope(double slope, double transitionDuration);
00066 
00067 protected:
00068         virtual void onExecutionManagerChanged();
00069         void getSamplePeriodFromEM();
00070 
00071         virtual void operate();
00072 
00073         void setCurvature(double transitionDuration);
00074 
00075 
00076         double T_s;
00077         double gain, finalGain, curGain, curvature;
00078         double y;
00079 
00080 private:
00081         DISALLOW_COPY_AND_ASSIGN(Ramp);
00082 };
00083 
00084 
00085 }
00086 }
00087 
00088 
00089 // include template definitions
00090 #include <barrett/systems/detail/ramp-inl.h>
00091 
00092 
00093 #endif /* BARRETT_SYSTEMS_RAMP_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Defines