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

Adds SE2BoxConstraint #135

Merged
merged 41 commits into from
Sep 23, 2017
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
dc493c5
Adds SE2 constraint
gilwoolee Feb 10, 2017
ca0a0c0
Merge branch 'master' into SE2constraint
gilwoolee Apr 4, 2017
fe1c182
Merge branch 'master' into SE2constraint
jslee02 Apr 11, 2017
ce374d6
Merge branch 'master' into SE2constraint
jslee02 Apr 14, 2017
801326c
Fix build errors and warnings
jslee02 May 16, 2017
337e715
Merge remote-tracking branch 'origin/master' into SE2constraint
jslee02 May 16, 2017
757352e
Fix minor styles issues
jslee02 May 16, 2017
3481930
More style update
jslee02 May 16, 2017
c573de5
Use slightly better Eigen operators accordingly
jslee02 May 16, 2017
4486492
Merge branch 'master' into SE2constraint
jslee02 May 23, 2017
cf3d06d
Fix typo
jslee02 Jun 12, 2017
1454a93
Fix conversion between SE(2) and 3-dim vector
jslee02 Jun 12, 2017
85878fa
Address Brian's comments
jslee02 Jun 13, 2017
9b37286
add se2BoxConstraint header
Jun 23, 2017
1252d83
nit: formatting
Jun 23, 2017
f34a1a1
nit
Jun 23, 2017
3ee9d34
add documentation to the member variables
Jun 23, 2017
ea56ec0
make conditions more intuitive(?)
Jun 23, 2017
fafa1d7
weighted distance for SE(2) group
Jun 26, 2017
96771e3
nit and syntax error fix
Jun 26, 2017
9c932f7
enforce weight vector to be of dimension 2 via type
Jun 26, 2017
bb4e0af
remove unused variable - warnings
Jun 26, 2017
61daeb9
create test scripts for SE2 constraint and distance files
Jun 26, 2017
e296d6b
remove ambiguity -> removes build errors
Jun 26, 2017
0c74175
introduce tests for SE2Weighted Distance
Jun 26, 2017
00cbd78
tests for SE2 Distance
Jun 26, 2017
22376f6
tests for SE2BoxConstraint
Jun 26, 2017
3b2c7c8
add more tests for SE2BoxConstraint
Jun 26, 2017
4e6e26d
Merge branch 'master' into SE2constraint
jslee02 Sep 18, 2017
3257249
Fix code format
jslee02 Sep 19, 2017
86b03a3
Fix style
jslee02 Sep 19, 2017
a094477
Fix SE2Weighted::distance to return always positive distance
jslee02 Sep 19, 2017
2f3b2cb
Try to use DART 6.1
jslee02 Sep 19, 2017
d525eb8
Try to use DART 6.1 (reverted from commit 2f3b2cb4eefaa6df49274006bcb…
jslee02 Sep 19, 2017
efc96e3
simplified logic statements; fixed threshold
Sep 20, 2017
99204b9
remove weighted.cpp
Sep 20, 2017
c44447e
introduce cartesianproduct files and make changes in affected files
Sep 20, 2017
69f7802
Edit affected test files
Sep 20, 2017
156baef
warn that weighted is deprecated
Sep 20, 2017
ee789b1
alias
Sep 22, 2017
920d75f
include namespace for weighted
Sep 22, 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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ file(GLOB_RECURSE headers_planner "${CMAKE_SOURCE_DIR}/include/aikido/planner/*.
file(GLOB_RECURSE headers_util "${CMAKE_SOURCE_DIR}/include/aikido/util/*.hpp")
file(GLOB_RECURSE headers_rviz "${CMAKE_SOURCE_DIR}/include/aikido/rviz/*.hpp")
file(GLOB_RECURSE headers_distance "${CMAKE_SOURCE_DIR}/include/aikido/distance/*.hpp")
file(GLOB_RECURSE headers_distance "${CMAKE_SOURCE_DIR}/include/aikido/control/*.hpp")
file(GLOB_RECURSE headers_control "${CMAKE_SOURCE_DIR}/include/aikido/control/*.hpp")
format_add_sources(${headers_statespace})
format_add_sources(${headers_perception})
format_add_sources(${headers_planner})
Expand Down
3 changes: 2 additions & 1 deletion include/aikido/constraint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
#include "constraint/Testable.hpp"
#include "constraint/TestableIntersection.hpp"
#include "constraint/uniform/RnBoxConstraint.hpp"
#include "constraint/uniform/SE2BoxConstraint.hpp"
#include "constraint/uniform/SO2UniformSampler.hpp"
#include "constraint/uniform/SO3UniformSampler.hpp"
#include "constraint/uniform/SO3UniformSampler.hpp"
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "../../statespace/dart/WeldJoint.hpp"
#include "../../util/metaprogramming.hpp"
#include "../uniform/RnBoxConstraint.hpp"
#include "../uniform/SE2BoxConstraint.hpp"
#include "../uniform/SO2UniformSampler.hpp"
#include "../uniform/SO3UniformSampler.hpp"
#include "../uniform/RnConstantSampler.hpp"
Expand Down Expand Up @@ -90,12 +91,16 @@ std::unique_ptr<OutputConstraint> createBoxConstraint(
const auto joint = _stateSpace->getJoint();

if (isLimited(joint))
{
return dart::common::make_unique<RBoxConstraint<N>>(
std::move(_stateSpace), std::move(_rng),
getPositionLowerLimits(joint), getPositionUpperLimits(joint));
}
else
{
return dart::common::make_unique<Satisfied>(
std::move(_stateSpace));
}
}

//=============================================================================
Expand Down Expand Up @@ -301,6 +306,27 @@ struct createSampleableFor_impl<statespace::dart::SO3Joint>
};

//=============================================================================
template <class OutputConstraint>
std::unique_ptr<OutputConstraint> createBoxConstraint(
std::shared_ptr<statespace::dart::SE2Joint> _stateSpace,
std::unique_ptr<util::RNG> _rng)
{
const auto joint = _stateSpace->getJoint();

if (isLimited(joint))
{
return dart::common::make_unique<SE2BoxConstraint>(
std::move(_stateSpace), std::move(_rng),
getPositionLowerLimits(joint).tail<2>(),
getPositionUpperLimits(joint).tail<2>());
}
else
{
return dart::common::make_unique<Satisfied>(
std::move(_stateSpace));
}
}

template <>
struct createDifferentiableFor_impl<statespace::dart::SE2Joint>
{
Expand All @@ -321,10 +347,17 @@ struct createTestableFor_impl<statespace::dart::SE2Joint>
using StateSpace = statespace::dart::SE2Joint;
using StateSpacePtr = std::shared_ptr<StateSpace>;

static std::unique_ptr<Testable> create(StateSpacePtr /*_stateSpace*/)
static std::unique_ptr<Testable> create(StateSpacePtr _stateSpace)
{
throw std::runtime_error(
"No Testable is available for SE2Joint.");
auto joint = _stateSpace->getJoint();
if (joint->hasPositionLimit(0))
{
throw std::invalid_argument(
"Rotational component of SE2Joint must not have limits.");
}

return createBoxConstraint<Testable>(
std::move(_stateSpace), nullptr);
}
};

Expand All @@ -335,10 +368,17 @@ struct createProjectableFor_impl<statespace::dart::SE2Joint>
using StateSpace = statespace::dart::SE2Joint;
using StateSpacePtr = std::shared_ptr<StateSpace>;

static std::unique_ptr<Projectable> create(StateSpacePtr /*_stateSpace*/)
static std::unique_ptr<Projectable> create(StateSpacePtr _stateSpace)
{
throw std::runtime_error(
"No Projectable is available for SE2Joint.");
auto joint = _stateSpace->getJoint();
if (joint->hasPositionLimit(0))
{
throw std::invalid_argument(
"Rotational component of SE2Joint must not have limits.");
}

return createBoxConstraint<Projectable>(
std::move(_stateSpace), nullptr);
}
};

