Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New vector field planner impelementation #268

Merged
merged 34 commits into from
Dec 10, 2017
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5a30b77
new vector field planner and added move end effector pose vector field
dqyi11 Nov 24, 2017
15e7fe0
add move to end effector pose test cases
dqyi11 Nov 25, 2017
57d342e
merge from master
dqyi11 Nov 25, 2017
b7fc1b5
refactor code and format
dqyi11 Nov 26, 2017
99a3706
add new tests to plan to end effector pose
dqyi11 Nov 26, 2017
8870a96
add functions of enabling collision checking and dof limit checking
dqyi11 Nov 26, 2017
a6f9ace
fix doc strings
dqyi11 Nov 26, 2017
b471f86
add velocity gain to support controlling in complex scenarios
Nov 27, 2017
2c80af7
Merge branch 'master' into enhancement/dqyi/vectorFieldPlanner
jslee02 Nov 28, 2017
5aa1f22
add new class for collision error
dqyi11 Nov 28, 2017
e7f506a
Merge branch 'enhancement/dqyi/vectorFieldPlanner' of https://github.…
dqyi11 Nov 28, 2017
3d501b6
address JS's comments
dqyi11 Nov 29, 2017
cec4bf3
address JS's comments and add doc strings for some member variables
dqyi11 Nov 29, 2017
0c89b74
Fix const-correctness in ConfigurationSpaceVectorField
jslee02 Nov 29, 2017
c35fc80
Fix code style
jslee02 Nov 29, 2017
28dc85f
fix doc string style
dqyi11 Nov 29, 2017
45ee24a
Add invalid max distance variable
jslee02 Nov 30, 2017
ced7229
update cpde style
dqyi11 Nov 30, 2017
2ef5f78
fix code style
dqyi11 Nov 30, 2017
78d57c1
fix typos
dqyi11 Nov 30, 2017
74272f6
address Mike's comments
dqyi11 Dec 5, 2017
a5221d6
Merge branch 'master' into enhancement/dqyi/vectorFieldPlanner
dqyi11 Dec 5, 2017
81f3ba2
add parameter for constraint check resolution
dqyi11 Dec 5, 2017
5be7e08
add doc strings, moved implementation details, add plannerStatus as o…
dqyi11 Dec 5, 2017
cda62da
address Mike's comments
dqyi11 Dec 7, 2017
fdd6562
update for formatting
dqyi11 Dec 7, 2017
85c93d7
Merge branch 'master' into enhancement/dqyi/vectorFieldPlanner
brianhou Dec 7, 2017
b2dc8f2
Merge branch 'master' into enhancement/dqyi/vectorFieldPlanner
brianhou Dec 8, 2017
46c0bae
address Mike's comments
dqyi11 Dec 9, 2017
8ba6b05
Merge branch 'enhancement/dqyi/vectorFieldPlanner' of https://github.…
dqyi11 Dec 9, 2017
daf3120
address Mike's comments
Dec 9, 2017
a4c3fd1
change to use TestableIntersection
dqyi11 Dec 9, 2017
79e9f1d
fix doc strings
dqyi11 Dec 10, 2017
cbca871
add changelog.md
dqyi11 Dec 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#ifndef AIKIDO_PLANNER_VECTORFIELD_CONFIGURATIONSPACEVECTORFIELD_HPP_
#define AIKIDO_PLANNER_VECTORFIELD_CONFIGURATIONSPACEVECTORFIELD_HPP_

#include <aikido/planner/vectorfield/VectorFieldPlannerStatus.hpp>
#include <aikido/statespace/dart/MetaSkeletonStateSpace.hpp>

