Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ostasse/sot-core
  • gsaurel/sot-core
  • stack-of-tasks/sot-core
3 results
Show changes
Showing
with 1826 additions and 0 deletions
#ifndef _SOT_CORE_CAUSAL_FILTER_H_
#define _SOT_CORE_CAUSAL_FILTER_H_
/*
* Copyright 2017-, Rohan Budhirja, LAAS-CNRS
*
* This file is part of sot-torque-control.
* sot-torque-control 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-torque-control 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-torque-control. If not, see <http://www.gnu.org/licenses/>.
*/
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <Eigen/Core>
/** \addtogroup Filters
\section subsec_causalfilter CausalFilter
Filter data with an IIR or FIR filter.
Filter a data sequence, \f$x\f$, using a digital filter.
The filter is a direct form II transposed implementation
of the standard difference equation.
This means that the filter implements:
\f$ a[0]*y[N] = b[0]*x[N] + b[1]*x[N-1] + ... + b[m-1]*x[N-(m-1)]
- a[1]*y[N-1] - ... - a[n-1]*y[N-(n-1)] \f$
where \f$m\f$ is the degree of the numerator,
\f$n\f$ is the degree of the denominator,
and \f$N\f$ is the sample number
*/
namespace dynamicgraph {
namespace sot {
class CausalFilter {
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
/** --- CONSTRUCTOR ----
\param[in] timestep
\param[in] xSize
\param[in] filter_numerator
\param[in] filter_denominator
xSize is
*/
CausalFilter(const double &timestep, const int &xSize,
const Eigen::VectorXd &filter_numerator,
const Eigen::VectorXd &filter_denominator);
void get_x_dx_ddx(const Eigen::VectorXd &base_x,
Eigen::VectorXd &x_output_dx_ddx);
void switch_filter(const Eigen::VectorXd &filter_numerator,
const Eigen::VectorXd &filter_denominator);
private:
/// sampling timestep of the input signal
double m_dt;
/// Size
int m_x_size;
/// Size of the numerator \f$m\f$
Eigen::VectorXd::Index m_filter_order_m;
/// Size of the denominator \f$n\f$
Eigen::VectorXd::Index m_filter_order_n;
/// Coefficients of the numerator \f$b\f$
Eigen::VectorXd m_filter_numerator;
/// Coefficients of the denominator \f$a\f$
Eigen::VectorXd m_filter_denominator;
bool m_first_sample;
///
int m_pt_numerator;
int m_pt_denominator;
Eigen::MatrixXd m_input_buffer;
Eigen::MatrixXd m_output_buffer;
}; // class CausalFilter
} // namespace sot
} // namespace dynamicgraph
#endif /* _SOT_CORE_CAUSAL_FILTER_H_ */
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef __SOT_CLAMP_WORKSPACE_HH__
#define __SOT_CLAMP_WORKSPACE_HH__
/* STL */
#include <utility>
/* Matrix */
#include <dynamic-graph/linear-algebra.h>
/* SOT */
#include <dynamic-graph/all-signals.h>
#include <dynamic-graph/entity.h>
#include <sot/core/exception-task.hh>
#include <sot/core/matrix-geometry.hh>
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#if defined(WIN32)
#if defined(clamp_workspace_EXPORTS)
#define SOTCLAMPWORKSPACE_EXPORT __declspec(dllexport)
#else
#define SOTCLAMPWORKSPACE_EXPORT __declspec(dllimport)
#endif
#else
#define SOTCLAMPWORKSPACE_EXPORT
#endif
namespace dynamicgraph {
namespace sot {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
class SOTCLAMPWORKSPACE_EXPORT ClampWorkspace : public dynamicgraph::Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName(void) const { return CLASS_NAME; }
/* --- SIGNALS ------------------------------------------------------------ */
public:
dynamicgraph::SignalPtr<MatrixHomogeneous, int> positionrefSIN;
dynamicgraph::SignalPtr<MatrixHomogeneous, int> positionSIN;
dynamicgraph::SignalTimeDependent<dynamicgraph::Matrix, int> alphaSOUT;
dynamicgraph::SignalTimeDependent<dynamicgraph::Matrix, int> alphabarSOUT;
dynamicgraph::SignalTimeDependent<MatrixHomogeneous, int> handrefSOUT;
public:
ClampWorkspace(const std::string &name);
virtual ~ClampWorkspace(void) {}
void update(int time);
virtual dynamicgraph::Matrix &computeOutput(dynamicgraph::Matrix &res,
int time);
virtual dynamicgraph::Matrix &computeOutputBar(dynamicgraph::Matrix &res,
int time);
virtual MatrixHomogeneous &computeRef(MatrixHomogeneous &res, int time);
virtual void display(std::ostream &) const;
private:
int timeUpdate;
dynamicgraph::Matrix alpha;
dynamicgraph::Matrix alphabar;
MatrixHomogeneous prefMp;
dynamicgraph::Vector pd;
MatrixRotation Rd;
MatrixHomogeneous handref;
double beta;
double scale;
double dm_min;
double dm_max;
double dm_min_yaw;
double dm_max_yaw;
double theta_min;
double theta_max;
int mode;
enum { FRAME_POINT, FRAME_REF } frame;
std::pair<double, double> bounds[3];
};
} /* namespace sot */
} /* namespace dynamicgraph */
#endif
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef __SOT_SOTCOMFREEZER_H_H
#define __SOT_SOTCOMFREEZER_H_H
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Matrix */
#include <dynamic-graph/linear-algebra.h>
/* SOT */
#include <dynamic-graph/all-signals.h>
#include <dynamic-graph/entity.h>
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#if defined(WIN32)
#if defined(com_freezer_EXPORTS)
#define SOTCOMFREEZER_EXPORT __declspec(dllexport)
#else
#define SOTCOMFREEZER_EXPORT __declspec(dllimport)
#endif
#else
#define SOTCOMFREEZER_EXPORT
#endif
namespace dynamicgraph {
namespace sot {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
class SOTCOMFREEZER_EXPORT CoMFreezer : public dynamicgraph::Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName() const { return CLASS_NAME; }
private:
dynamicgraph::Vector m_lastCoM;
bool m_previousPGInProcess;
int m_lastStopTime;
public: /* --- CONSTRUCTION --- */
CoMFreezer(const std::string &name);
virtual ~CoMFreezer(void);
public: /* --- SIGNAL --- */
dynamicgraph::SignalPtr<dynamicgraph::Vector, int> CoMRefSIN;
dynamicgraph::SignalPtr<unsigned, int> PGInProcessSIN;
dynamicgraph::SignalTimeDependent<dynamicgraph::Vector, int> freezedCoMSOUT;
public: /* --- FUNCTION --- */
dynamicgraph::Vector &computeFreezedCoM(dynamicgraph::Vector &freezedCoM,
const int &time);
public: /* --- PARAMS --- */
virtual void display(std::ostream &os) const;
};
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_SOTCOMFREEZER_H_H */
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* File: Contiifstream.h
* Project: SOT
* Author: Nicolas Mansard
* CNRS/AIST
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
*
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_CONTIIFSTREAM_HH__
#define __SOT_CONTIIFSTREAM_HH__
......@@ -26,8 +14,6 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <iostream>
#include <fstream>
#include <sstream>
#ifndef WIN32
......@@ -35,46 +21,43 @@
#endif
#include <list>
#include <dynamic-graph/interpreter.h>
#include <sot-core/sot-core-api.h>
#include "sot/core/api.hh"
#ifndef WIN32
#include <pthread.h>
#endif
namespace dynamicgraph {
namespace sot {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
class SOT_CORE_EXPORT Contiifstream
{
protected:
class SOT_CORE_EXPORT Contiifstream {
protected:
std::string filename;
unsigned int cursor;
std::streamoff cursor;
static const unsigned int BUFFER_SIZE = 256;
char buffer[BUFFER_SIZE];
std::list< std::string > reader;
std::list<std::string> reader;
bool first;
public: /* --- Constructor --- */
Contiifstream( const std::string& n="" );
~Contiifstream( void );
void open( const std::string& n ) { filename=n; cursor=0; }
public: /* --- READ FILE --- */
bool loop( void );
public: /* --- READ LIST --- */
inline bool ready( void ) { return 0<reader.size();}
std::string next( void ) ;
};
} // namespace sot
#endif /* #ifndef __SOT_CONTIIFSTREAM_HH__ */
public: /* --- Constructor --- */
Contiifstream(const std::string &n = "");
~Contiifstream(void);
void open(const std::string &n) {
filename = n;
cursor = 0;
}
public: /* --- READ FILE --- */
bool loop(void);
public: /* --- READ LIST --- */
inline bool ready(void) { return 0 < reader.size(); }
std::string next(void);
};
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_CONTIIFSTREAM_HH__ */
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef __SOT_Control_GR_HH__
#define __SOT_Control_GR_HH__
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Matrix */
#include <dynamic-graph/linear-algebra.h>
/* SOT */
#include <dynamic-graph/entity.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#if defined(WIN32)
#if defined(control_gr_EXPORTS)
#define ControlGR_EXPORT __declspec(dllexport)
#else
#define ControlGR_EXPORT __declspec(dllimport)
#endif
#else
#define ControlGR_EXPORT
#endif
namespace dynamicgraph {
namespace sot {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
class ControlGR_EXPORT ControlGR : public Entity {
public: /* --- CONSTRUCTOR ---- */
ControlGR(const std::string &name);
public: /* --- INIT --- */
void init(const double &step);
public: /* --- CONSTANTS --- */
/* Default values. */
static const double TIME_STEP_DEFAULT; // = 0.001
public: /* --- ENTITY INHERITANCE --- */
static const std::string CLASS_NAME;
virtual void display(std::ostream &os) const;
virtual const std::string &getClassName(void) const { return CLASS_NAME; }
protected:
/* Parameters of the torque-control function:
* tau = - A*qddot = g */
double TimeStep;
double _dimension;
public: /* --- SIGNALS --- */
SignalPtr<dynamicgraph::Matrix, int> matrixASIN;
SignalPtr<dynamicgraph::Vector, int> accelerationSIN;
SignalPtr<dynamicgraph::Vector, int> gravitySIN;
SignalTimeDependent<dynamicgraph::Vector, int> controlSOUT;
protected:
double &setsize(int dimension);
dynamicgraph::Vector &computeControl(dynamicgraph::Vector &tau, int t);
};
} // namespace sot
} // namespace dynamicgraph
#endif // #ifndef __SOT_Control_GR_HH__
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef __SOT_Control_PD_HH__
#define __SOT_Control_PD_HH__
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Matrix */
#include <dynamic-graph/linear-algebra.h>
/* SOT */
#include <dynamic-graph/entity.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#if defined(WIN32)
#if defined(control_pd_EXPORTS)
#define ControlPD_EXPORT __declspec(dllexport)
#else
#define ControlPD_EXPORT __declspec(dllimport)
#endif
#else
#define ControlPD_EXPORT
#endif
namespace dynamicgraph {
namespace sot {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
class ControlPD_EXPORT ControlPD : public Entity {
public: /* --- CONSTRUCTOR ---- */
ControlPD(const std::string &name);
public: /* --- INIT --- */
void init(const double &step);
public: /* --- CONSTANTS --- */
/* Default values. */
static const double TIME_STEP_DEFAULT; // = 0.001
public: /* --- ENTITY INHERITANCE --- */
static const std::string CLASS_NAME;
virtual void display(std::ostream &os) const;
virtual const std::string &getClassName(void) const { return CLASS_NAME; }
protected:
/* Parameters of the torque-control function:
* tau = kp * (qd-q) + kd* (dqd-dq) */
double TimeStep;
public: /* --- SIGNALS --- */
SignalPtr<dynamicgraph::Vector, int> KpSIN;
SignalPtr<dynamicgraph::Vector, int> KdSIN;
SignalPtr<dynamicgraph::Vector, int> positionSIN;
SignalPtr<dynamicgraph::Vector, int> desiredpositionSIN;
SignalPtr<dynamicgraph::Vector, int> velocitySIN;
SignalPtr<dynamicgraph::Vector, int> desiredvelocitySIN;
SignalTimeDependent<dynamicgraph::Vector, int> controlSOUT;
SignalTimeDependent<dynamicgraph::Vector, int> positionErrorSOUT;
SignalTimeDependent<dynamicgraph::Vector, int> velocityErrorSOUT;
protected:
dynamicgraph::Vector &computeControl(dynamicgraph::Vector &tau, int t);
dynamicgraph::Vector position_error_;
dynamicgraph::Vector velocity_error_;
dynamicgraph::Vector &getPositionError(dynamicgraph::Vector &position_error,
int t);
dynamicgraph::Vector &getVelocityError(dynamicgraph::Vector &velocity_error,
int t);
};
} // namespace sot
} // namespace dynamicgraph
#endif // #ifndef __SOT_Control_PD_HH__
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef SOT_CORE_DEBUG_HH
#define SOT_CORE_DEBUG_HH
#include <cstdarg>
#include <cstdio>
#include <fstream>
#include <sstream>
#include "sot/core/api.hh"
#ifndef VP_DEBUG_MODE
#define VP_DEBUG_MODE 0
#endif //! VP_DEBUG_MODE
#ifndef VP_TEMPLATE_DEBUG_MODE
#define VP_TEMPLATE_DEBUG_MODE 0
#endif //! VP_TEMPLATE_DEBUG_MODE
#define SOT_COMMON_TRACES \
do { \
va_list arg; \
va_start(arg, format); \
vsnprintf(charbuffer, SIZE, format, arg); \
va_end(arg); \
outputbuffer << tmpbuffer.str() << charbuffer << std::endl; \
} while (0)
namespace dynamicgraph {
namespace sot {
class SOT_CORE_EXPORT DebugTrace {
public:
static const int SIZE = 512;
std::stringstream tmpbuffer;
std::ostream &outputbuffer;
char charbuffer[SIZE + 1];
int traceLevel;
int traceLevelTemplate;
DebugTrace(std::ostream &os) : outputbuffer(os) {}
inline void trace(const int level, const char *format, ...) {
if (level <= traceLevel) SOT_COMMON_TRACES;
tmpbuffer.str("");
}
inline void trace(const char *format, ...) {
SOT_COMMON_TRACES;
tmpbuffer.str("");
}
inline void trace(const int level = -1) {
if (level <= traceLevel) outputbuffer << tmpbuffer.str();
tmpbuffer.str("");
}
inline void traceTemplate(const int level, const char *format, ...) {
if (level <= traceLevelTemplate) SOT_COMMON_TRACES;
tmpbuffer.str("");
}
inline void traceTemplate(const char *format, ...) {
SOT_COMMON_TRACES;
tmpbuffer.str("");
}
inline DebugTrace &pre(const std::ostream &) { return *this; }
inline DebugTrace &pre(const std::ostream &, int level) {
traceLevel = level;
return *this;
}
static const char *DEBUG_FILENAME_DEFAULT;
static void openFile(const char *filename = DEBUG_FILENAME_DEFAULT);
static void closeFile(const char *filename = DEBUG_FILENAME_DEFAULT);
};
SOT_CORE_EXPORT extern DebugTrace sotDEBUGFLOW;
SOT_CORE_EXPORT extern DebugTrace sotERRORFLOW;
} // namespace sot
} // namespace dynamicgraph
#ifdef VP_DEBUG
#define sotPREDEBUG \
__FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define sotPREERROR \
"\t!! " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define sotDEBUG(level) \
if ((level > VP_DEBUG_MODE) || \
(!dynamicgraph::sot::sotDEBUGFLOW.outputbuffer.good())) \
; \
else \
dynamicgraph::sot::sotDEBUGFLOW.outputbuffer << sotPREDEBUG
#define sotDEBUGMUTE(level) \
if ((level > VP_DEBUG_MODE) || \
(!dynamicgraph::sot::sotDEBUGFLOW.outputbuffer.good())) \
; \
else \
dynamicgraph::sot::sotDEBUGFLOW.outputbuffer
#define sotERROR \
if (!dynamicgraph::sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else \
dynamicgraph::sot::sotERRORFLOW.outputbuffer << sotPREERROR
#define sotDEBUGF \
if (!dynamicgraph::sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else \
dynamicgraph::sot::sotDEBUGFLOW \
.pre(dynamicgraph::sot::sotDEBUGFLOW.tmpbuffer << sotPREDEBUG, \
VP_DEBUG_MODE) \
.trace
#define sotERRORF \
if (!dynamicgraph::sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else \
sot::sotERRORFLOW.pre(sot::sotERRORFLOW.tmpbuffer << sotPREERROR).trace
// TEMPLATE
#define sotTDEBUG(level) \
if ((level > VP_TEMPLATE_DEBUG_MODE) || \
(!dynamicgraph::sot::sotDEBUGFLOW.outputbuffer.good())) \
; \
else \
dynamicgraph::sot::sotDEBUGFLOW.outputbuffer << sotPREDEBUG
#define sotTDEBUGF \
if (!dynamicgraph::sot::sotDEBUGFLOW.outputbuffer.good()) \
; \
else \
dynamicgraph::sot::sotDEBUGFLOW \
.pre(dynamicgraph::sot::sotDEBUGFLOW.tmpbuffer << sotPREDEBUG, \
VP_TEMPLATE_DEBUG_MODE) \
.trace
namespace dynamicgraph {
namespace sot {
inline bool sotDEBUG_ENABLE(const int &level) { return level <= VP_DEBUG_MODE; }
inline bool sotTDEBUG_ENABLE(const int &level) {
return level <= VP_TEMPLATE_DEBUG_MODE;
}
} // namespace sot
} // namespace dynamicgraph
/* -------------------------------------------------------------------------- */
#else // VP_DEBUG
#define sotPREERROR \
"\t!! " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") :"
#define sotDEBUG(level) \
if (1) \
; \
else \
::dynamicgraph::sot::__null_stream()
#define sotDEBUGMUTE(level) \
if (1) \
; \
else \
::dynamicgraph::sot::__null_stream()
#define sotERROR sotERRORFLOW.outputbuffer << sotPREERROR
namespace dynamicgraph {
namespace sot {
inline void sotDEBUGF(const int, const char *, ...) {}
inline void sotDEBUGF(const char *, ...) {}
inline void sotERRORF(const int, const char *, ...) {}
inline void sotERRORF(const char *, ...) {}
inline std::ostream &__null_stream() {
// This function should never be called. With -O3,
// it should not appear in the generated binary.
static std::ostream os(NULL);
return os;
}
} // namespace sot
} // namespace dynamicgraph
// TEMPLATE
#define sotTDEBUG(level) \
if (1) \
; \
else \
::dynamicgraph::sot::__null_stream()
namespace dynamicgraph {
namespace sot {
inline void sotTDEBUGF(const int, const char *, ...) {}
inline void sotTDEBUGF(const char *, ...) {}
} // namespace sot
} // namespace dynamicgraph
#define sotDEBUG_ENABLE(level) false
#define sotTDEBUG_ENABLE(level) false
#endif // VP_DEBUG
#define sotDEBUGIN(level) sotDEBUG(level) << "# In {" << std::endl
#define sotDEBUGOUT(level) sotDEBUG(level) << "# Out }" << std::endl
#define sotDEBUGINOUT(level) sotDEBUG(level) << "# In/Out { }" << std::endl
#define sotTDEBUGIN(level) sotTDEBUG(level) << "# In {" << std::endl
#define sotTDEBUGOUT(level) sotTDEBUG(level) << "# Out }" << std::endl
#define sotTDEBUGINOUT(level) sotTDEBUG(level) << "# In/Out { }" << std::endl
#endif //! #ifdef SOT_CORE_DEBUG_HH
// Local variables:
// c-basic-offset: 2
// End:
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef __SOT_DERIVATOR_IMPL_H__
#define __SOT_DERIVATOR_IMPL_H__
#include <sot/core/derivator.hh>
#include <sot/core/matrix-geometry.hh>
/* --------------------------------------------------------------------- */
/* --- API ------------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#if defined(WIN32)
#if defined(derivator_EXPORTS)
#define DERIVATOR_EXPORT __declspec(dllexport)
#else
#define DERIVATOR_EXPORT __declspec(dllimport)
#endif
#else
#define DERIVATOR_EXPORT
#endif
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
#ifdef WIN32
#define DECLARE_SPECIFICATION(className, sotSigType) \
class DERIVATOR_EXPORT className : public Derivator<sotSigType> { \
public: \
className(const std::string &name); \
};
#else
#define DECLARE_SPECIFICATION(className, sotSigType) \
typedef Derivator<sotSigType> className;
#endif
DECLARE_SPECIFICATION(DerivatorDouble, double)
DECLARE_SPECIFICATION(DerivatorVector, dynamicgraph::Vector)
DECLARE_SPECIFICATION(DerivatorMatrix, dynamicgraph::Matrix)
DECLARE_SPECIFICATION(DerivatorVectorQuaternion, VectorQuaternion)
} /* namespace sot */
} /* namespace dynamicgraph */
#endif // #ifndef __SOT_DERIVATOR_H__
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
*/
#ifndef __SOT_DERIVATOR_H__
#define __SOT_DERIVATOR_H__
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Matrix */
#include <dynamic-graph/linear-algebra.h>
/* SOT */
#include <dynamic-graph/all-signals.h>
#include <dynamic-graph/entity.h>
#include <sot/core/flags.hh>
#include <sot/core/matrix-geometry.hh>
#include <sot/core/pool.hh>
/* STD */
#include <string>
namespace dynamicgraph {
namespace sot {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
template <class T>
class Derivator : public dynamicgraph::Entity {
DYNAMIC_GRAPH_ENTITY_DECL();
protected:
T memory;
bool initialized;
double timestep;
static const double TIMESTEP_DEFAULT; //= 1.;
public: /* --- CONSTRUCTION --- */
static std::string getTypeName(void) { return "Unknown"; }
Derivator(const std::string &name)
: dynamicgraph::Entity(name),
memory(),
initialized(false),
timestep(TIMESTEP_DEFAULT),
SIN(NULL, "sotDerivator<" + getTypeName() + ">(" + name + ")::input(" +
getTypeName() + ")::sin"),
SOUT(boost::bind(&Derivator<T>::computeDerivation, this, _1, _2), SIN,
"sotDerivator<" + getTypeName() + ">(" + name + ")::output(" +
getTypeName() + ")::sout"),
timestepSIN("sotDerivator<" + getTypeName() + ">(" + name +
")::input(double)::dt") {
signalRegistration(SIN << SOUT << timestepSIN);
timestepSIN.setReferenceNonConstant(&timestep);
timestepSIN.setKeepReference(true);
}
virtual ~Derivator(void){};
public: /* --- SIGNAL --- */
dynamicgraph::SignalPtr<T, int> SIN;
dynamicgraph::SignalTimeDependent<T, int> SOUT;
dynamicgraph::Signal<double, int> timestepSIN;
protected:
T &computeDerivation(T &res, int time) {
if (initialized) {
res = memory;
res *= -1;
memory = SIN(time);
res += memory;
if (timestep != 1.) res *= (1. / timestep);
} else {
initialized = true;
memory = SIN(time);
res = memory;
res *= 0;
}
return res;
}
};
// TODO Derivation of unit quaternion?
template <>
VectorQuaternion &Derivator<VectorQuaternion>::computeDerivation(
VectorQuaternion &res, int time) {
if (initialized) {
res = memory;
res.coeffs() *= -1;
memory = SIN(time);
res.coeffs() += memory.coeffs();
if (timestep != 1.) res.coeffs() *= (1. / timestep);
} else {
initialized = true;
memory = SIN(time);
res = memory;
res.coeffs() *= 0;
}
return res;
}
} /* namespace sot */
} /* namespace dynamicgraph */
#endif // #ifndef __SOT_DERIVATOR_H__
/*
* Copyright 2010,
* Florent Lamiraux
*
* CNRS
*
*/
#ifndef SOT_DEVICE_HH
#define SOT_DEVICE_HH
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <pinocchio/fwd.hpp>
/* -- MaaL --- */
#include <dynamic-graph/linear-algebra.h>
/* SOT */
#include <dynamic-graph/all-signals.h>
#include <dynamic-graph/entity.h>
#include <sot/core/matrix-geometry.hh>
#include "sot/core/api.hh"
#include "sot/core/periodic-call.hh"
namespace dynamicgraph {
namespace sot {
/// Define the type of input expected by the robot
enum ControlInput {
CONTROL_INPUT_NO_INTEGRATION = 0,
CONTROL_INPUT_ONE_INTEGRATION = 1,
CONTROL_INPUT_TWO_INTEGRATION = 2,
CONTROL_INPUT_SIZE = 3
};
const std::string ControlInput_s[] = {"noInteg", "oneInteg", "twoInteg"};
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
class SOT_CORE_EXPORT Device : public Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName(void) const { return CLASS_NAME; }
enum ForceSignalSource {
FORCE_SIGNAL_RLEG,
FORCE_SIGNAL_LLEG,
FORCE_SIGNAL_RARM,
FORCE_SIGNAL_LARM
};
protected:
dynamicgraph::Vector state_;
dynamicgraph::Vector velocity_;
bool sanityCheck_;
dynamicgraph::Vector vel_control_;
ControlInput controlInputType_;
bool withForceSignals[4];
PeriodicCall periodicCallBefore_;
PeriodicCall periodicCallAfter_;
double timestep_;
/// \name Robot bounds used for sanity checks
/// \{
Vector upperPosition_;
Vector upperVelocity_;
Vector upperTorque_;
Vector lowerPosition_;
Vector lowerVelocity_;
Vector lowerTorque_;
/// \}
public:
/* --- CONSTRUCTION --- */
Device(const std::string &name);
/* --- DESTRUCTION --- */
virtual ~Device();
virtual void setStateSize(const unsigned int &size);
virtual void setState(const dynamicgraph::Vector &st);
void setVelocitySize(const unsigned int &size);
virtual void setVelocity(const dynamicgraph::Vector &vel);
virtual void setSecondOrderIntegration();
virtual void setNoIntegration();
virtual void setControlInputType(const std::string &cit);
virtual void increment(const double &dt = 5e-2);
/// \name Sanity check parameterization
/// \{
void setSanityCheck(const bool &enableCheck);
void setPositionBounds(const Vector &lower, const Vector &upper);
void setVelocityBounds(const Vector &lower, const Vector &upper);
void setTorqueBounds(const Vector &lower, const Vector &upper);
/// \}
PeriodicCall &periodicCallBefore() { return periodicCallBefore_; }
PeriodicCall &periodicCallAfter() { return periodicCallAfter_; }
public: /* --- DISPLAY --- */
virtual void display(std::ostream &os) const;
virtual void cmdDisplay();
SOT_CORE_EXPORT friend std::ostream &operator<<(std::ostream &os,
const Device &r) {
r.display(os);
return os;
}
public: /* --- SIGNALS --- */
dynamicgraph::SignalPtr<dynamicgraph::Vector, int> controlSIN;
dynamicgraph::SignalPtr<dynamicgraph::Vector, int> attitudeSIN;
dynamicgraph::SignalPtr<dynamicgraph::Vector, int> zmpSIN;
/// \name Device current state.
/// \{
dynamicgraph::Signal<dynamicgraph::Vector, int> stateSOUT;
dynamicgraph::Signal<dynamicgraph::Vector, int> velocitySOUT;
dynamicgraph::Signal<MatrixRotation, int> attitudeSOUT;
/*! \brief The current state of the robot from the command viewpoint. */
dynamicgraph::Signal<dynamicgraph::Vector, int> motorcontrolSOUT;
dynamicgraph::Signal<dynamicgraph::Vector, int> previousControlSOUT;
/*! \brief The ZMP reference send by the previous controller. */
dynamicgraph::Signal<dynamicgraph::Vector, int> ZMPPreviousControllerSOUT;
/// \}
/// \name Real robot current state
/// This corresponds to the real encoders values and take into
/// account the stabilization step. Therefore, this usually
/// does *not* match the state control input signal.
/// \{
/// Motor positions
dynamicgraph::Signal<dynamicgraph::Vector, int> robotState_;
/// Motor velocities
dynamicgraph::Signal<dynamicgraph::Vector, int> robotVelocity_;
/// The force torque sensors
dynamicgraph::Signal<dynamicgraph::Vector, int> *forcesSOUT[4];
/// Motor torques
/// \todo why pseudo ?
dynamicgraph::Signal<dynamicgraph::Vector, int> pseudoTorqueSOUT;
/// \}
protected:
/// Compute roll pitch yaw angles of freeflyer joint.
void integrateRollPitchYaw(dynamicgraph::Vector &state,
const dynamicgraph::Vector &control, double dt);
/// Store Position of free flyer joint
MatrixHomogeneous ffPose_;
/// Compute the new position, from the current control.
///
/// When sanity checks are enabled, this checks that the control is within
/// bounds. There are three cases, depending on what the control is:
/// - position: checks that the position is within bounds,
/// - velocity: checks that the velocity and the future position are
/// within bounds,
/// - acceleration: checks that the acceleration, the future velocity and
/// position are within bounds.
/// \todo in order to check the acceleration, we need
/// pinocchio and the contact forces in order to estimate
/// the joint torques for the given acceleration.
virtual void integrate(const double &dt);
protected:
/// Get freeflyer pose
const MatrixHomogeneous &freeFlyerPose() const;
public:
virtual void setRoot(const dynamicgraph::Matrix &root);
virtual void setRoot(const MatrixHomogeneous &worldMwaist);
private:
// Intermediate variable to avoid dynamic allocation
dynamicgraph::Vector forceZero6;
};
} // namespace sot
} // namespace dynamicgraph
#endif /* #ifndef SOT_DEVICE_HH */
/*
* Copyright 2019,
* Joseph Mirabel
*
* LAAS-CNRS
*
*/
#ifndef DYNAMICGRAPH_SOT_DOUBLE_CONSTANT_H
#define DYNAMICGRAPH_SOT_DOUBLE_CONSTANT_H
#include <dynamic-graph/entity.h>
#include <dynamic-graph/signal-time-dependent.h>
namespace dynamicgraph {
namespace sot {
class DoubleConstant : public Entity {
public:
static const std::string CLASS_NAME;
virtual const std::string &getClassName(void) const { return CLASS_NAME; }
DoubleConstant(const std::string &name);
virtual ~DoubleConstant(void) {}
SignalTimeDependent<double, int> SOUT;
/// \brief Set value of vector (and therefore of output signal)
void setValue(const double &inValue);
};
} // namespace sot
} // namespace dynamicgraph
#endif // DYNAMICGRAPH_SOT_DOUBLE_CONSTANT_H
// Copyright (c) 2018, Joseph Mirabel
// Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
#ifndef __SOT_EVENT_H__
#define __SOT_EVENT_H__
#include <dynamic-graph/command-bind.h>
#include <dynamic-graph/command-getter.h>
#include <dynamic-graph/command-setter.h>
#include <dynamic-graph/entity.h>
#include <dynamic-graph/pool.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <dynamic-graph/signal.h>
#include <sot/core/config.hh>
namespace dynamicgraph {
namespace sot {
/// Event
///
/// This entity detects changes in value of an input boolean signal
///
/// Input signal is
/// - condition (boolean),
/// Output signal is
/// - check
/// output value is true if value of input signal changes with respect to the
/// evaluation.
///
/// Method addSignal stores signals that are recomputed each time the output
/// signal is recomputed and the value is true. One typical use case of this
/// feature consists in plugging the output signal to a ROS topic using
/// dynamicgraph::RosPublish entity (see dynamic_graph_bridge) and to call
/// addSignal with the trigger signal of the RosPublish entity as the input.
/// Thus each time the output signal changes value, the new value is published
/// to the ROS topic.
///
/// If command setOnlyUp is called with true as input, signals are recomputed
/// only if the output value switches from false to true.
class SOT_CORE_DLLAPI Event : public dynamicgraph::Entity {
DYNAMIC_GRAPH_ENTITY_DECL();
Event(const std::string &name)
: Entity(name),
checkSOUT("Event(" + name + ")::output(bool)::check"),
conditionSIN(NULL, "Event(" + name + ")::input(bool)::condition"),
lastVal_(2), // lastVal_ should be different true and false.
timeSinceUp_(0),
repeatAfterNIterations_(0) {
checkSOUT.setFunction(boost::bind(&Event::check, this, _1, _2));
signalRegistration(conditionSIN);
signalRegistration(checkSOUT);
using command::makeCommandVoid1;
std::string docstring =
"\n"
" Add a signal\n";
addCommand("addSignal",
makeCommandVoid1(*this, &Event::addSignal, docstring));
docstring =
"\n"
" Get list of signals\n";
addCommand("list", new command::Getter<Event, std::string>(
*this, &Event::getSignalsByName, docstring));
docstring =
"\n"
" Repease event if input signal remains True for a while\n"
" Input: number of iterations before repeating output\n."
" 0 for no repetition";
addCommand("repeat", new command::Setter<Event, int>(*this, &Event::repeat,
docstring));
}
~Event() {}
/// Header documentation of the python class
virtual std::string getDocString() const {
return "Send an event when the input changes\n\n"
" The signal triggered is called whenever the condition is "
"satisfied.\n";
}
void addSignal(const std::string &signal) {
std::istringstream iss(signal);
triggers.push_back(&PoolStorage::getInstance()->getSignal(iss));
}
// Returns the Python string representation of the list of signal names.
std::string getSignalsByName() const {
std::ostringstream oss;
oss << "(";
for (Triggers_t::const_iterator _sig = triggers.begin();
_sig != triggers.end(); ++_sig)
oss << '\'' << (*_sig)->getName() << "\', ";
oss << ")";
return oss.str();
}
void repeat(const int &nbIterations) {
repeatAfterNIterations_ = nbIterations;
}
private:
typedef SignalBase<int> *Trigger_t;
typedef std::vector<Trigger_t> Triggers_t;
bool &check(bool &ret, const int &time);
Signal<bool, int> checkSOUT;
Triggers_t triggers;
SignalPtr<bool, int> conditionSIN;
bool lastVal_;
int timeSinceUp_, repeatAfterNIterations_;
};
} // namespace sot
} // namespace dynamicgraph
#endif // __SOT_EVENT_H__
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: exception-abstract.h
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_ABSTRACT_EXCEPTION_H
#define __SOT_ABSTRACT_EXCEPTION_H
......@@ -25,44 +14,43 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
/* Classes standards. */
#include <iostream> /* Classe ostream. */
#include <string> /* Classe string. */
#include <sot-core/sot-core-api.h>
#include <exception>
#include <ostream> /* Classe ostream. */
#include <string> /* Classe string. */
#include "sot/core/api.hh"
// Uncomment this macros to have lines parameter on the throw display
// #define SOT_EXCEPTION_PASSING_PARAM
// #define SOT_EXCEPTION_PASSING_PARAM
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
/* \class ExceptionAbstract
*/
class SOT_CORE_EXPORT ExceptionAbstract
{
class SOT_CORE_EXPORT ExceptionAbstract : public std::exception {
public:
enum ExceptionEnum
{
ABSTRACT = 0
,SIGNAL = 100
,TASK = 200
,FEATURE = 300
,FACTORY = 400
,DYNAMIC = 500
,TRACES = 600
,TOOLS = 700
,PATTERN_GENERATOR= 800
};
enum ExceptionEnum {
ABSTRACT = 0,
SIGNAL = 100,
TASK = 200,
FEATURE = 300,
FACTORY = 400,
DYNAMIC = 500,
TRACES = 600,
TOOLS = 700,
PATTERN_GENERATOR = 800
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return EXCEPTION_NAME; }
virtual const std::string &getExceptionName(void) const {
return EXCEPTION_NAME;
}
protected:
/** Error code.
......@@ -72,74 +60,77 @@ class SOT_CORE_EXPORT ExceptionAbstract
/** Error message (can be empty). */
std::string message;
private:
private:
/** forbid the empty constructor (private). */
ExceptionAbstract( void );
public:
ExceptionAbstract(void);
ExceptionAbstract( const int& code, const std::string & msg = "" );
virtual ~ExceptionAbstract( void ){}
public:
ExceptionAbstract(const int &code, const std::string &msg = "");
virtual ~ExceptionAbstract(void) throw() {}
/** Access to the error code. */
int getCode (void);
int getCode(void);
/** Reference access to the error message (can be empty). */
const std::string &getStringMessage (void);
const std::string &getStringMessage(void);
/** Access to the pointer on the array of \e char related to the error string.
* Cannot be \e NULL.
/** Access to the pointer on the array of \e char related to the error
* string. Cannot be \e NULL.
*/
const char *getMessage (void);
const char *getMessage(void);
const char *what() const throw();
/** Print the error structure. */
SOT_CORE_EXPORT friend std::ostream & operator << (std::ostream & os,
const sot::ExceptionAbstract & err);
SOT_CORE_EXPORT friend std::ostream &operator<<(std::ostream &os,
const ExceptionAbstract &err);
#ifdef SOT_EXCEPTION_PASSING_PARAM
#ifdef SOT_EXCEPTION_PASSING_PARAM
public:
class Param
{
public:
static const int BUFFER_SIZE = 80;
const char * functionPTR;
char function[ BUFFER_SIZE ];
int line;
const char * filePTR;
char file[ BUFFER_SIZE ];
bool pointersSet,set;
public:
Param( const int& _line, const char * _function, const char * _file );
Param( void ) : pointersSet(false),set(false) {}
Param& initCopy( const Param& p );
};
class Param {
public:
static const int BUFFER_SIZE = 80;
const char *functionPTR;
char function[BUFFER_SIZE];
int line;
const char *filePTR;
char file[BUFFER_SIZE];
bool pointersSet, set;
public:
Param(const int &_line, const char *_function, const char *_file);
Param(void) : pointersSet(false), set(false) {}
Param &initCopy(const Param &p);
};
protected:
mutable Param p;
template<class Exc>
friend const Exc& operator+ ( const ExceptionAbstract::Param& p, const Exc& e )
{ e.p.initCopy(p); return e; }
template<class Exc>
friend Exc& operator+ ( const ExceptionAbstract::Param& p, Exc& e )
{ e.p.initCopy(p); return e; }
#endif //#ifdef SOT_EXCEPTION_PASSING_PARAM
template <class Exc>
friend const Exc &operator+(const ExceptionAbstract::Param &p, const Exc &e) {
e.p.initCopy(p);
return e;
}
template <class Exc>
friend Exc &operator+(const ExceptionAbstract::Param &p, Exc &e) {
e.p.initCopy(p);
return e;
}
#endif //#ifdef SOT_EXCEPTION_PASSING_PARAM
};
#define SOT_RETHROW ( const ExceptionAbstract& err ) { throw err; }
#define SOT_RETHROW \
(const ExceptionAbstract &err) { throw err; }
#ifdef SOT_EXCEPTION_PASSING_PARAM
# define SOT_THROW throw ExceptionAbstract::Param(__LINE__,__FUNCTION__,__FILE__) +
#else //#ifdef SOT_EXCEPTION_PASSING_PARAM
# define SOT_THROW throw
#endif //#ifdef SOT_EXCEPTION_PASSING_PARAM
#ifdef SOT_EXCEPTION_PASSING_PARAM
#define SOT_THROW \
throw ExceptionAbstract::Param(__LINE__, __FUNCTION__, __FILE__) +
#else //#ifdef SOT_EXCEPTION_PASSING_PARAM
#define SOT_THROW throw
#endif //#ifdef SOT_EXCEPTION_PASSING_PARAM
} // namespace sot
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_ABSTRACT_EXCEPTION_H */
......
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: exception-dynamic.h
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_DYNAMIC_EXCEPTION_H
#define __SOT_DYNAMIC_EXCEPTION_H
......@@ -25,50 +14,48 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <sot/core/exception-abstract.hh>
#include <sot-core/exception-abstract.h>
#include <sot-core/sot-core-api.h>
#include "sot/core/api.hh"
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
/* \class ExceptionDynamic
*/
class SOT_CORE_EXPORT ExceptionDynamic
:public ExceptionAbstract
class SOT_CORE_EXPORT ExceptionDynamic : public ExceptionAbstract
{
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::DYNAMIC
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::DYNAMIC
,CANT_DESTROY_SIGNAL
,JOINT_RANK
,DYNAMIC_JRL
,JOINT_SIZE
,INTEGRATION
};
,
CANT_DESTROY_SIGNAL,
JOINT_RANK,
DYNAMIC_JRL,
JOINT_SIZE,
INTEGRATION
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return EXCEPTION_NAME; }
public:
ExceptionDynamic ( const ExceptionDynamic::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionDynamic( const ExceptionDynamic::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
virtual ~ExceptionDynamic( void ){}
virtual const std::string &getExceptionName(void) const {
return EXCEPTION_NAME;
}
public:
ExceptionDynamic(const ExceptionDynamic::ErrorCodeEnum &errcode,
const std::string &msg = "");
ExceptionDynamic(const ExceptionDynamic::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionDynamic(void) throw() {}
};
} // namespace sot
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_DYNAMIC_EXCEPTION_H */
......
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: exception-factory.h
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_EXCEPTION_FACTORY_H
#define __SOT_EXCEPTION_FACTORY_H
......@@ -25,51 +14,51 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <sot/core/exception-abstract.hh>
#include <sot-core/exception-abstract.h>
#include <sot-core/sot-core-api.h>
#include "sot/core/api.hh"
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
/* \class ExceptionFactory
*/
class SOT_CORE_EXPORT ExceptionFactory
:public ExceptionAbstract
class SOT_CORE_EXPORT ExceptionFactory : public ExceptionAbstract
{
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::FACTORY
,UNREFERED_OBJECT
,UNREFERED_SIGNAL
,UNREFERED_FUNCTION
,DYNAMIC_LOADING
,SIGNAL_CONFLICT
,FUNCTION_CONFLICT
,OBJECT_CONFLICT
,SYNTAX_ERROR // j' aime bien FATAL_ERROR aussi faut que je la case qq part...
,READ_FILE
};
public:
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::FACTORY,
UNREFERED_OBJECT,
UNREFERED_SIGNAL,
UNREFERED_FUNCTION,
DYNAMIC_LOADING,
SIGNAL_CONFLICT,
FUNCTION_CONFLICT,
OBJECT_CONFLICT,
SYNTAX_ERROR // j' aime bien FATAL_ERROR aussi faut que je la case qq
// part...
,
READ_FILE
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void )const{ return ExceptionFactory::EXCEPTION_NAME; }
ExceptionFactory ( const ExceptionFactory::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionFactory ( const ExceptionFactory::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
virtual ~ExceptionFactory( void ){}
virtual const std::string &getExceptionName(void) const {
return ExceptionFactory::EXCEPTION_NAME;
}
ExceptionFactory(const ExceptionFactory::ErrorCodeEnum &errcode,
const std::string &msg = "");
ExceptionFactory(const ExceptionFactory::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionFactory(void) throw() {}
};
} // namespace sot
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_EXCEPTION_FACTORY_H */
......
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: exception-feature.h
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_EXCEPTION_FEATURE_H
#define __SOT_EXCEPTION_FEATURE_H
......@@ -25,45 +14,44 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <sot/core/exception-abstract.hh>
#include <sot-core/exception-abstract.h>
#include <sot-core/sot-core-api.h>
#include "sot/core/api.hh"
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
/* \class ExceptionFeature
*/
class SOT_CORE_EXPORT ExceptionFeature
:public ExceptionAbstract
class SOT_CORE_EXPORT ExceptionFeature : public ExceptionAbstract
{
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::FEATURE
,BAD_INIT
,UNCOMPATIBLE_SIZE
};
public:
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::FEATURE,
BAD_INIT,
UNCOMPATIBLE_SIZE
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return ExceptionFeature::EXCEPTION_NAME; }
virtual const std::string &getExceptionName(void) const {
return ExceptionFeature::EXCEPTION_NAME;
}
ExceptionFeature ( const ExceptionFeature::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionFeature(const ExceptionFeature::ErrorCodeEnum &errcode,
const std::string &msg = "");
ExceptionFeature ( const ExceptionFeature::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
ExceptionFeature(const ExceptionFeature::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionFeature( void ){}
virtual ~ExceptionFeature(void) throw() {}
};
} // namespace sot
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_EXCEPTION_FEATURE_H */
......
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: exception-signal.h
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_SIGNAL_EXCEPTION_H
#define __SOT_SIGNAL_EXCEPTION_H
......@@ -25,51 +14,49 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <sot/core/exception-abstract.hh>
#include <sot-core/exception-abstract.h>
#include <sot-core/sot-core-api.h>
#include "sot/core/api.hh"
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
/* \class ExceptionSignal
*/
class SOT_CORE_EXPORT ExceptionSignal
:public ExceptionAbstract
class SOT_CORE_EXPORT ExceptionSignal : public ExceptionAbstract
{
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::SIGNAL
,READWRITE_LOCK
,COPY_NOT_INITIALIZED
,NOT_INITIALIZED
,PLUG_IMPOSSIBLE
,SET_IMPOSSIBLE
,BAD_CAST
};
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::SIGNAL
,
READWRITE_LOCK,
COPY_NOT_INITIALIZED,
NOT_INITIALIZED,
PLUG_IMPOSSIBLE,
SET_IMPOSSIBLE,
BAD_CAST
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return EXCEPTION_NAME; }
public:
ExceptionSignal ( const ExceptionSignal::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionSignal( const ExceptionSignal::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
virtual ~ExceptionSignal( void ){}
virtual const std::string &getExceptionName(void) const {
return EXCEPTION_NAME;
}
public:
ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode,
const std::string &msg = "");
ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionSignal(void) throw() {}
};
} // namespace sot
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_SIGNAL_EXCEPTION_H */
......
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: exception-task.h
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_EXCEPTION_TASK_H
#define __SOT_EXCEPTION_TASK_H
......@@ -25,47 +14,45 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <sot/core/exception-abstract.hh>
#include <sot-core/exception-abstract.h>
#include <sot-core/sot-core-api.h>
#include "sot/core/api.hh"
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
/* \class ExceptionTask
*/
class SOT_CORE_EXPORT ExceptionTask
:public ExceptionAbstract
class SOT_CORE_EXPORT ExceptionTask : public ExceptionAbstract
{
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::TASK
,EMPTY_LIST
,NON_ADEQUATE_FEATURES
,MATRIX_SIZE
,BOUND_TYPE
,PARSER_MULTI_BOUND
};
public:
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::TASK,
EMPTY_LIST,
NON_ADEQUATE_FEATURES,
MATRIX_SIZE,
BOUND_TYPE,
PARSER_MULTI_BOUND
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return EXCEPTION_NAME; }
ExceptionTask ( const ExceptionTask::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionTask( const ExceptionTask::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
virtual ~ExceptionTask( void ){}
virtual const std::string &getExceptionName(void) const {
return EXCEPTION_NAME;
}
ExceptionTask(const ExceptionTask::ErrorCodeEnum &errcode,
const std::string &msg = "");
ExceptionTask(const ExceptionTask::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionTask(void) throw() {}
};
} // namespace sot
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_EXCEPTION_TASK_H */
......
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Copyright Projet JRL-Japan, 2007
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*
* File: exception-tools.h
* Project: SOT
* Author: Nicolas Mansard
*
* Version control
* ===============
*
* $Id$
*
* Description
* ============
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
*/
#ifndef __SOT_TOOLS_EXCEPTION_H
#define __SOT_TOOLS_EXCEPTION_H
......@@ -25,47 +14,44 @@
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <sot/core/exception-abstract.hh>
#include <sot-core/exception-abstract.h>
#include <sot-core/sot-core-api.h>
#include "sot/core/api.hh"
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
namespace dynamicgraph {
namespace sot {
/* \class ExceptionTools
*/
class SOT_CORE_EXPORT ExceptionTools
:public ExceptionAbstract
class SOT_CORE_EXPORT ExceptionTools : public ExceptionAbstract
{
public:
enum ErrorCodeEnum
{
GENERIC = ExceptionAbstract::TOOLS
enum ErrorCodeEnum {
GENERIC = ExceptionAbstract::TOOLS
,CORBA
,KALMAN_SIZE
};
,
CORBA,
KALMAN_SIZE,
PARAMETER_SERVER
};
static const std::string EXCEPTION_NAME;
virtual const std::string& getExceptionName( void ) const { return EXCEPTION_NAME; }
public:
ExceptionTools ( const ExceptionTools::ErrorCodeEnum& errcode,
const std::string & msg = "" );
ExceptionTools( const ExceptionTools::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... );
virtual ~ExceptionTools( void ){}
virtual const std::string &getExceptionName() const { return EXCEPTION_NAME; }
public:
ExceptionTools(const ExceptionTools::ErrorCodeEnum &errcode,
const std::string &msg = "");
ExceptionTools(const ExceptionTools::ErrorCodeEnum &errcode,
const std::string &msg, const char *format, ...);
virtual ~ExceptionTools(void) throw() {}
};
} // namespace sot
} // namespace sot
} // namespace dynamicgraph
#endif /* #ifndef __SOT_TOOLS_EXCEPTION_H */
......
/*
* Copyright 2018,
* Julian Viereck
*
* CNRS/AIST
*
*/
#ifndef __SOT_EXPMOVINGAVG_H__
#define __SOT_EXPMOVINGAVG_H__
/* --------------------------------------------------------------------- */
/* --- INCLUDE --------------------------------------------------------- */
/* --------------------------------------------------------------------- */
#include <dynamic-graph/entity.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <sot/core/config.hh>
namespace dynamicgraph {
namespace sot {
/* --------------------------------------------------------------------- */
/* --- TRACER ---------------------------------------------------------- */
/* --------------------------------------------------------------------- */
using dynamicgraph::Entity;
using dynamicgraph::SignalPtr;
using dynamicgraph::SignalTimeDependent;
class SOT_CORE_DLLAPI ExpMovingAvg : public Entity {
DYNAMIC_GRAPH_ENTITY_DECL();
public:
SignalPtr<dynamicgraph::Vector, int> updateSIN;
SignalTimeDependent<int, int> refresherSINTERN;
SignalTimeDependent<dynamicgraph::Vector, int> averageSOUT;
public:
ExpMovingAvg(const std::string &n);
virtual ~ExpMovingAvg(void);
void setAlpha(const double &alpha_);
protected:
dynamicgraph::Vector &update(dynamicgraph::Vector &res, const int &inTime);
dynamicgraph::Vector average;
double alpha;
bool init;
};
} /* namespace sot */
} /* namespace dynamicgraph */
#endif /* #ifndef __SOT_TRACER_H__ */