rosflight_sil.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Daniel Koch, James Jackson and Gary Ellingson, BYU MAGICC Lab.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef ROSFLIGHT_SIM_ROSFLIGHT_SIL_H
33 #define ROSFLIGHT_SIM_ROSFLIGHT_SIL_H
34 
35 #include <geometry_msgs/Vector3.h>
36 #include <nav_msgs/Odometry.h>
37 #include <ros/ros.h>
38 #include <gazebo/common/Plugin.hh>
39 #include <gazebo/common/common.hh>
40 #include <gazebo/gazebo.hh>
41 #include <gazebo/physics/physics.hh>
42 
43 #include <mavlink/mavlink.h>
44 #include <rosflight.h>
46 
50 
52 
53 namespace rosflight_sim
54 {
55 class ROSflightSIL : public gazebo::ModelPlugin
56 {
57 public:
58  ROSflightSIL();
59  ~ROSflightSIL();
60 
61 protected:
62  void Reset() override;
63  void Load(gazebo::physics::ModelPtr _model, sdf::ElementPtr _sdf) override;
64  void OnUpdate(const gazebo::common::UpdateInfo& _info);
65 
66 private:
67  void windCallback(const geometry_msgs::Vector3& msg);
68  void publishTruth();
69 
73 
74  std::string mav_type_;
75  std::string namespace_;
76  std::string link_name_;
77 
78  gazebo::physics::WorldPtr world_;
79  gazebo::physics::ModelPtr model_;
80  gazebo::physics::LinkPtr link_;
81  gazebo::physics::JointPtr joint_;
82  gazebo::physics::EntityPtr parent_link_;
83  gazebo::event::ConnectionPtr updateConnection_; // Pointer to the update event connection.
84 
88 
90 
91  // container for forces
92  Eigen::Matrix<double, 6, 1> forces_, applied_forces_;
93 
94  // Time Counters
95  uint64_t start_time_us_;
96 
98 
99  // For reset handlin
101 
102  // helper functions for converting to and from eigen
103  Eigen::Vector3d vec3_to_eigen_from_gazebo(GazeboVector vec);
104  GazeboVector vec3_to_gazebo_from_eigen(Eigen::Vector3d vec);
105  Eigen::Matrix3d rotation_to_eigen_from_gazebo(GazeboQuaternion vec);
106 };
107 
108 } // namespace rosflight_sim
109 
110 #endif // ROSFLIGHT_SIM_ROSFLIGHT_SIL_H
msg
ros::Publisher truth_NWU_pub_
Definition: rosflight_sil.h:87
gazebo::math::Vector3 GazeboVector
Definition: gz_compat.h:72
rosflight_firmware::Mavlink comm_
Definition: rosflight_sil.h:71
Eigen::Matrix3d rotation_to_eigen_from_gazebo(GazeboQuaternion vec)
Eigen::Vector3d vec3_to_eigen_from_gazebo(GazeboVector vec)
Eigen::Matrix< double, 6, 1 > forces_
Definition: rosflight_sil.h:92
MAVForcesAndMoments * mav_dynamics_
Definition: rosflight_sil.h:89
gazebo::physics::EntityPtr parent_link_
Definition: rosflight_sil.h:82
GazeboVector vec3_to_gazebo_from_eigen(Eigen::Vector3d vec)
Eigen::Matrix< double, 6, 1 > applied_forces_
Definition: rosflight_sil.h:92
gazebo::math::Pose GazeboPose
Definition: gz_compat.h:73
gazebo::physics::JointPtr joint_
Definition: rosflight_sil.h:81
rosflight_firmware::ROSflight firmware_
Definition: rosflight_sil.h:72
gazebo::physics::WorldPtr world_
Definition: rosflight_sil.h:78
void Load(gazebo::physics::ModelPtr _model, sdf::ElementPtr _sdf) override
void OnUpdate(const gazebo::common::UpdateInfo &_info)
gazebo::event::ConnectionPtr updateConnection_
Definition: rosflight_sil.h:83
ros::Publisher truth_NED_pub_
Definition: rosflight_sil.h:86
gazebo::physics::LinkPtr link_
Definition: rosflight_sil.h:80
void windCallback(const geometry_msgs::Vector3 &msg)
gazebo::physics::ModelPtr model_
Definition: rosflight_sil.h:79
gazebo::math::Quaternion GazeboQuaternion
Definition: gz_compat.h:74


rosflight_sim
Author(s): James Jackson, Gary Ellingson, Daniel Koch
autogenerated on Thu Apr 15 2021 05:09:58