euler_converter.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 
00010 * Redistributions in binary form must reproduce the above copyright notice,
00011   this list of conditions and the following disclaimer in the documentation
00012   and/or other materials provided with the distribution.
00013 
00014 * Neither the name of the copyright holder nor the names of its
00015   contributors may be used to endorse or promote products derived from
00016   this software without specific prior written permission.
00017 
00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00022 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00023 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00024 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00025 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00026 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00027 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00028 ******************************************************************************/
00029 
00030 #ifndef TOWR_VARIABLES_ANGULAR_STATE_CONVERTER_H_
00031 #define TOWR_VARIABLES_ANGULAR_STATE_CONVERTER_H_
00032 
00033 #include <array>
00034 
00035 #include <Eigen/Dense>
00036 #include <Eigen/Sparse>
00037 
00038 #include "cartesian_dimensions.h"
00039 #include "node_spline.h"
00040 
00041 namespace towr {
00042 
00062 class EulerConverter {
00063 public:
00064   using Vector3d    = Eigen::Vector3d;
00065   using EulerAngles = Vector3d; 
00066   using EulerRates  = Vector3d; 
00067 
00068   using JacobianRow = Eigen::SparseVector<double, Eigen::RowMajor>;
00069   using MatrixSXd   = Eigen::SparseMatrix<double, Eigen::RowMajor>;
00070   using Jacobian    = MatrixSXd;
00071   using JacRowMatrix = std::array<std::array<JacobianRow, k3D>, k3D>;
00072 
00073   EulerConverter () = default;
00074 
00090   EulerConverter (const NodeSpline::Ptr& euler_angles);
00091   virtual ~EulerConverter () = default;
00092 
00098   Eigen::Quaterniond GetQuaternionBaseToWorld (double t) const;
00099 
00105   MatrixSXd GetRotationMatrixBaseToWorld(double t) const;
00106 
00112   Vector3d GetAngularVelocityInWorld(double t) const;
00113 
00119   Vector3d GetAngularAccelerationInWorld(double t) const;
00120 
00128   Jacobian GetDerivOfAngVelWrtEulerNodes(double t) const;
00129 
00137   Jacobian GetDerivOfAngAccWrtEulerNodes(double t) const;
00138 
00150   Jacobian DerivOfRotVecMult(double t, const Vector3d& v, bool inverse) const;
00151 private:
00152   NodeSpline::Ptr euler_;
00153 
00154   // Internal calculations for the conversion from euler rates to angular
00155   // velocities and accelerations. These are done using the matrix M defined
00156   // here: http://docs.leggedrobotics.com/kindr/cheatsheet_latest.pdf
00163   static MatrixSXd GetM(const EulerAngles& xyz);
00164 
00168   static MatrixSXd GetMdot(const EulerAngles& xyz, const EulerRates& xyz_d);
00169 
00178   Jacobian GetDerivMwrtNodes(double t, Dim3D dim) const;
00179 
00185   Jacobian GetDerivMdotwrtNodes(double t, Dim3D dim) const;
00186 
00192   JacRowMatrix GetDerivativeOfRotationMatrixWrtNodes(double t) const;
00193 
00195   static MatrixSXd GetRotationMatrixBaseToWorld(const EulerAngles& xyz);
00196 
00198   static Eigen::Quaterniond GetQuaternionBaseToWorld(const EulerAngles& pos);
00199 
00201   static Vector3d GetAngularAccelerationInWorld(State euler);
00202 
00204   static Vector3d GetAngularVelocityInWorld(const EulerAngles& pos,
00205                                             const EulerRates& vel);
00206 
00207   JacobianRow GetJac(double t, Dx deriv, Dim3D dim) const;
00208   Jacobian jac_wrt_nodes_structure_;
00209 };
00210 
00211 } /* namespace towr */
00212 
00213 #endif /* TOWR_VARIABLES_ANGULAR_STATE_CONVERTER_H_ */


towr_core
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 9 2018 03:12:44