Ignition Gazebo

API Reference

3.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 IGNITION_GAZEBO_SYSTEMS_MULTICOPTERVELOCITYCONTROL_COMMON_HH_
19 #define IGNITION_GAZEBO_SYSTEMS_MULTICOPTERVELOCITYCONTROL_COMMON_HH_
20 
21 #include <Eigen/Geometry>
22 #include <vector>
23 
24 #include <sdf/sdf.hh>
25 
26 #include "ignition/gazebo/config.hh"
28 #include "ignition/gazebo/Model.hh"
29 
30 #include "Parameters.hh"
31 
32 namespace ignition
33 {
34 namespace gazebo
35 {
36 // Inline bracket to help doxygen filtering.
37 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
38 namespace systems
39 {
40 namespace multicopter_control
41 {
43  struct EigenTwist
44  {
45  Eigen::Vector3d linear;
46  Eigen::Vector3d angular;
47  };
48 
51  struct FrameData
52  {
53  // Even though this struct contains Eigen objects, None of them are
54  // fixed-size vectorizable, so there is no need to override the new operator
55  Eigen::Isometry3d pose;
56  Eigen::Vector3d linearVelocityWorld;
57  Eigen::Vector3d angularVelocityBody;
58  };
59 
66  const sdf::ElementPtr &_sdf,
67  const Model &_model,
68  const Entity &_comLink);
69 
74  std::optional<Eigen::Matrix4Xd> calculateAllocationMatrix(
75  const RotorConfiguration &_rotorConfiguration);
76 
82  const Entity &_link);
83 
88  std::optional<FrameData> getFrameData(const EntityComponentManager &_ecm,
89  const Entity &_link,
90  const NoiseParameters &_noise);
91 
96  inline Eigen::Matrix3d skewMatrixFromVector(const Eigen::Vector3d &_vector)
97  {
98  Eigen::Matrix3d skewMatrix;
99  skewMatrix << 0, -_vector.z(), _vector.y(), _vector.z(), 0, -_vector.x(),
100  -_vector.y(), _vector.x(), 0;
101  return skewMatrix;
102  }
103 
108  inline Eigen::Vector3d vectorFromSkewMatrix(
109  const Eigen::Matrix3d &_skewMatrix)
110  {
111  return Eigen::Vector3d(_skewMatrix(2, 1), _skewMatrix(0, 2),
112  _skewMatrix(1, 0));
113  }
114 
115 } // namespace multicopter_control
116 } // namespace systems
117 } // namespace IGNITION_GAZEBO_VERSION_NAMESPACE
118 } // namespace gazebo
119 } // namespace ignition
120 
121 #endif
This class provides wrappers around entities and components which are more convenient and straight-fo...
Definition: Model.hh:60
Eigen::Vector3d linear
Definition: Common.hh:45
Frame data of a link including its pose and linear velocity in world frame as well as its angular vel...
Definition: Common.hh:51
Eigen::Vector3d linearVelocityWorld
Definition: Common.hh:56
Eigen::Vector3d angularVelocityBody
Definition: Common.hh:57
The EntityComponentManager constructs, deletes, and returns components and entities. A component can be of any class which inherits from components::BaseComponent.
Definition: EntityComponentManager.hh:64
Eigen::Vector3d vectorFromSkewMatrix(const Eigen::Matrix3d &_skewMatrix)
Creates a vector from a skew symmetric matrix(so3). This is sometimes referred to as the vee map or i...
Definition: Common.hh:108
Eigen::Vector3d angular
Definition: Common.hh:46
RotorConfiguration loadRotorConfiguration(const EntityComponentManager &_ecm, const sdf::ElementPtr &_sdf, const Model &_model, const Entity &_comLink)
Loads rotor configuration from SDF.
std::optional< FrameData > getFrameData(const EntityComponentManager &_ecm, const Entity &_link, const NoiseParameters &_noise)
Retrieves the frame data of the given link and applies noise.
Eigen::Isometry3d pose
Definition: Common.hh:55
Eigen::Matrix3d skewMatrixFromVector(const Eigen::Vector3d &_vector)
Creates a skew symmetric matrix (so(3)) from a vector. This is sometimes referred to as the hat map...
Definition: Common.hh:96
Struct containing linear and angular velocities.
Definition: Common.hh:43
std::optional< Eigen::Matrix4Xd > calculateAllocationMatrix(const RotorConfiguration &_rotorConfiguration)
Create the matrix that maps rotor velocities to thrust and moments.
Noise parameters used when computing frame data. These are all assumed to be gaussian.
Definition: Parameters.hh:84
This library is part of the Ignition Robotics project.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light. At its core, an Entity is just an identifier.
Definition: Entity.hh:59
void createFrameDataComponents(EntityComponentManager &_ecm, const Entity &_link)
Creates components necessary for obtaining the frame data of the given link.