Expand All @@ -350,10 +390,26 @@ struct createSampleableFor_impl<statespace::dart::SE2Joint>
using StateSpacePtr = std::shared_ptr<StateSpace>;

static std::unique_ptr<Sampleable> create(
StateSpacePtr /*_stateSpace*/, std::unique_ptr<util::RNG> /*_rng*/)
StateSpacePtr stateSpace, std::unique_ptr<util::RNG> rng)
{
throw std::runtime_error(
"No Sampleable is available for SE2Joint.");
auto joint = stateSpace->getJoint();
if (joint->hasPositionLimit(0))
{
throw std::invalid_argument(
"Rotational component of SE2Joint must not have limits.");
}
else if (!(joint->hasPositionLimit(1) && joint->hasPositionLimit(2)))
{
throw std::runtime_error(
"Unable to create Sampleable for unbounded SE2.");
}
else
{
return dart::common::make_unique<SE2BoxConstraint>(
std::move(stateSpace), std::move(rng),
getPositionLowerLimits(joint).tail<2>(),
getPositionUpperLimits(joint).tail<2>());
}
}
};

Expand Down
78 changes: 78 additions & 0 deletions include/aikido/constraint/uniform/SE2BoxConstraint.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#ifndef AIKIDO_STATESPACE_SE2BOXCONSTRAINT_HPP_
#define AIKIDO_STATESPACE_SE2BOXCONSTRAINT_HPP_

#include "../../statespace/SE2.hpp"
#include "../Differentiable.hpp"
#include "../Projectable.hpp"
#include "../Sampleable.hpp"
#include "../Testable.hpp"

