Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Why doesn't LinearVelocity Component update?

I'm just starting with creating plugins, and I wanted to get the speed of a vehicle. For that, I wrote a plugin added in the sdf's model section. I created a LinearVelocity component in the Configure function like this:

// Check if there's LinearVelocity component
auto modelLinearVel =

if (modelLinearVel == nullptr){
  components::LinearVelocity()); //math::Vector3d(0,0,0)

As I see in the component inspector, my model has a Linear Velocity component, but velocity data keeps being 0 0 0. I also "cout" it from PostUpdate with this code:

auto _kitt_entity = _ecm.EntityByComponents(components::Name("ModelName"));

auto kitts_velocity = _ecm.ComponentData<components::LinearVelocity>(_kitt_entity);
if (kitts_velocity) {
  std::cout << "Velocity= " << kitts_velocity.value() << std::endl;
  std::cout << "No velocity, Kitt" << std::endl;

The output is:

Velocity= 0 0 0

Am I skipping an important step to make gazebo know that it has to calculate and update that component? Does it only work with linear and screw joints? Is it a link property and models don't have it updated?