Skip to content

Commit

Permalink
Implement BLF_DEFINE_INTEGRATOR_STRUCTURE macro
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRomualdi committed Mar 25, 2021
1 parent 863e220 commit cea6f53
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,10 @@ namespace BipedalLocomotion
namespace ContinuousDynamicalSystem
{
template <typename _DynamicalSystem> class ForwardEuler;
}
}

namespace internal
{

/**
* Internal description of the ForwardEuler integrator
*/
template <typename _DynamicalSystem> struct traits<ForwardEuler<_DynamicalSystem>>
{
/** State of the integrator */
using State = typename traits<_DynamicalSystem>::State;

/** State derivative of the integrator */
using StateDerivative = typename traits<_DynamicalSystem>::StateDerivative;

/** Type of the dynamical system */
using DynamicalSystem = _DynamicalSystem;
};

} // namespace internal
} // namespace ContinuousDynamicalSystem
} // namespace BipedalLocomotion
BLF_DEFINE_INTEGRATOR_STRUCTURE(ForwardEuler, _DynamicalSystemType)

namespace BipedalLocomotion
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace ContinuousDynamicalSystem
{

/**
* Integrator base class.
* Integrator base class. f$. Please inherit publicly from this class in order to define your custom
* integrator. Just be sure to call after your class definition #BLF_DEFINE_INTEGRATOR_STRUCTURE()
*/
template <class _Derived> class Integrator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define BLF_CONTINUOUS_DYNAMICAL_SYSTEM_STATE_INPUT(...) using Input = std::tuple<__VA_ARGS__>

/**
* The user must call this macro before defining a ContinuousDynamicalSystem::DynamicalSystem
* The user must call this macro before defining a custom ContinuousDynamicalSystem::DynamicalSystem
* @param DynamicalSystemType the type of the dynamical system
* @param StateType the list of the types used to define the state. The list must be defined using
* round parenthesis. E.g. `(Eigen::VectorXd, Eigen::VectorXd)`.
Expand Down Expand Up @@ -47,6 +47,31 @@
} \
}

/**
* The user must call this macro before defining a custom ContinuousDynamicalSystem::Integrator
* @param IntegratorType the type of the integrator.
* @param DynamicalSystemType the type of the dynamical system.
*/
#define BLF_DEFINE_INTEGRATOR_STRUCTURE(IntegratorType, DynamicalSystemType) \
namespace BipedalLocomotion \
{ \
namespace ContinuousDynamicalSystem \
{ \
namespace internal \
{ \
template <class DynamicalSystemType> struct traits<IntegratorType<DynamicalSystemType>> \
{ \
/** State of the integrator */ \
using State = typename traits<DynamicalSystemType>::State; \
/** State derivative of the integrator */ \
using StateDerivative = typename traits<DynamicalSystemType>::StateDerivative; \
/** Type of the dynamical system */ \
using DynamicalSystem = DynamicalSystemType; \
}; \
} \
} \
}

namespace BipedalLocomotion
{
namespace ContinuousDynamicalSystem
Expand Down

0 comments on commit cea6f53

Please sign in to comment.