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

Feature/vector field planner #246

Merged
merged 41 commits into from
Oct 30, 2017
Merged

Feature/vector field planner #246

merged 41 commits into from
Oct 30, 2017

Conversation

dqyi11
Copy link
Contributor

@dqyi11 dqyi11 commented Oct 20, 2017

[A vector field planner that generate trajectories based on defined vector fields. Currently only a vector field for straight hand movement is added.]


Before creating a pull request

  • Document new methods and classes
  • Format code with make format

Before merging a pull request

  • Set version target by selecting a milestone on the right side
  • Summarize this change in CHANGELOG.md
  • Add unit test(s) for this change

@dqyi11 dqyi11 added this to the Aikido 0.2.0 milestone Oct 20, 2017
@codecov
Copy link

codecov bot commented Oct 20, 2017

Codecov Report

Merging #246 into master will increase coverage by 0.42%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
+ Coverage   70.48%   70.91%   +0.42%     
==========================================
  Files         181      173       -8     
  Lines        5476     5126     -350     
  Branches      870      811      -59     
==========================================
- Hits         3860     3635     -225     
+ Misses       1092     1002      -90     
+ Partials      524      489      -35
Impacted Files Coverage Δ
src/control/ros/Conversions.cpp 69.16% <100%> (+0.54%) ⬆️
src/planner/World.cpp 82.53% <100%> (-1.14%) ⬇️
src/statespace/dart/SO3Joint.cpp 28.57% <0%> (-71.43%) ⬇️
src/planner/ompl/CRRT.cpp 63.37% <0%> (-0.59%) ⬇️
...e/dart/detail/MetaSkeletonStateSpaceSaver-impl.hpp

Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

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

I know most of the code came from @mkoval 's code, but you should convert the code style to AIKIDO! 😈

This is just about code style. Let me do another round once they are fixed. 😄

CHANGELOG.md Outdated

* Planner

* Added vector field planner [#246](https://github.com/personalrobotics/aikido/pull/246)
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this under the below section for 0.2.0. It's duplicated.

@@ -0,0 +1,87 @@
#ifndef AIKIDO_PLANNER_VECTOR_FIELD_PLANNER_HPP_
#define AIKIDO_PLANNER_VECTOR_FIELD_PLANNER_HPP_
Copy link
Member

Choose a reason for hiding this comment

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

Nit: AIKIDO_PLANNER_VECTORFIELD_VECTORFIELDPLANNER_HPP_. The convention is not to put space for a name or a directory name (e.g., not VECTOR_FIELD_PLANNER but VECTORFIELDPLANNER).

CACHE_AND_CONTINUE,
CONTINUE
};
};
Copy link
Member

Choose a reason for hiding this comment

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

If you put this enum in a struct is to avoid scope confliction, you could consider using enum class, which is introduced in C++11.

/// Callback function of joint velocity calculated by a vector field and a
/// MetaSkeleton.
/// \param stateSpace MetaSkeleton state space
/// \param t planned time of a given duration
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think the convention is beginning with a capital letter as Planned time .... There are many docstring begin with a lower letter.

/// MetaSkeleton.
/// \param stateSpace MetaSkeleton state space
/// \param t planned time of a given duration
/// \param qd joint velocity calculated by a vector field and meta skeleton
Copy link
Member

Choose a reason for hiding this comment

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

Nit: \param[out] qt Joint velocity ....


/*
* VectorFieldTerminated
*/
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Please remove these redundant comments and add the function definition splitter.

* DofLimitError
*/
DofLimitError::DofLimitError(
dart::dynamics::DegreeOfFreedom* dof, std::string const& what_arg)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: const std::string& whatArg

@@ -0,0 +1,31 @@
#ifndef AIKIDO_PLANNER_VECTORFIELDPLANNEREXCEPTIONS_H_
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 this file to the include directory.

@@ -0,0 +1,31 @@
#ifndef AIKIDO_PLANNER_VECTORFIELDPLANNEREXCEPTIONS_H_
#define AIKIDO_PLANNER_VECTORFIELDPLANNEREXCEPTIONS_H_
#include <string>
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 an empty line after the header guard.

