Commit 762d643b authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Remove articulated models

parent ff8b2c31
......@@ -149,11 +149,6 @@ SET(${PROJECT_NAME}_HEADERS
include/hpp/fcl/traversal/traversal_node_bvh_shape.h
include/hpp/fcl/traversal/traversal_node_base.h
include/hpp/fcl/data_types.h
include/hpp/fcl/articulated_model/model.h
include/hpp/fcl/articulated_model/joint_config.h
include/hpp/fcl/articulated_model/model_config.h
include/hpp/fcl/articulated_model/joint.h
include/hpp/fcl/articulated_model/link.h
include/hpp/fcl/BVH/BV_splitter.h
include/hpp/fcl/BVH/BVH_internal.h
include/hpp/fcl/BVH/BVH_model.h
......
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2011-2014, Willow Garage, Inc.
* Copyright (c) 2014-2015, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Dalibor Matura, Jia Pan */
#ifndef FCL_ARTICULATED_MODEL_JOINT_H
#define FCL_ARTICULATED_MODEL_JOINT_H
#include <hpp/fcl/math/transform.h>
#include <hpp/fcl/data_types.h>
#include <string>
#include <vector>
#include <map>
#include <limits>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
namespace fcl
{
class JointConfig;
class Link;
enum JointType {JT_UNKNOWN, JT_PRISMATIC, JT_REVOLUTE, JT_BALLEULER};
/// @brief Base Joint
class Joint
{
public:
Joint(const boost::shared_ptr<Link>& link_parent, const boost::shared_ptr<Link>& link_child,
const Transform3f& transform_to_parent,
const std::string& name);
Joint(const std::string& name);
virtual ~Joint() {}
const std::string& getName() const;
void setName(const std::string& name);
virtual Transform3f getLocalTransform() const = 0;
virtual std::size_t getNumDofs() const = 0;
boost::shared_ptr<JointConfig> getJointConfig() const;
void setJointConfig(const boost::shared_ptr<JointConfig>& joint_cfg);
boost::shared_ptr<Link> getParentLink() const;
boost::shared_ptr<Link> getChildLink() const;
void setParentLink(const boost::shared_ptr<Link>& link);
void setChildLink(const boost::shared_ptr<Link>& link);
JointType getJointType() const;
const Transform3f& getTransformToParent() const;
void setTransformToParent(const Transform3f& t);
protected:
/// links to parent and child are only for connection, so weak_ptr to avoid cyclic dependency
boost::weak_ptr<Link> link_parent_, link_child_;
JointType type_;
std::string name_;
boost::shared_ptr<JointConfig> joint_cfg_;
Transform3f transform_to_parent_;
};
class PrismaticJoint : public Joint
{
public:
PrismaticJoint(const boost::shared_ptr<Link>& link_parent, const boost::shared_ptr<Link>& link_child,
const Transform3f& transform_to_parent,
const std::string& name,
const Vec3f& axis);
virtual ~PrismaticJoint() {}
Transform3f getLocalTransform() const;
std::size_t getNumDofs() const;
const Vec3f& getAxis() const;
protected:
Vec3f axis_;
};
class RevoluteJoint : public Joint
{
public:
RevoluteJoint(const boost::shared_ptr<Link>& link_parent, const boost::shared_ptr<Link>& link_child,
const Transform3f& transform_to_parent,
const std::string& name,
const Vec3f& axis);
virtual ~RevoluteJoint() {}
Transform3f getLocalTransform() const;
std::size_t getNumDofs() const;
const Vec3f& getAxis() const;
protected:
Vec3f axis_;
};
class BallEulerJoint : public Joint
{
public:
BallEulerJoint(const boost::shared_ptr<Link>& link_parent, const boost::shared_ptr<Link>& link_child,
const Transform3f& transform_to_parent,
const std::string& name);
virtual ~BallEulerJoint() {}
std::size_t getNumDofs() const;
Transform3f getLocalTransform() const;
};
}
#endif
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2011-2014, Willow Garage, Inc.
* Copyright (c) 2014-2015, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Dalibor Matura, Jia Pan */
#ifndef FCL_ARTICULATED_MODEL_JOINT_CONFIG_H
#define FCL_ARTICULATED_MODEL_JOINT_CONFIG_H
#include <hpp/fcl/data_types.h>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <vector>
namespace fcl
{
class Joint;
class JointConfig
{
public:
JointConfig();
JointConfig(const JointConfig& joint_cfg);
JointConfig(const boost::shared_ptr<Joint>& joint,
FCL_REAL default_value = 0,
FCL_REAL default_value_min = 0,
FCL_REAL default_value_max = 0);
std::size_t getDim() const;
inline FCL_REAL operator [] (std::size_t i) const
{
return values_[i];
}
inline FCL_REAL& operator [] (std::size_t i)
{
return values_[i];
}
FCL_REAL getValue(std::size_t i) const;
FCL_REAL& getValue(std::size_t i);
FCL_REAL getLimitMin(std::size_t i) const;
FCL_REAL& getLimitMin(std::size_t i);
FCL_REAL getLimitMax(std::size_t i) const;
FCL_REAL& getLimitMax(std::size_t i);
boost::shared_ptr<Joint> getJoint() const;
private:
boost::weak_ptr<Joint> joint_;
std::vector<FCL_REAL> values_;
std::vector<FCL_REAL> limits_min_;
std::vector<FCL_REAL> limits_max_;
};
}
#endif
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2011-2014, Willow Garage, Inc.
* Copyright (c) 2014-2015, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Dalibor Matura, Jia Pan */
#ifndef FCL_ARTICULATED_MODEL_LINK_H
#define FCL_ARTICULATED_MODEL_LINK_H
#include <hpp/fcl/data_types.h>
#include <hpp/fcl/collision_object.h>
#include <boost/shared_ptr.hpp>
#include <vector>
namespace fcl
{
class Joint;
class Link
{
public:
Link(const std::string& name);
const std::string& getName() const;
void setName(const std::string& name);
void addChildJoint(const boost::shared_ptr<Joint>& joint);
void setParentJoint(const boost::shared_ptr<Joint>& joint);
void addObject(const boost::shared_ptr<CollisionObject>& object);
std::size_t getNumChildJoints() const;
std::size_t getNumObjects() const;
protected:
std::string name_;
std::vector<boost::shared_ptr<CollisionObject> > objects_;
std::vector<boost::shared_ptr<Joint> > children_joints_;
boost::shared_ptr<Joint> parent_joint_;
};
}
#endif
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2011-2014, Willow Garage, Inc.
* Copyright (c) 2014-2015, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Dalibor Matura, Jia Pan */
#ifndef FCL_ARTICULATED_MODEL_MODEL_H
#define FCL_ARTICULATED_MODEL_MODEL_H
#include <hpp/fcl/articulated_model/joint.h>
#include <hpp/fcl/articulated_model/link.h>
#include <hpp/fcl/data_types.h>
#include <boost/shared_ptr.hpp>
#include <map>
#include <stdexcept>
namespace fcl
{
class ModelParseError : public std::runtime_error
{
public:
ModelParseError(const std::string& error_msg) : std::runtime_error(error_msg) {}
};
class Model
{
public:
Model() {}
virtual ~Model() {}
const std::string& getName() const;
void addLink(const boost::shared_ptr<Link>& link);
void addJoint(const boost::shared_ptr<Joint>& joint);
void initRoot(const std::map<std::string, std::string>& link_parent_tree);
void initTree(std::map<std::string, std::string>& link_parent_tree);
std::size_t getNumDofs() const;
std::size_t getNumLinks() const;
std::size_t getNumJoints() const;
boost::shared_ptr<Link> getRoot() const;
boost::shared_ptr<Link> getLink(const std::string& name) const;
boost::shared_ptr<Joint> getJoint(const std::string& name) const;
std::vector<boost::shared_ptr<Link> > getLinks() const;
std::vector<boost::shared_ptr<Joint> > getJoints() const;
protected:
boost::shared_ptr<Link> root_link_;
std::map<std::string, boost::shared_ptr<Link> > links_;
std::map<std::string, boost::shared_ptr<Joint> > joints_;
std::string name_;
};
}
#endif
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2011-2014, Willow Garage, Inc.
* Copyright (c) 2014-2015, Open Source Robotics Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Open Source Robotics Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/** \author Dalibor Matura, Jia Pan */
#ifndef FCL_ARTICULATED_MODEL_MODEL_CONFIG_H
#define FCL_ARTICULATED_MODEL_MODEL_CONFIG_H
#include <hpp/fcl/data_types.h>
#include <hpp/fcl/articulated_model/joint_config.h>
#include <string>
#include <map>
#include <boost/weak_ptr.hpp>
#include <boost/shared_ptr.hpp>
namespace fcl
{
class ModelConfig
{
public:
ModelConfig();
ModelConfig(const ModelConfig& model_cfg);
ModelConfig(std::map<std::string, boost::shared_ptr<Joint> > joints_map);
JointConfig getJointConfigByJointName(const std::string& joint_name) const;
JointConfig& getJointConfigByJointName(const std::string& joint_name);
JointConfig getJointConfigByJoint(boost::shared_ptr<Joint> joint) const;
JointConfig& getJointConfigByJoint(boost::shared_ptr<Joint> joint);
std::map<std::string, JointConfig> getJointCfgsMap() const
{ return joint_cfgs_map_; }
private:
std::map<std::string, JointConfig> joint_cfgs_map_;
};
}
#endif
#ifndef FCL_MATH_SAMPLING_H
#define FCL_MATH_SAMPLING_H
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_real.hpp>
#include <boost/random/normal_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/assign/list_of.hpp>
#include <hpp/fcl/math/vec_nf.h>
#include <hpp/fcl/math/transform.h>
namespace fcl
{
/// @brief Random number generation. An instance of this class
/// cannot be used by multiple threads at once (member functions
/// are not const). However, the constructor is thread safe and
/// different instances can be used safely in any number of
/// threads. It is also guaranteed that all created instances will
/// have a different random seed.
class RNG
{
public:
/// @brief Constructor. Always sets a different random seed
RNG();
/// @brief Generate a random real between 0 and 1
double uniform01()
{
return uni_();
}
/// @brief Generate a random real within given bounds: [\e lower_bound, \e upper_bound)
double uniformReal(double lower_bound, double upper_bound)
{
assert(lower_bound <= upper_bound);
return (upper_bound - lower_bound) * uni_() + lower_bound;
}
/// @brief Generate a random integer within given bounds: [\e lower_bound, \e upper_bound]
int uniformInt(int lower_bound, int upper_bound)
{
int r = (int)floor(uniformReal((double)lower_bound, (double)(upper_bound) + 1.0));
return (r > upper_bound) ? upper_bound : r;
}
/// @brief Generate a random boolean
bool uniformBool()
{
return uni_() <= 0.5;
}
/// @brief Generate a random real using a normal distribution with mean 0 and variance 1
double gaussian01()
{
return normal_();
}
/// @brief Generate a random real using a normal distribution with given mean and variance
double gaussian(double mean, double stddev)
{
return normal_() * stddev + mean;
}
/// @brief Generate a random real using a half-normal distribution. The value is within specified bounds [\e r_min, \e r_max], but with a bias towards \e r_max. The function is implemended using a Gaussian distribution with mean at \e r_max - \e r_min. The distribution is 'folded' around \e r_max axis towards \e r_min. The variance of the distribution is (\e r_max - \e r_min) / \e focus. The higher the focus, the more probable it is that generated numbers are close to \e r_max.
double halfNormalReal(double r_min, double r_max, double focus = 3.0);