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 8 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,75 @@
#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 filed 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: filed --> field

/// 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)
: mStateSpace(_stateSpace)
, mMetaSkeleton(_stateSpace->getMetaSkeleton())
, mBodyNode(_bodyNode)
{
}
Copy link
Member

Choose a reason for hiding this comment

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

Please move the function definitions to the .cpp file.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Add // Do nothing to indicate this function is intentionally empty.


/// Vectorfield callback function
///
/// \param[out] _qd Joint velocities
/// \return Whether joint velocities are successfully computed
virtual bool getJointVelocities(Eigen::VectorXd& _qd) = 0;
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 this function can be a const function.


/// Vectorfield planning status callback function
///
/// \return Status of planning
virtual VectorFieldPlannerStatus checkPlanningStatus() = 0;
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 this function can be a const function.


/// Meta skeleton spate space
Copy link
Member

Choose a reason for hiding this comment

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

Typo: spate --> state

virtual aikido::statespace::dart::MetaSkeletonStateSpacePtr
Copy link
Member

@jslee02 jslee02 Nov 28, 2017

Choose a reason for hiding this comment

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

Why are these functions (and below getters) virtual? Any possibility that a subclass overrides this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I don't know why I wrote that way. Good catch! Thanks!

getMetaSkeletonStateSpace()
{
return mStateSpace;
}
Copy link
Member

@jslee02 jslee02 Nov 28, 2017

Choose a reason for hiding this comment

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

Please add const functions for

  • getMetaSkeletonStateSpace()
  • getMetaSkeleton()
  • getBodyNode()

that return pointers to const objects accordingly like aikido::statespace::dart::MetaSkeletonStateSpaceConstPtr getMetaSkeletonStateSpace() const where MetaSkeletonStateSpaceConstPtr is defined as using MetaSkeletonStateSpaceConstPtr = std::shared_ptr<const MetaSkeletonStateSpace>.

This is necessary for const-correctness. Without const functions of this getters, a const instance of ConfigurationSpaceVectorField might be able to modify the MetaSkeletonStateSpace through this getter for example, which is not an expected behavior from a const instance.

Edit: MetaSkeletonStateSpaceConstPtr --> ConstMetaSkeletonStateSpacePtr

Copy link
Contributor Author

@dqyi11 dqyi11 Nov 29, 2017

Choose a reason for hiding this comment

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

Should ConstPtr be defined in original header file? Fox example using MetaSkeletonStateSpaceConstPtr = std::shared_ptr<const MetaSkeletonStateSpace> in MetaSkeletonStateSpace.hpp?


/// Meta skeleton
virtual dart::dynamics::MetaSkeletonPtr getMetaSkeleton()
{
return mMetaSkeleton;
}

/// Body node of end-effector
virtual dart::dynamics::BodyNodePtr getBodyNode()
{
return mBodyNode;
}

protected:
aikido::statespace::dart::MetaSkeletonStateSpacePtr mStateSpace;
dart::dynamics::MetaSkeletonPtr mMetaSkeleton;
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,58 @@ 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] _jointLimitTolerance 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 _jointLimitTolerance = 3e-2,
Copy link
Member

Choose a reason for hiding this comment

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

According to this logic, it seems _jointLimitTolerance is misleading by its name. This logic looks like adding a safe margin to the actual limit. I think this should be renamed to something like jointVelocityLimitMargin or jointVelocityLimitPadding.

Copy link
Contributor Author

@dqyi11 dqyi11 Nov 29, 2017

Choose a reason for hiding this comment

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

Yes. I will use jointLimitPadding. This is the padding for position limit.

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);
virtual bool getJointVelocities(Eigen::VectorXd& _qd) 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);
virtual VectorFieldPlannerStatus checkPlanningStatus() 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:
Eigen::Vector3d mDirection;
double mDistance;
double mMaxDistance;
double mPositionTolerance;
double mAngularTolerance;
double mLinearVelocityGain;
double mInitialStepSize;
double mJointLimitTolerance;
double mOptimizationTolerance;
double mPadding;
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,74 @@
#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 en-effector pose
Copy link
Member

Choose a reason for hiding this comment

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

Typo: en-effector --> end-effector

/// \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] _jointLimitTolerance 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 _jointLimitTolerance = 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
virtual bool getJointVelocities(Eigen::VectorXd& _qd) override;

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

protected:
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.

double mPoseErrorTolerance;
double mLinearVelocityGain;
double mAngularVelocityGain;
double mInitialStepSize;
double mJointLimitTolerance;
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