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 <gazebo/common/common.hh>
36 #include <gazebo/common/Plugin.hh>
37 #include <gazebo/gazebo.hh>
38 #include <gazebo/physics/physics.hh>
39 #include <ros/ros.h>
40 #include <geometry_msgs/Vector3.h>
41 #include <nav_msgs/Odometry.h>
42 
43 #include <rosflight.h>
45 #include <mavlink/mavlink.h>
46 
50 
52 
53 namespace rosflight_sim
54 {
55 
56 class ROSflightSIL : public gazebo::ModelPlugin
57 {
58 public:
59  ROSflightSIL();
60  ~ROSflightSIL();
61 
62 protected:
63  void Reset() override;
64  void Load(gazebo::physics::ModelPtr _model, sdf::ElementPtr _sdf) override;
65  void OnUpdate(const gazebo::common::UpdateInfo &_info);
66 
67 private:
68  void windCallback(const geometry_msgs::Vector3 &msg);
69  void publishTruth();
70 
74 
75  std::string mav_type_;
76  std::string namespace_;
77  std::string link_name_;
78 
79  gazebo::physics::WorldPtr world_;
80  gazebo::physics::ModelPtr model_;
81  gazebo::physics::LinkPtr link_;
82  gazebo::physics::JointPtr joint_;
83  gazebo::physics::EntityPtr parent_link_;
84  gazebo::event::ConnectionPtr updateConnection_; // Pointer to the update event connection.
85 
89 
91 
92  // container for forces
93  Eigen::Matrix<double, 6, 1> forces_, applied_forces_;
94 
95  // Time Counters
96  uint64_t start_time_us_;
97 
99 
100  // For reset handlin
102 
103  // helper functions for converting to and from eigen
104  Eigen::Vector3d vec3_to_eigen_from_gazebo(GazeboVector vec);
105  GazeboVector vec3_to_gazebo_from_eigen(Eigen::Vector3d vec);
106  Eigen::Matrix3d rotation_to_eigen_from_gazebo(GazeboQuaternion vec);
107 
108 };
109 
110 } // namespace rosflight_sim
111 
112 #endif // ROSFLIGHT_SIM_ROSFLIGHT_SIL_H
msg
ros::Publisher truth_NWU_pub_
Definition: rosflight_sil.h:88
gazebo::math::Vector3 GazeboVector
Definition: gz_compat.h:69
rosflight_firmware::Mavlink comm_
Definition: rosflight_sil.h:72
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:93
MAVForcesAndMoments * mav_dynamics_
Definition: rosflight_sil.h:90
gazebo::physics::EntityPtr parent_link_
Definition: rosflight_sil.h:83
GazeboVector vec3_to_gazebo_from_eigen(Eigen::Vector3d vec)
Eigen::Matrix< double, 6, 1 > applied_forces_
Definition: rosflight_sil.h:93
gazebo::math::Pose GazeboPose
Definition: gz_compat.h:70
gazebo::physics::JointPtr joint_
Definition: rosflight_sil.h:82
rosflight_firmware::ROSflight firmware_
Definition: rosflight_sil.h:73
gazebo::physics::WorldPtr world_
Definition: rosflight_sil.h:79
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:84
ros::Publisher truth_NED_pub_
Definition: rosflight_sil.h:87
gazebo::physics::LinkPtr link_
Definition: rosflight_sil.h:81
void windCallback(const geometry_msgs::Vector3 &msg)
gazebo::physics::ModelPtr model_
Definition: rosflight_sil.h:80
gazebo::math::Quaternion GazeboQuaternion
Definition: gz_compat.h:71


rosflight_sim
Author(s): James Jackson, Gary Ellingson, Daniel Koch
autogenerated on Wed Jul 3 2019 20:00:29