Commit 5921e17a authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

format

parent 96916aba
......@@ -97,8 +97,8 @@ public:
void setTorqueBounds(const Vector &lower, const Vector &upper);
/// \}
PeriodicCall& periodicCallBefore() { return periodicCallBefore_; }
PeriodicCall& periodicCallAfter() { return periodicCallAfter_; }
PeriodicCall &periodicCallBefore() { return periodicCallBefore_; }
PeriodicCall &periodicCallAfter() { return periodicCallAfter_; }
public: /* --- DISPLAY --- */
virtual void display(std::ostream &os) const;
......
......@@ -19,8 +19,8 @@
#include <vector>
/* SOT */
#include <dynamic-graph/signal-caster.h>
#include "sot/core/api.hh"
#include <dynamic-graph/signal-caster.h>
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
......
......@@ -90,21 +90,19 @@ public:
void popNumCoef() { numerator.pop_back(); }
void popDenomCoef() { denominator.pop_back(); }
const std::vector<coefT>& numCoeffs() const { return numerator; }
void numCoeffs(const std::vector<coefT>& coeffs) { numerator = coeffs; }
const std::vector<coefT> &numCoeffs() const { return numerator; }
void numCoeffs(const std::vector<coefT> &coeffs) { numerator = coeffs; }
const std::vector<coefT>& denomCoeffs() const { return denominator; }
void denomCoeffs(const std::vector<coefT>& coeffs) { denominator = coeffs; }
const std::vector<coefT> &denomCoeffs() const { return denominator; }
void denomCoeffs(const std::vector<coefT> &coeffs) { denominator = coeffs; }
public:
dynamicgraph::SignalPtr<sigT, int> SIN;
dynamicgraph::SignalTimeDependent<sigT, int> SOUT;
virtual void display(std::ostream &os) const
{
os << this->getClassName() << ": " << getName() << '\n'
<< " ";
virtual void display(std::ostream &os) const {
os << this->getClassName() << ": " << getName() << '\n' << " ";
if (numerator.empty() || denominator.empty()) {
os << "ill-formed.";
return;
......
......@@ -33,8 +33,7 @@ namespace sot {
namespace dg = dynamicgraph;
template <class Object> struct MailboxTimestampedObject
{
template <class Object> struct MailboxTimestampedObject {
Object obj;
struct timeval timestamp;
};
......@@ -73,10 +72,11 @@ public: /* --- SIGNALS --- */
} /* namespace sot */
template <class Object> struct signal_io<sot::MailboxTimestampedObject<Object> >
: signal_io_unimplemented<sot::MailboxTimestampedObject<Object> > {};
template <class Object>
struct signal_io<sot::MailboxTimestampedObject<Object> >
: signal_io_unimplemented<sot::MailboxTimestampedObject<Object> > {};
template <> struct signal_io<timeval> : signal_io_unimplemented<timeval > {};
template <> struct signal_io<timeval> : signal_io_unimplemented<timeval> {};
} /* namespace dynamicgraph */
#endif // #ifndef __SOT_MAILBOX_HH
......@@ -19,8 +19,8 @@
#include <vector>
/* SOT */
#include <dynamic-graph/signal-caster.h>
#include "sot/core/api.hh"
#include <dynamic-graph/signal-caster.h>
#include <sot/core/exception-task.hh>
/* --------------------------------------------------------------------- */
......@@ -73,7 +73,8 @@ SOT_CORE_EXPORT std::istream &operator>>(std::istream &os, VectorMultiBound &v);
} /* namespace sot */
template <> struct signal_io<sot::MultiBound> : signal_io_unimplemented<sot::MultiBound> {};
template <>
struct signal_io<sot::MultiBound> : signal_io_unimplemented<sot::MultiBound> {};
} /* namespace dynamicgraph */
#endif // #ifndef __SOT_MultiBound_H__
......@@ -195,7 +195,8 @@ public:
};
} // namespace sot
template <> struct signal_io<sot::Trajectory> : signal_io_unimplemented<sot::Trajectory> {};
template <>
struct signal_io<sot::Trajectory> : signal_io_unimplemented<sot::Trajectory> {};
} // namespace dynamicgraph
......
......@@ -108,8 +108,7 @@ public: /* --- SIGNAL --- */
int getSignalNumber() const { return (int)signalsIN.size(); }
signal_t* getSignalIn(int i)
{
signal_t *getSignalIn(int i) {
if (i < 0 || i >= (int)signalsIN.size())
throw std::out_of_range("Wrong signal index");
return signalsIN[i];
......
......@@ -40,7 +40,8 @@
namespace dynamicgraph {
namespace sot {
class SOTVECTORTOROTATION_EXPORT VectorToRotation : public dynamicgraph::Entity {
class SOTVECTORTOROTATION_EXPORT VectorToRotation
: public dynamicgraph::Entity {
enum sotAxis { AXIS_X, AXIS_Y, AXIS_Z };
unsigned int size;
......
#include <sot/core/admittance-control-op-point.hh>
typedef boost::mpl::vector<dynamicgraph::sot::core::AdmittanceControlOpPoint> entities_t;
typedef boost::mpl::vector<dynamicgraph::sot::core::AdmittanceControlOpPoint>
entities_t;
#include <sot/core/feature-point6d-relative.hh>
typedef boost::mpl::vector<dynamicgraph::sot::FeaturePoint6dRelative> entities_t;
typedef boost::mpl::vector<dynamicgraph::sot::FeaturePoint6dRelative>
entities_t;
......@@ -2,7 +2,6 @@
namespace dgs = dynamicgraph::sot;
typedef boost::mpl::vector<
dgs::FeaturePose<dgs::SE3Representation>
, dgs::FeaturePose<dgs::R3xSO3Representation>
> entities_t;
typedef boost::mpl::vector<dgs::FeaturePose<dgs::SE3Representation>,
dgs::FeaturePose<dgs::R3xSO3Representation> >
entities_t;
#include <sot/core/derivator.hh>
namespace dg = ::dynamicgraph;
typedef boost::mpl::vector<
dg::sot::Derivator<double>
, dg::sot::Derivator<dg::Vector>
, dg::sot::Derivator<dg::Matrix>
, dg::sot::Derivator<dg::sot::VectorQuaternion>
> entities_t;
typedef boost::mpl::vector<dg::sot::Derivator<double>,
dg::sot::Derivator<dg::Vector>,
dg::sot::Derivator<dg::Matrix>,
dg::sot::Derivator<dg::sot::VectorQuaternion> >
entities_t;
#include <sot/core/fir-filter.hh>
namespace dg = ::dynamicgraph;
typedef boost::mpl::vector<
dg::sot::FIRFilter<double, double>
, dg::sot::FIRFilter<dg::Vector, double>
, dg::sot::FIRFilter<dg::Vector, dg::Matrix>
> entities_t;
typedef boost::mpl::vector<dg::sot::FIRFilter<double, double>,
dg::sot::FIRFilter<dg::Vector, double>,
dg::sot::FIRFilter<dg::Vector, dg::Matrix> >
entities_t;
......@@ -10,28 +10,34 @@
namespace dg = dynamicgraph;
namespace dgc = dynamicgraph::command;
namespace dgs = dynamicgraph::sot;
using dg::Vector;
using dg::Matrix;
using dg::Vector;
template<typename S, typename C> void exposeIntegratorEuler()
{
template <typename S, typename C> void exposeIntegratorEuler() {
typedef dgs::IntegratorEuler<S, C> IE_t;
const std::string cName =
dgc::Value::typeName(dgc::ValueHelper<C>::TypeID);
const std::string cName = dgc::Value::typeName(dgc::ValueHelper<C>::TypeID);
dg::python::exposeEntity<IE_t>()
.add_property("numerators",
+[](const IE_t& e) { return dg::python::to_py_list(e.numCoeffs().begin(), e.numCoeffs().end()); },
+[](IE_t& e, bp::object iterable) { e.numCoeffs(dg::python::to_std_vector<C>(iterable)); })
.add_property("denominators",
+[](const IE_t& e) { return dg::python::to_py_list(e.denomCoeffs().begin(), e.denomCoeffs().end()); },
+[](IE_t& e, bp::object iterable) { e.denomCoeffs(dg::python::to_std_vector<C>(iterable)); })
;
.add_property("numerators",
+[](const IE_t &e) {
return dg::python::to_py_list(e.numCoeffs().begin(),
e.numCoeffs().end());
},
+[](IE_t &e, bp::object iterable) {
e.numCoeffs(dg::python::to_std_vector<C>(iterable));
})
.add_property("denominators",
+[](const IE_t &e) {
return dg::python::to_py_list(e.denomCoeffs().begin(),
e.denomCoeffs().end());
},
+[](IE_t &e, bp::object iterable) {
e.denomCoeffs(dg::python::to_std_vector<C>(iterable));
});
}
BOOST_PYTHON_MODULE(wrap)
{
BOOST_PYTHON_MODULE(wrap) {
bp::import("dynamic_graph");
exposeIntegratorEuler<double, double>();
......
......@@ -6,170 +6,157 @@ namespace dg = dynamicgraph;
namespace dgs = dynamicgraph::sot;
namespace bp = boost::python;
typedef bp::return_value_policy<bp::reference_existing_object> reference_existing_object;
typedef bp::return_value_policy<bp::reference_existing_object>
reference_existing_object;
template<typename Operator>
void exposeUnaryOp()
{
template <typename Operator> void exposeUnaryOp() {
typedef dgs::UnaryOp<Operator> O_t;
dg::python::exposeEntity<O_t, bp::bases<dg::Entity>, dg::python::AddCommands>()
dg::python::exposeEntity<O_t, bp::bases<dg::Entity>,
dg::python::AddCommands>()
.def_readonly("sin", &O_t::SIN)
.def_readonly("sout", &O_t::SOUT)
;
.def_readonly("sout", &O_t::SOUT);
}
template<typename Operator>
void exposeBinaryOp()
{
template <typename Operator> void exposeBinaryOp() {
typedef dgs::BinaryOp<Operator> O_t;
dg::python::exposeEntity<O_t, bp::bases<dg::Entity>, dg::python::AddCommands>()
dg::python::exposeEntity<O_t, bp::bases<dg::Entity>,
dg::python::AddCommands>()
.def_readonly("sin1", &O_t::SIN1)
.def_readonly("sin2", &O_t::SIN2)
.def_readonly("sout", &O_t::SOUT)
;
.def_readonly("sout", &O_t::SOUT);
}
template<typename Operator>
auto exposeVariadicOpBase()
{
template <typename Operator> auto exposeVariadicOpBase() {
typedef dgs::VariadicOp<Operator> O_t;
typedef typename O_t::Base B_t;
return
dg::python::exposeEntity<O_t, bp::bases<dg::Entity>, dg::python::AddCommands>()
return dg::python::exposeEntity<O_t, bp::bases<dg::Entity>,
dg::python::AddCommands>()
.def_readonly("sout", &O_t::SOUT)
.def("sin", &B_t::getSignalIn, reference_existing_object())
.add_property("n_sin", &B_t::getSignalNumber, &B_t::setSignalNumber,
"the number of input signal.")
"the number of input signal.")
.def("setSignalNumber", &B_t::setSignalNumber,
"set the number of input signal.", bp::arg("size"))
"set the number of input signal.", bp::arg("size"))
.def("getSignalNumber", &B_t::getSignalNumber,
"get the number of input signal.", bp::arg("size"))
;
"get the number of input signal.", bp::arg("size"));
}
template<typename Operator>
struct exposeVariadicOpImpl {
static void run () { exposeVariadicOpBase<Operator>(); }
template <typename Operator> struct exposeVariadicOpImpl {
static void run() { exposeVariadicOpBase<Operator>(); }
};
template<typename T>
struct exposeVariadicOpImpl<dgs::AdderVariadic<T> > {
static void run () {
template <typename T> struct exposeVariadicOpImpl<dgs::AdderVariadic<T> > {
static void run() {
typedef dgs::VariadicOp<dgs::AdderVariadic<T> > E_t;
exposeVariadicOpBase<dgs::AdderVariadic<T> >()
.add_property("coeffs", +[](E_t& e) { return e.op.coeffs; },
+[](E_t& e, const dg::Vector& c) { e.op.setCoeffs(c); },
"the multipliers.")
;
exposeVariadicOpBase<dgs::AdderVariadic<T> >().add_property(
"coeffs", +[](E_t &e) { return e.op.coeffs; },
+[](E_t &e, const dg::Vector &c) { e.op.setCoeffs(c); },
"the multipliers.");
}
};
template<typename Operator>
void exposeVariadicOp()
{
template <typename Operator> void exposeVariadicOp() {
exposeVariadicOpImpl<Operator>::run();
}
BOOST_PYTHON_MODULE(wrap)
{
BOOST_PYTHON_MODULE(wrap) {
using namespace dynamicgraph;
using namespace dynamicgraph::sot;
exposeUnaryOp < VectorSelecter> ();
exposeUnaryOp < VectorComponent> ();
exposeUnaryOp < MatrixSelector> ();
exposeUnaryOp < MatrixColumnSelector> ();
exposeUnaryOp < MatrixTranspose> ();
exposeUnaryOp < Diagonalizer> ();
/* ---------------------------------------------------------------------- */
/* --- INVERSION -------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
exposeUnaryOp < Inverser<Matrix> > ();
exposeUnaryOp < Inverser<MatrixHomogeneous> > ();
exposeUnaryOp < Inverser<MatrixTwist> > ();
exposeUnaryOp < Normalize> ();
exposeUnaryOp < InverserRotation> ();
exposeUnaryOp < InverserQuaternion> ();
/* ----------------------------------------------------------------------- */
/* --- SE3/SO3 conversions ----------------------------------------------- */
/* ----------------------------------------------------------------------- */
exposeUnaryOp < SkewSymToVector> ();
exposeUnaryOp < PoseUThetaToMatrixHomo> ();
exposeUnaryOp < MatrixHomoToPoseUTheta> ();
exposeUnaryOp < MatrixHomoToSE3Vector> ();
exposeUnaryOp < SE3VectorToMatrixHomo> ();
exposeUnaryOp < PoseQuaternionToMatrixHomo> ();
exposeUnaryOp < MatrixHomoToPoseQuaternion> ();
exposeUnaryOp < MatrixHomoToPoseRollPitchYaw> ();
exposeUnaryOp < PoseRollPitchYawToMatrixHomo> ();
exposeUnaryOp < PoseRollPitchYawToPoseUTheta> ();
exposeUnaryOp < HomoToMatrix> ();
exposeUnaryOp < MatrixToHomo> ();
exposeUnaryOp < HomoToTwist> ();
exposeUnaryOp < HomoToRotation> ();
exposeUnaryOp < MatrixHomoToPose> ();
exposeUnaryOp < RPYToMatrix> ();
exposeUnaryOp < MatrixToRPY> ();
exposeUnaryOp < RPYToQuaternion> ();
exposeUnaryOp < QuaternionToRPY> ();
exposeUnaryOp < QuaternionToMatrix> ();
exposeUnaryOp < MatrixToQuaternion> ();
exposeUnaryOp < MatrixToUTheta> ();
exposeUnaryOp < UThetaToQuaternion> ();
/* --- MULTIPLICATION --------------------------------------------------- */
exposeBinaryOp < Multiplier_double_vector > ();
exposeBinaryOp < Multiplier_matrix_vector > ();
exposeBinaryOp < Multiplier_matrixHomo_vector > ();
exposeBinaryOp < Multiplier_matrixTwist_vector > ();
/* --- SUBSTRACTION ----------------------------------------------------- */
exposeBinaryOp < Substraction<dynamicgraph::Matrix> > ();
exposeBinaryOp < Substraction<dynamicgraph::Vector> > ();
exposeBinaryOp < Substraction<double> > ();
/* --- STACK ------------------------------------------------------------ */
exposeBinaryOp < VectorStack > ();
/* ---------------------------------------------------------------------- */
exposeBinaryOp < Composer > ();
/* --- CONVOLUTION PRODUCT ---------------------------------------------- */
exposeBinaryOp < ConvolutionTemporal > ();
/* --- BOOLEAN REDUCTION ------------------------------------------------ */
exposeBinaryOp < Comparison<double> > ();
exposeBinaryOp < MatrixComparison<Vector> > ();
exposeBinaryOp < WeightedAdder<dynamicgraph::Matrix> > ();
exposeBinaryOp < WeightedAdder<dynamicgraph::Vector> > ();
exposeBinaryOp < WeightedAdder<double> > ();
/* --- VectorMix ------------------------------------------------------------ */
exposeVariadicOp < VectorMix > ();
/* --- ADDITION --------------------------------------------------------- */
exposeVariadicOp < AdderVariadic<Matrix> > ();
exposeVariadicOp < AdderVariadic<Vector> > ();
exposeVariadicOp < AdderVariadic<double> > ();
/* --- MULTIPLICATION --------------------------------------------------- */
exposeVariadicOp < Multiplier<Matrix> > ();
exposeVariadicOp < Multiplier<Vector> > ();
exposeVariadicOp < Multiplier<MatrixRotation> > ();
exposeVariadicOp < Multiplier<MatrixHomogeneous> > ();
exposeVariadicOp < Multiplier<MatrixTwist> > ();
exposeVariadicOp < Multiplier<VectorQuaternion> > ();
exposeVariadicOp < Multiplier<double> > ();
/* --- BOOLEAN --------------------------------------------------------- */
exposeVariadicOp < BoolOp<0> > ();
exposeVariadicOp < BoolOp<1> > ();
exposeUnaryOp<VectorSelecter>();
exposeUnaryOp<VectorComponent>();
exposeUnaryOp<MatrixSelector>();
exposeUnaryOp<MatrixColumnSelector>();
exposeUnaryOp<MatrixTranspose>();
exposeUnaryOp<Diagonalizer>();
/* ---------------------------------------------------------------------- */
/* --- INVERSION -------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
exposeUnaryOp<Inverser<Matrix> >();
exposeUnaryOp<Inverser<MatrixHomogeneous> >();
exposeUnaryOp<Inverser<MatrixTwist> >();
exposeUnaryOp<Normalize>();
exposeUnaryOp<InverserRotation>();
exposeUnaryOp<InverserQuaternion>();
/* ----------------------------------------------------------------------- */
/* --- SE3/SO3 conversions ----------------------------------------------- */
/* ----------------------------------------------------------------------- */
exposeUnaryOp<SkewSymToVector>();
exposeUnaryOp<PoseUThetaToMatrixHomo>();
exposeUnaryOp<MatrixHomoToPoseUTheta>();
exposeUnaryOp<MatrixHomoToSE3Vector>();
exposeUnaryOp<SE3VectorToMatrixHomo>();
exposeUnaryOp<PoseQuaternionToMatrixHomo>();
exposeUnaryOp<MatrixHomoToPoseQuaternion>();
exposeUnaryOp<MatrixHomoToPoseRollPitchYaw>();
exposeUnaryOp<PoseRollPitchYawToMatrixHomo>();
exposeUnaryOp<PoseRollPitchYawToPoseUTheta>();
exposeUnaryOp<HomoToMatrix>();
exposeUnaryOp<MatrixToHomo>();
exposeUnaryOp<HomoToTwist>();
exposeUnaryOp<HomoToRotation>();
exposeUnaryOp<MatrixHomoToPose>();
exposeUnaryOp<RPYToMatrix>();
exposeUnaryOp<MatrixToRPY>();
exposeUnaryOp<RPYToQuaternion>();
exposeUnaryOp<QuaternionToRPY>();
exposeUnaryOp<QuaternionToMatrix>();
exposeUnaryOp<MatrixToQuaternion>();
exposeUnaryOp<MatrixToUTheta>();
exposeUnaryOp<UThetaToQuaternion>();
/* --- MULTIPLICATION --------------------------------------------------- */
exposeBinaryOp<Multiplier_double_vector>();
exposeBinaryOp<Multiplier_matrix_vector>();
exposeBinaryOp<Multiplier_matrixHomo_vector>();
exposeBinaryOp<Multiplier_matrixTwist_vector>();
/* --- SUBSTRACTION ----------------------------------------------------- */
exposeBinaryOp<Substraction<dynamicgraph::Matrix> >();
exposeBinaryOp<Substraction<dynamicgraph::Vector> >();
exposeBinaryOp<Substraction<double> >();
/* --- STACK ------------------------------------------------------------ */
exposeBinaryOp<VectorStack>();
/* ---------------------------------------------------------------------- */
exposeBinaryOp<Composer>();
/* --- CONVOLUTION PRODUCT ---------------------------------------------- */
exposeBinaryOp<ConvolutionTemporal>();
/* --- BOOLEAN REDUCTION ------------------------------------------------ */
exposeBinaryOp<Comparison<double> >();
exposeBinaryOp<MatrixComparison<Vector> >();
exposeBinaryOp<WeightedAdder<dynamicgraph::Matrix> >();
exposeBinaryOp<WeightedAdder<dynamicgraph::Vector> >();
exposeBinaryOp<WeightedAdder<double> >();
/* --- VectorMix ------------------------------------------------------------
*/
exposeVariadicOp<VectorMix>();
/* --- ADDITION --------------------------------------------------------- */
exposeVariadicOp<AdderVariadic<Matrix> >();
exposeVariadicOp<AdderVariadic<Vector> >();
exposeVariadicOp<AdderVariadic<double> >();
/* --- MULTIPLICATION --------------------------------------------------- */
exposeVariadicOp<Multiplier<Matrix> >();
exposeVariadicOp<Multiplier<Vector> >();
exposeVariadicOp<Multiplier<MatrixRotation> >();
exposeVariadicOp<Multiplier<MatrixHomogeneous> >();
exposeVariadicOp<Multiplier<MatrixTwist> >();
exposeVariadicOp<Multiplier<VectorQuaternion> >();
exposeVariadicOp<Multiplier<double> >();
/* --- BOOLEAN --------------------------------------------------------- */
exposeVariadicOp<BoolOp<0> >();
exposeVariadicOp<BoolOp<1> >();
}
......@@ -89,7 +89,8 @@ struct VectorSelecter : public UnaryOpHeader<dg::Vector, dg::Vector> {
size += M - m;
}
inline void addSpecificCommands(Entity &ent, Entity::CommandMap_t &commandMap) {
inline void addSpecificCommands(Entity &ent,
Entity::CommandMap_t &commandMap) {
using namespace dynamicgraph::command;
std::string doc;
......@@ -117,7 +118,8 @@ struct VectorComponent : public UnaryOpHeader<dg::Vector, double> {
int index;
inline void setIndex(const int &m) { index = m; }
inline void addSpecificCommands(Entity &ent, Entity::CommandMap_t &commandMap) {
inline void addSpecificCommands(Entity &ent,
Entity::CommandMap_t &commandMap) {
std::string doc;
boost::function<void(const int &)> callback =
......@@ -158,7 +160,8 @@ public:
jmax = M;
}
inline void addSpecificCommands(Entity &ent, Entity::CommandMap_t &commandMap) {
inline void addSpecificCommands(Entity &ent,
Entity::CommandMap_t &commandMap) {
using namespace dynamicgraph::command;
std::string doc;
......@@ -196,7 +199,8 @@ public:
imax = M;
}
inline void addSpecificCommands(Entity &ent, Entity::CommandMap_t &commandMap) {
inline void addSpecificCommands(Entity &ent,
Entity::CommandMap_t &commandMap) {
using namespace dynamicgraph::command;
std::string doc;
......@@ -231,7 +235,8 @@ public:
nbr = r;
nbc = c;
}
inline void addSpecificCommands(Entity &ent, Entity::CommandMap_t &commandMap) {
inline void addSpecificCommands(Entity &ent,
Entity::CommandMap_t &commandMap) {
using namespace dynamicgraph::command;
std::string doc;
......@@ -255,7 +260,9 @@ struct Inverser : public UnaryOpHeader<matrixgen, matrixgen> {
};
struct Normalize : public UnaryOpHeader<dg::Vector, double> {
inline void operator()(const dg::Vector &m, double &res) const { res = m.norm(); }
inline void operator()(const dg::Vector &m, double &res) const {
res = m.norm();
}
inline std::string getDocString() const {
std::string docString("Computes the norm of a vector\n"
......@@ -412,7 +419,7 @@ struct HomoToMatrix : public UnaryOpHeader<MatrixHomogeneous, Matrix> {
struct MatrixToHomo : public UnaryOpHeader<Matrix, MatrixHomogeneous> {
inline void operator()(const Eigen::Matrix<double, 4, 4> &M,