Gazebo Common

API Reference

5.6.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 GZ_COMMON_ANIMATION_HH_
18 #define GZ_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 <gz/utils/ImplPtr.hh>
29 
30 #include <gz/common/graphics/Export.hh>
31 
32 namespace gz
33 {
34  namespace common
35  {
36  class KeyFrame;
37  class PoseKeyFrame;
38  class NumericKeyFrame;
39 
43  class GZ_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  GZ_UTILS_IMPL_PTR(dataPtr)
108  };
109 
111  class GZ_COMMON_GRAPHICS_VISIBLE PoseAnimation : public Animation
112  {
122  public: PoseAnimation(const std::string &_name,
123  const double _length, const bool _loop,
124  double _tension = 0.0);
125 
129  public: PoseKeyFrame *CreateKeyFrame(const double _time);
130 
133  public: void InterpolatedKeyFrame(PoseKeyFrame &_kf);
134 
138  protected: void InterpolatedKeyFrame(const double _time,
139  PoseKeyFrame &_kf);
140 
142  protected: void BuildInterpolationSplines();
143 
145  GZ_UTILS_IMPL_PTR(dataPtr)
146  };
147 
149  class GZ_COMMON_GRAPHICS_VISIBLE NumericAnimation : public Animation
150  {
155  public: NumericAnimation(const std::string &_name,
156  const double _length, const bool _loop);
157 
161  public: NumericKeyFrame *CreateKeyFrame(const double _time);
162 
166  public: void InterpolatedKeyFrame(NumericKeyFrame &_kf) const;
167 
169  GZ_UTILS_IMPL_PTR(dataPtr)
170  };
171 
174  class GZ_COMMON_GRAPHICS_VISIBLE TrajectoryInfo
175  {
177  public: TrajectoryInfo();
178 
181  public: unsigned int Id() const;
182 
185  public: void SetId(unsigned int _id);
186 
189  public: unsigned int AnimIndex() const;
190 
194  public: void SetAnimIndex(unsigned int _index);
195 
198  public: std::chrono::steady_clock::duration Duration() const;
199 
203  public: double DistanceSoFar(
204  const std::chrono::steady_clock::duration &_time) const;
205 
208  public: std::chrono::steady_clock::time_point StartTime() const;
209 
212  public: void SetStartTime(
213  const std::chrono::steady_clock::time_point &_startTime);
214 
217  public: std::chrono::steady_clock::time_point EndTime() const;
218 
221  public: void SetEndTime(
222  const std::chrono::steady_clock::time_point &_endTime);
223 
226  public: bool Translated() const;
227 
230  public: void SetTranslated(bool _translated);
231 
235 
244  public: void SetWaypoints(
246  _waypoints, double _tension = 0.0);
247 
249  GZ_UTILS_IMPL_PTR(dataPtr)
250  };
251  }
252 }
253 #endif