CartDemoPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GAZEBO_PLUGINS_CARTDEMOPLUGIN_HH_
18 #define GAZEBO_PLUGINS_CARTDEMOPLUGIN_HH_
19 #include <ignition/transport/Node.hh>
20 
21 #include "gazebo/common/PID.hh"
22 #include "gazebo/common/Plugin.hh"
23 #include "gazebo/physics/physics.hh"
25 #include "gazebo/util/system.hh"
26 
27 #define NUM_JOINTS 3
28 
29 namespace gazebo
30 {
37  {
38  public: CartDemoPlugin();
39  public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
40  public: virtual void Init();
41 
42  private: void OnUpdate();
43 
44  private: transport::NodePtr node;
45 
46  private: event::ConnectionPtr updateConnection;
47 
48  private: physics::ModelPtr model;
49 
50  private: physics::JointPtr joints[NUM_JOINTS];
51  private: common::PID jointPIDs[NUM_JOINTS];
52  private: double jointPositions[NUM_JOINTS];
53  private: double jointVelocities[NUM_JOINTS];
54  private: double jointMaxEfforts[NUM_JOINTS];
55 
56  private: common::Time prevUpdateTime;
57 
58  // Place ignition::transport objects at the end of this file to
59  // guarantee they are destructed first.
60 
62  private: ignition::transport::Node nodeIgn;
63  };
64 }
65 #endif
This plugin drives a four wheeled cart model forward and back by applying a small wheel torque...
Definition: CartDemoPlugin.hh:36
Forward declarations for the common classes.
Definition: Animation.hh:26
Forward declarations for transport.
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
#define NUM_JOINTS
Definition: CartDemoPlugin.hh:27
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
A plugin with access to physics::Model.
Definition: Plugin.hh:305
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:59
Generic PID controller class.
Definition: PID.hh:36
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44