Gazebo Sim

API Reference

8.7.0
Common.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef GZ_SIM_SYSTEMS_MULTICOPTERVELOCITYCONTROL_COMMON_HH_
19 #define GZ_SIM_SYSTEMS_MULTICOPTERVELOCITYCONTROL_COMMON_HH_
20 
21 #include <Eigen/Geometry>
22 #include <optional>
23 #include <vector>
24 
25 #include <sdf/sdf.hh>
26 
27 #include "gz/sim/config.hh"
29 #include "gz/sim/Model.hh"
30 
31 #include "Parameters.hh"
32 
33 namespace gz
34 {
35 namespace sim
36 {
37 // Inline bracket to help doxygen filtering.
38 inline namespace GZ_SIM_VERSION_NAMESPACE {
39 namespace systems
40 {
41 namespace multicopter_control
42 {
44  struct EigenTwist
45  {
46  Eigen::Vector3d linear;
47  Eigen::Vector3d angular;
48  };
49 
52  struct FrameData
53  {
54  // Even though this struct contains Eigen objects, None of them are
55  // fixed-size vectorizable, so there is no need to override the new operator
56  Eigen::Isometry3d pose;
57  Eigen::Vector3d linearVelocityWorld;
58  Eigen::Vector3d angularVelocityBody;
59  };
60 
67  const sdf::ElementPtr &_sdf,
68  const Model &_model,
69  const Entity &_comLink);
70 
75  std::optional<Eigen::Matrix4Xd> calculateAllocationMatrix(
76  const RotorConfiguration &_rotorConfiguration);
77 
83  const Entity &_link);
84 
89  std::optional<FrameData> getFrameData(const EntityComponentManager &_ecm,
90  const Entity &_link,
91  const NoiseParameters &_noise);
92 
97  inline Eigen::Matrix3d skewMatrixFromVector(const Eigen::Vector3d &_vector)
98  {
99  Eigen::Matrix3d skewMatrix;
100  skewMatrix << 0, -_vector.z(), _vector.y(), _vector.z(), 0, -_vector.x(),
101  -_vector.y(), _vector.x(), 0;
102  return skewMatrix;
103  }
104 
109  inline Eigen::Vector3d vectorFromSkewMatrix(
110  const Eigen::Matrix3d &_skewMatrix)
111  {
112  return Eigen::Vector3d(_skewMatrix(2, 1), _skewMatrix(0, 2),
113  _skewMatrix(1, 0));
114  }
115 
116 } // namespace multicopter_control
117 } // namespace systems
118 } // namespace GZ_SIM_VERSION_NAMESPACE
119 } // namespace sim
120 } // namespace gz
121 
122 #endif