@@ -0,0 +1,31 @@
#ifndef AIKIDO_PLANNER_VECTORFIELDPLANNEREXCEPTIONS_H_
#define AIKIDO_PLANNER_VECTORFIELDPLANNEREXCEPTIONS_H_
Copy link
Member

Choose a reason for hiding this comment

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

Nit: AIKIDO_PLANNER_VECTORFIELD_VECTORFIELDPLANNEREXCEPTIONS_HPP_

Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

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

I don't know how we exactly started to using nested namespace and subdirectory for aikido::planner::ompl and aikido::planner::parabolic, but I guess this is because these are dependent on external libraries. If that's true, then I think we may don't want to the same thing for vector field planner because it doesn't have any external dependencies. @mkoval, @psigen, @brianhou, @gilwoolee: Do we have the convention here?

Minor comments

  • Please re-run make format.
  • Put the source files the associated header files are under detail directory also to detail directory accordingly.
  • It seems const std::shared_ptr<T> is used where std::shared_ptr<const T> should be used.

}

//==============================================================================

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Remove empty line between a separator and a function definition.

}

//==============================================================================

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Remove empty line between a separator and a function definition.

namespace planner {
namespace vectorfield {

static void CheckDofLimits(
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Function name should use camelCase.

}

//==============================================================================

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Remove empty line between a separator and a function definition.

}

//==============================================================================

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Remove empty line between a separator and a function definition.

double _optimizationTolerance,
double _timestep,
double _padding,
Eigen::VectorXd* _jointVelocity)
Copy link
Member

Choose a reason for hiding this comment

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

This also should be changed to reference as Eigen::VectorXd&.

bool computeJointVelocityFromTwist(
const Eigen::Vector6d& _desiredTwist,
const aikido::statespace::dart::MetaSkeletonStateSpacePtr _stateSpace,
const 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.

Nit: const dart::dynamics::ConstBodyNodePtr&


bool computeJointVelocityFromTwist(
const Eigen::Vector6d& _desiredTwist,
const aikido::statespace::dart::MetaSkeletonStateSpacePtr _stateSpace,
Copy link
Member

Choose a reason for hiding this comment

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

Let's define const shared_ptr type as using ConstMetaSkeletonStateSpacePtr = std::shared_ptr<const MetaSkeletonStateSpace> in MetaSkeletonStateSpace.hpp and replace this to const aikido::statespace::dart::ConstMetaSkeletonStateSpacePtr&

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 change seems not supporting MetaSkeletonStateSpaceSaver.


const auto problem = std::make_shared<Problem>(numDofs);
problem->setLowerBounds(lowerLimits);
problem->setUpperBounds(upperLimits);
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 could optimize this code a bit by passing velocityLowerLimits and velocityUpperLimits instead of passing the copies of them. This could be simply done by changing the above if-statement as:

    if (position
        < positionLowerLimit - _timestep * velocityLowerLimit + _padding)
      velocityLowerLimits[i] = 0.0;

    if (position
        > positionUpperLimit - _timestep * velocityUpperLimit - _padding)
      velocityUpperLimits[i] = 0.0;


if (position
< positionLowerLimit - _timestep * velocityLowerLimit + _padding)
lowerLimits[i] = 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 restriction can be a little bit relaxed. Current logic just sets the velocity to zero when the integrated position with the velocity exceeds the padded position limit. However, if the current position doesn't yet exceed the padded position limit, then it would be fine to integrate the position towards the padded position limit with the proper velocity, which might be less than the velocity limit.

I propose to change the logic as

lowerLimits[i] = std::max(velocityLowerLimits[i], ((velocityLowerLimits[i] + _padding) - position) / _timestep);

Similarly, below can be changed as

upperLimits[i] = std::min(velocityUpperLimits[i], ((velocityUpperLimits[i] - _padding) - position) / _timestep);

One (positive I think) side effect is that the new logic will compute lower/upperLimits that will fix the current position limit violations if there are.

Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

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

I think class MoveHandStraightVectorField should be exposed instead of putting it under detail because this is reusable by the users.

@brianhou brianhou merged commit f46c2af into master Oct 30, 2017
@brianhou brianhou deleted the feature/VectorFieldPlanner branch October 30, 2017 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants