00001 /* 00002 * Copyright 2015 Fadri Furrer, ASL, ETH Zurich, Switzerland 00003 * Copyright 2015 Michael Burri, ASL, ETH Zurich, Switzerland 00004 * Copyright 2015 Mina Kamel, ASL, ETH Zurich, Switzerland 00005 * Copyright 2015 Janosch Nikolic, ASL, ETH Zurich, Switzerland 00006 * Copyright 2015 Markus Achtelik, ASL, ETH Zurich, Switzerland 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); 00009 * you may not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, 00016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 */ 00020 00021 00022 #ifndef ROTORS_GAZEBO_PLUGINS_MOTOR_MODEL_H 00023 #define ROTORS_GAZEBO_PLUGINS_MOTOR_MODEL_H 00024 00025 #include <Eigen/Eigen> 00026 00027 class MotorModel 00028 { 00029 public: 00030 MotorModel() 00031 : motor_rot_vel_(0.0), 00032 ref_motor_rot_vel_(0.0), 00033 prev_sim_time_(0.0), 00034 sampling_time_(0.01) {} 00035 virtual ~MotorModel() {} 00036 void GetMotorVelocity(double &result) const { 00037 result = motor_rot_vel_; 00038 } 00039 void SetReferenceMotorVelocity(double ref_motor_rot_vel) { 00040 ref_motor_rot_vel_ = ref_motor_rot_vel; 00041 } 00042 00043 virtual void InitializeParams() = 0; 00044 virtual void Publish() = 0; 00045 00046 protected: 00047 double motor_rot_vel_; 00048 double ref_motor_rot_vel_; 00049 double prev_ref_motor_rot_vel_; 00050 double prev_sim_time_; 00051 double sampling_time_; 00052 00053 00054 virtual void UpdateForcesAndMoments() = 0; 00055 }; 00056 00057 #endif // ROTORS_GAZEBO_PLUGINS_MOTOR_MODEL_H