-
Notifications
You must be signed in to change notification settings - Fork 52
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
base: gz-rendering9
Are you sure you want to change the base?
Visualize Frustum #1095
Conversation
@@ -0,0 +1,180 @@ | |||
/* | |||
* Copyright (C) 2015 Open Source Robotics Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright (C) 2015 Open Source Robotics Foundation | |
* Copyright (C) 2024 Open Source Robotics Foundation |
/// \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);*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove ?
/// \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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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; |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include <cmath>
src/FrustumVisual.cc
Outdated
@@ -0,0 +1,28 @@ | |||
/* | |||
* Copyright (C) 2020 Open Source Robotics Foundation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright (C) 2020 Open Source Robotics Foundation | |
* Copyright (C) 2024 Open Source Robotics Foundation |
Signed-off-by: Utkarsh <[email protected]>
023c4b4
to
9cc0e9e
Compare
Signed-off-by: Utkarsh <[email protected]>
@ahcorde , thank you for review. I have addressed all the review comments. |
🎉 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,
Play the simulation.
Select the topic from scroll down.
Refresh it to get the "logical_camera/frustum" topic.
Subcriibed to "logical_camera/frustum".
Final output
Checklist
codecheck
passedSupporting PRs