Ignition Common

API Reference

4.4.0
Animation.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 IGNITION_COMMON_ANIMATION_HH_
18 #define IGNITION_COMMON_ANIMATION_HH_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 #include <ignition/math/Pose3.hh>
25 #include <ignition/math/Spline.hh>
27 
28 #include <ignition/utils/ImplPtr.hh>
29 
30 #include <ignition/common/graphics/Export.hh>
31 
32 namespace ignition
33 {
34  namespace common
35  {
36  class KeyFrame;
37  class PoseKeyFrame;
38  class NumericKeyFrame;
39 
43  class IGNITION_COMMON_GRAPHICS_VISIBLE Animation
44  {
49  public: Animation(const std::string &_name,
50  const double _length, const bool _loop);
51 
54  public: double Length() const;
55 
58  public: void Length(const double _len);
59 
62  public: void Time(const double _time);
63 
66  public: void AddTime(const double _time);
67 
70  public: double Time() const;
71 
74  public: bool InterpolateX() const;
75 
78  public: void SetInterpolateX(const bool _interpolateX);
79 
82  public: unsigned int KeyFrameCount() const;
83 
87  public: common::KeyFrame *KeyFrame(const unsigned int _index) const;
88 
92  protected: template<typename KeyFrameType>
93  KeyFrameType *CreateKeyFrame(const double _time);
94 
101  protected: double KeyFramesAtTime(
102  double _time, common::KeyFrame **_kf1,
103  common::KeyFrame **_kf2,
104  unsigned int &_firstKeyIndex) const;
105 
107  IGN_UTILS_IMPL_PTR(dataPtr)
108  };
109 
111  class IGNITION_COMMON_GRAPHICS_VISIBLE PoseAnimation : public Animation
112  {
117  public: PoseAnimation(const std::string &_name,
118  const double _length, const bool _loop);
119 
131  public: PoseAnimation(const std::string &_name,
132  const double _length, const bool _loop,
133  double _tension);
134 
138  public: PoseKeyFrame *CreateKeyFrame(const double _time);
139 
142  public: void InterpolatedKeyFrame(PoseKeyFrame &_kf);
143 
147  protected: void InterpolatedKeyFrame(const double _time,
148  PoseKeyFrame &_kf);
149 
151  protected: void BuildInterpolationSplines();
152 
154  IGN_UTILS_IMPL_PTR(dataPtr)
155  };
156 
158  class IGNITION_COMMON_GRAPHICS_VISIBLE NumericAnimation : public Animation
159  {
164  public: NumericAnimation(const std::string &_name,
165  const double _length, const bool _loop);
166 
170  public: NumericKeyFrame *CreateKeyFrame(const double _time);
171 
175  public: void InterpolatedKeyFrame(NumericKeyFrame &_kf) const;
176 
178  IGN_UTILS_IMPL_PTR(dataPtr)
179  };
180 
183  class IGNITION_COMMON_GRAPHICS_VISIBLE TrajectoryInfo
184  {
186  public: TrajectoryInfo();
187 
190  public: unsigned int Id() const;
191 
194  public: void SetId(unsigned int _id);
195 
198  public: unsigned int AnimIndex() const;
199 
203  public: void SetAnimIndex(unsigned int _index);
204 
207  public: std::chrono::steady_clock::duration Duration() const;
208 
212  public: double DistanceSoFar(
213  const std::chrono::steady_clock::duration &_time) const;
214 
217  public: std::chrono::steady_clock::time_point StartTime() const;
218 
221  public: void SetStartTime(
222  const std::chrono::steady_clock::time_point &_startTime);
223 
226  public: std::chrono::steady_clock::time_point EndTime() const;
227 
230  public: void SetEndTime(
231  const std::chrono::steady_clock::time_point &_endTime);
232 
235  public: bool Translated() const;
236 
239  public: void SetTranslated(bool _translated);
240 
243  public: common::PoseAnimation *Waypoints() const;
244 
248  public: void SetWaypoints(
250  _waypoints);
251 
260  public: void SetWaypoints(
262  _waypoints, double _tension);
263 
265  IGN_UTILS_IMPL_PTR(dataPtr)
266  };
267  }
268 }
269 #endif
Information about a trajectory for an animation (e.g., Actor) This contains the keyframe information...
Definition: Animation.hh:183
Manages an animation, which is a collection of keyframes and the ability to interpolate between the k...
Definition: Animation.hh:43
A numeric animation.
Definition: Animation.hh:158
STL class.
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:33
STL class.
A pose animation.
Definition: Animation.hh:111
A key frame in an animation.
Definition: KeyFrame.hh:34
A keyframe for a NumericAnimation.
Definition: KeyFrame.hh:82
Forward declarations for the common classes.
A keyframe for a PoseAnimation.
Definition: KeyFrame.hh:52