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

Ray intersection simulation feature #641

Merged
merged 9 commits into from
Jun 12, 2024

Conversation

romulogcerqueira
Copy link
Contributor

@romulogcerqueira romulogcerqueira commented May 16, 2024

🎉 New feature

Related to gazebosim/gz-sensors#26

Summary

dartsim does support ray-based collisions via Bullet backend, which is also supported by gz-physics.

This PR creates a simulation feature to compute and retrieve ray castings. Also, it updates dartsim version >= 6.10, which fixes the issues when no ray hit.

This addition is useful for range-based applications (e.g. laser, altimeter etc.).

Test it

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@github-actions github-actions bot added the 🎵 harmonic Gazebo Harmonic label May 16, 2024
dartsim/src/SimulationFeatures_TEST.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures_TEST.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures_TEST.cc Outdated Show resolved Hide resolved
include/gz/physics/GetRayIntersection.hh Outdated Show resolved Hide resolved
include/gz/physics/detail/GetRayIntersection.hh Outdated Show resolved Hide resolved
@romulogcerqueira
Copy link
Contributor Author

@ahcorde Comments have been addressed.

Thank you for the review!

@romulogcerqueira romulogcerqueira requested a review from ahcorde May 22, 2024 16:01
@romulogcerqueira
Copy link
Contributor Author

Any additional suggestions/reviews? @azeey @ahcorde @mxgrey @scpeters

CMakeLists.txt Show resolved Hide resolved
Copy link
Contributor

@azeey azeey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Definitely a nice feature to have.

It's a shame that the ode collision detector doesn't support this since that's the default for Gazebo. Do you by any chance know if this would be straight forward to implement for the bullet-featherstone physics engine plugin (not collision detector). I ask because we've been making improvements to the plugin and it might become the default engine for Gazebo at some point.

@romulogcerqueira
Copy link
Contributor Author

Thanks for the contribution! Definitely a nice feature to have.

It's a shame that the ode collision detector doesn't support this since that's the default for Gazebo. Do you by any chance know if this would be straight forward to implement for the bullet-featherstone physics engine plugin (not collision detector). I ask because we've been making improvements to the plugin and it might become the default engine for Gazebo at some point.

Thanks for your feedback, @azeey.

I'm not familiar with Bullet featherstone, however, it seems that this feature can be implemented for that plugin by creating a simulation feature that casts the world and calls the Bullet raycasting methods directly, e.g.:

  const auto worldInfo = this->ReferenceInterface<WorldInfo>(_worldID);

  const auto btFrom = convertVec(Eigen::Vector3d(0,0,0));
  const auto btTo = convertVec(Eigen::Vector3d(1,1,1));

  btCollisionWorld::ClosestRayResultCallback closestResults(btFrom, btTo);
  auto collisionWorld = worldInfo->world->getCollisionWorld();
  collisionWorld->rayTest(btFrom, btTo, closestResults);

@romulogcerqueira
Copy link
Contributor Author

@azeey @ahcorde, please let me know if there are additional comments or if this PR is ready to go.

Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
…mulation step

Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
@romulogcerqueira
Copy link
Contributor Author

PR rebased with last changes on gz-physics7 branch.

Comments have been addressed.

@azeey @ahcorde, please let me know if there are additional comments or if this PR is ready to go.

CMakeLists.txt Show resolved Hide resolved
include/gz/physics/GetRayIntersection.hh Outdated Show resolved Hide resolved
include/gz/physics/GetRayIntersection.hh Show resolved Hide resolved
dartsim/src/SimulationFeatures_TEST.cc Outdated Show resolved Hide resolved
dartsim/src/SimulationFeatures.hh Show resolved Hide resolved
romulogcerqueira and others added 2 commits June 7, 2024 13:20
Co-authored-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
@romulogcerqueira
Copy link
Contributor Author

@azeey All comments have been addressed.

Signed-off-by: Rômulo Cerqueira <romulogcerqueira@gmail.com>
@azeey
Copy link
Contributor

azeey commented Jun 10, 2024

@rakeshv24 PTAL

@azeey azeey dismissed ahcorde’s stale review June 12, 2024 16:46

Concern has been addressed

@azeey azeey enabled auto-merge (squash) June 12, 2024 16:48
@azeey azeey merged commit b5d1508 into gazebosim:gz-physics7 Jun 12, 2024
8 checks passed
@romulogcerqueira
Copy link
Contributor Author

Thanks, @azeey.

Any idea when this might be released?

@romulogcerqueira romulogcerqueira deleted the rc-ray_intersection branch June 12, 2024 17:59
@peci1
Copy link
Contributor

peci1 commented Jun 25, 2024

Hmm, Gazebo Classic also reported name of the collision that was hit. That was super useful for some scenarios, or e.g. for reporting laser retro/fiducial of the hit collision.

https://github.com/gazebosim/gazebo-classic/blob/e4b4d0fb752c7e43e34ab97d0e01a2a3eaca1ed4/gazebo/physics/ode/ODERayShape.cc#L126

Do you think it could be added?

@azeey
Copy link
Contributor

azeey commented Jun 25, 2024

Release is pending #659. If we do add this, it should be done soon since modifying RayIntersectionT would be a breaking change. Maybe we can add the additional parameters to RayIntersectionT without the actual implementation?

@peci1
Copy link
Contributor

peci1 commented Jun 26, 2024

Maybe we can add the additional parameters to RayIntersectionT without the actual implementation?

That would be the quickest thinkable solution. I briefly looked into dart and the colliding body names should be available, so the implementation should be quite easy.

@peci1 peci1 mentioned this pull request Jun 26, 2024
7 tasks
@peci1
Copy link
Contributor

peci1 commented Jun 26, 2024

I guess "entity number (ID) of the collision" would be better than the name of the collision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎵 harmonic Gazebo Harmonic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants