All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JointController.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 
44  {
47  public: explicit JointController(ModelPtr _model);
48 
50  public: virtual ~JointController();
51 
54  public: void AddJoint(JointPtr _joint);
55 
57  public: void Update();
58 
60  public: void Reset();
61 
66  public: void SetJointPosition(
67  const std::string &_name, double _position, int _index = 0);
68 
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 
89  public: bool SetPositionTarget(const std::string &_jointName,
90  double _target);
91 
96  public: bool SetVelocityTarget(const std::string &_jointName,
97  double _target);
98 
102  public: std::map<std::string, common::PID> GetPositionPIDs() const;
103 
107  public: std::map<std::string, common::PID> GetVelocityPIDs() const;
108 
112  public: std::map<std::string, double> GetForces() const;
113 
117  public: std::map<std::string, double> GetPositions() const;
118 
122  public: std::map<std::string, double> GetVelocities() const;
123 
126  private: void OnJointCmd(ConstJointCmdPtr &_msg);
127 
147  public: void SetJointPosition(
148  JointPtr _joint, double _position, int _index = 0);
149 
162 
169 
179 
187 
189  private: JointControllerPrivate *dataPtr;
190  };
192  }
193 }
194 #endif