JointState.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 /* Desc: A joint state
18  * Author: Nate Koenig
19  */
20 
21 #ifndef _JOINTSTATE_HH_
22 #define _JOINTSTATE_HH_
23 
24 #include <vector>
25 #include <string>
26 
27 #include "gazebo/physics/State.hh"
28 #include "gazebo/math/Pose.hh"
29 #include "gazebo/util/system.hh"
30 
31 namespace gazebo
32 {
33  namespace physics
34  {
37 
41  {
43  public: JointState();
44 
49  public: JointState(JointPtr _joint, const common::Time &_realTime,
50  const common::Time &_simTime);
51 
54  public: explicit JointState(JointPtr _joint);
55 
60  public: explicit JointState(const sdf::ElementPtr _sdf);
61 
63  public: virtual ~JointState();
64 
69  public: void Load(JointPtr _joint, const common::Time &_realTime,
70  const common::Time &_simTime);
71 
74  public: virtual void Load(const sdf::ElementPtr _elem);
75 
78  public: unsigned int GetAngleCount() const;
79 
84  public: math::Angle GetAngle(unsigned int _axis) const;
85 
88  public: const std::vector<math::Angle> &GetAngles() const;
89 
92  public: bool IsZero() const;
93 
96  public: void FillSDF(sdf::ElementPtr _sdf);
97 
101  public: JointState &operator=(const JointState &_state);
102 
106  public: JointState operator-(const JointState &_state) const;
107 
111  public: JointState operator+(const JointState &_state) const;
112 
117  public: inline friend std::ostream &operator<<(std::ostream &_out,
118  const gazebo::physics::JointState &_state)
119  {
120  _out << "<joint name='" << _state.GetName() << "'>";
121 
122  int i = 0;
123  for (std::vector<math::Angle>::const_iterator iter =
124  _state.angles.begin(); iter != _state.angles.end(); ++iter)
125  {
126  _out << "<angle axis='" << i << "'>" << (*iter) << "</angle>";
127  }
128 
129  _out << "</joint>";
130 
131  return _out;
132  }
133 
134  private: std::vector<math::Angle> angles;
135  };
137  }
138 }
139 #endif
std::string GetName() const
Get the name associated with this State.
State of an entity.
Definition: State.hh:43
friend std::ostream & operator<<(std::ostream &_out, const gazebo::physics::JointState &_state)
Stream insertion operator.
Definition: JointState.hh:117
keeps track of state of a physics::Joint
Definition: JointState.hh:40
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:98
An angle and related functions.
Definition: Angle.hh:52
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43