quadrotor_hardware_gazebo.h
Go to the documentation of this file.
00001 //=================================================================================================
00002 // Copyright (c) 2013, Johannes Meyer, TU Darmstadt
00003 // All rights reserved.
00004 
00005 // Redistribution and use in source and binary forms, with or without
00006 // modification, are permitted provided that the following conditions are met:
00007 //     * Redistributions of source code must retain the above copyright
00008 //       notice, this list of conditions and the following disclaimer.
00009 //     * Redistributions in binary form must reproduce the above copyright
00010 //       notice, this list of conditions and the following disclaimer in the
00011 //       documentation and/or other materials provided with the distribution.
00012 //     * Neither the name of the Flight Systems and Automatic Control group,
00013 //       TU Darmstadt, nor the names of its contributors may be used to
00014 //       endorse or promote products derived from this software without
00015 //       specific prior written permission.
00016 
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00018 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //=================================================================================================
00028 
00029 #ifndef HECTOR_QUADROTOR_CONTROLLER_QUADROTOR_HARDWARE_GAZEBO_H
00030 #define HECTOR_QUADROTOR_CONTROLLER_QUADROTOR_HARDWARE_GAZEBO_H
00031 
00032 #include <gazebo_ros_control/robot_hw_sim.h>
00033 #include <hector_quadrotor_controller/quadrotor_interface.h>
00034 
00035 #include <nav_msgs/Odometry.h>
00036 #include <sensor_msgs/Imu.h>
00037 #include <hector_uav_msgs/MotorStatus.h>
00038 
00039 #include <ros/node_handle.h>
00040 #include <ros/callback_queue.h>
00041 
00042 namespace hector_quadrotor_controller_gazebo {
00043 
00044 using namespace hector_quadrotor_controller;
00045 using namespace hardware_interface;
00046 using namespace gazebo_ros_control;
00047 
00048 class QuadrotorHardwareSim : public RobotHWSim, public QuadrotorInterface
00049 {
00050 public:
00051   QuadrotorHardwareSim();
00052   virtual ~QuadrotorHardwareSim();
00053 
00054   virtual const ros::Time &getTimestamp() { return header_.stamp; }
00055 
00056   virtual PoseHandlePtr getPose()                 { return PoseHandlePtr(new PoseHandle(this, &pose_)); }
00057   virtual TwistHandlePtr getTwist()               { return TwistHandlePtr(new TwistHandle(this, &twist_)); }
00058   virtual AccelerationHandlePtr getAcceleration() { return AccelerationHandlePtr(new AccelerationHandle(this, &acceleration_)); }
00059   virtual ImuHandlePtr getSensorImu()             { return ImuHandlePtr(new ImuHandle(this, &imu_)); }
00060   virtual MotorStatusHandlePtr getMotorStatus()   { return MotorStatusHandlePtr(new MotorStatusHandle(this, &motor_status_)); }
00061 
00062   virtual bool getMassAndInertia(double &mass, double inertia[3]);
00063 
00064   virtual bool initSim(
00065       const std::string& robot_namespace,
00066       ros::NodeHandle model_nh,
00067       gazebo::physics::ModelPtr parent_model,
00068       const urdf::Model *const urdf_model,
00069       std::vector<transmission_interface::TransmissionInfo> transmissions);
00070 
00071   virtual void readSim(ros::Time time, ros::Duration period);
00072 
00073   virtual void writeSim(ros::Time time, ros::Duration period);
00074 
00075 private:
00076   void stateCallback(const nav_msgs::OdometryConstPtr &state);
00077   void imuCallback(const sensor_msgs::ImuConstPtr &imu);
00078   void motorStatusCallback(const hector_uav_msgs::MotorStatusConstPtr &motor_status);
00079 
00080 protected:
00081   std_msgs::Header header_;
00082   Pose pose_;
00083   Twist twist_;
00084   Vector3 acceleration_;
00085   Imu imu_;
00086   MotorStatus motor_status_;
00087   std::string base_link_frame_, world_frame_;
00088 
00089   WrenchCommandHandlePtr wrench_output_;
00090   MotorCommandHandlePtr motor_output_;
00091 
00092   gazebo::physics::ModelPtr model_;
00093   gazebo::physics::LinkPtr link_;
00094   gazebo::physics::PhysicsEnginePtr physics_;
00095 
00096   gazebo::math::Pose gz_pose_;
00097   gazebo::math::Vector3 gz_velocity_, gz_acceleration_, gz_angular_velocity_;
00098 
00099   ros::CallbackQueue callback_queue_;
00100   ros::Subscriber subscriber_state_;
00101   ros::Subscriber subscriber_imu_;
00102   ros::Subscriber subscriber_motor_status_;
00103   ros::Publisher publisher_wrench_command_;
00104   ros::Publisher publisher_motor_command_;
00105 };
00106 
00107 } // namespace hector_quadrotor_controller_gazebo
00108 
00109 #endif // HECTOR_QUADROTOR_CONTROLLER_QUADROTOR_HARDWARE_GAZEBO_H


hector_quadrotor_controller_gazebo
Author(s): Johannes Meyer
autogenerated on Thu Jun 6 2019 21:32:57