5 #ifndef __pinocchio_autodiff_cppad_hpp__
6 #define __pinocchio_autodiff_cppad_hpp__
8 #include "pinocchio/math/fwd.hpp"
9 #define PINOCCHIO_WITH_CPPAD_SUPPORT
16 #define EIGEN_MATRIXBASE_PLUGIN <pinocchio/autodiff/cppad/math/eigen_plugin.hpp>
18 #include <boost/mpl/int.hpp>
19 #include <cppad/cppad.hpp>
20 #include <Eigen/Dense>
30 template<
typename Scalar>
31 struct constant_pi<CppAD::AD<Scalar>> : constant_pi<Scalar>
33 typedef CppAD::AD<Scalar> ADScalar;
36 static inline ADScalar get(
const mpl::int_<N> & n)
38 return ADScalar(constant_pi<Scalar>::get(n));
41 #if BOOST_VERSION >= 107700
42 template<
class T, T value>
43 static inline ADScalar get(
const std::integral_constant<T, value> & n)
45 return ADScalar(constant_pi<Scalar>::get(n));
48 template<
class T, T value>
49 static inline ADScalar get(
const boost::integral_constant<T, value> & n)
51 return ADScalar(constant_pi<Scalar>::get(n));
65 template<
typename Scalar>
66 struct cast_impl<CppAD::AD<Scalar>, Scalar>
68 #if EIGEN_VERSION_AT_LEAST(3, 2, 90)
71 static inline Scalar run(
const CppAD::AD<Scalar> & x)
73 return CppAD::Value(x);
83 struct NumTraits<CppAD::AD<Base>>
85 typedef CppAD::AD<Base> Real;
87 typedef CppAD::AD<Base> NonInteger;
89 typedef CppAD::AD<Base> Literal;
91 typedef CppAD::AD<Base> Nested;
102 RequireInitialization = 1,
111 static CppAD::AD<Base> epsilon(
void)
113 return CppAD::numeric_limits<CppAD::AD<Base>>::epsilon();
118 static CppAD::AD<Base> dummy_precision(
void)
120 return 100. * CppAD::numeric_limits<CppAD::AD<Base>>::epsilon();
124 static CppAD::AD<Base> lowest(
void)
126 return CppAD::numeric_limits<CppAD::AD<Base>>::min();
130 static CppAD::AD<Base> highest(
void)
132 return CppAD::numeric_limits<CppAD::AD<Base>>::max();
136 static int digits10(
void)
138 return CppAD::numeric_limits<CppAD::AD<Base>>::digits10;
144 #include "pinocchio/utils/static-if.hpp"
150 const AD<Base> & conj(
const AD<Base> & x)
155 const AD<Base> & real(
const AD<Base> & x)
162 AD<Base> imag(
const AD<Base> & )
164 return CppAD::AD<Base>(0.);
167 AD<Base> abs2(
const AD<Base> & x)
172 template<
typename Scalar>
173 AD<Scalar> min(
const AD<Scalar> & x,
const AD<Scalar> & y)
175 using ::pinocchio::internal::if_then_else;
176 using ::pinocchio::internal::LT;
177 return if_then_else(LT, y, x, y, x);
180 template<
typename Scalar>
181 AD<Scalar> max(
const AD<Scalar> & x,
const AD<Scalar> & y)
183 using ::pinocchio::internal::if_then_else;
184 using ::pinocchio::internal::LT;
185 return if_then_else(LT, x, y, y, x);
191 template<
class Scalar>
192 bool isfinite(
const AD<Scalar> & x)
194 return isfinite(Value(x));
198 #include "pinocchio/utils/static-if.hpp"
202 template<
typename Scalar>
206 typedef CppAD::AD<Scalar> ADScalar;
211 return ADScalar(Base::template precision<degree>());
215 template<
typename Scalar,
typename ADScalar>
218 static Scalar cast(
const CppAD::AD<ADScalar> & value)
220 return scalar_cast<Scalar>(CppAD::Value(value));
226 #include "pinocchio/autodiff/cppad/spatial/se3-tpl.hpp"
227 #include "pinocchio/autodiff/cppad/spatial/log.hxx"
228 #include "pinocchio/autodiff/cppad/utils/static-if.hpp"
229 #include "pinocchio/autodiff/cppad/math/quaternion.hpp"
230 #include "pinocchio/autodiff/cppad/algorithm/aba.hpp"
Main pinocchio namespace.
Cast scalar type from type FROM to type TO.
static Scalar precision()
Computes the expected tolerance of the argument of a Taylor series expansion for a certain degree acc...