Skip to content

Conversation

BA-Utkarsh
Copy link
Contributor

@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,

Signed-off-by: Utkarsh <Utkarsh.Yenurkar@Sony.com>
Signed-off-by: Utkarsh <Utkarsh.Yenurkar@Sony.com>
@BA-Utkarsh
Copy link
Contributor Author

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

@arjo129
Copy link
Contributor

arjo129 commented Jan 9, 2025

Thanks for the contribution. There are still stray spaces in the code. Do you mind fixing them: https://github.com/gazebosim/gz-sim/actions/runs/12514253900/job/35270143157?pr=2707

Also is there a chance that we can visualize the frustum without the need for pressing play?

Signed-off-by: Utkarsh <Utkarsh.Yenurkar@Sony.com>
@BA-Utkarsh BA-Utkarsh requested a review from ahcorde January 10, 2025 07:44
Signed-off-by: Utkarsh <Utkarsh.Yenurkar@Sony.com>
@BA-Utkarsh BA-Utkarsh requested a review from ahcorde January 11, 2025 10:23
{
std::lock_guard<std::mutex> lock(this->dataPtr->serviceMutex);
this->dataPtr->frustum->SetVisible(_value);
gzerr << "Frustum Visual Display " << ((_value) ? "ON." : "OFF.")
Copy link
Contributor

Choose a reason for hiding this comment

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

is it really error level of logging?

}
std::string childname = std::string(
comp->Data());
if (nextstring.compare(childname) == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

nextstring and childname are std::strings, why not use == for it?
Like: if (nextstring == childname)

{
std::vector<transport::MessagePublisher> publishers;
this->dataPtr->node.TopicInfo(topic, publishers);
for (auto pub : publishers)
Copy link
Contributor

Choose a reason for hiding this comment

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

do you really need a pub by copy? Just curious

// Get updated list
std::vector<std::string> allTopics;
this->dataPtr->node.TopicList(allTopics);
for (auto topic : allTopics)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe const reference could be enough for topic?

{
auto frustumURIVec = common::split(common::trimmed(
this->dataPtr->frustumString), "::");
if (frustumURIVec.size() > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

size() is already unsigned, maybe !frustumURIVec.empty() is more c++-like
(and for some containers size() operation can be quite costly)

bool foundChild = false;
for (auto child : children)
{
std::string nextstring = frustumURIVec[i+1];
Copy link
Contributor

Choose a reason for hiding this comment

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

it can be const reference on a left side of expression, you don't need a full string copy here AFAIS
const std::string &nextstring = frustumURIVec[i+1]; or use auto instead of std::string


this->dataPtr->visualDirty = true;

for (auto data_values : this->dataPtr->msg.header().data())
Copy link
Contributor

Choose a reason for hiding this comment

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

const reference should be fine here I suppose

Comment on lines +428 to +429
if (this->dataPtr->frustumString.compare(
common::trimmed(data_values.value(0))) != 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

seems it's comparing of 2 strings, seems better to use != here

}
}
}
if (this->dataPtr->topicList.size() > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above about size() and empty

@BA-Utkarsh
Copy link
Contributor Author

BA-Utkarsh commented Jan 13, 2025

@ntfshard , \cc: @ahcorde
All the changes are done from the reference of https://github.com/gazebosim/gz-sim/blob/gz-sim9/src/gui/plugins/visualize_lidar/
I have not modified the code (apart from frustum part). visualize_lidar are already in the upstream repo. Thus taking the same reference.

In my opinion, the changes are not needed for now. @ahcorde , please let me know your views on the same..

@iche033 iche033 added the needs upstream release Blocked by a release of an upstream library label Jan 17, 2025
@BA-Utkarsh
Copy link
Contributor Author

@mjcarroll , please let us know your view as well..

@BA-Utkarsh
Copy link
Contributor Author

@mjcarroll @ahcorde @iche033 any update?

BA-Utkarsh and others added 4 commits January 28, 2025 20:34
Co-authored-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Utkarsh Yenurkar <80967869+BA-Utkarsh@users.noreply.github.com>
Co-authored-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Utkarsh Yenurkar <80967869+BA-Utkarsh@users.noreply.github.com>
Co-authored-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Utkarsh Yenurkar <80967869+BA-Utkarsh@users.noreply.github.com>
Co-authored-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Utkarsh Yenurkar <80967869+BA-Utkarsh@users.noreply.github.com>
BA-Utkarsh and others added 2 commits January 28, 2025 20:35
Co-authored-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Utkarsh Yenurkar <80967869+BA-Utkarsh@users.noreply.github.com>
Signed-off-by: Utkarsh <Utkarsh.Yenurkar@Sony.com>
@BA-Utkarsh
Copy link
Contributor Author

@ntfshard , \cc: @ahcorde All the changes are done from the reference of https://github.com/gazebosim/gz-sim/blob/gz-sim9/src/gui/plugins/visualize_lidar/ I have not modified the code (apart from frustum part). visualize_lidar are already in the upstream repo. Thus taking the same reference.

In my opinion, the changes are not needed for now. @ahcorde , please let me know your views on the same..

@ntfshard thank you for #2739

BA-Utkarsh and others added 2 commits January 28, 2025 23:37
Signed-off-by: Utkarsh <Utkarsh.Yenurkar@Sony.com>
Co-authored-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Utkarsh Yenurkar <80967869+BA-Utkarsh@users.noreply.github.com>
@BA-Utkarsh BA-Utkarsh requested a review from iche033 January 28, 2025 19:21
Co-authored-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Utkarsh Yenurkar <80967869+BA-Utkarsh@users.noreply.github.com>
@BA-Utkarsh BA-Utkarsh requested a review from iche033 January 29, 2025 05:14
@iche033
Copy link
Contributor

iche033 commented Jan 30, 2025

Thanks for the contribution. This looks to me. We can apply optimizations similar to #2739 in a separate PR. I also ticked a feature request for extending the Visualize Frustum plugin to support other camera sensor types, #2746, any help is welcome :)

@BA-Utkarsh
Copy link
Contributor Author

BA-Utkarsh commented Jan 30, 2025

Thanks for the contribution. This looks to me.

Thank you very much @iche033 for your support.
Let me know the procedure to merge quickly @mjcarroll @ahcorde

We can apply optimizations similar to #2739 in a separate PR.

Surely, will create a separate PR after this merge.

I also ticked a feature request for extending the Visualize Frustum plugin to support other camera sensor types, #2746, any help is welcome :)

Oh great!

@iche033 iche033 dismissed ahcorde’s stale review January 30, 2025 17:47

addressed all comments

@iche033 iche033 merged commit 1eebaa3 into gazebosim:gz-sim9 Jan 30, 2025
10 of 11 checks passed
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 needs upstream release Blocked by a release of an upstream library

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants