All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LinkState.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
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 link state
18  * Author: Nate Koenig
19  */
20 
21 #ifndef _LINKSTATE_HH_
22 #define _LINKSTATE_HH_
23 
24 #include <vector>
25 #include <string>
26 
27 #include "gazebo/sdf/sdf.hh"
28 #include "gazebo/physics/State.hh"
30 #include "gazebo/math/Pose.hh"
31 
32 namespace gazebo
33 {
34  namespace physics
35  {
38 
47  class LinkState : public State
48  {
50  public: LinkState();
51 
57  public: explicit LinkState(const LinkPtr _link);
58 
63  public: explicit LinkState(const sdf::ElementPtr _sdf);
64 
66  public: virtual ~LinkState();
67 
72  public: virtual void Load(const sdf::ElementPtr _elem);
73 
76  public: const math::Pose &GetPose() const;
77 
80  public: const math::Pose &GetVelocity() const;
81 
84  public: const math::Pose &GetAcceleration() const;
85 
88  public: const math::Pose &GetWrench() const;
89 
94  public: unsigned int GetCollisionStateCount() const;
95 
103  public: CollisionState GetCollisionState(unsigned int _index) const;
104 
113  const std::string &_collisionName) const;
114 
117  public: const std::vector<CollisionState> &GetCollisionStates() const;
118 
121  public: bool IsZero() const;
122 
126  public: LinkState &operator=(const LinkState &_state);
127 
131  public: LinkState operator-(const LinkState &_state) const;
132 
136  public: LinkState operator+(const LinkState &_state) const;
137 
142  public: friend std::ostream &operator<<(std::ostream &_out,
143  const gazebo::physics::LinkState &_state)
144  {
145  _out << "<link name='" << _state.name << "'>\n";
146  _out << "<pose>" << _state.pose << "</pose>\n";
147  _out << "<velocity>" << _state.velocity << "</velocity>\n";
148  _out << "<acceleration>" << _state.acceleration << "</acceleration>\n";
149  _out << "<wrench>" << _state.wrench << "</wrench>\n";
150 
151  for (std::vector<CollisionState>::const_iterator iter =
152  _state.collisionStates.begin();
153  iter != _state.collisionStates.end(); ++iter)
154  {
155  _out << *iter;
156  }
157 
158  _out << "</link>\n";
159 
160  return _out;
161  }
162 
164  private: math::Pose pose;
165 
167  private: math::Pose velocity;
168 
170  private: math::Pose acceleration;
171 
173  private: math::Pose wrench;
174 
176  private: std::vector<CollisionState> collisionStates;
177  };
179  }
180 }
181 #endif