Aikido
util.hpp
Go to the documentation of this file.
1 #ifndef AIKIDO_ROBOT_UTIL_HPP_
2 #define AIKIDO_ROBOT_UTIL_HPP_
3 
4 #include <dart/dart.hpp>
5 #include <dart/dynamics/dynamics.hpp>
6 
8 #include "aikido/common/RNG.hpp"
14 #include "aikido/io/yaml.hpp"
19 
20 namespace aikido {
21 namespace robot {
22 
23 // TODO: These are mostly planning methods used in Robot classes.
24 // The planning methods will be removed once we have a Planner API.
25 namespace util {
26 
28 {
29  VectorFieldPlannerParameters() = default;
31  double linearVelocity,
34  double initialStepSize,
35  double jointLimitTolerance,
37  double linearGain = 1.0,
38  double angularGain = 0.2,
39  double timestep = 0.1)
48  , timestep(timestep){
49  // Do nothing
50  };
51 
52  double linearVelocity;
58  double linearGain;
59  double angularGain;
60  double timestep;
61 };
62 
64 {
66  common::RNG* rng = nullptr,
67  std::size_t maxNumTrials = 5,
68  double maxExtensionDistance = std::numeric_limits<double>::infinity(),
69  double maxDistanceBtwProjections = 0.1,
70  double minStepSize = 0.05,
71  double minTreeConnectionDistance = 0.1,
72  std::size_t projectionMaxIteration = 20,
73  double projectionTolerance = 1e-4)
74  : rng(rng)
82  {
83  // Do nothing
84  }
85 
87  std::size_t maxNumTrials;
90  double minStepSize;
94 };
95 
106  const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
107  const statespace::StateSpace::State* goalState,
108  const constraint::TestablePtr& collisionTestable,
109  common::RNG* rng,
110  double timelimit);
111 
122  const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
123  const std::vector<statespace::StateSpace::State*>& goalStates,
124  const constraint::TestablePtr& collisionTestable,
125  common::RNG* rng,
126  double timelimit);
127 
143  const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
144  const dart::dynamics::BodyNodePtr& bodyNode,
145  const constraint::dart::TSRPtr& tsr,
146  const constraint::TestablePtr& collisionTestable,
147  common::RNG* rng,
148  double timelimit,
149  std::size_t maxNumTrials,
150  const distance::ConstConfigurationRankerPtr& ranker = nullptr);
151 
167  const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
168  const dart::dynamics::BodyNodePtr& bodyNode,
169  const constraint::dart::TSRPtr& goalTsr,
170  const constraint::dart::TSRPtr& constraintTsr,
171  const constraint::TestablePtr& collisionTestable,
172  double timelimit,
173  const CRRTPlannerParameters& crrtParameters = CRRTPlannerParameters());
174 
191  const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
192  const dart::dynamics::BodyNodePtr& body,
193  const Eigen::Vector3d& direction,
194  const constraint::TestablePtr& collisionTestable,
195  double distance,
196  double timelimit,
197  double positionTolerance = 1e-3,
198  double angularTolerance = 1e-3,
199  const VectorFieldPlannerParameters& vfParameters
201  const CRRTPlannerParameters& crrtParameters = CRRTPlannerParameters());
202 
218  const dart::dynamics::MetaSkeletonPtr& metaSkeleton,
219  const dart::dynamics::BodyNodePtr& bodyNode,
220  const constraint::TestablePtr& collisionTestable,
221  const Eigen::Vector3d& direction,
222  double distance,
223  double timelimit,
224  double positionTolerance = 1e-3,
225  double angularTolerance = 1e-3,
226  const CRRTPlannerParameters& crrtParameters = CRRTPlannerParameters());
227 
231 std::unordered_map<std::string, const Eigen::VectorXd>
232 parseYAMLToNamedConfigurations(const YAML::Node& node);
233 
244  const dart::dynamics::BodyNodePtr& bodyNode,
245  const Eigen::Vector3d& direction,
246  double distance,
247  const constraint::dart::TSRPtr& goal,
248  const constraint::dart::TSRPtr& constraint,
249  double positionTolerance = 1e-3,
250  double angularTolerance = 1e-3);
251 
256 Eigen::Isometry3d getLookAtIsometry(
257  const Eigen::Vector3d& positionFrom, const Eigen::Vector3d& positionTo);
258 
264 const dart::dynamics::BodyNode* getBodyNodeOrThrow(
265  const dart::dynamics::MetaSkeleton& skeleton,
266  const std::string& bodyNodeName);
267 
273 dart::dynamics::BodyNode* getBodyNodeOrThrow(
274  dart::dynamics::MetaSkeleton& skeleton, const std::string& bodyNodeName);
275 
276 } // namespace util
277 } // namespace robot
278 } // namespace aikido
279 
280 #endif // AIKIDO_ROBOT_UTIL_HPP_
aikido::robot::util::CRRTPlannerParameters::minStepSize
double minStepSize
Definition: util.hpp:90
aikido::robot::util::VectorFieldPlannerParameters::negativeDistanceTolerance
double negativeDistanceTolerance
Definition: util.hpp:53
aikido::robot::util::VectorFieldPlannerParameters::constraintCheckResolution
double constraintCheckResolution
Definition: util.hpp:57
aikido::robot::util::VectorFieldPlannerParameters::angularGain
double angularGain
Definition: util.hpp:59
aikido::robot::util::CRRTPlannerParameters::CRRTPlannerParameters
CRRTPlannerParameters(common::RNG *rng=nullptr, std::size_t maxNumTrials=5, double maxExtensionDistance=std::numeric_limits< double >::infinity(), double maxDistanceBtwProjections=0.1, double minStepSize=0.05, double minTreeConnectionDistance=0.1, std::size_t projectionMaxIteration=20, double projectionTolerance=1e-4)
Definition: util.hpp:65
aikido::statespace::dart::MetaSkeletonStateSpacePtr
std::shared_ptr< MetaSkeletonStateSpace > MetaSkeletonStateSpacePtr
Definition: MetaSkeletonStateSpace.hpp:17
RNG.hpp
ConfigurationRanker.hpp
aikido::robot::util::VectorFieldPlannerParameters
Definition: util.hpp:27
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
aikido::robot::util::planToConfiguration
trajectory::TrajectoryPtr planToConfiguration(const statespace::dart::MetaSkeletonStateSpacePtr &space, const dart::dynamics::MetaSkeletonPtr &metaSkeleton, const statespace::StateSpace::State *goalState, const constraint::TestablePtr &collisionTestable, common::RNG *rng, double timelimit)
Plan the robot to a specific configuration.
aikido::robot::util::planToEndEffectorOffsetByCRRT
trajectory::InterpolatedPtr planToEndEffectorOffsetByCRRT(const statespace::dart::MetaSkeletonStateSpacePtr &space, const dart::dynamics::MetaSkeletonPtr &metaSkeleton, const dart::dynamics::BodyNodePtr &bodyNode, const constraint::TestablePtr &collisionTestable, const Eigen::Vector3d &direction, double distance, double timelimit, double positionTolerance=1e-3, double angularTolerance=1e-3, const CRRTPlannerParameters &crrtParameters=CRRTPlannerParameters())
Plan to a desired end-effector offset with fixed orientation using CRRT.
aikido::constraint::dart::TSRPtr
std::shared_ptr< TSR > TSRPtr
Definition: TSR.hpp:17
aikido::robot::util::planToTSR
trajectory::TrajectoryPtr planToTSR(const statespace::dart::MetaSkeletonStateSpacePtr &space, const dart::dynamics::MetaSkeletonPtr &metaSkeleton, const dart::dynamics::BodyNodePtr &bodyNode, const constraint::dart::TSRPtr &tsr, const constraint::TestablePtr &collisionTestable, common::RNG *rng, double timelimit, std::size_t maxNumTrials, const distance::ConstConfigurationRankerPtr &ranker=nullptr)
Plan the configuration of the metakeleton such that the specified bodynode is set to a sample in TSR.
aikido::robot::util::VectorFieldPlannerParameters::jointLimitTolerance
double jointLimitTolerance
Definition: util.hpp:56
TSR.hpp
aikido::robot::util::planToConfigurations
trajectory::TrajectoryPtr planToConfigurations(const statespace::dart::MetaSkeletonStateSpacePtr &space, const dart::dynamics::MetaSkeletonPtr &metaSkeleton, const std::vector< statespace::StateSpace::State * > &goalStates, const constraint::TestablePtr &collisionTestable, common::RNG *rng, double timelimit)
Plan the robot to a set of configurations.
aikido::robot::util::CRRTPlannerParameters::projectionTolerance
double projectionTolerance
Definition: util.hpp:93
Spline.hpp
aikido::trajectory::InterpolatedPtr
std::shared_ptr< Interpolated > InterpolatedPtr
Definition: Interpolated.hpp:11
Interpolated.hpp
aikido::trajectory::TrajectoryPtr
std::shared_ptr< Trajectory > TrajectoryPtr
Definition: Trajectory.hpp:13
aikido::robot::util::VectorFieldPlannerParameters::linearVelocity
double linearVelocity
Definition: util.hpp:50
aikido::robot::util::VectorFieldPlannerParameters::VectorFieldPlannerParameters
VectorFieldPlannerParameters(double linearVelocity, double negativeDistanceTolerance, double positiveDistanceTolerance, double initialStepSize, double jointLimitTolerance, double constraintCheckResolution, double linearGain=1.0, double angularGain=0.2, double timestep=0.1)
Definition: util.hpp:30
yaml.hpp
aikido::robot::util::planToEndEffectorOffset
trajectory::TrajectoryPtr planToEndEffectorOffset(const statespace::dart::MetaSkeletonStateSpacePtr &space, const dart::dynamics::MetaSkeletonPtr &metaSkeleton, const dart::dynamics::BodyNodePtr &body, const Eigen::Vector3d &direction, const constraint::TestablePtr &collisionTestable, double distance, double timelimit, double positionTolerance=1e-3, double angularTolerance=1e-3, const VectorFieldPlannerParameters &vfParameters=VectorFieldPlannerParameters(), const CRRTPlannerParameters &crrtParameters=CRRTPlannerParameters())
Plan to a desired end-effector offset with fixed orientation.
aikido::robot::util::CRRTPlannerParameters
Definition: util.hpp:63
aikido::robot::util::getLookAtIsometry
Eigen::Isometry3d getLookAtIsometry(const Eigen::Vector3d &positionFrom, const Eigen::Vector3d &positionTo)
Get a pose at a point looking at another point.
aikido::common::RNG
Implementation of the C++11 "random engine" concept that uses virtual function calls to erase the typ...
Definition: RNG.hpp:24
CollisionFree.hpp
aikido::distance::ConstConfigurationRankerPtr
std::shared_ptr< const ConfigurationRanker > ConstConfigurationRankerPtr
Definition: ConfigurationRanker.hpp:13
aikido::robot::util::VectorFieldPlannerParameters::VectorFieldPlannerParameters
VectorFieldPlannerParameters()=default
Trajectory.hpp
aikido::robot::util::CRRTPlannerParameters::maxExtensionDistance
double maxExtensionDistance
Definition: util.hpp:88
aikido::robot::util::planToTSRwithTrajectoryConstraint
trajectory::InterpolatedPtr planToTSRwithTrajectoryConstraint(const statespace::dart::MetaSkeletonStateSpacePtr &space, const dart::dynamics::MetaSkeletonPtr &metaSkeleton, const dart::dynamics::BodyNodePtr &bodyNode, const constraint::dart::TSRPtr &goalTsr, const constraint::dart::TSRPtr &constraintTsr, const constraint::TestablePtr &collisionTestable, double timelimit, const CRRTPlannerParameters &crrtParameters=CRRTPlannerParameters())
Returns a Trajectory that moves the configuration of the metakeleton such that the specified bodynode...
aikido::robot::util::getBodyNodeOrThrow
const dart::dynamics::BodyNode * getBodyNodeOrThrow(const dart::dynamics::MetaSkeleton &skeleton, const std::string &bodyNodeName)
Get a specific BodyNode of a MetaSkeleton or throw an execption if it doesn't exist.
aikido::robot::util::VectorFieldPlannerParameters::positiveDistanceTolerance
double positiveDistanceTolerance
Definition: util.hpp:54
Testable.hpp
MetaSkeletonStateSpace.hpp
aikido::robot::util::CRRTPlannerParameters::maxDistanceBtwProjections
double maxDistanceBtwProjections
Definition: util.hpp:89
aikido::robot::util::VectorFieldPlannerParameters::linearGain
double linearGain
Definition: util.hpp:58
aikido::robot::util::CRRTPlannerParameters::rng
common::RNG * rng
Definition: util.hpp:86
aikido::robot::util::CRRTPlannerParameters::maxNumTrials
std::size_t maxNumTrials
Definition: util.hpp:87
ExecutorThread.hpp
aikido::statespace::StateSpace::State
Definition: StateSpace.hpp:167
aikido::robot::util::VectorFieldPlannerParameters::initialStepSize
double initialStepSize
Definition: util.hpp:55
aikido::constraint::TestablePtr
std::shared_ptr< Testable > TestablePtr
Definition: Testable.hpp:13
aikido::robot::util::VectorFieldPlannerParameters::timestep
double timestep
Definition: util.hpp:60
aikido::robot::util::getGoalAndConstraintTSRForEndEffectorOffset
bool getGoalAndConstraintTSRForEndEffectorOffset(const dart::dynamics::BodyNodePtr &bodyNode, const Eigen::Vector3d &direction, double distance, const constraint::dart::TSRPtr &goal, const constraint::dart::TSRPtr &constraint, double positionTolerance=1e-3, double angularTolerance=1e-3)
Gets Goal and Constraint TSR for end-effector.
TrajectoryExecutor.hpp
aikido::robot::util::CRRTPlannerParameters::projectionMaxIteration
std::size_t projectionMaxIteration
Definition: util.hpp:92
aikido::robot::util::parseYAMLToNamedConfigurations
std::unordered_map< std::string, const Eigen::VectorXd > parseYAMLToNamedConfigurations(const YAML::Node &node)
Parses YAML node for named configurtaions.
aikido::robot::util::CRRTPlannerParameters::minTreeConnectionDistance
double minTreeConnectionDistance
Definition: util.hpp:91