Skip to content

Commit

Permalink
[bindings][python] expose referenceConfigurations and loadReferenceCo…
Browse files Browse the repository at this point in the history
…nfigurations. Make previous functions deprecated
  • Loading branch information
proyan committed Feb 13, 2019
1 parent b36be07 commit a24594d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
11 changes: 10 additions & 1 deletion bindings/python/multibody/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define __pinocchio_python_model_hpp__

#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <boost/python/overloads.hpp>
#include <eigenpy/memory.hpp>

Expand All @@ -15,6 +16,7 @@
#include "pinocchio/algorithm/check.hpp"
#include "pinocchio/parsers/sample-models.hpp"
#include "pinocchio/bindings/python/utils/eigen_container.hpp"
#include "pinocchio/bindings/python/utils/std-aligned-map.hpp"
#include "pinocchio/bindings/python/utils/printable.hpp"
#include "pinocchio/bindings/python/utils/copyable.hpp"

Expand Down Expand Up @@ -87,6 +89,11 @@ namespace pinocchio
make_getter(&Model::neutralConfiguration, bp::return_value_policy<bp::return_by_value>()),
make_setter(&Model::neutralConfiguration, bp::return_value_policy<bp::return_by_value>()),
"Joint's neutral configurations.")

.add_property("referenceConfigurations",
make_getter(&Model::referenceConfigurations, bp::return_value_policy<bp::return_by_value>()),
make_setter(&Model::referenceConfigurations, bp::return_value_policy<bp::return_by_value>()),
"Model reference configurations.")
.add_property("rotorInertia",
make_getter(&Model::rotorInertia, bp::return_value_policy<bp::return_by_value>()),
make_setter(&Model::rotorInertia, bp::return_value_policy<bp::return_by_value>()),
Expand Down Expand Up @@ -197,7 +204,9 @@ namespace pinocchio
bp::class_< std::vector<bool> >("StdVec_Bool")
.def(bp::vector_indexing_suite< std::vector<bool> >());
bp::class_< std::vector<double> >("StdVec_double")
.def(bp::vector_indexing_suite< std::vector<double> >());
.def(bp::vector_indexing_suite< std::vector<double> >());

StdAlignedMapPythonVisitor<std::string, Model::ConfigVectorType>::expose("StdMap_string");

bp::class_<Model>("Model",
"Articulated rigid body model (const)",
Expand Down
8 changes: 4 additions & 4 deletions bindings/python/parsers/parsers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ namespace pinocchio
"Parse the URDF file given in input and return a proper pinocchio model");
#endif // #ifdef PINOCCHIO_WITH_LUA5

bp::def("getNeutralConfiguration",
static_cast<Model::ConfigVectorType (*)(Model &, const std::string &, const bool)>(&srdf::getNeutralConfiguration),
bp::def("loadReferenceConfigurations",
static_cast<void (*)(Model &, const std::string &, const bool)>(&srdf::loadReferenceConfigurations),
bp::args("Model for which we want the neutral config","srdf filename (string)", "verbosity"
),
"Get the neutral configuration of a given model associated to a SRDF file");

"Get the reference configurations of a given model from the SRDF file.");
bp::def("loadRotorParameters",
static_cast<bool (*)(Model &, const std::string &, const bool)>(&srdf::loadRotorParameters),
bp::args("Model for which we are loading the rotor parameters",
Expand Down
10 changes: 8 additions & 2 deletions bindings/python/scripts/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@ def getJacobianTimeVariation(model,data,jointId,local):
def differentiate(model,q0,q1):
return pin.difference(model,q0,q1)

@deprecated("This function has been renamed difference and will be removed in future releases of Pinocchio. Please change for new getNeutralConfiguration function.")
@deprecated("This function has been renamed loadReferenceConfigurations and will be removed in future releases of Pinocchio. Please change for new loadReferenceConfigurations function.")
def getNeutralConfigurationFromSrdf(model, filename, verbose):
return pin.getNeutralConfiguration(model,filename,verbose)
pin.loadReferenceConfigurations(model,filename,verbose)
return model.referenceConfigurations["half_sitting"]

@deprecated("This function has been renamed loadReferenceConfigurations and will be removed in future releases of Pinocchio. Please change for new loadReferenceConfigurations function.")
def getNeutralConfiguration(model, filename, verbose):
pin.loadReferenceConfigurations(model,filename,verbose)
return model.referenceConfigurations["half_sitting"]

@deprecated("This function has been renamed difference and will be removed in future releases of Pinocchio. Please change for new loadRotorParameters function.")
def loadRotorParamsFromSrdf(model, filename, verbose):
Expand Down

0 comments on commit a24594d

Please sign in to comment.