Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
orientation.hpp
Go to the documentation of this file.
1/*****************************************************************************/
2/********** !!! WARNING: CODE GENERATED BY TAPROOT. DO NOT EDIT !!! **********/
3/*****************************************************************************/
4
5/*
6 * Copyright (c) 2022-2023 Advanced Robotics at the University of Washington <robomstr@uw.edu>
7 *
8 * This file is part of Taproot.
9 *
10 * Taproot is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Taproot is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Taproot. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef TAPROOT_ORIENTATION_HPP_
25#define TAPROOT_ORIENTATION_HPP_
26
29
31{
33{
34public:
35 inline Orientation(const float roll, const float pitch, const float yaw)
36 : matrix_(tap::algorithms::fromEulerAngles(roll, pitch, yaw))
37 {
38 }
39
40 /* rvalue reference */
41 inline Orientation(Orientation&& other) : matrix_(std::move(other.matrix_)) {}
42
43 /* Costly; use rvalue reference whenever possible */
44 inline Orientation(Orientation& other) : matrix_(CMSISMat(other.matrix_)) {}
45
46 /* Costly; use rvalue reference whenever possible */
47 inline Orientation(const CMSISMat<3, 3>& matrix) : matrix_(matrix) {}
48
49 inline Orientation(CMSISMat<3, 3>&& matrix) : matrix_(std::move(matrix)) {}
50
51 inline Orientation compose(const Orientation& other) const
52 {
53 return Orientation(this->matrix_ * other.matrix_);
54 }
55
62 inline float roll() const { return atan2(matrix_.data[7], matrix_.data[8]); }
63
64 inline float pitch() const { return asinf(-matrix_.data[6]); }
65
66 inline float yaw() const { return atan2(matrix_.data[3], matrix_.data[0]); }
67
68 const inline CMSISMat<3, 3>& matrix() const { return matrix_; }
69
73 static CMSISMat<3, 3> fromEulerAngles(const float roll, const float pitch, const float yaw)
74 {
76 {cosf(yaw) * cosf(pitch),
77 (cosf(yaw) * sinf(pitch) * sinf(roll)) - (sinf(yaw) * cosf(roll)),
78 (cosf(yaw) * sinf(pitch) * cosf(roll)) + sinf(yaw) * sinf(roll),
79 sinf(yaw) * cosf(pitch),
80 sinf(yaw) * sinf(pitch) * sinf(roll) + cosf(yaw) * cosf(roll),
81 sinf(yaw) * sinf(pitch) * cosf(roll) - cosf(yaw) * sinf(roll),
82 -sinf(pitch),
83 cosf(pitch) * sinf(roll),
84 cosf(pitch) * cosf(roll)});
85 }
86
87 friend class Transform;
88 friend class DynamicOrientation;
89
90private:
91 CMSISMat<3, 3> matrix_;
92}; // class Orientation
93} // namespace tap::algorithms::transforms
94
95#endif // TAPROOT_ORIENTATION_HPP_
Definition dynamic_orientation.hpp:34
Definition orientation.hpp:33
Orientation(const CMSISMat< 3, 3 > &matrix)
Definition orientation.hpp:47
Orientation(const float roll, const float pitch, const float yaw)
Definition orientation.hpp:35
Orientation(Orientation &other)
Definition orientation.hpp:44
Orientation(CMSISMat< 3, 3 > &&matrix)
Definition orientation.hpp:49
float pitch() const
Definition orientation.hpp:64
static CMSISMat< 3, 3 > fromEulerAngles(const float roll, const float pitch, const float yaw)
Definition orientation.hpp:73
Orientation compose(const Orientation &other) const
Definition orientation.hpp:51
float roll() const
Definition orientation.hpp:62
float yaw() const
Definition orientation.hpp:66
Orientation(Orientation &&other)
Definition orientation.hpp:41
const CMSISMat< 3, 3 > & matrix() const
Definition orientation.hpp:68
Definition transform.hpp:60
Definition angular_velocity.hpp:30
Definition ballistics.cpp:29
Definition cmsis_mat.hpp:45
std::array< float, ROWS *COLS > data
Definition cmsis_mat.hpp:46