22 #ifndef ROTORS_GAZEBO_PLUGINS_MOTOR_MODELS_H 23 #define ROTORS_GAZEBO_PLUGINS_MOTOR_MODELS_H 29 #include <boost/bind.hpp> 30 #include <Eigen/Eigen> 32 #include <gazebo/common/common.hh> 33 #include <gazebo/common/Plugin.hh> 34 #include <gazebo/gazebo.hh> 35 #include <gazebo/physics/physics.hh> 41 #include "Float32.pb.h" 42 #include "CommandMotorSpeed.pb.h" 43 #include "WindSpeed.pb.h" 46 const static int CCW = 1;
47 const static int CW = -1;
78 command_sub_topic_(
mav_msgs::default_topics::COMMAND_ACTUATORS),
79 wind_speed_sub_topic_(
mav_msgs::default_topics::WIND_SPEED),
80 motor_speed_pub_topic_(
mav_msgs::default_topics::MOTOR_MEASUREMENT),
81 motor_position_pub_topic_(
mav_msgs::default_topics::MOTOR_POSITION_MEASUREMENT),
82 motor_force_pub_topic_(
mav_msgs::default_topics::MOTOR_FORCE_MEASUREMENT),
84 publish_position_(false),
85 publish_force_(false),
89 max_force_(kDefaultMaxForce),
90 max_rot_velocity_(kDefaulMaxRotVelocity),
91 moment_constant_(kDefaultMomentConstant),
92 motor_constant_(kDefaultMotorConstant),
93 ref_motor_input_(0.0),
94 rolling_moment_coefficient_(kDefaultRollingMomentCoefficient),
95 rotor_drag_coefficient_(kDefaultRotorDragCoefficient),
97 time_constant_down_(kDefaultTimeConstantDown),
98 time_constant_up_(kDefaultTimeConstantUp),
99 node_handle_(nullptr),
100 wind_speed_W_(0, 0, 0),
101 pubs_and_subs_created_(false) {}
105 virtual void InitializeParams();
106 virtual void Publish();
109 virtual void UpdateForcesAndMoments();
110 virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
111 virtual void OnUpdate(
const common::UpdateInfo & );
122 void CreatePubsAndSubs();
125 double NormalizeAngle(
double input);
184 void ControlCommandCallback(GzCommandMotorInputMsgPtr& command_motor_input_msg);
186 void WindSpeedCallback(GzWindSpeedMsgPtr& wind_speed_msg);
194 #endif // ROTORS_GAZEBO_PLUGINS_MOTOR_MODELS_H
const boost::shared_ptr< const gz_mav_msgs::WindSpeed > GzWindSpeedMsgPtr
static constexpr double kDefaultRotorVelocitySlowdownSim
event::ConnectionPtr updateConnection_
Pointer to the update event connection.
static constexpr double kDefaultTimeConstantDown
std::string command_sub_topic_
gazebo::transport::NodePtr node_handle_
std::string motor_position_pub_topic_
std::string motor_force_pub_topic_
gazebo::transport::PublisherPtr motor_position_pub_
const boost::shared_ptr< const gz_mav_msgs::CommandMotorSpeed > GzCommandMotorInputMsgPtr
gazebo::transport::SubscriberPtr wind_speed_sub_
gazebo::transport::PublisherPtr motor_velocity_pub_
static constexpr double kDefaultRollingMomentCoefficient
ignition::math::Vector3d wind_speed_W_
std::string wind_speed_sub_topic_
double rotor_velocity_slowdown_sim_
double rotor_drag_coefficient_
gz_std_msgs::Float32 position_msg_
gz_std_msgs::Float32 turning_velocity_msg_
static constexpr double kDefaultMotorConstant
std::unique_ptr< FirstOrderFilter< double > > rotor_velocity_filter_
bool pubs_and_subs_created_
Flag that is set to true once CreatePubsAndSubs() is called, used to prevent CreatePubsAndSubs() from...
static constexpr double kDefaultTimeConstantUp
gz_std_msgs::Float32 force_msg_
static constexpr double kDefaultRotorDragCoefficient
gazebo::transport::PublisherPtr motor_force_pub_
static constexpr double kDefaultMaxForce
static constexpr double kDefaulMaxRotVelocity
double rolling_moment_coefficient_
double time_constant_down_
static constexpr double kDefaultMomentConstant
boost::thread callback_queue_thread_
gazebo::transport::SubscriberPtr command_sub_
std::string motor_speed_pub_topic_