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
32namespace 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
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 const 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 const double _target);
111
117 public: bool SetForce(const std::string &_jointName, const double _force);
118
122 public: std::map<std::string, common::PID> GetPositionPIDs() const;
123
127 public: std::map<std::string, common::PID> GetVelocityPIDs() const;
128
132 public: std::map<std::string, double> GetForces() const;
133
137 public: std::map<std::string, double> GetPositions() const;
138
142 public: std::map<std::string, double> GetVelocities() const;
143
151 private: bool OnJointCmdReq(const ignition::msgs::StringMsg &_req,
152 ignition::msgs::JointCmd &_rep);
153
156 private: void OnJointCommand(const ignition::msgs::JointCmd &_msg);
157
175 public: void SetJointPosition(
176 JointPtr _joint, double _position, int _index = 0);
177
179 private: JointControllerPrivate *dataPtr;
180 };
182 }
183}
184#endif
default namespace for gazebo
Forward declarations for transport.
Generic PID controller class.
Definition PID.hh:37
A Time class, can be used to hold wall- or sim-time.
Definition Time.hh:48
A class for manipulating physics::Joint.
Definition JointController.hh:45
std::map< std::string, double > GetForces() const
Get all the applied forces.
void SetJointPosition(const std::string &_name, double _position, int _index=0)
Set the positions of a Joint by name.
void SetPositionPID(const std::string &_jointName, const common::PID &_pid)
Set the position PID values for a joint.
bool SetVelocityTarget(const std::string &_jointName, const double _target)
Set the target velocity for the velocity PID controller.
void Reset()
Reset all commands.
void SetJointPosition(JointPtr _joint, double _position, int _index=0)
Set the positions of a Joint by name The position is specified in native units, which means,...
common::Time GetLastUpdateTime() const
Get the last time the controller was updated.
virtual ~JointController()
Destructor.
bool SetForce(const std::string &_jointName, const double _force)
Set the applied effort for the specified joint.
std::map< std::string, JointPtr > GetJoints() const
Get all the joints.
std::map< std::string, double > GetPositions() const
Get all the position PID set points.
JointController(ModelPtr _model)
Constructor.
std::map< std::string, common::PID > GetVelocityPIDs() const
Get all the velocity PID controllers.
bool SetPositionTarget(const std::string &_jointName, const double _target)
Set the target position for the position PID controller.
void AddJoint(JointPtr _joint)
Add a joint to control.
std::map< std::string, double > GetVelocities() const
Get all the velocity PID set points.
void SetVelocityPID(const std::string &_jointName, const common::PID &_pid)
Set the velocity PID values for a joint.
std::map< std::string, common::PID > GetPositionPIDs() const
Get all the position PID controllers.
void RemoveJoint(Joint *_joint)
Remove a joint from control.
void SetJointPositions(const std::map< std::string, double > &_jointPositions)
Set the positions of a set of Joint's.
void Update()
Update the joint control.
Base class for all joints.
Definition Joint.hh:51
boost::shared_ptr< Model > ModelPtr
Definition PhysicsTypes.hh:93
boost::shared_ptr< Joint > JointPtr
Definition PhysicsTypes.hh:117
Forward declarations for the common classes.
Definition Animation.hh:27