namespace aikido {
namespace planner {
namespace vectorfield {

/// This class defines a vector field in a configuration space
///
/// Any vector field should inherit this class to implememnt functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "implememnt" -> "implement"

/// for calculating joint velocities giving joint positions and time,
/// and checking planning status.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what "and time" means here. I think this should just say "joint positions."

To be pedantic, we shouldn't be referring to joints at all in this class. A vector field is defined over an abstract state space - it does not technically even have to be a MetaSkeletonStateSpace!

class ConfigurationSpaceVectorField
{
public:
/// Constructor
///
/// \param[in] _stateSpace MetaSkeleton state space
/// \param[in] _bn Body node of end-effector
ConfigurationSpaceVectorField(
aikido::statespace::dart::MetaSkeletonStateSpacePtr _stateSpace,
dart::dynamics::BodyNodePtr _bodyNode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A generic vector field can be defined on any state space, not only MetaSkeletonStateSpaces. Also, it is not necessarily parameterized by a BodyNode. Those are implementation details of how some vector fields are implemented, e.g. those that move a BodyNode along a constraint. I think we should replace MetaSkeletonStateSpace with StateSpace and remove all of the reference to BodyNodes from this base class.

It would also be useful to introduce a subclass that handles the conversion from task space to configuration space. That class could take a BodyNodePtr and handle the necessary Jacobian calculations to convert a twist in SE(3) to the tangent space of the MetaSkeleton's configuration space.


/// Vectorfield callback function
///
/// \param[out] _qd Joint velocities
/// \return Whether joint velocities are successfully computed
virtual bool getJointVelocities(Eigen::VectorXd& _qd) const = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should take a StateSpace::State * output parameter, not an Eigen::VectorXd.


/// Vectorfield planning status callback function
///
/// \return Status of planning
virtual VectorFieldPlannerStatus checkPlanningStatus() const = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this function get it's input from? This function should take a const StateSpace::State * as an argument at a minimum. Ideally, we would pass the entire trajectory that has already been integrated - but that would be significantly more difficult to implement.


/// Meta skeleton state space
aikido::statespace::dart::MetaSkeletonStateSpacePtr
getMetaSkeletonStateSpace() const;

/// Returns meta skeleton
dart::dynamics::MetaSkeletonPtr getMetaSkeleton();

/// Returns const meta skeleton
dart::dynamics::ConstMetaSkeletonPtr getMetaSkeleton() const;

/// Returns body node of end-effector
dart::dynamics::BodyNodePtr getBodyNode();

/// Returns const body node of end-effector
dart::dynamics::ConstBodyNodePtr getBodyNode() const;

protected:
/// State space of vector field
aikido::statespace::dart::MetaSkeletonStateSpacePtr mStateSpace;
/// Meta Skeleton of state space
dart::dynamics::MetaSkeletonPtr mMetaSkeleton;
/// BodyNode of end-effector
dart::dynamics::BodyNodePtr mBodyNode;
};

using ConfigurationSpaceVectorFieldPtr
= std::shared_ptr<ConfigurationSpaceVectorField>;

} // namespace vectorfield
} // namespace planner
} // namespace aikido

#endif // AIKIDO_PLANNER_VECTORFIELD_CONFIGURATIONSPACEVECTORFIELD_HPP_
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef AIKIDO_PLANNER_VECTORFIELD_MOVEENDEFFECTOROFFSETVECTORFIELD_HPP_
#define AIKIDO_PLANNER_VECTORFIELD_MOVEENDEFFECTOROFFSETVECTORFIELD_HPP_

#include <aikido/planner/vectorfield/VectorFieldPlanner.hpp>
#include <aikido/planner/vectorfield/ConfigurationSpaceVectorField.hpp>

namespace aikido {
namespace planner {
Expand All @@ -12,70 +12,68 @@ namespace vectorfield {
/// This class defines two callback functions for vectorfield planner.
/// One for generating joint velocity in MetaSkeleton state space,
/// and one for determining vectorfield planner status.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a short description of what the vector field does. E.g. what equation it implements and what the intended use-case is.

class MoveEndEffectorOffsetVectorField
class MoveEndEffectorOffsetVectorField : public ConfigurationSpaceVectorField
{
public:
/// Constructor
///
/// \param[in] _stateSpace MetaSkeleton state space
/// \param[in] _bn Body node of end-effector
/// \param[in] _linearVelocity Linear velocity in all the directions
/// \param[in] _startTime Start time of a planned trajectory
/// \param[in] _endTime End time of a planned trajectory
/// \param[in] _timestep Time step size
/// \param[in] _linearGain Gain of P control on linear deviation
/// \param[in] _linearTolerance Tolerance on linear deviation
/// \param[in] _angularGain Gain of P control on angular deviation
/// \param[in] _angularTolerance Tolerance on angular deviation
/// \param[in] _direction Unit vector in the direction of motion
/// \param[in] _distance Minimum distance in meters
/// \param[in] _maxDistance Maximum distance in meters
/// \param[in] _positionTolerance Constraint tolerance in meters
/// \param[in] _angularTolerance Constraint tolerance in radians
/// \param[in] _linearVelocityGain Linear velocity gain in workspace.
/// \param[in] _initialStepSize Initial step size
/// \param[in] _jointLimitPadding If less then this distance to joint
/// limit, velocity is bounded in that direction to 0
/// \param[in] _optimizationTolerance Tolerance on optimization
/// \param[in] _padding Padding to the boundary
MoveEndEffectorOffsetVectorField(
aikido::statespace::dart::MetaSkeletonStateSpacePtr _stateSpace,
dart::dynamics::BodyNodePtr _bn,
const Eigen::Vector3d& _linearVelocity,
double _startTime,
double _endTime,
double _timestep,
double _linearGain = 1.,
double _linearTolerance = 0.01,
double _angularGain = 1.,
double _angularTolerance = 0.01,
double _optimizationTolerance = 1e-3,
double _padding = 1e-5);
const Eigen::Vector3d& _direction,
double _distance,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: _minDistance to be consistent with _maxDistance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is following the naming in prpy. This is usually the expected distance to move. The planner will terminate once this distance is reached. It will fail it _maxDistance is reached.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not what the planner currently does it PrPy. It integrates as far as possible until it either reaches _maxDistance or is unable to continue. Then, it returns success if the resulting trajectory has length greater than _distance. I.e. the planner will return a trajectory of length [_distance, _maxDistance] upon success.

I agree with @jslee02's naming suggestion - I think _minDistance is more descriptive.

double _maxDistance = std::numeric_limits<double>::max(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns the maximum finite double. Why not use infinity() instead?

double _positionTolerance = 0.01,
double _angularTolerance = 0.15,
double _linearVelocityGain = 1.0,
double _initialStepSize = 1e-1,
double _jointLimitPadding = 3e-2,
double _optimizationTolerance = 1e-3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally try to avoid putting these type of defaults in Aikido because they tend to only work well for one robot, e.g. HERB. These numbers would have to be re-tuned for a robot with a different size workspace.

I suggest making these mandatory arguments and providing good defaults for HERB in libherb.


/// Vectorfield callback function
///
/// \param[in] _stateSpace MetaSkeleton state space
/// \param[in] _t Current time being planned
/// \param[out] _dq Joint velocities
/// \param[out] _qd Joint velocities
/// \return Whether joint velocities are successfully computed
bool operator()(
const aikido::statespace::dart::MetaSkeletonStateSpacePtr& _stateSpace,
double _t,
Eigen::VectorXd& _dq);
bool getJointVelocities(Eigen::VectorXd& _qd) const override;

/// Vectorfield planning status callback function
///
/// \param[in] _stateSpace MetaSkeleton state space
/// \param[in] _t Current time being planned
/// \return Status of planning
VectorFieldPlannerStatus operator()(
const aikido::statespace::dart::MetaSkeletonStateSpacePtr& _stateSpace,
double _t);
VectorFieldPlannerStatus checkPlanningStatus() const override;

private:
dart::dynamics::BodyNodePtr mBodynode;
Eigen::Vector3d mVelocity;
Eigen::Vector3d mLinearDirection;
double mStartTime;
double mEndTime;
double mTimestep;
double mLinearGain;
double mLinearTolerance;
double mAngularGain;
protected:
/// Movement direction.
Eigen::Vector3d mDirection;
/// Movement distance.
double mDistance;
/// Maximum distance allowed to move.
double mMaxDistance;
/// Tolerance of linear deviation error.
double mPositionTolerance;
/// Tolerance of angular error.
double mAngularTolerance;
/// Linear velocity gain.
double mLinearVelocityGain;
/// Initial step size in adaptive integration.
double mInitialStepSize;
/// Padding for joint limits.
double mJointLimitPadding;
/// Tolerance of optimization solver.
double mOptimizationTolerance;
double mPadding;
/// Start pose of the end-effector.
Eigen::Isometry3d mStartPose;
Eigen::Isometry3d mTargetPose;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should flag this class with EIGEN_MAKE_ALIGNED_OPERATOR_NEW. See my comment on MoveEndEffectorPoseVectorField.

};

} // namespace vectorfield
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#ifndef AIKIDO_PLANNER_VECTORFIELD_MOVEENDEFFECTORPOSEVECTORFIELD_HPP_
#define AIKIDO_PLANNER_VECTORFIELD_MOVEENDEFFECTORPOSEVECTORFIELD_HPP_

#include <aikido/planner/vectorfield/ConfigurationSpaceVectorField.hpp>

namespace aikido {
namespace planner {
namespace vectorfield {

/// Vector field for moving end-effector by a direction and distance.
///
/// This class defines two callback functions for vectorfield planner.
/// One for generating joint velocity in MetaSkeleton state space,
/// and one for determining vectorfield planner status.
class MoveEndEffectorPoseVectorField : public ConfigurationSpaceVectorField
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide a short description of what the vector field does. E.g. what equation it implements and what the intended use-case is.

{
public:
/// Constructor
///
/// \param[in] _stateSpace MetaSkeleton state space
/// \param[in] _bn Body node of end-effector
/// \param[in] _goalPose Desired end-effector pose
/// \param[in] _poseErrorTolerance Constraint error tolerance in meters
/// \param[in] _linearVelocityGain Linear velocity gain in workspace
/// \param[in] _angularVelocityGain Angular velocity gain in workspace
/// \param[in] _initialStepSize Initial step size
/// \param[in] _jointLimitPadding If less then this distance to joint
/// limit, velocity is bounded in that direction to 0
/// \param[in] _optimizationTolerance Tolerance on optimization
MoveEndEffectorPoseVectorField(
aikido::statespace::dart::MetaSkeletonStateSpacePtr _stateSpace,
dart::dynamics::BodyNodePtr _bn,
const Eigen::Isometry3d& _goalPose,
double _linearVelocityGain = 1.0,
double _angularVelocityGain = 1.0,
double _poseErrorTolerance = 0.5,
double _initialStepSize = 1e-1,
double _jointLimitPadding = 3e-2,
double _optimizationTolerance = 5e-2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove these defaults. See my comment on MoveEndEffectorOffsetVectorField .


/// Vectorfield callback function
///
/// \param[in] _q Position in configuration space
/// \param[in] _t Current time being planned
/// \param[out] _qd Joint velocities
/// \return Whether joint velocities are successfully computed
bool getJointVelocities(Eigen::VectorXd& _qd) const override;

/// Vectorfield planning status callback function
///
/// \param[in] _q Position in configuration space
/// \param[in] _t Current time being planned
/// \return Status of planning
VectorFieldPlannerStatus checkPlanningStatus() const override;

protected:
/// Goal pose.
Eigen::Isometry3d mGoalPose;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This object contains a Isometry3d member variable, which is a fixed-size vectorizable type. Therefore, we should flag this class with EIGEN_MAKE_ALIGNED_OPERATOR_NEW.

/// Tolerance of pose error.
double mPoseErrorTolerance;
/// Linear velocity gain.
double mLinearVelocityGain;
/// Angular velocit gain.
double mAngularVelocityGain;
/// Initial step size of adaptive integration.
double mInitialStepSize;
/// Padding of joint limits
double mJointLimitPadding;
/// Tolerance of optimization solver.
double mOptimizationTolerance;
Eigen::VectorXd mVelocityLowerLimits;
Eigen::VectorXd mVelocityUpperLimits;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This object contains a Isometry3d member variable, which is a fixed-size vectorizable type. Therefore, we should flag this class with EIGEN_MAKE_ALIGNED_OPERATOR_NEW.


} // namespace vectorfield
} // namespace planner
} // namespace aikido

#endif // ifndef
// AIKIDO_PLANNER_VECTORFIELD_MOVEENDEFFECTORPOSEVECTORFIELD_HPP_
Loading