From 5921e17ab3a8db2a98ae94d228283db924d2e140 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Fri, 13 Nov 2020 11:15:56 +0100 Subject: [PATCH] format --- include/sot/core/device.hh | 4 +- include/sot/core/flags.hh | 2 +- include/sot/core/integrator-abstract.hh | 14 +- include/sot/core/mailbox.hh | 10 +- include/sot/core/multi-bound.hh | 5 +- include/sot/core/trajectory.hh | 3 +- include/sot/core/variadic-op.hh | 3 +- include/sot/core/vector-to-rotation.hh | 3 +- .../admittance-control-op-point-python.h | 3 +- src/feature/feature-point6d-relative-python.h | 3 +- src/feature/feature-pose-python.h | 7 +- src/matrix/derivator-python.h | 11 +- src/matrix/fir-filter-python.h | 9 +- .../integrator-euler-python-module-py.cc | 34 ++- src/matrix/operator-python-module-py.cc | 255 +++++++++--------- src/matrix/operator.hh | 78 ++++-- src/python-module.cc | 136 +++++----- src/signal/signal-cast.cpp | 4 +- src/tools/joint-trajectory-entity-python.h | 3 +- src/tools/switch-python-module-py.cc | 27 +- src/tools/timer-python.h | 10 +- src/tools/type-name-helper.hh | 8 +- 22 files changed, 329 insertions(+), 303 deletions(-) diff --git a/include/sot/core/device.hh b/include/sot/core/device.hh index 0c9f1c562..eef2d4b8c 100644 --- a/include/sot/core/device.hh +++ b/include/sot/core/device.hh @@ -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; diff --git a/include/sot/core/flags.hh b/include/sot/core/flags.hh index e233969d4..2874f405c 100644 --- a/include/sot/core/flags.hh +++ b/include/sot/core/flags.hh @@ -19,8 +19,8 @@ #include /* SOT */ -#include #include "sot/core/api.hh" +#include /* --------------------------------------------------------------------- */ /* --- CLASS ----------------------------------------------------------- */ diff --git a/include/sot/core/integrator-abstract.hh b/include/sot/core/integrator-abstract.hh index 7af240312..332eacf70 100644 --- a/include/sot/core/integrator-abstract.hh +++ b/include/sot/core/integrator-abstract.hh @@ -90,21 +90,19 @@ public: void popNumCoef() { numerator.pop_back(); } void popDenomCoef() { denominator.pop_back(); } - const std::vector& numCoeffs() const { return numerator; } - void numCoeffs(const std::vector& coeffs) { numerator = coeffs; } + const std::vector &numCoeffs() const { return numerator; } + void numCoeffs(const std::vector &coeffs) { numerator = coeffs; } - const std::vector& denomCoeffs() const { return denominator; } - void denomCoeffs(const std::vector& coeffs) { denominator = coeffs; } + const std::vector &denomCoeffs() const { return denominator; } + void denomCoeffs(const std::vector &coeffs) { denominator = coeffs; } public: dynamicgraph::SignalPtr SIN; dynamicgraph::SignalTimeDependent 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; diff --git a/include/sot/core/mailbox.hh b/include/sot/core/mailbox.hh index 53600f5fe..af87346b2 100644 --- a/include/sot/core/mailbox.hh +++ b/include/sot/core/mailbox.hh @@ -33,8 +33,7 @@ namespace sot { namespace dg = dynamicgraph; -template struct MailboxTimestampedObject -{ +template struct MailboxTimestampedObject { Object obj; struct timeval timestamp; }; @@ -73,10 +72,11 @@ public: /* --- SIGNALS --- */ } /* namespace sot */ -template struct signal_io > -: signal_io_unimplemented > {}; +template +struct signal_io > + : signal_io_unimplemented > {}; -template <> struct signal_io : signal_io_unimplemented {}; +template <> struct signal_io : signal_io_unimplemented {}; } /* namespace dynamicgraph */ #endif // #ifndef __SOT_MAILBOX_HH diff --git a/include/sot/core/multi-bound.hh b/include/sot/core/multi-bound.hh index fd5ba3ac0..755758b7b 100644 --- a/include/sot/core/multi-bound.hh +++ b/include/sot/core/multi-bound.hh @@ -19,8 +19,8 @@ #include /* SOT */ -#include #include "sot/core/api.hh" +#include #include /* --------------------------------------------------------------------- */ @@ -73,7 +73,8 @@ SOT_CORE_EXPORT std::istream &operator>>(std::istream &os, VectorMultiBound &v); } /* namespace sot */ -template <> struct signal_io : signal_io_unimplemented {}; +template <> +struct signal_io : signal_io_unimplemented {}; } /* namespace dynamicgraph */ #endif // #ifndef __SOT_MultiBound_H__ diff --git a/include/sot/core/trajectory.hh b/include/sot/core/trajectory.hh index 85d15cb4a..b5bb1e4f8 100644 --- a/include/sot/core/trajectory.hh +++ b/include/sot/core/trajectory.hh @@ -195,7 +195,8 @@ public: }; } // namespace sot -template <> struct signal_io : signal_io_unimplemented {}; +template <> +struct signal_io : signal_io_unimplemented {}; } // namespace dynamicgraph diff --git a/include/sot/core/variadic-op.hh b/include/sot/core/variadic-op.hh index 83e4bf884..c03018f5a 100644 --- a/include/sot/core/variadic-op.hh +++ b/include/sot/core/variadic-op.hh @@ -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]; diff --git a/include/sot/core/vector-to-rotation.hh b/include/sot/core/vector-to-rotation.hh index a6c5bb8d8..7d60cc73d 100644 --- a/include/sot/core/vector-to-rotation.hh +++ b/include/sot/core/vector-to-rotation.hh @@ -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; diff --git a/src/control/admittance-control-op-point-python.h b/src/control/admittance-control-op-point-python.h index 8c65fbee0..321bd05eb 100644 --- a/src/control/admittance-control-op-point-python.h +++ b/src/control/admittance-control-op-point-python.h @@ -1,3 +1,4 @@ #include -typedef boost::mpl::vector entities_t; +typedef boost::mpl::vector + entities_t; diff --git a/src/feature/feature-point6d-relative-python.h b/src/feature/feature-point6d-relative-python.h index 2066f4c1b..d18d6a3b7 100644 --- a/src/feature/feature-point6d-relative-python.h +++ b/src/feature/feature-point6d-relative-python.h @@ -1,3 +1,4 @@ #include -typedef boost::mpl::vector entities_t; +typedef boost::mpl::vector + entities_t; diff --git a/src/feature/feature-pose-python.h b/src/feature/feature-pose-python.h index fecbdf9e0..55a7b901d 100644 --- a/src/feature/feature-pose-python.h +++ b/src/feature/feature-pose-python.h @@ -2,7 +2,6 @@ namespace dgs = dynamicgraph::sot; -typedef boost::mpl::vector< - dgs::FeaturePose -, dgs::FeaturePose - > entities_t; +typedef boost::mpl::vector, + dgs::FeaturePose > + entities_t; diff --git a/src/matrix/derivator-python.h b/src/matrix/derivator-python.h index b1645bce1..e08c43ede 100644 --- a/src/matrix/derivator-python.h +++ b/src/matrix/derivator-python.h @@ -1,9 +1,8 @@ #include namespace dg = ::dynamicgraph; -typedef boost::mpl::vector< - dg::sot::Derivator - , dg::sot::Derivator - , dg::sot::Derivator - , dg::sot::Derivator -> entities_t; +typedef boost::mpl::vector, + dg::sot::Derivator, + dg::sot::Derivator, + dg::sot::Derivator > + entities_t; diff --git a/src/matrix/fir-filter-python.h b/src/matrix/fir-filter-python.h index e22ac891d..1266eb6bb 100644 --- a/src/matrix/fir-filter-python.h +++ b/src/matrix/fir-filter-python.h @@ -1,8 +1,7 @@ #include namespace dg = ::dynamicgraph; -typedef boost::mpl::vector< - dg::sot::FIRFilter - , dg::sot::FIRFilter - , dg::sot::FIRFilter -> entities_t; +typedef boost::mpl::vector, + dg::sot::FIRFilter, + dg::sot::FIRFilter > + entities_t; diff --git a/src/matrix/integrator-euler-python-module-py.cc b/src/matrix/integrator-euler-python-module-py.cc index 670a40161..e921d35ec 100644 --- a/src/matrix/integrator-euler-python-module-py.cc +++ b/src/matrix/integrator-euler-python-module-py.cc @@ -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 void exposeIntegratorEuler() -{ +template void exposeIntegratorEuler() { typedef dgs::IntegratorEuler IE_t; - const std::string cName = - dgc::Value::typeName(dgc::ValueHelper::TypeID); + const std::string cName = dgc::Value::typeName(dgc::ValueHelper::TypeID); dg::python::exposeEntity() - .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(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(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(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(iterable)); + }); } -BOOST_PYTHON_MODULE(wrap) -{ +BOOST_PYTHON_MODULE(wrap) { bp::import("dynamic_graph"); exposeIntegratorEuler(); diff --git a/src/matrix/operator-python-module-py.cc b/src/matrix/operator-python-module-py.cc index b53f8ec7d..d9e3a7533 100644 --- a/src/matrix/operator-python-module-py.cc +++ b/src/matrix/operator-python-module-py.cc @@ -6,170 +6,157 @@ namespace dg = dynamicgraph; namespace dgs = dynamicgraph::sot; namespace bp = boost::python; -typedef bp::return_value_policy reference_existing_object; +typedef bp::return_value_policy + reference_existing_object; -template -void exposeUnaryOp() -{ +template void exposeUnaryOp() { typedef dgs::UnaryOp O_t; - dg::python::exposeEntity, dg::python::AddCommands>() + dg::python::exposeEntity, + dg::python::AddCommands>() .def_readonly("sin", &O_t::SIN) - .def_readonly("sout", &O_t::SOUT) - ; - + .def_readonly("sout", &O_t::SOUT); } -template -void exposeBinaryOp() -{ +template void exposeBinaryOp() { typedef dgs::BinaryOp O_t; - dg::python::exposeEntity, dg::python::AddCommands>() + dg::python::exposeEntity, + 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 -auto exposeVariadicOpBase() -{ +template auto exposeVariadicOpBase() { typedef dgs::VariadicOp O_t; typedef typename O_t::Base B_t; - return - dg::python::exposeEntity, dg::python::AddCommands>() + return dg::python::exposeEntity, + 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 -struct exposeVariadicOpImpl { - static void run () { exposeVariadicOpBase(); } +template struct exposeVariadicOpImpl { + static void run() { exposeVariadicOpBase(); } }; -template -struct exposeVariadicOpImpl > { - static void run () { +template struct exposeVariadicOpImpl > { + static void run() { typedef dgs::VariadicOp > E_t; - exposeVariadicOpBase >() - .add_property("coeffs", +[](E_t& e) { return e.op.coeffs; }, - +[](E_t& e, const dg::Vector& c) { e.op.setCoeffs(c); }, - "the multipliers.") - ; + exposeVariadicOpBase >().add_property( + "coeffs", +[](E_t &e) { return e.op.coeffs; }, + +[](E_t &e, const dg::Vector &c) { e.op.setCoeffs(c); }, + "the multipliers."); } }; -template -void exposeVariadicOp() -{ +template void exposeVariadicOp() { exposeVariadicOpImpl::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 > (); - exposeUnaryOp < Inverser > (); - exposeUnaryOp < Inverser > (); - 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 > (); - exposeBinaryOp < Substraction > (); - exposeBinaryOp < Substraction > (); - - /* --- STACK ------------------------------------------------------------ */ - exposeBinaryOp < VectorStack > (); - - /* ---------------------------------------------------------------------- */ - exposeBinaryOp < Composer > (); - - /* --- CONVOLUTION PRODUCT ---------------------------------------------- */ - exposeBinaryOp < ConvolutionTemporal > (); - - /* --- BOOLEAN REDUCTION ------------------------------------------------ */ - exposeBinaryOp < Comparison > (); - exposeBinaryOp < MatrixComparison > (); - - exposeBinaryOp < WeightedAdder > (); - exposeBinaryOp < WeightedAdder > (); - exposeBinaryOp < WeightedAdder > (); - - /* --- VectorMix ------------------------------------------------------------ */ - exposeVariadicOp < VectorMix > (); - - /* --- ADDITION --------------------------------------------------------- */ - exposeVariadicOp < AdderVariadic > (); - exposeVariadicOp < AdderVariadic > (); - exposeVariadicOp < AdderVariadic > (); - - /* --- MULTIPLICATION --------------------------------------------------- */ - exposeVariadicOp < Multiplier > (); - exposeVariadicOp < Multiplier > (); - exposeVariadicOp < Multiplier > (); - exposeVariadicOp < Multiplier > (); - exposeVariadicOp < Multiplier > (); - exposeVariadicOp < Multiplier > (); - exposeVariadicOp < Multiplier > (); - - /* --- BOOLEAN --------------------------------------------------------- */ - exposeVariadicOp < BoolOp<0> > (); - exposeVariadicOp < BoolOp<1> > (); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + + /* ---------------------------------------------------------------------- */ + /* --- INVERSION -------------------------------------------------------- */ + /* ---------------------------------------------------------------------- */ + exposeUnaryOp >(); + exposeUnaryOp >(); + exposeUnaryOp >(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + + /* ----------------------------------------------------------------------- */ + /* --- SE3/SO3 conversions ----------------------------------------------- */ + /* ----------------------------------------------------------------------- */ + + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + exposeUnaryOp(); + + /* --- MULTIPLICATION --------------------------------------------------- */ + + exposeBinaryOp(); + exposeBinaryOp(); + exposeBinaryOp(); + exposeBinaryOp(); + + /* --- SUBSTRACTION ----------------------------------------------------- */ + exposeBinaryOp >(); + exposeBinaryOp >(); + exposeBinaryOp >(); + + /* --- STACK ------------------------------------------------------------ */ + exposeBinaryOp(); + + /* ---------------------------------------------------------------------- */ + exposeBinaryOp(); + + /* --- CONVOLUTION PRODUCT ---------------------------------------------- */ + exposeBinaryOp(); + + /* --- BOOLEAN REDUCTION ------------------------------------------------ */ + exposeBinaryOp >(); + exposeBinaryOp >(); + + exposeBinaryOp >(); + exposeBinaryOp >(); + exposeBinaryOp >(); + + /* --- VectorMix ------------------------------------------------------------ + */ + exposeVariadicOp(); + + /* --- ADDITION --------------------------------------------------------- */ + exposeVariadicOp >(); + exposeVariadicOp >(); + exposeVariadicOp >(); + + /* --- MULTIPLICATION --------------------------------------------------- */ + exposeVariadicOp >(); + exposeVariadicOp >(); + exposeVariadicOp >(); + exposeVariadicOp >(); + exposeVariadicOp >(); + exposeVariadicOp >(); + exposeVariadicOp >(); + + /* --- BOOLEAN --------------------------------------------------------- */ + exposeVariadicOp >(); + exposeVariadicOp >(); } diff --git a/src/matrix/operator.hh b/src/matrix/operator.hh index 9724e716c..1b62bff6d 100644 --- a/src/matrix/operator.hh +++ b/src/matrix/operator.hh @@ -89,7 +89,8 @@ struct VectorSelecter : public UnaryOpHeader { 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 { 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 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 { }; struct Normalize : public UnaryOpHeader { - 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 { struct MatrixToHomo : public UnaryOpHeader { inline void operator()(const Eigen::Matrix &M, - MatrixHomogeneous &res) { + MatrixHomogeneous &res) { res = M; } }; @@ -440,7 +447,6 @@ struct HomoToRotation } }; - struct MatrixHomoToPose : public UnaryOpHeader { inline void operator()(const MatrixHomogeneous &M, Vector &res) { res.resize(3); @@ -489,16 +495,22 @@ struct QuaternionToMatrix struct MatrixToQuaternion : public UnaryOpHeader { - inline void operator()(const MatrixRotation &r, VectorQuaternion &res) { res = r; } + inline void operator()(const MatrixRotation &r, VectorQuaternion &res) { + res = r; + } }; struct MatrixToUTheta : public UnaryOpHeader { - inline void operator()(const MatrixRotation &r, VectorUTheta &res) { res = r; } + inline void operator()(const MatrixRotation &r, VectorUTheta &res) { + res = r; + } }; struct UThetaToQuaternion : public UnaryOpHeader { - inline void operator()(const VectorUTheta &r, VectorQuaternion &res) { res = r; } + inline void operator()(const VectorUTheta &r, VectorQuaternion &res) { + res = r; + } }; template @@ -547,8 +559,8 @@ struct Multiplier_FxE__E : public BinaryOpHeader { }; template <> -inline void Multiplier_FxE__E:: +inline void +Multiplier_FxE__E:: operator()(const dynamicgraph::sot::MatrixHomogeneous &f, const dynamicgraph::Vector &e, dynamicgraph::Vector &res) const { res = f.matrix() * e; @@ -579,7 +591,6 @@ template struct Substraction : public BinaryOpHeader { } }; - /* --- STACK ------------------------------------------------------------ */ struct VectorStack : public BinaryOpHeader= v1min) && (v1.size() >= v1max)); assert((v2max >= v2min) && (v2.size() >= v2max)); @@ -612,7 +623,8 @@ public: v2max = 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; @@ -639,8 +651,9 @@ public: struct Composer : public BinaryOpHeader { - inline void operator()(const dynamicgraph::Matrix &R, const dynamicgraph::Vector &t, - MatrixHomogeneous &H) const { + inline void operator()(const dynamicgraph::Matrix &R, + const dynamicgraph::Vector &t, + MatrixHomogeneous &H) const { H.linear() = R; H.translation() = t; } @@ -654,7 +667,7 @@ struct ConvolutionTemporal MemoryType memory; inline void convolution(const MemoryType &f1, const dynamicgraph::Matrix &f2, - dynamicgraph::Vector &res) { + dynamicgraph::Vector &res) { const Vector::Index nconv = (Vector::Index)f1.size(), nsig = f2.rows(); sotDEBUG(15) << "Size: " << nconv << "x" << nsig << std::endl; if (nconv > f2.cols()) @@ -676,7 +689,8 @@ struct ConvolutionTemporal } } inline void operator()(const dynamicgraph::Vector &v1, - const dynamicgraph::Matrix &m2, dynamicgraph::Vector &res) { + const dynamicgraph::Matrix &m2, + dynamicgraph::Vector &res) { memory.push_front(v1); while ((Vector::Index)memory.size() > m2.cols()) memory.pop_back(); @@ -687,7 +701,9 @@ struct ConvolutionTemporal /* --- BOOLEAN REDUCTION ------------------------------------------------ */ template struct Comparison : public BinaryOpHeader { - inline void operator()(const T &a, const T &b, bool &res) const { res = (a < b); } + inline void operator()(const T &a, const T &b, bool &res) const { + res = (a < b); + } inline std::string getDocString() const { typedef BinaryOpHeader Base; return std::string("Comparison of inputs:\n" @@ -735,7 +751,8 @@ struct MatrixComparison : public BinaryOpHeader { "comparison can be made <=.\n"); } MatrixComparison() : any(true), equal(false) {} - inline void addSpecificCommands(Entity &ent, Entity::CommandMap_t &commandMap) { + inline void addSpecificCommands(Entity &ent, + Entity::CommandMap_t &commandMap) { using namespace dynamicgraph::command; ADD_COMMAND( "setTrueIfAny", @@ -766,7 +783,8 @@ public: res += gain2 * v2; } - 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; @@ -838,7 +856,8 @@ public: typedef std::vector segments_t; Base *entity; segments_t idxs; - inline void operator()(const std::vector &vs, Vector &res) const { + inline void operator()(const std::vector &vs, + Vector &res) const { res = *vs[0]; for (std::size_t i = 0; i < idxs.size(); ++i) { const segment_t &s = idxs[i]; @@ -932,7 +951,9 @@ template struct Multiplier : public VariadicOpHeader { ent->setSignalNumber(2); } }; -template <> inline void Multiplier::setIdentity(double &res) const { res = 1; } +template <> inline void Multiplier::setIdentity(double &res) const { + res = 1; +} template <> inline void Multiplier:: operator()(const std::vector &vs, @@ -946,8 +967,8 @@ operator()(const std::vector &vs, } } template <> -inline void Multiplier::operator()(const std::vector &vs, - Vector &res) const { +inline void Multiplier:: +operator()(const std::vector &vs, Vector &res) const { if (vs.size() == 0) res.resize(0); else { @@ -957,7 +978,6 @@ inline void Multiplier::operator()(const std::vector &vs } } - /* --- BOOLEAN --------------------------------------------------------- */ template struct BoolOp : public VariadicOpHeader { typedef VariadicOp Base; diff --git a/src/python-module.cc b/src/python-module.cc index baabaaa40..731db0d93 100644 --- a/src/python-module.cc +++ b/src/python-module.cc @@ -7,82 +7,96 @@ namespace dg = dynamicgraph; namespace dgs = dynamicgraph::sot; -typedef bp::return_value_policy reference_existing_object; +typedef bp::return_value_policy + reference_existing_object; -BOOST_PYTHON_MODULE(wrap) -{ +BOOST_PYTHON_MODULE(wrap) { bp::import("dynamic_graph"); using dgs::PeriodicCall; bp::class_("PeriodicCall", bp::no_init) - .def("addSignal", static_cast &)> (&PeriodicCall::addSignal), - "Add the signal to the refresh list", (bp::arg("name"), "signal")) - .def("addSignal", static_cast (&PeriodicCall::addSignal), - "Add the signal to the refresh list", (bp::arg("signal_name"))) + .def("addSignal", + static_cast &)>( + &PeriodicCall::addSignal), + "Add the signal to the refresh list", (bp::arg("name"), "signal")) + .def("addSignal", + static_cast( + &PeriodicCall::addSignal), + "Add the signal to the refresh list", (bp::arg("signal_name"))) - .def("addDownsampledSignal", static_cast &, const unsigned int &)> (&PeriodicCall::addDownsampledSignal), - "Add the signal to the refresh list\n" - "The downsampling factor: 1 means every time, " - "2 means every other time, etc...", - (bp::arg("name"), "signal", "factor")) - .def("addDownsampledSignal", static_cast (&PeriodicCall::addDownsampledSignal), - "Add the signal to the refresh list\n" - "The downsampling factor: 1 means every time, " - "2 means every other time, etc...", - (bp::arg("signal_name"), "factor")) + .def("addDownsampledSignal", + static_cast &, + const unsigned int &)>(&PeriodicCall::addDownsampledSignal), + "Add the signal to the refresh list\n" + "The downsampling factor: 1 means every time, " + "2 means every other time, etc...", + (bp::arg("name"), "signal", "factor")) + .def("addDownsampledSignal", + static_cast( + &PeriodicCall::addDownsampledSignal), + "Add the signal to the refresh list\n" + "The downsampling factor: 1 means every time, " + "2 means every other time, etc...", + (bp::arg("signal_name"), "factor")) - .def("rmSignal", &PeriodicCall::rmSignal, "Remove the signal to the refresh list", bp::arg("name")) - .def("clear", &PeriodicCall::clear, "Clear all signals and commands from the refresh list.") - .def("__str__", +[](const PeriodicCall& e) { - std::ostringstream os; - e.display(os); - return os.str(); - }) - ; + .def("rmSignal", &PeriodicCall::rmSignal, + "Remove the signal to the refresh list", bp::arg("name")) + .def("clear", &PeriodicCall::clear, + "Clear all signals and commands from the refresh list.") + .def("__str__", +[](const PeriodicCall &e) { + std::ostringstream os; + e.display(os); + return os.str(); + }); dynamicgraph::python::exposeEntity() - .add_property("after", - bp::make_function(&dgs::Device::periodicCallAfter, reference_existing_object())) - .def_readonly("before", - bp::make_function(&dgs::Device::periodicCallBefore, reference_existing_object())) - ; + .add_property("after", bp::make_function(&dgs::Device::periodicCallAfter, + reference_existing_object())) + .def_readonly("before", + bp::make_function(&dgs::Device::periodicCallBefore, + reference_existing_object())); using dgs::Flags; bp::class_("Flags", bp::init<>()) - .def(bp::init()) - .def("__init__", bp::make_constructor(+[](bp::list bools) { - std::vector flags (bp::len(bools)); - for (std::size_t i = 0; i < flags.size(); ++i) flags[i] = bp::extract(bools[i]); - return new Flags(flags); - })) - .def("__init__", bp::make_constructor(+[](bp::tuple bools) { - std::vector flags (bp::len(bools)); - for (std::size_t i = 0; i < flags.size(); ++i) flags[i] = bp::extract(bools[i]); - return new Flags(flags); - })) - .def("add", &Flags::add) - .def("set", &Flags::set) - .def("unset", &Flags::unset) + .def(bp::init()) + .def("__init__", bp::make_constructor(+[](bp::list bools) { + std::vector flags(bp::len(bools)); + for (std::size_t i = 0; i < flags.size(); ++i) + flags[i] = bp::extract(bools[i]); + return new Flags(flags); + })) + .def("__init__", bp::make_constructor(+[](bp::tuple bools) { + std::vector flags(bp::len(bools)); + for (std::size_t i = 0; i < flags.size(); ++i) + flags[i] = bp::extract(bools[i]); + return new Flags(flags); + })) + .def("add", &Flags::add) + .def("set", &Flags::set) + .def("unset", &Flags::unset) - .def(bp::self & bp::self) - .def(bp::self | bp::self) - .def(bp::self &= bp::self) - .def(bp::self |= bp::self) + .def(bp::self & bp::self) + .def(bp::self | bp::self) + .def(bp::self &= bp::self) + .def(bp::self |= bp::self) - .def("__call__", &Flags::operator()) - .def("__bool__", &Flags::operator bool) - .def("reversed", &Flags::operator!) + .def("__call__", &Flags::operator()) + .def("__bool__", &Flags::operator bool) + .def("reversed", &Flags::operator!) - .def("set", +[](Flags& f, const std::string& s) { - std::istringstream is (s); - is >> f; - }) - .def("__str__", +[](const Flags& f) { - std::ostringstream os; - os << f; - return os.str(); - }) - ; + .def("set", + +[](Flags &f, const std::string &s) { + std::istringstream is(s); + is >> f; + }) + .def("__str__", +[](const Flags &f) { + std::ostringstream os; + os << f; + return os.str(); + }); dg::python::exposeSignalsOfType("Flags"); } diff --git a/src/signal/signal-cast.cpp b/src/signal/signal-cast.cpp index d24340e7e..c20bf06e5 100644 --- a/src/signal/signal-cast.cpp +++ b/src/signal/signal-cast.cpp @@ -36,8 +36,8 @@ namespace dgsot = dynamicgraph::sot; /* --- CASTER IMPLEMENTATION ------------------------------------------------ */ /* --- CASTER IMPLEMENTATION ------------------------------------------------ */ -//DG_SIGNAL_CAST_DEFINITION(sot::Flags); -//DG_ADD_CASTER(sot::Flags, flags); +// DG_SIGNAL_CAST_DEFINITION(sot::Flags); +// DG_ADD_CASTER(sot::Flags, flags); /* --- TIMEVAL -------------------------------------------------------------- */ /* --- TIMEVAL -------------------------------------------------------------- */ diff --git a/src/tools/joint-trajectory-entity-python.h b/src/tools/joint-trajectory-entity-python.h index 26ee4a939..f4307f8cb 100644 --- a/src/tools/joint-trajectory-entity-python.h +++ b/src/tools/joint-trajectory-entity-python.h @@ -1,3 +1,4 @@ #include -typedef boost::mpl::vector entities_t; +typedef boost::mpl::vector + entities_t; diff --git a/src/tools/switch-python-module-py.cc b/src/tools/switch-python-module-py.cc index 444352458..0c9f87c8d 100644 --- a/src/tools/switch-python-module-py.cc +++ b/src/tools/switch-python-module-py.cc @@ -2,32 +2,29 @@ #include namespace dg = dynamicgraph; -typedef bp::return_value_policy reference_existing_object; +typedef bp::return_value_policy + reference_existing_object; -template -void exposeSwitch() -{ +template void exposeSwitch() { typedef dg::sot::Switch E_t; typedef typename E_t::Base B_t; - dg::python::exposeEntity, dg::python::AddCommands>() + dg::python::exposeEntity, + dg::python::AddCommands>() .def_readonly("sout", &E_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_readonly("selection", &E_t::selectionSIN) .def_readonly("boolSelection", &E_t::boolSelectionSIN) .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")); } -BOOST_PYTHON_MODULE(wrap) -{ - exposeSwitch (); - exposeSwitch (); - exposeSwitch (); - +BOOST_PYTHON_MODULE(wrap) { + exposeSwitch(); + exposeSwitch(); + exposeSwitch(); } diff --git a/src/tools/timer-python.h b/src/tools/timer-python.h index be2cbe575..2e57bf6ee 100644 --- a/src/tools/timer-python.h +++ b/src/tools/timer-python.h @@ -1,9 +1,7 @@ -#include #include +#include typedef boost::mpl::vector< - Timer -, Timer -, Timer -, Timer -> entities_t; + Timer, Timer, + Timer, Timer > + entities_t; diff --git a/src/tools/type-name-helper.hh b/src/tools/type-name-helper.hh index f7c92eba1..61c6308ff 100644 --- a/src/tools/type-name-helper.hh +++ b/src/tools/type-name-helper.hh @@ -17,10 +17,14 @@ template struct TypeNameHelper { static inline std::string typeName(); }; template -inline std::string TypeNameHelper::typeName() { return "unspecified"; } +inline std::string TypeNameHelper::typeName() { + return "unspecified"; +} #define ADD_KNOWN_TYPE(typeid) \ - template <> inline std::string TypeNameHelper::typeName () { return #typeid; } + template <> inline std::string TypeNameHelper::typeName() { \ + return #typeid; \ + } ADD_KNOWN_TYPE(bool) ADD_KNOWN_TYPE(double)