##

SkeletonAnimation.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 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 _GAZEBO_SKELETONANIMATION_HH_
#define _GAZEBO_SKELETONANIMATION_HH_
#include <map>
#include <utility>
#include <string>
#include <ignition/math/Matrix4.hh>
#include <ignition/math/Pose3.hh>
#include "gazebo/util/system.hh"
#include "gazebo/common/CommonTypes.hh"
namespace gazebo
{
namespace common
{
class GZ_COMMON_VISIBLE NodeAnimation
{
public: explicit NodeAnimation(const std::string &_name);
public: ~NodeAnimation();
public: void SetName(const std::string &_name);
public: std::string GetName() const;
public: void AddKeyFrame(const double _time,
const ignition::math::Matrix4d &_trans);
public: void AddKeyFrame(const double _time,
const ignition::math::Pose3d &_pose);
public: unsigned int GetFrameCount() const;
public: void GetKeyFrame(const unsigned int _i, double &_time,
ignition::math::Matrix4d &_trans) const;
public: std::pair<double, ignition::math::Matrix4d> KeyFrame(
const unsigned int _i) const;
public: double GetLength() const;
public: ignition::math::Matrix4d FrameAt(
double _time, bool _loop = true) const;
public: void Scale(const double _scale);
public: double GetTimeAtX(const double _x) const;
protected: std::string name;
protected: std::map<double, ignition::math::Matrix4d> keyFrames;
protected: double length;
};
class GZ_COMMON_VISIBLE SkeletonAnimation
{
public: explicit SkeletonAnimation(const std::string &_name);
public: ~SkeletonAnimation();
public: void SetName(const std::string &_name);
public: std::string GetName() const;
public: unsigned int GetNodeCount() const;
public: bool HasNode(const std::string &_node) const;
public: void AddKeyFrame(const std::string &_node, const double _time,
const ignition::math::Matrix4d &_mat);
public: void AddKeyFrame(const std::string &_node, const double _time,
const ignition::math::Pose3d &_pose);
public: ignition::math::Matrix4d NodePoseAt(const std::string &_node,
const double _time, const bool _loop = true);
public: std::map<std::string, ignition::math::Matrix4d> PoseAt(
const double _time, const bool _loop = true) const;
public: std::map<std::string, ignition::math::Matrix4d> PoseAtX(
const double _x, const std::string &_node,
const bool _loop = true) const;
public: void Scale(const double _scale);
public: double GetLength() const;
protected: std::string name;
protected: double length;
protected: std::map<std::string, NodeAnimation*> animations;
};
}
}
#endif
gazebo::common::SkeletonAnimation::name
std::string name
the node name
Definition: SkeletonAnimation.hh:213
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::NodeAnimation::GetFrameCount
unsigned int GetFrameCount() const
Returns the number of key frames.
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::SkeletonAnimation::PoseAtX
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...
gazebo::common::NodeAnimation::SetName
void SetName(const std::string &_name)
Changes the name of the animation.
system.hh
gazebo::common::NodeAnimation::~NodeAnimation
~NodeAnimation()
Destructor. It empties the key frames list.
gazebo::common::NodeAnimation::GetLength
double GetLength() const
Returns the duration of the animations.
gazebo::common::SkeletonAnimation::AddKeyFrame
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.
CommonTypes.hh
gazebo::common::NodeAnimation::length
double length
the duration of the animations (time of last key frame)
Definition: SkeletonAnimation.hh:122
gazebo::common::SkeletonAnimation::GetLength
double GetLength() const
Returns the duration of the animations.
gazebo::common::SkeletonAnimation::Scale
void Scale(const double _scale)
Scales every animation in the animations list.
gazebo::common::NodeAnimation::GetTimeAtX
double GetTimeAtX(const double _x) const
Returns the time where a transformation's translational value along the X axis is equal to _x.
gazebo::common::SkeletonAnimation::animations
std::map< std::string, NodeAnimation * > animations
a dictionary of node animations
Definition: SkeletonAnimation.hh:219
gazebo::common::SkeletonAnimation
Skeleton animation.
Definition: SkeletonAnimation.hh:126
gazebo::common::SkeletonAnimation::SkeletonAnimation
SkeletonAnimation(const std::string &_name)
The Constructor.
gazebo::common::NodeAnimation::Scale
void Scale(const double _scale)
Scales each transformation in the key frames.
gazebo::common::SkeletonAnimation::SetName
void SetName(const std::string &_name)
Changes the name.
gazebo::common::NodeAnimation::keyFrames
std::map< double, ignition::math::Matrix4d > keyFrames
the dictionary of key frames, indexed by time
Definition: SkeletonAnimation.hh:119
gazebo::common::NodeAnimation::GetName
std::string GetName() const
Returns the name.
gazebo::common::NodeAnimation::name
std::string name
the name of the animation
Definition: SkeletonAnimation.hh:116
gazebo::common::NodeAnimation::GetKeyFrame
void GetKeyFrame(const unsigned int _i, double &_time, ignition::math::Matrix4d &_trans) const
Finds a key frame using the index.
gazebo::common::NodeAnimation::AddKeyFrame
void AddKeyFrame(const double _time, const ignition::math::Matrix4d &_trans)
Adds a key frame at a specific time.
gazebo::common::NodeAnimation::KeyFrame
std::pair< double, ignition::math::Matrix4d > KeyFrame(const unsigned int _i) const
Returns a key frame using the index.
gazebo::common::SkeletonAnimation::GetName
std::string GetName() const
Returns the name.
gazebo::common::SkeletonAnimation::HasNode
bool HasNode(const std::string &_node) const
Looks for a node with a specific name in the animations.
gazebo::common::SkeletonAnimation::~SkeletonAnimation
~SkeletonAnimation()
The destructor.
gazebo::common::SkeletonAnimation::NodePoseAt
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...
gazebo::common::SkeletonAnimation::PoseAt
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...
gazebo::common::SkeletonAnimation::length
double length
the duration of the longest animation
Definition: SkeletonAnimation.hh:216
gazebo::common::NodeAnimation
Node animation.
Definition: SkeletonAnimation.hh:39
gazebo::common::SkeletonAnimation::GetNodeCount
unsigned int GetNodeCount() const
Returns the number of animation nodes.
gazebo::common::NodeAnimation::NodeAnimation
NodeAnimation(const std::string &_name)
constructor
gazebo::common::NodeAnimation::FrameAt
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...
gazebo::common::KeyFrame
A key frame in an animation.
Definition: KeyFrame.hh:35