JointController.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 
57  public: void Update();
58 
60  public: void Reset();
61 
64  public: void SetJointPosition(
65  const std::string &_name, double _position, int _index = 0);
66 
69  public: void SetJointPositions(
70  const std::map<std::string, double> &_jointPositions);
71 
74  public: common::Time GetLastUpdateTime() const;
75 
79  public: std::map<std::string, JointPtr> GetJoints() const;
80 
84  public: void SetPositionPID(const std::string &_jointName,
85  const common::PID &_pid);
86 
91  public: bool SetPositionTarget(const std::string &_jointName,
92  double _target);
93 
97  public: void SetVelocityPID(const std::string &_jointName,
98  const common::PID &_pid);
99 
104  public: bool SetVelocityTarget(const std::string &_jointName,
105  double _target);
106 
110  public: std::map<std::string, common::PID> GetPositionPIDs() const;
111 
115  public: std::map<std::string, common::PID> GetVelocityPIDs() const;
116 
120  public: std::map<std::string, double> GetForces() const;
121 
125  public: std::map<std::string, double> GetPositions() const;
126 
130  public: std::map<std::string, double> GetVelocities() const;
131 
134  private: void OnJointCmd(ConstJointCmdPtr &_msg);
135 
153  public: void SetJointPosition(
154  JointPtr _joint, double _position, int _index = 0);
155 
157  private: JointControllerPrivate *dataPtr;
158  };
160  }
161 }
162 #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:108
default namespace for gazebo
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:88
Generic PID controller class.
Definition: PID.hh:36
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44