namespace aikido {
namespace constraint {

/// A BoxConstraint on SE2.
/// This class does *not* allow constraint on rotation.
/// For each dimension x and y, this constraint has lowerLimit and upperLimit.
class SE2BoxConstraint
: public constraint::Projectable
, public constraint::Sampleable
, public constraint::Testable
{
public:
using constraint::Projectable::project;

/// Constructor.
/// \param _space Space in which this constraint operates.
/// \param _rng Random number generator to be used for sampling.
/// \param _lowerLimits Lower limits on the state, only on x and y.
/// \param _upperLimits Upper limits on the state, only on x and y.
SE2BoxConstraint(
std::shared_ptr<statespace::SE2> _space,
std::unique_ptr<util::RNG> _rng,
const Eigen::Vector2d& _lowerLimits,
const Eigen::Vector2d& _upperLimits);

// Documentation inherited.
statespace::StateSpacePtr getStateSpace() const override;

// Documentation inherited.
bool isSatisfied(const statespace::StateSpace::State* state) const override;

// Documentation inherited.
bool project(
const statespace::StateSpace::State* _s,
statespace::StateSpace::State* _out) const override;

// Documentation inherited.
std::unique_ptr<constraint::SampleGenerator>
createSampleGenerator() const override;

/// Returns lower limits of this constraint.
Eigen::Vector2d getLowerLimits() const;

/// Returns upper limits of this constraint.
Eigen::Vector2d getUpperLimits() const;

private:
std::shared_ptr<statespace::SE2> mSpace;
std::unique_ptr<util::RNG> mRng;

/// Lower limits on the state. The first element encodes the rotational limit
/// and the last two elements encode the translational limits.
Eigen::Vector3d mLowerLimits;

/// Upper limits on the state. The first element encodes the rotational limit
/// and the last two elements encode the translational limits.
Eigen::Vector3d mUpperLimits;

// DOFs of joint that have limits, in this case translational DOFs.
// TODO: Confirm this with Gilwoo
size_t mRnDimension;
Copy link
Contributor

Choose a reason for hiding this comment

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

@gilwoolee : is the docstring for this variable right?

// DOF of the joint
size_t mDimension;
};

} // namespace constraint
} // namespace aikido

#endif // AIKIDO_STATESPACE_SE2BOXCONSTRAINT_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ RBoxConstraint<N>::RBoxConstraint(std::shared_ptr<statespace::R<N>> _space,
if (mLowerLimits[i] > mUpperLimits[i])
{
std::stringstream msg;
msg << "Unable to sample from StateSpace because lower limit exeeds"
" upper limit on dimension " << i << ": "
msg << "Unable to sample from StateSpace because lower limit exceeds"
<< " upper limit on dimension " << i << ": "
<< mLowerLimits[i] << " > " << mUpperLimits[i] << ".";
throw std::invalid_argument(msg.str());
}
Expand Down
17 changes: 16 additions & 1 deletion include/aikido/distance/detail/defaults-impl.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include <dart/common/StlHelpers.hpp>

#include "../../statespace/CartesianProduct.hpp"
#include "../../statespace/Rn.hpp"
#include "../../statespace/SE2.hpp"
#include "../../statespace/SO2.hpp"
#include "../../statespace/SO3.hpp"
#include "../../util/metaprogramming.hpp"
#include "../RnEuclidean.hpp"
#include "../SE2.hpp"
#include "../SO2Angular.hpp"
#include "../SO3Angular.hpp"
#include "../Weighted.hpp"
Expand All @@ -20,6 +23,7 @@ using Ptr = std::unique_ptr<DistanceMetric>;
template <class Space>
struct createDistanceMetricFor_impl
{
// Nothing defined
};

//=============================================================================
Expand Down Expand Up @@ -116,6 +120,16 @@ struct createDistanceMetricFor_impl<statespace::CartesianProduct>
}
};

//=============================================================================
template <>
struct createDistanceMetricFor_impl<statespace::SE2>
{
static Ptr create(std::shared_ptr<statespace::SE2> _sspace)
{
return make_unique<SE2>(std::move(_sspace));
}
};

//=============================================================================
using SupportedStateSpaces = util::type_list<statespace::CartesianProduct,
statespace::R0,
Expand All @@ -124,7 +138,8 @@ using SupportedStateSpaces = util::type_list<statespace::CartesianProduct,
statespace::R3,
statespace::R6,
statespace::SO2,
statespace::SO3>;
statespace::SO3,
statespace::SE2>;

} // namespace detail

Expand Down
1 change: 1 addition & 0 deletions src/constraint/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(sources
uniform/RnConstantSampler.cpp
uniform/SO2UniformSampler.cpp
uniform/SO3UniformSampler.cpp
uniform/SE2BoxConstraint.cpp
CartesianProductProjectable.cpp
CartesianProductSampleable.cpp
CartesianProductTestable.cpp
Expand Down
Loading