JointController.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_JOINTCONTROLLER_HH_
18 #define _GAZEBO_JOINTCONTROLLER_HH_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 #include "gazebo/common/PID.hh"
25 #include "gazebo/common/Time.hh"
28 #include "gazebo/msgs/msgs.hh"
29 #include "gazebo/util/system.hh"
30 
31 namespace gazebo
32 {
33  namespace physics
34  {
35  // Forward declare private data values.
36  class JointControllerPrivate;
37 
40 
43  class GZ_PHYSICS_VISIBLE JointController
44  {
47  public: explicit JointController(ModelPtr _model);
48 
50  public: virtual ~JointController();
51 
54  public: void AddJoint(JointPtr _joint);
55 
58  public: void RemoveJoint(Joint *_joint);
59 
61  public: void Update();
62 
64  public: void Reset();
65 
68  public: void SetJointPosition(
69  const std::string &_name, double _position, int _index = 0);
70 
73  public: void SetJointPositions(
74  const std::map<std::string, double> &_jointPositions);
75 
78  public: common::Time GetLastUpdateTime() const;
79 
83  public: std::map<std::string, JointPtr> GetJoints() const;
84 
88  public: void SetPositionPID(const std::string &_jointName,
89  const common::PID &_pid);
90 
95  public: bool SetPositionTarget(const std::string &_jointName,
96  double _target);
97 
101  public: void SetVelocityPID(const std::string &_jointName,
102  const common::PID &_pid);
103 
108  public: bool SetVelocityTarget(const std::string &_jointName,
109  double _target);
110 
114  public: std::map<std::string, common::PID> GetPositionPIDs() const;
115 
119  public: std::map<std::string, common::PID> GetVelocityPIDs() const;
120 
124  public: std::map<std::string, double> GetForces() const;
125 
129  public: std::map<std::string, double> GetPositions() const;
130 
134  public: std::map<std::string, double> GetVelocities() const;
135 
138  private: void OnJointCmd(ConstJointCmdPtr &_msg);
139 
157  public: void SetJointPosition(
158  JointPtr _joint, double _position, int _index = 0);
159 
161  private: JointControllerPrivate *dataPtr;
162  };
164  }
165 }
166 #endif
Forward declarations for the common classes.
Definition: Animation.hh:33
Forward declarations for transport.
A class for manipulating physics::Joint.
Definition: JointController.hh:43
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
default namespace for gazebo
Base class for all joints.
Definition: Joint.hh:53
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
Generic PID controller class.
Definition: PID.hh:36
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44