All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Actor.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 #ifndef _ACTOR_HH_
18 #define _ACTOR_HH_
19 
20 #include <string>
21 #include <map>
22 #include <vector>
23 
24 #include "gazebo/physics/Model.hh"
25 #include "gazebo/common/Time.hh"
28 
29 namespace gazebo
30 {
31  namespace common
32  {
33  class Mesh;
34  class Color;
35  }
36 
37  namespace physics
38  {
40  {
41  unsigned int id;
42  std::string type;
43  double duration;
44  double startTime;
45  double endTime;
46  bool translated;
47  };
48 
51 
55  class Actor : public Model
56  {
59  public: explicit Actor(BasePtr _parent);
60 
62  public: virtual ~Actor();
63 
66  public: void Load(sdf::ElementPtr _sdf);
67 
69  public: virtual void Init();
70 
72  public: virtual void Play();
73 
75  public: virtual void Stop();
76 
78  public: virtual bool IsActive();
79 
81  public: void Update();
82 
84  public: virtual void Fini();
85 
88  public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
89 
92  public: virtual const sdf::ElementPtr GetSDF();
93 
99  private: void AddSphereInertia(sdf::ElementPtr _linkSdf,
100  const math::Pose &_pose,
101  double _mass, double _radius);
102 
108  private: void AddSphereCollision(sdf::ElementPtr _linkSdf,
109  const std::string &_name,
110  const math::Pose &_pose,
111  double _radius);
112 
120  private: void AddSphereVisual(sdf::ElementPtr _linkSdf,
121  const std::string &_name,
122  const math::Pose &_pose,
123  double _radius,
124  const std::string &_material,
125  const common::Color &_ambient);
126 
134  private: void AddBoxVisual(sdf::ElementPtr _linkSdf,
135  const std::string &_name,
136  const math::Pose &_pose,
137  const math::Vector3 &_size,
138  const std::string &_material,
139  const common::Color &_ambient);
140 
145  private: void AddActorVisual(sdf::ElementPtr _linkSdf,
146  const std::string &_name,
147  const math::Pose &_pose);
148 
151  private: void LoadAnimation(sdf::ElementPtr _sdf);
152 
155  private: void LoadScript(sdf::ElementPtr _sdf);
156 
161  private: void SetPose(std::map<std::string, math::Matrix4> _frame,
162  std::map<std::string, std::string> _skelMap, double _time);
163 
165  protected: const common::Mesh *mesh;
166 
169 
171  protected: std::string skinFile;
172 
174  protected: double skinScale;
175 
177  protected: double startDelay;
178 
180  protected: double scriptLength;
181 
183  protected: double lastScriptTime;
184 
186  protected: bool loop;
187 
189  protected: bool active;
190 
192  protected: bool autoStart;
193 
195  protected: LinkPtr mainLink;
196 
199 
202 
204  protected: std::map<unsigned int, common::PoseAnimation*> trajectories;
205 
207  protected: std::vector<TrajectoryInfo> trajInfo;
208 
210  protected: std::map<std::string, common::SkeletonAnimation*>
212 
214  protected: std::map<std::string, std::map<std::string, std::string> >
216 
218  protected: std::map<std::string, bool> interpolateX;
219 
221  protected: math::Vector3 lastPos;
222 
224  protected: double pathLength;
225 
227  protected: unsigned int lastTraj;
228 
230  protected: std::string visualName;
231 
233  protected: uint32_t visualId;
234 
237 
239  protected: std::string oldAction;
240  };
242  }
243 }
244 #endif