onComplete SetAnimation problem...
void SetAnimation (const common::PoseAnimationPtr &_anim, boost::function< void()> _onComplete)
With the second parameter...I'm trying to do "Things to try on your own" section in the wiki of Gazebo, "Controlling a Robot"...
Here is my code:
#include <boost/bind.hpp>
#include "common/CommonTypes.hh"
#include "common/Animation.hh"
#include "common/KeyFrame.hh"
#include "physics/Entity.hh"
#include "physics/World.hh"
#include "gazebo.hh"
namespace gazebo
{
class AnimationTest : public WorldPlugin
{
public: void Load(physics::WorldPtr _parent, sdf::ElementPtr /*_sdf*/)
{
gazebo::common::PoseAnimationPtr anim(
new gazebo::common::PoseAnimation("test", 1000.0, true));
gazebo::common::PoseAnimationPtr anim2(
new gazebo::common::PoseAnimation("test2", 1000.0, true));
gazebo::common::PoseKeyFrame *key;
gazebo::common::PoseKeyFrame *key2;
key = anim->CreateKeyFrame(0);
key->SetTranslation( math::Vector3(0,0,0) );
key->SetRotation( math::Quaternion(0,0,0) );
key = anim->CreateKeyFrame(10.0);
key->SetTranslation( math::Vector3(5,0,0) );
key->SetRotation( math::Quaternion(0,0,1.5707) );
key2 = anim2->CreateKeyFrame(0);
key2->SetTranslation( math::Vector3(0,0,0) );
key2->SetRotation( math::Quaternion(0,0,0) );
key2 = anim2->CreateKeyFrame(10.0);
key2->SetTranslation( math::Vector3(0,3,0) );
key2->SetRotation( math::Quaternion(0,0,0) );
_parent->GetEntity("box_model")->SetAnimation(anim);
_parent->GetEntity("box_model2")->SetAnimation(anim2, anim);
}
};
// Register this plugin with the simulator
GZ_REGISTER_WORLD_PLUGIN(AnimationTest)
}
Thank you so much!