Home | Tutorials | Wiki | Issues
Ask Your Question
0

GetWorldLinearVel animation problem [closed]

asked 2016-09-07 10:38:56 -0500

Brosseau.F gravatar image

Hello everybody,

I am moving a box using the animation system (KeyFrame,...). I would like to output some datas like the model's position and speed. I have created a model plugin.

No problem for the position but I have some trouble for the speed.

The GetWorldLinearVel function seems to return a 0.0 value for x, y and z attributes.

Here is the code to get the speed datas :

custom_msgs::msg_command speed_msg;
speed_msg.header.stamp = ros::Time::now();
speed_msg.header.frame_id = m_model->GetName();

auto linear = m_model->GetWorldLinearVel();
speed_msg.yaw_rate.data = m_model->GetWorldAngularVel().z;

ROS_INFO("speed data");
ROS_INFO("x: %lf", linear.x);
ROS_INFO("y: %lf", linear.y);
ROS_INFO("z: %lf", linear.z);
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Brosseau.F
close date 2016-09-08 01:27:38.610779

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-09-07 10:45:22 -0500

nkoenig gravatar image

The animation framework is a cheat that bypasses the physics engine to move an object. A velocity is not applied to the object, instead the object's position is directly changed by Gazebo. Therefore, the physics engine will report a velocity of zero.

You could calculate a velocity manually in your program/plugin.

edit flag offensive delete link more

Comments

Thanks to both of you

Brosseau.F gravatar imageBrosseau.F ( 2016-09-08 01:34:06 -0500 )edit
1

answered 2016-09-07 10:52:07 -0500

chapulina gravatar image

I think that happens because when an entity is being animated, it is considered "static" by the physics engine. That is done so no forces interfere with the animation. So I would assume that the physics engine loses track of other things too, such as velocity.

A workaround would be to keep track of pose changes over time and calculate the velocity yourself.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-09-07 10:38:56 -0500

Seen: 234 times

Last updated: Sep 07 '16