Verified Commit c4b09b95 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

all: remove deprecated Model::neutralConfiguration

parent 63645f34
......@@ -122,17 +122,7 @@ namespace pinocchio
.add_property("parents",&Model::parents)
.add_property("names",&Model::names)
.add_property("name",&Model::name)
.add_property("referenceConfigurations", &Model::referenceConfigurations);
/// TODO: remove this pragma when neutralConfiguration will be removed
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
cl
.add_property("_neutralConfiguration",
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.");
#pragma GCC diagnostic pop
cl
.add_property("referenceConfigurations", &Model::referenceConfigurations)
.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>()),
......
......@@ -42,21 +42,6 @@ def _Model__BuildEmptyModel():
pin.Model.BuildEmptyModel = staticmethod(_Model__BuildEmptyModel)
# deprecate Model.neutralConfiguration. Since: 19 feb 2019
def _Model__neutralConfiguration(self):
message = "Using deprecated instance variable Model.neutralConfiguration. Please use Model.referenceConfigurations instead."
_warnings.warn(message, DeprecatedWarning, stacklevel=2)
return self._neutralConfiguration
pin.Model.neutralConfiguration = property(_Model__neutralConfiguration)
def _Model__set_neutralConfiguration(self,q):
message = "Using deprecated instance variable Model.neutralConfiguration. Please use Model.referenceConfigurations instead."
_warnings.warn(message, DeprecatedWarning, stacklevel=2)
self._neutralConfiguration = q
pin.Model.neutralConfiguration = pin.Model.neutralConfiguration.setter(_Model__set_neutralConfiguration)
@deprecated("This function has been renamed updateFramePlacements when taking two arguments, and framesForwardKinematics when taking three. Please change your code to the appropriate method.")
def framesKinematics(model,data,q=None):
if q is None:
......@@ -142,13 +127,11 @@ def differentiate(model,q0,q1):
@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):
pin.loadReferenceConfigurations(model,filename,verbose)
model.neutralConfiguration = model.referenceConfigurations["half_sitting"]
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)
model.neutralConfiguration = model.referenceConfigurations["half_sitting"]
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.")
......
......@@ -5,7 +5,7 @@ import pinocchio
model = pinocchio.buildSampleModelManipulator()
data = model.createData()
q = model.neutralConfiguration
q = pinocchio.neutral(model)
v = pinocchio.utils.zero(model.nv)
a = pinocchio.utils.zero(model.nv)
......
//
// Copyright (c) 2018 CNRS
// Copyright (c) 2018-2019 CNRS INRIA
//
#ifndef __pinocchio_utils_code_generator_algo_hpp__
......@@ -8,6 +8,8 @@
#ifdef PINOCCHIO_WITH_CPPADCG_SUPPORT
#include "pinocchio/codegen/code-generator-base.hpp"
#include "pinocchio/algorithm/joint-configuration.hpp"
#include "pinocchio/algorithm/crba.hpp"
#include "pinocchio/algorithm/rnea.hpp"
#include "pinocchio/algorithm/aba.hpp"
......@@ -33,7 +35,7 @@ namespace pinocchio
const std::string & library_name = "cg_rnea_eval")
: Base(model,model.nq+2*model.nv,model.nv,function_name,library_name)
{
ad_q = ADCongigVectorType(model.nq); ad_q = ad_model.neutralConfiguration;
ad_q = ADCongigVectorType(model.nq); ad_q = neutral(model);
ad_v = ADTangentVectorType(model.nv); ad_v.setZero();
ad_a = ADTangentVectorType(model.nv); ad_a.setZero();
x = VectorXs::Zero(Base::getInputDimension());
......@@ -131,7 +133,7 @@ namespace pinocchio
const std::string & library_name = "cg_aba_eval")
: Base(model,model.nq+2*model.nv,model.nv,function_name,library_name)
{
ad_q = ADCongigVectorType(model.nq); ad_q = ad_model.neutralConfiguration;
ad_q = ADCongigVectorType(model.nq); ad_q = neutral(model);
ad_v = ADTangentVectorType(model.nv); ad_v.setZero();
ad_tau = ADTangentVectorType(model.nv); ad_tau.setZero();
x = VectorXs::Zero(Base::getInputDimension());
......@@ -229,7 +231,7 @@ namespace pinocchio
const std::string & library_name = "cg_crba_eval")
: Base(model,model.nq,(model.nv*(model.nv+1))/2,function_name,library_name)
{
ad_q = ADCongigVectorType(model.nq); ad_q = ad_model.neutralConfiguration;
ad_q = ADCongigVectorType(model.nq); ad_q = neutral(model);
x = VectorXs::Zero(Base::getInputDimension());
res = VectorXs::Zero(Base::getOutputDimension());
......@@ -317,7 +319,7 @@ namespace pinocchio
const std::string & library_name = "cg_minv_eval")
: Base(model,model.nq,(model.nv*(model.nv+1))/2,function_name,library_name)
{
ad_q = ADCongigVectorType(model.nq); ad_q = ad_model.neutralConfiguration;
ad_q = ADCongigVectorType(model.nq); ad_q = neutral(model);
x = VectorXs::Zero(Base::getInputDimension());
res = VectorXs::Zero(Base::getOutputDimension());
......@@ -407,7 +409,7 @@ namespace pinocchio
const std::string & library_name = "cg_partial_rnea_eval")
: Base(model,model.nq+2*model.nv,3*model.nv*model.nv,function_name,library_name)
{
ad_q = ADCongigVectorType(model.nq); ad_q = ad_model.neutralConfiguration;
ad_q = ADCongigVectorType(model.nq); ad_q = neutral(model);
ad_v = ADTangentVectorType(model.nv); ad_v.setZero();
ad_a = ADTangentVectorType(model.nv); ad_a.setZero();
......@@ -516,7 +518,7 @@ namespace pinocchio
const std::string & library_name = "cg_partial_aba_eval")
: Base(model,model.nq+2*model.nv,3*model.nv*model.nv,function_name,library_name)
{
ad_q = ADCongigVectorType(model.nq); ad_q = ad_model.neutralConfiguration;
ad_q = ADCongigVectorType(model.nq); ad_q = neutral(model);
ad_v = ADTangentVectorType(model.nv); ad_v.setZero();
ad_tau = ADTangentVectorType(model.nv); ad_tau.setZero();
......
......@@ -111,10 +111,6 @@ namespace pinocchio
/// \brief Name of joint *i*
std::vector<std::string> names;
/// \brief Vector of joint's neutral configurations
PINOCCHIO_DEPRECATED
ConfigVectorType neutralConfiguration;
/// \brief Map of reference configurations, indexed by user given names.
ConfigVectorMap referenceConfigurations;
......@@ -209,11 +205,6 @@ namespace pinocchio
res.nvs = nvs;
// Eigen Vectors
// TODO: remove this pragma when neutralConfiguration will be removed
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
res.neutralConfiguration = neutralConfiguration.template cast<NewScalar>();
#pragma GCC diagnostic pop
res.rotorInertia = rotorInertia.template cast<NewScalar>();
res.rotorGearRatio = rotorGearRatio.template cast<NewScalar>();
res.effortLimit = effortLimit.template cast<NewScalar>();
......@@ -276,16 +267,7 @@ namespace pinocchio
&& other.nqs == nqs
&& other.idx_vs == idx_vs
&& other.nvs == nvs;
/// TODO: remove this pragma when neutralConfiguration will be removed
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
if(other.neutralConfiguration.size() != neutralConfiguration.size())
return false;
res &= other.neutralConfiguration == neutralConfiguration;
if(!res) return res;
#pragma GCC diagnostic pop
if(other.referenceConfigurations.size() != referenceConfigurations.size())
return false;
res &= other.referenceConfigurations == referenceConfigurations;
......
......@@ -110,14 +110,6 @@ namespace pinocchio
upperPositionLimit.conservativeResize(nq);
jmodel.jointConfigSelector(upperPositionLimit) = max_config;
// TODO: remove this pragma when neutralConfiguration will be removed
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
neutralConfiguration.conservativeResize(nq);
typedef NeutralStep<LieGroupMap,ConfigVectorType> NeutralVisitor;
NeutralStepAlgo<NeutralVisitor,JointModelDerived>::run(jmodel,neutralConfiguration);
#pragma GCC diagnostic pop
rotorInertia.conservativeResize(nv);
jmodel.jointVelocitySelector(rotorInertia).setZero();
rotorGearRatio.conservativeResize(nv);
......
......@@ -70,33 +70,6 @@ namespace pinocchio
#endif // ifdef PINOCCHIO_WITH_HPP_FCL
///
/// \brief Get the neutral configuration of a given model associated to a SRDF file.
/// It throws if the SRDF file is incorrect.
///
/// \param[in] model The Model for which we want the neutral config
/// \param[in] filename The complete path to the SRDF file.
/// \param[in] verbose Verbosity mode.
///
/// \return The neutral configuration as an eigen vector
///
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
PINOCCHIO_DEPRECATED
typename ModelTpl<Scalar,Options,JointCollectionTpl>::ConfigVectorType
getNeutralConfiguration(ModelTpl<Scalar,Options,JointCollectionTpl> & model,
const std::string & filename,
const bool verbose = false);
/// \copydoc pinocchio::srdf::getNeutralConfiguration
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
PINOCCHIO_DEPRECATED
typename ModelTpl<Scalar,Options,JointCollectionTpl>::ConfigVectorType
getNeutralConfigurationFromSrdf(ModelTpl<Scalar,Options,JointCollectionTpl> & model,
const std::string & filename,
const bool verbose = false)
{ return getNeutralConfiguration(model,filename,verbose); }
///
/// \brief Get the reference configurations of a given model associated to a SRDF file.
/// It throws if the SRDF file is incorrect. The reference configurations are
......
......@@ -201,88 +201,6 @@ namespace pinocchio
PINOCCHIO_CHECK_INPUT_ARGUMENT(false, "no rotor params found in the SRDF file");
return false; // warning : uninitialized vector is returned
}
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
typename ModelTpl<Scalar,Options,JointCollectionTpl>::ConfigVectorType
getNeutralConfiguration(ModelTpl<Scalar,Options,JointCollectionTpl> & model,
const std::string & filename,
const bool verbose)
{
typedef ModelTpl<Scalar,Options,JointCollectionTpl> Model;
typedef typename Model::JointModel JointModel;
// Check extension
const std::string extension = filename.substr(filename.find_last_of('.')+1);
if (extension != "srdf")
{
const std::string exception_message (filename + " does not have the right extension.");
throw std::invalid_argument(exception_message);
}
// Open file
std::ifstream srdf_stream(filename.c_str());
if (! srdf_stream.is_open())
{
const std::string exception_message (filename + " does not seem to be a valid file.");
throw std::invalid_argument(exception_message);
}
// Read xml stream
using boost::property_tree::ptree;
ptree pt;
read_xml(srdf_stream, pt);
// Iterate over all tags directly children of robot
BOOST_FOREACH(const ptree::value_type & v, pt.get_child("robot"))
{
// if we encounter a tag group_state
if (v.first == "group_state")
{
const std::string name = v.second.get<std::string>("<xmlattr>.name");
// Ensure that it is the half_sitting tag
if( name == "half_sitting")
{
// Iterate over all the joint tags
BOOST_FOREACH(const ptree::value_type & joint_tag, v.second)
{
if (joint_tag.first == "joint")
{
std::string joint_name = joint_tag.second.get<std::string>("<xmlattr>.name");
typename Model::JointIndex joint_id = model.getJointId(joint_name);
// Search in model the joint and its config id
if (joint_id != model.joints.size()) // != model.njoints
{
const JointModel & joint = model.joints[joint_id];
typename Model::ConfigVectorType joint_config(joint.nq());
const std::string joint_val = joint_tag.second.get<std::string>("<xmlattr>.value");
std::istringstream config_string(joint_val);
std::vector<double> config_vec((std::istream_iterator<double>(config_string)), std::istream_iterator<double>());
joint_config = Eigen::Map<typename Model::ConfigVectorType>(config_vec.data(), config_vec.size());
model.neutralConfiguration.segment(joint.idx_q(),joint.nq()) = joint_config;
if (verbose)
{
std::cout << "(" << joint_name << " , " << joint_config.transpose() << ")" << std::endl;
}
}
else
{
if (verbose) std::cout << "The Joint " << joint_name << " was not found in model" << std::endl;
}
}
}
return model.neutralConfiguration;
}
}
} // BOOST_FOREACH
if (verbose) std::cout << "no half_sitting configuration found in the SRDF file"; // Should we throw something here ?
typename Model::ConfigVectorType config (model.nq);
neutral (model, config);
return config;
}
template<typename Scalar, int Options, template<typename,int> class JointCollectionTpl>
struct LoadReferenceConfigurationStep
......
......@@ -41,11 +41,6 @@ namespace boost
ar & make_nvp("gravity",model.gravity);
ar & make_nvp("name",model.name);
// TODO: remove this pragma when neutralConfiguration will be removed
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
ar & make_nvp("neutralConfiguration",model.neutralConfiguration);
#pragma GCC diagnostic pop
ar & make_nvp("referenceConfigurations",model.referenceConfigurations);
ar & make_nvp("rotorInertia",model.rotorInertia);
ar & make_nvp("rotorGearRatio",model.rotorGearRatio);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment