Fawkes API  Fawkes Development Version
gyro.h
1 /***************************************************************************
2  * gyro.h - Plugin for a gyro sensor on a model
3  *
4  * Created: Tue Feb 04 14:42:29 2014
5  * Copyright 2014 Frederik Zwilling
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #include <boost/bind.hpp>
22 #include <gazebo/common/common.hh>
23 #include <gazebo/gazebo.hh>
24 #include <gazebo/physics/physics.hh>
25 #include <gazebo/transport/transport.hh>
26 #include <list>
27 #include <stdio.h>
28 #include <string.h>
29 
30 namespace gazebo {
31 /** @class Gyro
32  * Plugin for a gyro sensor on a model
33  * @author Frederik Zwilling
34  */
35 class Gyro : public ModelPlugin
36 {
37 public:
38  ///Constructor
39  Gyro();
40 
41  ///Destructor
42  ~Gyro();
43 
44  //Overridden ModelPlugin-Functions
45  virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/);
46  virtual void OnUpdate(const common::UpdateInfo &);
47  virtual void Reset();
48 
49 private:
50  /// Pointer to the model
51  physics::ModelPtr model_;
52  /// Pointer to the update event connection
53  event::ConnectionPtr update_connection_;
54  ///Node for communication to fawkes
55  transport::NodePtr node_;
56  ///name of the gyro and the communication channel
57  std::string name_;
58 
59  ///time variable to send in intervals
60  double last_sent_time_;
61 
62  ///time interval between to gyro msgs
63  double send_interval_;
64 
65  //Gyro Stuff:
66  ///Sending Gyro-angle to fawkes:
67  void send_gyro();
68 
69  ///Publisher for GyroAngle
70  transport::PublisherPtr gyro_pub_;
71 };
72 } // namespace gazebo
gazebo::Gyro::OnUpdate
virtual void OnUpdate(const common::UpdateInfo &)
Called by the world update start event.
Definition: gyro.cpp:75
gazebo::Gyro::Gyro
Gyro()
Constructor.
Definition: gyro.cpp:32
gazebo::Gyro::Load
virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr)
on loading of the plugin
Definition: gyro.cpp:45
gazebo::Gyro
Plugin for a gyro sensor on a model.
Definition: gyro.h:36
gazebo::Gyro::~Gyro
~Gyro()
Destructor.
Definition: gyro.cpp:36
gazebo::Gyro::Reset
virtual void Reset()
on Gazebo reset
Definition: gyro.cpp:88