diff --git a/include/trajopt/constraint/Constraint.hpp b/include/trajopt/constraint/Constraint.hpp index 5180efef..0c4b875f 100644 --- a/include/trajopt/constraint/Constraint.hpp +++ b/include/trajopt/constraint/Constraint.hpp @@ -2,7 +2,8 @@ #pragma once -#include +#include +#include #include #include @@ -25,24 +26,37 @@ namespace trajopt { /** * ConstraintType concept. + * + * To make TrajoptLib support a new constraint type, do the following in this + * file: + * + * 1. Include the type's header file + * 2. Add a constraint static assert for the type + * 3. Add the type to Constraint's std::variant type list */ template -concept ConstraintType = requires(T t) { - { - // Parameters: - // - // sleipnir::OptimizationProblem& problem - // const Pose2v& pose - // const Translation2v& linearVelocity - // const sleipnir::Variable& angularVelocity - // const Translation2v& linearAcceleration - // const sleipnir::Variable& angularAcceleration - t.Apply(std::declval(), - std::declval(), std::declval(), - std::declval(), std::declval(), - std::declval()) - }; // NOLINT(readability/braces) -}; +concept ConstraintType = + requires(T self, sleipnir::OptimizationProblem& problem, const Pose2v& pose, + const Translation2v& linearVelocity, + const sleipnir::Variable& angularVelocity, + const Translation2v& linearAcceleration, + const sleipnir::Variable& angularAcceleration) { + { + self.Apply(problem, pose, linearVelocity, angularVelocity, + linearAcceleration, angularAcceleration) + } -> std::same_as; + }; + +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); +static_assert(ConstraintType); using Constraint = std::variant