/usr/include/ignition/common1/ignition/common/Animation.hh is in libignition-common-dev 1.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | /*
* Copyright (C) 2016 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_COMMON_ANIMATION_HH_
#define IGNITION_COMMON_ANIMATION_HH_
#include <string>
#include <vector>
#include <ignition/math/Spline.hh>
#include <ignition/math/RotationSpline.hh>
#include <ignition/common/Export.hh>
namespace ignition
{
namespace common
{
class KeyFrame;
class PoseKeyFrame;
class NumericKeyFrame;
/// \class Animation Animation.hh ignition/common/Animation.hh
/// \brief Manages an animation, which is a collection of keyframes and
/// the ability to interpolate between the keyframes
class IGNITION_COMMON_VISIBLE Animation
{
/// \brief Constructor
/// \param[in] _name Name of the animation, should be unique
/// \param[in] _length Duration of the animation in seconds
/// \param[in] _loop Set to true if the animation should repeat
public: Animation(const std::string &_name,
const double _length, const bool _loop);
/// \brief Destructor
public: virtual ~Animation();
/// \brief Return the duration of the animation
/// \return Duration of the animation in seconds
public: double Length() const;
/// \brief Set the duration of the animation
/// \param[in] _len The length of the animation in seconds
public: void Length(const double _len);
/// \brief Set the current time position of the animation
/// \param[in] _time The time position in seconds
public: void Time(const double _time);
/// \brief Add time to the animation
/// \param[in] _time The amount of time to add in seconds
public: void AddTime(const double _time);
/// \brief Return the current time position
/// \return The time position in seconds
public: double Time() const;
/// \brief Return the number of key frames in the animation
/// \return The number of keyframes
public: unsigned int KeyFrameCount() const;
/// \brief Get a key frame using an index value
/// \param[in] _index The index of the key frame
/// \return A pointer the keyframe, NULL if the _index is invalid
public: common::KeyFrame *KeyFrame(const unsigned int _index) const;
/// \brief Get the two key frames that bound a time value
/// \param[in] _time The time in seconds
/// \param[out] _kf1 Lower bound keyframe that is returned
/// \param[out] _kf2 Upper bound keyframe that is returned
/// \param[out] _firstKeyIndex Index of the lower bound key frame
/// \return The time between the two keyframe
protected: double KeyFramesAtTime(
double _time, common::KeyFrame **_kf1,
common::KeyFrame **_kf2,
unsigned int &_firstKeyIndex) const;
#ifdef _WIN32
// Disable warning C4251 which is triggered by
// std::unique_ptr
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
/// \brief animation name
protected: std::string name;
/// \brief animation duration
protected: double length;
/// \brief current time position
protected: double timePos;
/// \brief determines if the interpolation splines need building
protected: mutable bool build;
/// \brief true if animation repeats
protected: bool loop;
/// \brief array of keyframe type alias
protected: typedef std::vector<common::KeyFrame*> KeyFrame_V;
/// \brief array of key frames
protected: KeyFrame_V keyFrames;
#ifdef _WIN32
#pragma warning(pop)
#endif
};
/// \brief A pose animation.
class IGNITION_COMMON_VISIBLE PoseAnimation : public Animation
{
/// \brief Constructor
/// \param[in] _name String name of the animation. This should be unique.
/// \param[in] _length Length of the animation in seconds
/// \param[in] _loop True == loop the animation
public: PoseAnimation(const std::string &_name,
const double _length, const bool _loop);
/// \brief Destructor
public: virtual ~PoseAnimation();
/// \brief Create a pose keyframe at the given time
/// \param[in] _time Time at which to create the keyframe
/// \return Pointer to the new keyframe
public: PoseKeyFrame *CreateKeyFrame(const double _time);
/// \brief Get a keyframe using the animation's current time.
/// \param[out] _kf PoseKeyFrame reference to hold the interpolated result
public: void InterpolatedKeyFrame(PoseKeyFrame &_kf) const;
/// \brief Get a keyframe using a passed in time.
/// \param[in] _time Time in seconds
/// \param[out] _kf PoseKeyFrame reference to hold the interpolated result
protected: void InterpolatedKeyFrame(const double _time,
PoseKeyFrame &_kf) const;
/// \brief Update the pose splines
protected: void BuildInterpolationSplines() const;
/// \brief smooth interpolation for position
private: mutable math::Spline *positionSpline;
/// \brief smooth interpolation for rotation
private: mutable math::RotationSpline *rotationSpline;
};
/// \brief A numeric animation.
class IGNITION_COMMON_VISIBLE NumericAnimation : public Animation
{
/// \brief Constructor
/// \param[in] _name String name of the animation. This should be unique.
/// \param[in] _length Length of the animation in seconds
/// \param[in] _loop True == loop the animation
public: NumericAnimation(const std::string &_name,
const double _length, const bool _loop);
/// \brief Destructor
public: virtual ~NumericAnimation();
/// \brief Create a numeric keyframe at the given time
/// \param[in] _time Time at which to create the keyframe
/// \return Pointer to the new keyframe
public: NumericKeyFrame *CreateKeyFrame(const double _time);
/// \brief Get a keyframe using the animation's current time.
/// \param[out] _kf NumericKeyFrame reference to hold the
/// interpolated result
public: void InterpolatedKeyFrame(NumericKeyFrame &_kf) const;
};
}
}
#endif
|