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 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 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 
125  public: void FillSDF(sdf::ElementPtr _sdf);
126 
130  public: LinkState &operator=(const LinkState &_state);
131 
135  public: LinkState operator-(const LinkState &_state) const;
136 
140  public: LinkState operator+(const LinkState &_state) const;
141 
146  public: friend std::ostream &operator<<(std::ostream &_out,
147  const gazebo::physics::LinkState &_state)
148  {
149  _out << " <link name='" << _state.name << "'>\n";
150  _out << " <pose>" << _state.pose << "</pose>\n";
151  _out << " <velocity>" << _state.velocity << "</velocity>\n";
152  _out << " <acceleration>" << _state.acceleration
153  << "</acceleration>\n";
154  _out << " <wrench>" << _state.wrench << "</wrench>\n";
155 
156  for (std::vector<CollisionState>::const_iterator iter =
157  _state.collisionStates.begin();
158  iter != _state.collisionStates.end(); ++iter)
159  {
160  _out << *iter;
161  }
162 
163  _out << " </link>\n";
164 
165  return _out;
166  }
167 
169  private: math::Pose pose;
170 
172  private: math::Pose velocity;
173 
175  private: math::Pose acceleration;
176 
178  private: math::Pose wrench;
179 
181  private: std::vector<CollisionState> collisionStates;
182  };
184  }
185 }
186 #endif