Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROS2] Ackermann Drive Plugin fails silently if the wheels have gemetries other than SphereShape or CylinderShape #1239

Open
SivertHavso opened this issue Feb 20, 2021 · 1 comment

Comments

@SivertHavso
Copy link

Description

gazebo_ros_ackermann_drive should warn users if the wheel radius is an invalid value.

The plugin finds the radius by calling GetRadius() on sphere and cylinder objects but this fails silently if the wheel geometry is a mesh.

Screenshots
The relevant parts of the code is:

  impl_->wheel_radius_ = impl_->CollisionRadius(
    impl_->joints_[GazeboRosAckermannDrivePrivate::REAR_RIGHT]->GetChild()->GetCollision(id));
double GazeboRosAckermannDrivePrivate::CollisionRadius(const gazebo::physics::CollisionPtr & _coll)
{
  if (!_coll || !(_coll->GetShape())) {
    return 0;
  }
  if (_coll->GetShape()->HasType(gazebo::physics::Base::CYLINDER_SHAPE)) {
    gazebo::physics::CylinderShape * cyl =
      dynamic_cast<gazebo::physics::CylinderShape *>(_coll->GetShape().get());
    return cyl->GetRadius();
  } else if (_coll->GetShape()->HasType(gazebo::physics::Base::SPHERE_SHAPE)) {
    gazebo::physics::SphereShape * sph =
      dynamic_cast<gazebo::physics::SphereShape *>(_coll->GetShape().get());
    return sph->GetRadius();
  }
  return 0;
}

The return value from the CollisionRadius() method is never checked.

Expected behavior

The limitation should be documented, and the plugin should output an error if impl_->wheel_radius_ is 0 or negative.

Additional context
I'll attempt to make a pull request to fix it soon

@Yadunund
Copy link

@SivertHavso I have opened this PR to address the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants