Commit 8d9f088c authored by Joseph Mirabel's avatar Joseph Mirabel
Browse files

[Refactoring] Remove usage of ConfigurationPtr_t in ConfigurationShooter

parent c85d6fe9
......@@ -35,7 +35,16 @@ namespace hpp {
{
public:
/// Shoot a random configuration
virtual ConfigurationPtr_t shoot () const = 0;
virtual ConfigurationPtr_t shoot () const
{
ConfigurationPtr_t q (new Configuration_t);
shoot (*q);
return q;
}
/// Shoot a random configuration
/// \param q the configuration (resized if necessary).
virtual void shoot (Configuration_t& q) const = 0;
virtual ~ConfigurationShooter () {};
protected:
......
......@@ -44,7 +44,7 @@ namespace hpp {
ptr->init (shPtr);
return shPtr;
}
virtual ConfigurationPtr_t shoot () const;
virtual void shoot (Configuration_t& q) const;
void center (ConfigurationIn_t c)
{
......
......@@ -42,7 +42,7 @@ namespace hpp {
ptr->init (shPtr);
return shPtr;
}
virtual ConfigurationPtr_t shoot () const;
virtual void shoot (Configuration_t& q) const;
void sampleExtraDOF(bool sampleExtraDOF){
sampleExtraDOF_=sampleExtraDOF;
......
......@@ -106,7 +106,7 @@ namespace hpp {
::pinocchio::details::Dispatch<ComputeSigmasStep>::run(jmodel.derived(), ComputeSigmasStep::ArgsType(model, sigmas));
}
ConfigurationPtr_t Gaussian::shoot () const
void Gaussian::shoot (Configuration_t& config) const
{
static boost::random::mt19937 eng;
vector_t velocity (robot_->numberDof());
......@@ -116,11 +116,9 @@ namespace hpp {
velocity[i] = distrib (eng);
}
ConfigurationPtr_t config(new Configuration_t(robot_->configSize ()));
::hpp::pinocchio::integrate (robot_, center_, velocity, *config);
::hpp::pinocchio::saturate (robot_, *config);
return config;
config.resize(robot_->configSize ());
::hpp::pinocchio::integrate (robot_, center_, velocity, config);
::hpp::pinocchio::saturate (robot_, config);
}
void Gaussian::sigma(const value_type& factor)
......
......@@ -26,12 +26,12 @@ namespace hpp {
namespace core {
namespace configurationShooter {
ConfigurationPtr_t Uniform::shoot () const
void Uniform::shoot (Configuration_t& config) const
{
size_type extraDim = robot_->extraConfigSpace ().dimension ();
size_type offset = robot_->configSize () - extraDim;
Configuration_t config(robot_->configSize ());
config.resize(robot_->configSize ());
config.head (offset) = ::pinocchio::randomConfiguration(robot_->model());
if(sampleExtraDOF_){
......@@ -52,7 +52,6 @@ namespace hpp {
}else{
config.tail(extraDim).setZero();
}
return boost::make_shared<Configuration_t> (config);
}
} // namespace configurationShooter
......
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