Skip to content
Snippets Groups Projects
controller-pd.h 3.18 KiB
Newer Older
Nicolas Mansard's avatar
Nicolas Mansard committed
/*
 * Copyright 2011, Nicolas Mansard, LAAS-CNRS
 *
 * This file is part of sot-dyninv.
 * sot-dyninv is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 * sot-dyninv is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.  You should
 * have received a copy of the GNU Lesser General Public License along
 * with sot-dyninv.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __sot_dyninv_ControllerPD_H__
#define __sot_dyninv_ControllerPD_H__
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */

#if defined (WIN32)
#  if defined (controller_pd_EXPORTS)
#    define SOTCONTROLLERPD_EXPORT __declspec(dllexport)
#  else
#    define SOTCONTROLLERPD_EXPORT __declspec(dllimport)
#  endif
#else
#  define SOTCONTROLLERPD_EXPORT
#endif

/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */


/* SOT */
Nicolas Mansard's avatar
Nicolas Mansard committed
#include <sot-dyninv/signal-helper.h>
#include <sot-dyninv/entity-helper.h>
Nicolas Mansard's avatar
Nicolas Mansard committed



namespace dynamicgraph {
  namespace sot {
    namespace dyninv {
Nicolas Mansard's avatar
Nicolas Mansard committed

      /* --------------------------------------------------------------------- */
      /* --- CLASS ----------------------------------------------------------- */
      /* --------------------------------------------------------------------- */
Nicolas Mansard's avatar
Nicolas Mansard committed

      class SOTCONTROLLERPD_EXPORT ControllerPD
	:public ::dynamicgraph::Entity
	,public ::dynamicgraph::EntityHelper<ControllerPD>
	{
Nicolas Mansard's avatar
Nicolas Mansard committed

	public: /* --- CONSTRUCTOR ---- */
Nicolas Mansard's avatar
Nicolas Mansard committed

	  ControllerPD( const std::string & name );
Nicolas Mansard's avatar
Nicolas Mansard committed

	protected:
	  /* Parameters of the torque-control function:
	   * tau = kp * (qd-q) + kd* (dqd-dq) */
	  int _dimension;
Nicolas Mansard's avatar
Nicolas Mansard committed

	public:
	  void size(const int & dimension);
	  int size(void) const;
	  void setStandardGains( const std::string & config );
	  void setGainVelocityOnly( void );
Nicolas Mansard's avatar
Nicolas Mansard committed

	public: /* --- ENTITY INHERITANCE --- */
Nicolas Mansard's avatar
Nicolas Mansard committed

	  static const std::string CLASS_NAME;
	  virtual void display( std::ostream& os ) const;
	  virtual const std::string& getClassName( void ) const { return CLASS_NAME; }
Nicolas Mansard's avatar
Nicolas Mansard committed

	  virtual void commandLine( const std::string& cmdLine,
				    std::istringstream& cmdArgs,
				    std::ostream& os );
Nicolas Mansard's avatar
Nicolas Mansard committed

Nicolas Mansard's avatar
Nicolas Mansard committed

	  DECLARE_SIGNAL_IN(Kp,ml::Vector);
	  DECLARE_SIGNAL_IN(Kd,ml::Vector);
	  DECLARE_SIGNAL_IN(position,ml::Vector);
	  DECLARE_SIGNAL_IN(positionRef,ml::Vector);
	  DECLARE_SIGNAL_IN(velocity,ml::Vector);
	  DECLARE_SIGNAL_IN(velocityRef,ml::Vector);
Nicolas Mansard's avatar
Nicolas Mansard committed

	  DECLARE_SIGNAL_OUT(control,ml::Vector);
Nicolas Mansard's avatar
Nicolas Mansard committed

Nicolas Mansard's avatar
Nicolas Mansard committed

    } // namespace dyninv
  } // namespace sot
} // namespace dynamicgraph
Nicolas Mansard's avatar
Nicolas Mansard committed



#endif // #ifndef __sot_dyninv_ControllerPD_H__