29 #ifndef UUV_SENSOR_PLUGINS_COMMON_H_ 30 #define UUV_SENSOR_PLUGINS_COMMON_H_ 33 #include <Eigen/Dense> 34 #include <gazebo/gazebo.hh> 47 bool GetSDFParam(sdf::ElementPtr sdf,
const std::string& name, T& param,
48 const T& default_value,
const bool& verbose =
false)
50 if (sdf->HasElement(name))
52 param = sdf->GetElement(name)->Get<T>();
57 param = default_value;
59 gzerr <<
"[uuv_sensor_plugins] Please specify a value for parameter \"" 84 timeConstantUp_(timeConstantUp),
85 timeConstantDown_(timeConstantDown),
86 previousState_(initialState) {}
94 if (inputState > previousState_)
97 double alphaUp = exp(- samplingTime / timeConstantUp_);
99 outputState = alphaUp * previousState_ + (1 - alphaUp) * inputState;
104 double alphaDown = exp(- samplingTime / timeConstantDown_);
105 outputState = alphaDown * previousState_ + (1 - alphaDown) * inputState;
107 previousState_ = outputState;
121 template<
class Derived>
123 const Eigen::MatrixBase<Derived> & theta)
125 typedef typename Derived::Scalar Scalar;
126 EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived);
127 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived, 3);
128 const Scalar q_squared = theta.squaredNorm() / 4.0;
132 return Eigen::Quaternion<Scalar>(sqrt(1 - q_squared), theta[0] * 0.5,
133 theta[1] * 0.5, theta[2] * 0.5);
137 const Scalar
w = 1.0 / sqrt(1 + q_squared);
138 const Scalar
f = w * 0.5;
139 return Eigen::Quaternion<Scalar>(w, theta[0] * f, theta[1] * f,
144 template<
class In,
class Out>
152 #endif // UUV_SENSOR_PLUGINS_COMMON_H_
bool GetSDFParam(sdf::ElementPtr sdf, const std::string &name, T ¶m, const T &default_value, const bool &verbose=false)
Obtains a parameter from sdf.
void copyPosition(const In &in, Out *out)
FirstOrderFilter(double timeConstantUp, double timeConstantDown, T initialState)
TFSIMD_FORCE_INLINE const tfScalar & w() const
T updateFilter(T inputState, double samplingTime)
Eigen::Quaternion< typename Derived::Scalar > QuaternionFromSmallAngle(const Eigen::MatrixBase< Derived > &theta)
Computes a quaternion from the 3-element small angle approximation theta.