Ignition Common

API Reference

4.1.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 
123  public: PoseKeyFrame *CreateKeyFrame(const double _time);
124 
127  public: void InterpolatedKeyFrame(PoseKeyFrame &_kf);
128 
132  protected: void InterpolatedKeyFrame(const double _time,
133  PoseKeyFrame &_kf);
134 
136  protected: void BuildInterpolationSplines();
137 
139  IGN_UTILS_IMPL_PTR(dataPtr)
140  };
141 
143  class IGNITION_COMMON_GRAPHICS_VISIBLE NumericAnimation : public Animation
144  {
149  public: NumericAnimation(const std::string &_name,
150  const double _length, const bool _loop);
151 
155  public: NumericKeyFrame *CreateKeyFrame(const double _time);
156 
160  public: void InterpolatedKeyFrame(NumericKeyFrame &_kf) const;
161 
163  IGN_UTILS_IMPL_PTR(dataPtr)
164  };
165 
168  class IGNITION_COMMON_GRAPHICS_VISIBLE TrajectoryInfo
169  {
171  public: TrajectoryInfo();
172 
175  public: unsigned int Id() const;
176 
179  public: void SetId(unsigned int _id);
180 
183  public: unsigned int AnimIndex() const;
184 
188  public: void SetAnimIndex(unsigned int _index);
189 
192  public: std::chrono::steady_clock::duration Duration() const;
193 
197  public: double DistanceSoFar(
198  const std::chrono::steady_clock::duration &_time) const;
199 
202  public: std::chrono::steady_clock::time_point StartTime() const;
203 
206  public: void SetStartTime(
207  const std::chrono::steady_clock::time_point &_startTime);
208 
211  public: std::chrono::steady_clock::time_point EndTime() const;
212 
215  public: void SetEndTime(
216  const std::chrono::steady_clock::time_point &_endTime);
217 
220  public: bool Translated() const;
221 
224  public: void SetTranslated(bool _translated);
225 
228  public: common::PoseAnimation *Waypoints() const;
229 
233  public: void SetWaypoints(
235  _waypoints);
236 
238  IGN_UTILS_IMPL_PTR(dataPtr)
239  };
240  }
241 }
242 #endif
Information about a trajectory for an animation (e.g., Actor) This contains the keyframe information...
Definition: Animation.hh:168
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:143
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