gazebo_fw_dynamics_plugin.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2017 Pavel Vechersky, ASL, ETH Zurich, Switzerland
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef ROTORS_GAZEBO_PLUGINS_FW_DYNAMICS_PLUGIN_H
00018 #define ROTORS_GAZEBO_PLUGINS_FW_DYNAMICS_PLUGIN_H
00019 
00020 #include <gazebo/common/Plugin.hh>
00021 #include <gazebo/common/common.hh>
00022 #include <gazebo/gazebo.hh>
00023 #include <gazebo/physics/physics.hh>
00024 #include <mav_msgs/default_topics.h>
00025 
00026 #include "Actuators.pb.h"
00027 #include "RollPitchYawrateThrust.pb.h"
00028 #include "WindSpeed.pb.h"
00029 
00030 #include "rotors_gazebo_plugins/common.h"
00031 #include "rotors_gazebo_plugins/fw_parameters.h"
00032 
00033 namespace gazebo {
00034 
00035 typedef const boost::shared_ptr<const gz_sensor_msgs::Actuators>
00036     GzActuatorsMsgPtr;
00037 typedef const boost::shared_ptr<const gz_mav_msgs::RollPitchYawrateThrust>
00038     GzRollPitchYawrateThrustMsgPtr;
00039 typedef const boost::shared_ptr<const gz_mav_msgs::WindSpeed>
00040     GzWindSpeedMsgPtr;
00041 
00042 // Default values.
00043 static constexpr bool kDefaultIsInputJoystick = false;
00044 
00045 // Constants.
00046 static constexpr double kAirDensity = 1.18;
00047 static constexpr double kGravity = 9.81;
00048 static constexpr double kMinAirSpeedThresh = 0.1;
00049 
00050 class GazeboFwDynamicsPlugin : public ModelPlugin {
00051  public:
00053   GazeboFwDynamicsPlugin();
00054 
00056   virtual ~GazeboFwDynamicsPlugin();
00057 
00058  protected:
00061   void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
00062 
00064   void OnUpdate(const common::UpdateInfo&);
00065 
00068   void UpdateForcesAndMoments();
00069 
00072   double NormalizedInputToAngle(const ControlSurface& surface, double input);
00073 
00074  private:
00077   bool is_input_joystick_;
00078 
00082   bool pubs_and_subs_created_;
00083 
00090   void CreatePubsAndSubs();
00091 
00093   std::string namespace_;
00095   std::string actuators_sub_topic_;
00097   std::string roll_pitch_yawrate_thrust_sub_topic_;
00099   std::string wind_speed_sub_topic_;
00100 
00102   transport::NodePtr node_handle_;
00103 
00105   gazebo::transport::SubscriberPtr actuators_sub_;
00107   gazebo::transport::SubscriberPtr roll_pitch_yawrate_thrust_sub_;
00109   gazebo::transport::SubscriberPtr wind_speed_sub_;
00110 
00112   physics::WorldPtr world_;
00114   physics::ModelPtr model_;
00116   physics::LinkPtr link_;
00118   event::ConnectionPtr updateConnection_;
00119 
00121   ignition::math::Vector3d W_wind_speed_W_B_;
00122 
00124   FWAerodynamicParameters aero_params_;
00125 
00127   FWVehicleParameters vehicle_params_;
00128 
00130   double delta_aileron_left_;
00132   double delta_aileron_right_;
00134   double delta_elevator_;
00136   double delta_flap_;
00138   double delta_rudder_;
00140   double throttle_;
00141 
00146   void ActuatorsCallback(GzActuatorsMsgPtr& actuators_msg);
00147 
00152   void RollPitchYawrateThrustCallback(GzRollPitchYawrateThrustMsgPtr&
00153                                           roll_pitch_yawrate_thrust_msg);
00154 
00158   void WindSpeedCallback(GzWindSpeedMsgPtr& wind_speed_msg);
00159 };
00160 
00161 }  // namespace gazebo
00162 
00163 #endif // ROTORS_GAZEBO_PLUGINS_FW_DYNAMICS_PLUGIN_H


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Thu Apr 18 2019 02:43:43