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

Visualize Frustum #1095

Open
wants to merge 2 commits into
base: gz-rendering9
Choose a base branch
from

Conversation

BA-Utkarsh
Copy link

@BA-Utkarsh BA-Utkarsh commented Dec 26, 2024

🎉 New feature

Summary

This PR mainly adds the visualization of Frustum.
We could see it was present in gazebo classic and from gazebo garden onwards the plugin/feature is not available.

Test it

$ Build gazebo from source.
$ . install/setup.sh
$ gz sim examples/worlds/visualize_frustum.sdf

Test Ref images,

  1. Play the simulation.
    frustum-1

  2. Select the topic from scroll down.
    frustum-2

  3. Refresh it to get the "logical_camera/frustum" topic.
    frustum-3

  4. Subcriibed to "logical_camera/frustum".
    frustum-4

  5. Final output
    frustum-6

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
  • All tests passed
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Supporting PRs

@@ -0,0 +1,180 @@
/*
* Copyright (C) 2015 Open Source Robotics Foundation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Copyright (C) 2015 Open Source Robotics Foundation
* Copyright (C) 2024 Open Source Robotics Foundation

Comment on lines 75 to 91
/// \brief Constructor
/// \param[in] _near Near plane distance. This is the distance from
/// the frustum's vertex to the closest plane
/// \param[in] _far Far plane distance. This is the distance from the
/// frustum's vertex to the farthest plane.
/// \param[in] _fov Field of view. The field of view is the
/// angle between the frustum's vertex and the edges of the near or far
/// plane. This value represents the horizontal angle.
/// \param[in] _aspectRatio The aspect ratio, which is the width divided
/// by height of the near or far planes.
/// \param[in] _pose Pose of the frustum, which is the vertex (top of
/// the pyramid).
/*protected: FrustumVisual(double _near,
double _far,
const math::Angle &_fov,
double _aspectRatio,
const gz::math::Pose3d &_pose = gz::math::Pose3d::Zero);*/
Copy link
Contributor

Choose a reason for hiding this comment

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

remove ?

Comment on lines 150 to 158
/// \brief Check if a box lies inside the pyramid frustum.
/// \param[in] _b Box to check.
/// \return True if the box is inside the pyramid frustum.
//public: virtual bool Contains(const gz::math::AxisAlignedBox &_b) const = 0; //TO-DO

/// \brief Check if a point lies inside the pyramid frustum.
/// \param[in] _p Point to check.
/// \return True if the point is inside the pyramid frustum.
//public: virtual bool Contains(const gz::math::Vector3d &_p) const = 0; //TO-DO
Copy link
Contributor

Choose a reason for hiding this comment

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

remove ?

private: void ComputePlanes();

/// \brief Private data pointer
//GZ_UTILS_IMPL_PTR(dataPtr)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove ?

@@ -0,0 +1,265 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Copyright (C) 2020 Open Source Robotics Foundation
* Copyright (C) 2024 Open Source Robotics Foundation

public: bool visible = true;

/// \brief Each corner of the frustum.
public: std::array<gz::math::Vector3d, 8> points;
Copy link
Contributor

Choose a reason for hiding this comment

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

include <array>

{
// enable GL_PROGRAM_POINT_SIZE so we can set gl_PointSize in vertex shader
auto engine = Ogre2RenderEngine::Instance();
std::string renderSystemName =
Copy link
Contributor

Choose a reason for hiding this comment

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

include <string>

//////////////////////////////////////////////////
void Ogre2FrustumVisual::Update()
{
std::shared_ptr<Ogre2DynamicRenderable> renderable =
Copy link
Contributor

Choose a reason for hiding this comment

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

include <memory>

this->dataPtr->rayLines.push_back(renderable);

// Tangent of half the field of view.
double tanFOV2 = std::tan(this->fov() * 0.5);
Copy link
Contributor

Choose a reason for hiding this comment

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

include <cmath>

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 Open Source Robotics Foundation
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Copyright (C) 2020 Open Source Robotics Foundation
* Copyright (C) 2024 Open Source Robotics Foundation

Signed-off-by: Utkarsh <[email protected]>
Signed-off-by: Utkarsh <[email protected]>
@BA-Utkarsh
Copy link
Author

@ahcorde , thank you for review. I have addressed all the review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

2 participants