19 namespace constraint {
62 template <
int N,
class OutputConstra
int>
65 std::unique_ptr<common::RNG> _rng)
67 const auto properties = _stateSpace->getProperties();
69 if (properties.isPositionLimited())
71 return ::aikido::common::make_unique<uniform::RBoxConstraint<N>>(
72 std::move(_stateSpace),
74 properties.getPositionLowerLimits(),
75 properties.getPositionUpperLimits());
79 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
92 return createBoxConstraint<N, Differentiable>(
93 std::move(_stateSpace),
nullptr);
106 return createBoxConstraint<N, Testable>(std::move(_stateSpace),
nullptr);
119 return createBoxConstraint<N, Projectable>(std::move(_stateSpace),
nullptr);
130 static std::unique_ptr<Sampleable>
create(
133 const auto properties = _stateSpace->getProperties();
135 if (properties.isPositionLimited())
137 return ::aikido::common::make_unique<uniform::RBoxConstraint<N>>(
138 std::move(_stateSpace),
140 properties.getPositionLowerLimits(),
141 properties.getPositionUpperLimits());
145 throw std::runtime_error(
"Unable to create Sampleable for unbounded Rn.");
159 if (_stateSpace->getProperties().isPositionLimited())
160 throw std::invalid_argument(
"SO2Joint must not have limits.");
162 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
175 if (_stateSpace->getProperties().isPositionLimited())
176 throw std::invalid_argument(
"SO2Joint must not have limits.");
178 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
191 if (_stateSpace->getProperties().isPositionLimited())
192 throw std::invalid_argument(
"SO2Joint must not have limits.");
194 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
205 static std::unique_ptr<Sampleable>
create(
208 if (_stateSpace->getProperties().isPositionLimited())
209 throw std::invalid_argument(
"SO2Joint must not have limits.");
211 return ::aikido::common::make_unique<uniform::SO2UniformSampler>(
212 std::move(_stateSpace), std::move(_rng));
225 if (_stateSpace->getProperties().isPositionLimited())
226 throw std::invalid_argument(
"SO3Joint must not have limits.");
228 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
241 if (_stateSpace->getProperties().isPositionLimited())
242 throw std::invalid_argument(
"SO3Joint must not have limits.");
244 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
257 if (_stateSpace->getProperties().isPositionLimited())
258 throw std::invalid_argument(
"SO3Joint must not have limits.");
260 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
271 static std::unique_ptr<Sampleable>
create(
274 if (_stateSpace->getProperties().isPositionLimited())
275 throw std::invalid_argument(
"SO3Joint must not have limits.");
277 return ::aikido::common::make_unique<uniform::SO3UniformSampler>(
278 std::move(_stateSpace), std::move(_rng));
283 template <
class OutputConstra
int>
285 std::shared_ptr<const statespace::dart::SE2Joint> _stateSpace,
286 std::unique_ptr<common::RNG> _rng)
288 const auto properties = _stateSpace->getProperties();
290 if (properties.isPositionLimited())
292 return ::aikido::common::make_unique<uniform::SE2BoxConstraint>(
293 std::move(_stateSpace),
295 properties.getPositionLowerLimits().tail<2>(),
296 properties.getPositionUpperLimits().tail<2>());
300 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
311 static std::unique_ptr<Differentiable>
create(
314 throw std::runtime_error(
315 "No DifferentiableConstraint is available for SE2Joint.");
328 const auto properties = _stateSpace->getProperties();
329 if (properties.hasPositionLimit(0))
331 throw std::invalid_argument(
332 "Rotational component of SE2Joint must not have limits.");
335 return createBoxConstraint<Testable>(std::move(_stateSpace),
nullptr);
348 const auto properties = _stateSpace->getProperties();
349 if (properties.hasPositionLimit(0))
351 throw std::invalid_argument(
352 "Rotational component of SE2Joint must not have limits.");
355 return createBoxConstraint<Projectable>(std::move(_stateSpace),
nullptr);
366 static std::unique_ptr<Sampleable>
create(
369 const auto properties = stateSpace->getProperties();
370 if (properties.hasPositionLimit(0))
372 throw std::invalid_argument(
373 "Rotational component of SE2Joint must not have limits.");
375 else if (!(properties.hasPositionLimit(1)
376 && properties.hasPositionLimit(2)))
378 throw std::runtime_error(
379 "Unable to create Sampleable for unbounded SE2.");
383 return ::aikido::common::make_unique<uniform::SE2BoxConstraint>(
384 std::move(stateSpace),
386 properties.getPositionLowerLimits().tail<2>(),
387 properties.getPositionUpperLimits().tail<2>());
399 static std::unique_ptr<Differentiable>
create(
402 throw std::runtime_error(
403 "No DifferentiableConstraint is available for SE3Joint.");
416 throw std::runtime_error(
"No Testable is available for SE3Joint.");
429 throw std::runtime_error(
"No Projectable is available for SE3Joint.");
440 static std::unique_ptr<Sampleable>
create(
443 throw std::runtime_error(
"No Sampleable is available for SE3Joint.");
448 template <
class OutputConstra
int>
450 std::shared_ptr<const statespace::dart::WeldJoint> _stateSpace,
451 std::unique_ptr<common::RNG> )
453 return ::aikido::common::make_unique<Satisfied>(std::move(_stateSpace));
465 return createBoxConstraint<Differentiable>(std::move(_stateSpace),
nullptr);
478 return createBoxConstraint<Testable>(std::move(_stateSpace),
nullptr);
491 return createBoxConstraint<Projectable>(std::move(_stateSpace),
nullptr);
502 static std::unique_ptr<Sampleable>
create(
506 Eigen::VectorXd positions = Eigen::Matrix<double, 0, 1>();
508 return ::aikido::common::make_unique<uniform::R0ConstantSampler>(
509 std::move(_stateSpace), positions);
516 template <
class Space>
518 std::shared_ptr<Space> _stateSpace)
521 std::move(_stateSpace));
525 template <
class Space>
527 std::shared_ptr<Space> _stateSpace)
530 std::move(_stateSpace));
534 template <
class Space>
536 std::shared_ptr<Space> _stateSpace)
539 std::move(_stateSpace));
543 template <
class Space>
545 std::shared_ptr<Space> _stateSpace, std::unique_ptr<common::RNG> _rng)
548 std::move(_stateSpace), std::move(_rng));