NASA Astrobee Robot Software  Astrobee Version:
Flight software for the Astrobee robots operating inside the International Space Station.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fam.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 PMC_FAM_H_
20 #define PMC_FAM_H_
21 
22 #include <Eigen/Dense>
23 
24 namespace pmc {
25 
26 struct FamInput {
27  Eigen::Vector3f body_force_cmd;
28  Eigen::Vector3f body_torque_cmd;
29  Eigen::Vector3f center_of_mass;
30  uint8_t speed_gain_cmd;
31 };
32 
33 class Fam {
34  public:
35  void Step(const FamInput& in, uint8_t* speed_cmd, Eigen::Matrix<float, 12, 1> & servo_pwm_cmd);
36  void UpdateCOM(const Eigen::Vector3f & com);
37  protected:
38  void CalcThrustMatrices(const Eigen::Vector3f & force, const Eigen::Vector3f & torque,
39  Eigen::Matrix<float, 6, 1>& pmc1_nozzle_thrusts, Eigen::Matrix<float, 6, 1>& pmc2_nozzle_thrusts);
40  float ComputePlenumDeltaPressure(float impeller_speed, Eigen::Matrix<float, 6, 1> & discharge_coeff,
41  const Eigen::Matrix<float, 6, 1> & nozzle_thrusts);
42  void CalcPMServoCmd(bool is_pmc1, uint8_t speed_gain_cmd, const Eigen::Matrix<float, 6, 1> & nozzle_thrusts,
43  uint8_t & impeller_speed_cmd, Eigen::Matrix<float, 6, 1> & servo_pwm_cmd,
44  Eigen::Matrix<float, 6, 1> & nozzle_theta_cmd,
45  Eigen::Matrix<float, 6, 1> & normalized_pressure_density, Eigen::Matrix<float, 6, 1> & command_area_per_nozzle);
46 
47  Eigen::Matrix<float, 3, 12> thrust2force_, thrust2torque_;
48  Eigen::Matrix<float, 12, 6> forcetorque2thrust_;
49 
50  static const float IMPELLER_SPEEDS[];
51  // this lookup table was computed in fam_force_allocation_module_prep.m. We do not expect the values to
52  // change so we have just copied them. it is a function of air density and the propeller properties.
53  static constexpr int THRUST_LOOKUP_SIZE = 316;
54  static const float THRUST_LOOKUP_BREAKPOINTS[];
55  static const float THRUST_LOOKUP_CDP[];
56 };
57 
58 } // end namespace pmc
59 
60 #endif // PMC_FAM_H_
pmc::Fam::UpdateCOM
void UpdateCOM(const Eigen::Vector3f &com)
Definition: fam.cc:109
pmc::Fam::thrust2torque_
Eigen::Matrix< float, 3, 12 > thrust2torque_
Definition: fam.h:47
pmc::Fam::forcetorque2thrust_
Eigen::Matrix< float, 12, 6 > forcetorque2thrust_
Definition: fam.h:48
pmc::Fam::THRUST_LOOKUP_SIZE
static constexpr int THRUST_LOOKUP_SIZE
Definition: fam.h:53
pmc::Fam
Definition: fam.h:33
pmc::FamInput::speed_gain_cmd
uint8_t speed_gain_cmd
Definition: fam.h:30
pmc::FamInput::body_force_cmd
Eigen::Vector3f body_force_cmd
Definition: fam.h:27
pmc::FamInput::center_of_mass
Eigen::Vector3f center_of_mass
Definition: fam.h:29
pmc::Fam::thrust2force_
Eigen::Matrix< float, 3, 12 > thrust2force_
Definition: fam.h:47
pmc::Fam::CalcThrustMatrices
void CalcThrustMatrices(const Eigen::Vector3f &force, const Eigen::Vector3f &torque, Eigen::Matrix< float, 6, 1 > &pmc1_nozzle_thrusts, Eigen::Matrix< float, 6, 1 > &pmc2_nozzle_thrusts)
Definition: fam.cc:126
pmc::Fam::ComputePlenumDeltaPressure
float ComputePlenumDeltaPressure(float impeller_speed, Eigen::Matrix< float, 6, 1 > &discharge_coeff, const Eigen::Matrix< float, 6, 1 > &nozzle_thrusts)
Definition: fam.cc:151
pmc::FamInput::body_torque_cmd
Eigen::Vector3f body_torque_cmd
Definition: fam.h:28
pmc::FamInput
Definition: fam.h:26
pmc::Fam::IMPELLER_SPEEDS
static const float IMPELLER_SPEEDS[]
Definition: fam.h:50
pmc::Fam::THRUST_LOOKUP_BREAKPOINTS
static const float THRUST_LOOKUP_BREAKPOINTS[]
Definition: fam.h:54
pmc::Fam::CalcPMServoCmd
void CalcPMServoCmd(bool is_pmc1, uint8_t speed_gain_cmd, const Eigen::Matrix< float, 6, 1 > &nozzle_thrusts, uint8_t &impeller_speed_cmd, Eigen::Matrix< float, 6, 1 > &servo_pwm_cmd, Eigen::Matrix< float, 6, 1 > &nozzle_theta_cmd, Eigen::Matrix< float, 6, 1 > &normalized_pressure_density, Eigen::Matrix< float, 6, 1 > &command_area_per_nozzle)
Definition: fam.cc:161
pmc::Fam::Step
void Step(const FamInput &in, uint8_t *speed_cmd, Eigen::Matrix< float, 12, 1 > &servo_pwm_cmd)
Definition: fam.cc:202
pmc
Definition: fam.h:24
pmc::Fam::THRUST_LOOKUP_CDP
static const float THRUST_LOOKUP_CDP[]
Definition: fam.h:55