NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
pose_vel_accel.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef EXECUTIVE_UTILS_SEQUENCER_SV_POSE_VEL_ACCEL_H_
20 #define EXECUTIVE_UTILS_SEQUENCER_SV_POSE_VEL_ACCEL_H_
21 
22 #include <stdint.h>
23 
24 #include <Eigen/Core>
25 
26 /* Defines heler functions and a class for the "ControlState" version
27  * of a state vector.
28  */
29 
30 namespace sequencer {
31 namespace sv {
32 namespace pose_vel_accel {
33 
34 extern const char* kName;
35 
36 struct StateVector {
37  public:
38  uint32_t sec;
39  uint32_t nsec;
40  Eigen::Matrix<float, 19, 1> vec;
41 
42  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
43 };
44 
45 // Helper functions to pull out the different parts of a state vector
46 template <typename Derived>
47 Eigen::Block<Derived, 3, 1> GetPosition(Eigen::MatrixBase<Derived>& state) { // NOLINT
48  return state.template block<3, 1>(0, 0);
49 }
50 template <typename Derived>
51 Eigen::Block<Derived, 3, 1> GetVelocity(Eigen::MatrixBase<Derived>& state) { // NOLINT
52  return state.template block<3, 1>(3, 0);
53 }
54 template <typename Derived>
55 Eigen::Block<Derived, 3, 1> GetAcceleration(Eigen::MatrixBase<Derived>& state) { // NOLINT
56  return state.template block<3, 1>(6, 0);
57 }
58 template <typename Derived>
59 Eigen::Block<Derived, 4, 1> GetQuaternion(Eigen::MatrixBase<Derived>& state) { // NOLINT
60  return state.template block<4, 1>(9, 0);
61 }
62 template <typename Derived>
63 Eigen::Block<Derived, 3, 1> GetAngularVelocity(Eigen::MatrixBase<Derived>& state) { // NOLINT
64  return state.template block<3, 1>(13, 0);
65 }
66 template <typename Derived>
67 Eigen::Block<Derived, 3, 1> GetAngularAcceleration(Eigen::MatrixBase<Derived>& state) { // NOLINT
68  return state.template block<3, 1>(16, 0);
69 }
70 
71 // Const variants
72 template <typename Derived>
73 Eigen::Block<const Derived, 3, 1> GetPosition(Eigen::MatrixBase<Derived> const& state) {
74  return state.template block<3, 1>(0, 0);
75 }
76 template <typename Derived>
77 Eigen::Block<const Derived, 3, 1> GetVelocity(Eigen::MatrixBase<Derived> const& state) {
78  return state.template block<3, 1>(3, 0);
79 }
80 template <typename Derived>
81 Eigen::Block<const Derived, 3, 1> GetAcceleration(Eigen::MatrixBase<Derived> const& state) {
82  return state.template block<3, 1>(6, 0);
83 }
84 template <typename Derived>
85 Eigen::Block<const Derived, 4, 1> GetQuaternion(Eigen::MatrixBase<Derived> const& state) {
86  return state.template block<4, 1>(9, 0);
87 }
88 template <typename Derived>
89 Eigen::Block<const Derived, 3, 1> GetAngularVelocity(Eigen::MatrixBase<Derived> const& state) {
90  return state.template block<3, 1>(13, 0);
91 }
92 template <typename Derived>
93 Eigen::Block<const Derived, 3, 1> GetAngularAcceleration(Eigen::MatrixBase<Derived> const& state) {
94  return state.template block<3, 1>(16, 0);
95 }
96 
97 } // end namespace pose_vel_accel
98 } // end namespace sv
99 } // end namespace sequencer
100 
101 #endif // EXECUTIVE_UTILS_SEQUENCER_SV_POSE_VEL_ACCEL_H_
102 
sequencer::sv::pose_vel_accel::GetAngularVelocity
Eigen::Block< Derived, 3, 1 > GetAngularVelocity(Eigen::MatrixBase< Derived > &state)
Definition: pose_vel_accel.h:63
sequencer::sv::pose_vel_accel::StateVector::sec
uint32_t sec
Definition: pose_vel_accel.h:38
sequencer::sv::pose_vel_accel::kName
const char * kName
sequencer::sv::pose_vel_accel::StateVector::vec
Eigen::Matrix< float, 19, 1 > vec
Definition: pose_vel_accel.h:40
sequencer::sv::pose_vel_accel::GetPosition
Eigen::Block< Derived, 3, 1 > GetPosition(Eigen::MatrixBase< Derived > &state)
Definition: pose_vel_accel.h:47
sequencer::sv::pose_vel_accel::GetAngularAcceleration
Eigen::Block< Derived, 3, 1 > GetAngularAcceleration(Eigen::MatrixBase< Derived > &state)
Definition: pose_vel_accel.h:67
sequencer::sv::pose_vel_accel::GetQuaternion
Eigen::Block< Derived, 4, 1 > GetQuaternion(Eigen::MatrixBase< Derived > &state)
Definition: pose_vel_accel.h:59
sequencer::sv::pose_vel_accel::GetVelocity
Eigen::Block< Derived, 3, 1 > GetVelocity(Eigen::MatrixBase< Derived > &state)
Definition: pose_vel_accel.h:51
sequencer::sv::pose_vel_accel::StateVector::nsec
uint32_t nsec
Definition: pose_vel_accel.h:39
sequencer::sv::pose_vel_accel::StateVector
Definition: pose_vel_accel.h:36
state
uint8_t state
Definition: signal_lights.h:90
sequencer::sv::pose_vel_accel::GetAcceleration
Eigen::Block< Derived, 3, 1 > GetAcceleration(Eigen::MatrixBase< Derived > &state)
Definition: pose_vel_accel.h:55
sequencer
Definition: command_conversion.h:41