Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to animate a hand using a plugin

asked 2013-02-24 22:48:02 -0500

lugd1229 gravatar image

updated 2013-03-07 22:19:36 -0500

nkoenig gravatar image

I use a plugin to control a hand model with two fingers from a position(0,0,0) to a high position(0,0,0.5), and the model will quiver up and down. The motion is not regular and not smooth, would you please help me? thank you

world file:

<plugin name="animate_pose1" filename="libanimate_pose1.so"/>

the animate_pose.cc:

  gazebo::common::PoseAnimationPtr anim(
      new gazebo::common::PoseAnimation("box::my_joint5", 10.0, 0));

  gazebo::common::PoseKeyFrame *key = anim->CreateKeyFrame(0.0);
  key = anim->CreateKeyFrame(0);
  key->SetTranslation(math::Vector3(0, 0, 0));
  key = anim->CreateKeyFrame(2.0);
  key->SetTranslation(math::Vector3(0, 0, 0.1));
  key = anim->CreateKeyFrame(4.0);
  key->SetTranslation(math::Vector3(0, 0, 0.2));
  key = anim->CreateKeyFrame(6.0);
  key->SetTranslation(math::Vector3(0, 0, 0.3));
  key = anim->CreateKeyFrame(8.0);
  key->SetTranslation(math::Vector3(0, 0, 0.4));
  key = anim->CreateKeyFrame(10.0);
  key->SetTranslation(math::Vector3(0, 0, 0.5));

  _parent->SetAnimation(anim);
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-03-07 22:23:30 -0500

nkoenig gravatar image

The motion is not smooth because there are 4 unnecessary key frames. You can do just this:

gazebo::common::PoseAnimationPtr anim(new gazebo::common::PoseAnimation("box::my_joint5", 10.0, 0));

gazebo::common::PoseKeyFrame *key = anim->CreateKeyFrame(0.0);
key = anim->CreateKeyFrame(0);
key->SetTranslation(math::Vector3(0, 0, 0));
key = anim->CreateKeyFrame(10.0);
key->SetTranslation(math::Vector3(0, 0, 0.5));

_parent->SetAnimation(anim);
edit flag offensive delete link more

Comments

thanks a lot.but use this cannot control one joint of the model that has 7 joints. how to control 7 joints using PoseAnimationPtr or NumericAnimation?

lugd1229 gravatar imagelugd1229 ( 2013-03-15 18:47:15 -0500 )edit

Use multiple animation to animate multiple joints.

nkoenig gravatar imagenkoenig ( 2013-03-17 21:23:37 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-02-24 22:48:02 -0500

Seen: 162 times

Last updated: Mar 07 '13