Skip to content

Update camera sensor only when needed #37

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

Merged
merged 2 commits into from
Aug 31, 2020
Merged

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Aug 11, 2020

Updated camera sensor to render and generate data only if there are subscribers or if it needs to save data to disk. This avoid unnecessary computation cost when the camera sensor is idle.

While testing I noticed that this->dataPtr->pub.HasConnections() reports correct value when I subscribe using ign topic -e -t. However, if I test with the ImageDisplay plugin in ign-gazebo, the HasConnections will always return true even after the plugin is closed. I verified that the ImageDisplay's destructor is called so maybe we're doing something wrong? cc @caguero

Signed-off-by: Ian Chen [email protected]

@iche033 iche033 requested a review from caguero August 11, 2020 23:25
@github-actions github-actions bot added the 🏰 citadel Ignition Citadel label Aug 11, 2020
Copy link
Contributor

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

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

LGTM, but maybe could use a debug statement.

@caguero
Copy link
Contributor

caguero commented Aug 18, 2020

Updated camera sensor to render and generate data only if there are subscribers or if it needs to save data to disk. This avoid unnecessary computation cost when the camera sensor is idle.

While testing I noticed that this->dataPtr->pub.HasConnections() reports correct value when I subscribe using ign topic -e -t. However, if I test with the ImageDisplay plugin in ign-gazebo, the HasConnections will always return true even after the plugin is closed. I verified that the ImageDisplay's destructor is called so maybe we're doing something wrong? cc @caguero

Signed-off-by: Ian Chen [email protected]

I did two quick tests:

  1. Purely in Ignition Transport: Publisher and Subscriber seems to behave as expected with HasConnections().
  2. With Ignition Gazebo using ImageDisplay: It also behaves as expected when I close the plugin. I don't get any connections from the publisher in Ignition Sensors.

Could you double-check and let me know how are you testing it?

Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Aug 21, 2020

Could you double-check and let me know how are you testing it?

I'm testing with the camera_sensor.sdf in ign-gazebo. With the new debug msgs added in 4ba2913, I see a msg printed that says the camera sensor is enabled when I subscribe to the /camera topic (I had to hit refresh button for topic to show up in ImageDisplay). When I close the ImageDisplay plugin, I don't see a msg about the caemra being disabled. I printed out this->dataPtr-pub->HasConnections() in the update loop and it's returning true.

I did the same with ign topic - launched the world paused, close the ImageDisplay plugin first so it does not connect to the sensor, hit Play, and tested echoing the /camera topic. With this, I see the msg about the Camera sensor being disabled when I control+c the ign topic process.

@caguero
Copy link
Contributor

caguero commented Aug 26, 2020

Could you double-check and let me know how are you testing it?

I'm testing with the camera_sensor.sdf in ign-gazebo. With the new debug msgs added in 4ba2913, I see a msg printed that says the camera sensor is enabled when I subscribe to the /camera topic (I had to hit refresh button for topic to show up in ImageDisplay). When I close the ImageDisplay plugin, I don't see a msg about the caemra being disabled. I printed out this->dataPtr-pub->HasConnections() in the update loop and it's returning true.

I did the same with ign topic - launched the world paused, close the ImageDisplay plugin first so it does not connect to the sensor, hit Play, and tested echoing the /camera topic. With this, I see the msg about the Camera sensor being disabled when I control+c the ign topic process.

I just tried it again and it seems to work as expected. This is the output when the plugin is enabled:

[GUI] [Dbg] [RenderUtil.cc:1033] Create scene [scene]
[Dbg] [CameraSensor.cc:348] Enabling camera sensor: 'camera::link::camera' data generation.

And this is the output when I close the plugin:

[Dbg] [CameraSensor.cc:337] Disabling camera sensor: 'camera::link::camera' data generation.

@iche033
Copy link
Contributor Author

iche033 commented Aug 26, 2020

I just tried it again and it seems to work as expected.

Great, it's working as it should. The problem could just be happening on my machine.

@mjcarroll are you able to help do a quick test to confirm? If you see the msg Enabling camera sensor printed when subscribing to the topic using ImageDisplay plugin, and the Disabling camera sensor msg when closing the ImageDisplay plugin, then I think it's working as expected and we can call it done.

@nkoenig
Copy link
Contributor

nkoenig commented Aug 31, 2020

I just tried it again and it seems to work as expected.

Great, it's working as it should. The problem could just be happening on my machine.

@mjcarroll are you able to help do a quick test to confirm? If you see the msg Enabling camera sensor printed when subscribing to the topic using ImageDisplay plugin, and the Disabling camera sensor msg when closing the ImageDisplay plugin, then I think it's working as expected and we can call it done.

This works for me.

@mjcarroll
Copy link
Contributor

@mjcarroll are you able to help do a quick test to confirm? If you see the msg Enabling camera sensor printed when subscribing to the topic using ImageDisplay plugin, and the Disabling camera sensor msg when closing the ImageDisplay plugin, then I think it's working as expected and we can call it done.

This is the exact behavior I observed building citadel packages from source locally. LGTM.

@iche033 iche033 merged commit 6f1e16a into ign-sensors3 Aug 31, 2020
@iche033 iche033 deleted the camera_render branch August 31, 2020 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants