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 
00108   static MatrixSXd GetRotationMatrixBaseToWorld(const EulerAngles& xyz);
00109 
00115   Vector3d GetAngularVelocityInWorld(double t) const;
00116 
00122   Vector3d GetAngularAccelerationInWorld(double t) const;
00123 
00131   Jacobian GetDerivOfAngVelWrtEulerNodes(double t) const;
00132 
00140   Jacobian GetDerivOfAngAccWrtEulerNodes(double t) const;
00141 
00153   Jacobian DerivOfRotVecMult(double t, const Vector3d& v, bool inverse) const;
00154 
00156   static Eigen::Quaterniond GetQuaternionBaseToWorld(const EulerAngles& pos);
00157 
00158 private:
00159   NodeSpline::Ptr euler_;
00160 
00161   // Internal calculations for the conversion from euler rates to angular
00162   // velocities and accelerations. These are done using the matrix M defined
00163   // here: http://docs.leggedrobotics.com/kindr/cheatsheet_latest.pdf
00170   static MatrixSXd GetM(const EulerAngles& xyz);
00171 
00175   static MatrixSXd GetMdot(const EulerAngles& xyz, const EulerRates& xyz_d);
00176 
00185   Jacobian GetDerivMwrtNodes(double t, Dim3D dim) const;
00186 
00192   Jacobian GetDerivMdotwrtNodes(double t, Dim3D dim) const;
00193 
00199   JacRowMatrix GetDerivativeOfRotationMatrixWrtNodes(double t) const;
00200 
00202   static Vector3d GetAngularAccelerationInWorld(State euler);
00203 
00205   static Vector3d GetAngularVelocityInWorld(const EulerAngles& pos,
00206                                             const EulerRates& vel);
00207 
00208   JacobianRow GetJac(double t, Dx deriv, Dim3D dim) const;
00209   Jacobian jac_wrt_nodes_structure_;
00210 };
00211 
00212 } /* namespace towr */
00213 
00214 #endif /* TOWR_VARIABLES_ANGULAR_STATE_CONVERTER_H_ */


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Apr 15 2019 02:42:32