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 #include <ignition/msgs.hh>
24 
25 #include "gazebo/common/PID.hh"
26 #include "gazebo/common/Time.hh"
29 #include "gazebo/msgs/msgs.hh"
30 #include "gazebo/util/system.hh"
31 
32 namespace gazebo
33 {
34  namespace physics
35  {
36  // Forward declare private data values.
37  class JointControllerPrivate;
38 
41 
44  class GZ_PHYSICS_VISIBLE JointController
45  {
48  public: explicit JointController(ModelPtr _model);
49 
51  public: virtual ~JointController();
52 
55  public: void AddJoint(JointPtr _joint);
56 
59  public: void RemoveJoint(Joint *_joint);
60 
62  public: void Update();
63 
65  public: void Reset();
66 
69  public: void SetJointPosition(
70  const std::string &_name, double _position, int _index = 0);
71 
74  public: void SetJointPositions(
75  const std::map<std::string, double> &_jointPositions);
76 
79  public: common::Time GetLastUpdateTime() const;
80 
84  public: std::map<std::string, JointPtr> GetJoints() const;
85 
89  public: void SetPositionPID(const std::string &_jointName,
90  const common::PID &_pid);
91 
96  public: bool SetPositionTarget(const std::string &_jointName,
97  double _target);
98 
102  public: void SetVelocityPID(const std::string &_jointName,
103  const common::PID &_pid);
104 
109  public: bool SetVelocityTarget(const std::string &_jointName,
110  double _target);
111 
115  public: std::map<std::string, common::PID> GetPositionPIDs() const;
116 
120  public: std::map<std::string, common::PID> GetVelocityPIDs() const;
121 
125  public: std::map<std::string, double> GetForces() const;
126 
130  public: std::map<std::string, double> GetPositions() const;
131 
135  public: std::map<std::string, double> GetVelocities() const;
136 
144  private: bool OnJointCmdReq(const ignition::msgs::StringMsg &_req,
145  ignition::msgs::JointCmd &_rep);
146 
149  private: void OnJointCommand(const ignition::msgs::JointCmd &_msg);
150 
154  private: void OnJointCmd(ConstJointCmdPtr &_msg);
155 
173  public: void SetJointPosition(
174  JointPtr _joint, double _position, int _index = 0);
175 
177  private: JointControllerPrivate *dataPtr;
178  };
180  }
181 }
182 #endif
Forward declarations for transport.
A class for manipulating physics::Joint.
Definition: JointController.hh:44
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
default namespace for gazebo
Base class for all joints.
Definition: Joint.hh:50
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