SkeletonAnimation.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2012 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 _GAZEBO_SKELETONANIMATION_HH_
18#define _GAZEBO_SKELETONANIMATION_HH_
19
20#include <map>
21#include <utility>
22#include <string>
23
24#include <ignition/math/Matrix4.hh>
25#include <ignition/math/Pose3.hh>
26
27#include "gazebo/util/system.hh"
29
30namespace gazebo
31{
32 namespace common
33 {
36
39 class GZ_COMMON_VISIBLE NodeAnimation
40 {
43 public: explicit NodeAnimation(const std::string &_name);
44
46 public: ~NodeAnimation();
47
50 public: void SetName(const std::string &_name);
51
54 public: std::string GetName() const;
55
59 public: void AddKeyFrame(const double _time,
60 const ignition::math::Matrix4d &_trans);
61
65 public: void AddKeyFrame(const double _time,
66 const ignition::math::Pose3d &_pose);
67
70 public: unsigned int GetFrameCount() const;
71
78 public: void GetKeyFrame(const unsigned int _i, double &_time,
79 ignition::math::Matrix4d &_trans) const;
80
86 public: std::pair<double, ignition::math::Matrix4d> KeyFrame(
87 const unsigned int _i) const;
88
91 public: double GetLength() const;
92
99 public: ignition::math::Matrix4d FrameAt(
100 double _time, bool _loop = true) const;
101
105 public: void Scale(const double _scale);
106
113 public: double GetTimeAtX(const double _x) const;
114
116 protected: std::string name;
117
119 protected: std::map<double, ignition::math::Matrix4d> keyFrames;
120
122 protected: double length;
123 };
124
126 class GZ_COMMON_VISIBLE SkeletonAnimation
127 {
130 public: explicit SkeletonAnimation(const std::string &_name);
131
135
138 public: void SetName(const std::string &_name);
139
142 public: std::string GetName() const;
143
146 public: unsigned int GetNodeCount() const;
147
151 public: bool HasNode(const std::string &_node) const;
152
157 public: void AddKeyFrame(const std::string &_node, const double _time,
158 const ignition::math::Matrix4d &_mat);
159
165 public: void AddKeyFrame(const std::string &_node, const double _time,
166 const ignition::math::Pose3d &_pose);
167
177 public: ignition::math::Matrix4d NodePoseAt(const std::string &_node,
178 const double _time, const bool _loop = true);
179
188 public: std::map<std::string, ignition::math::Matrix4d> PoseAt(
189 const double _time, const bool _loop = true) const;
190
199 public: std::map<std::string, ignition::math::Matrix4d> PoseAtX(
200 const double _x, const std::string &_node,
201 const bool _loop = true) const;
202
203
206 public: void Scale(const double _scale);
207
210 public: double GetLength() const;
211
213 protected: std::string name;
214
216 protected: double length;
217
219 protected: std::map<std::string, NodeAnimation*> animations;
220 };
222 }
223}
224
225#endif
common
Definition FuelModelDatabase.hh:37
Node animation.
Definition SkeletonAnimation.hh:40
void SetName(const std::string &_name)
Changes the name of the animation.
NodeAnimation(const std::string &_name)
constructor
~NodeAnimation()
Destructor. It empties the key frames list.
ignition::math::Matrix4d FrameAt(double _time, bool _loop=true) const
Returns a frame transformation at a specific time if a node does not exist at that time (with toleran...
std::map< double, ignition::math::Matrix4d > keyFrames
the dictionary of key frames, indexed by time
Definition SkeletonAnimation.hh:119
unsigned int GetFrameCount() const
Returns the number of key frames.
void AddKeyFrame(const double _time, const ignition::math::Matrix4d &_trans)
Adds a key frame at a specific time.
double length
the duration of the animations (time of last key frame)
Definition SkeletonAnimation.hh:122
std::string GetName() const
Returns the name.
std::string name
the name of the animation
Definition SkeletonAnimation.hh:116
std::pair< double, ignition::math::Matrix4d > KeyFrame(const unsigned int _i) const
Returns a key frame using the index.
void GetKeyFrame(const unsigned int _i, double &_time, ignition::math::Matrix4d &_trans) const
Finds a key frame using the index.
void Scale(const double _scale)
Scales each transformation in the key frames.
double GetTimeAtX(const double _x) const
Returns the time where a transformation's translational value along the X axis is equal to _x.
double GetLength() const
Returns the duration of the animations.
void AddKeyFrame(const double _time, const ignition::math::Pose3d &_pose)
Adds a key frame at a specific time.
Skeleton animation.
Definition SkeletonAnimation.hh:127
void SetName(const std::string &_name)
Changes the name.
std::map< std::string, ignition::math::Matrix4d > PoseAtX(const double _x, const std::string &_node, const bool _loop=true) const
Returns a dictionary of transformations indexed by name where a named node transformation's translati...
unsigned int GetNodeCount() const
Returns the number of animation nodes.
std::map< std::string, ignition::math::Matrix4d > PoseAt(const double _time, const bool _loop=true) const
Returns a dictionary of transformations indexed by name at a specific time if a node does not exist a...
bool HasNode(const std::string &_node) const
Looks for a node with a specific name in the animations.
double length
the duration of the longest animation
Definition SkeletonAnimation.hh:216
SkeletonAnimation(const std::string &_name)
The Constructor.
std::string GetName() const
Returns the name.
ignition::math::Matrix4d NodePoseAt(const std::string &_node, const double _time, const bool _loop=true)
Returns the key frame transformation for a named animation at a specific time if a node does not exis...
std::string name
the node name
Definition SkeletonAnimation.hh:213
void AddKeyFrame(const std::string &_node, const double _time, const ignition::math::Pose3d &_pose)
Adds or replaces a named key frame at a specific time.
void Scale(const double _scale)
Scales every animation in the animations list.
double GetLength() const
Returns the duration of the animations.
std::map< std::string, NodeAnimation * > animations
a dictionary of node animations
Definition SkeletonAnimation.hh:219
void AddKeyFrame(const std::string &_node, const double _time, const ignition::math::Matrix4d &_mat)
Adds or replaces a named key frame at a specific time.
Forward declarations for the common classes.
Definition Animation.hh:27