Gazebo Common

API Reference

4.7.0
gz/common/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 <gz/math/Pose3.hh>
25 #include <gz/math/Spline.hh>
26 #include <gz/math/RotationSpline.hh>
27 
28 #include <ignition/utils/ImplPtr.hh>
29 
30 #include <gz/common/config.hh>
31 #include <gz/common/graphics/Export.hh>
32 
33 namespace ignition
34 {
35  namespace common
36  {
37  class KeyFrame;
38  class PoseKeyFrame;
39  class NumericKeyFrame;
40 
44  class IGNITION_COMMON_GRAPHICS_VISIBLE Animation
45  {
50  public: Animation(const std::string &_name,
51  const double _length, const bool _loop);
52 
55  public: double Length() const;
56 
59  public: void Length(const double _len);
60 
63  public: void Time(const double _time);
64 
67  public: void AddTime(const double _time);
68 
71  public: double Time() const;
72 
75  public: bool InterpolateX() const;
76 
79  public: void SetInterpolateX(const bool _interpolateX);
80 
83  public: unsigned int KeyFrameCount() const;
84 
88  public: common::KeyFrame *KeyFrame(const unsigned int _index) const;
89 
93  protected: template<typename KeyFrameType>
94  KeyFrameType *CreateKeyFrame(const double _time);
95 
102  protected: double KeyFramesAtTime(
103  double _time, common::KeyFrame **_kf1,
104  common::KeyFrame **_kf2,
105  unsigned int &_firstKeyIndex) const;
106 
108  IGN_UTILS_IMPL_PTR(dataPtr)
109  };
110 
112  class IGNITION_COMMON_GRAPHICS_VISIBLE PoseAnimation : public Animation
113  {
118  public: PoseAnimation(const std::string &_name,
119  const double _length, const bool _loop);
120 
132  public: PoseAnimation(const std::string &_name,
133  const double _length, const bool _loop,
134  double _tension);
135 
139  public: PoseKeyFrame *CreateKeyFrame(const double _time);
140 
143  public: void InterpolatedKeyFrame(PoseKeyFrame &_kf);
144 
148  protected: void InterpolatedKeyFrame(const double _time,
149  PoseKeyFrame &_kf);
150 
152  protected: void BuildInterpolationSplines();
153 
155  IGN_UTILS_IMPL_PTR(dataPtr)
156  };
157 
159  class IGNITION_COMMON_GRAPHICS_VISIBLE NumericAnimation : public Animation
160  {
165  public: NumericAnimation(const std::string &_name,
166  const double _length, const bool _loop);
167 
171  public: NumericKeyFrame *CreateKeyFrame(const double _time);
172 
176  public: void InterpolatedKeyFrame(NumericKeyFrame &_kf) const;
177 
179  IGN_UTILS_IMPL_PTR(dataPtr)
180  };
181 
184  class IGNITION_COMMON_GRAPHICS_VISIBLE TrajectoryInfo
185  {
187  public: TrajectoryInfo();
188 
191  public: unsigned int Id() const;
192 
195  public: void SetId(unsigned int _id);
196 
199  public: unsigned int AnimIndex() const;
200 
204  public: void SetAnimIndex(unsigned int _index);
205 
208  public: std::chrono::steady_clock::duration Duration() const;
209 
213  public: double DistanceSoFar(
214  const std::chrono::steady_clock::duration &_time) const;
215 
218  public: std::chrono::steady_clock::time_point StartTime() const;
219 
222  public: void SetStartTime(
223  const std::chrono::steady_clock::time_point &_startTime);
224 
227  public: std::chrono::steady_clock::time_point EndTime() const;
228 
231  public: void SetEndTime(
232  const std::chrono::steady_clock::time_point &_endTime);
233 
236  public: bool Translated() const;
237 
240  public: void SetTranslated(bool _translated);
241 
244  public: common::PoseAnimation *Waypoints() const;
245 
249  public: void SetWaypoints(
251  _waypoints);
252 
261  public: void SetWaypoints(
263  _waypoints, double _tension);
264 
266  IGN_UTILS_IMPL_PTR(dataPtr)
267  };
268  }
269 }
270 #endif
Forward declarations for the common classes.
STL class.
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: gz/common/Time.hh:34
Manages an animation, which is a collection of keyframes and the ability to interpolate between the k...
Definition: gz/common/Animation.hh:44
A keyframe for a NumericAnimation.
Definition: gz/common/KeyFrame.hh:83
A pose animation.
Definition: gz/common/Animation.hh:112
Information about a trajectory for an animation (e.g., Actor) This contains the keyframe information.
Definition: gz/common/Animation.hh:184
A keyframe for a PoseAnimation.
Definition: gz/common/KeyFrame.hh:53
STL class.
A key frame in an animation.
Definition: gz/common/KeyFrame.hh:35
A numeric animation.
Definition: gz/common/Animation.hh:159