osrf / rmf_demos

Demos to showcase the capabilities of RMF
Apache License 2.0
69 stars 38 forks source link

Create initial light tuning plugin #166

Closed mrushyendra closed 3 years ago

mrushyendra commented 3 years ago

Creates an Ignition GUI plugin to spawn lights and edit their parameters without having to modify the world SDF file and recompile each time. It supports multiple lights, pose changes by dragging on screen, and saving the sdf file snippets for each light to disk.

light_tuning_plugin

To enable changing light poses by dragging, it currently uses a workaround where a simple cube model is spawned at the same location as the light. The pose of this cube is used to update the pose field in the light creation menu.

Some other changes I considered, but are not included in this PR is to split the pose and direction inputs into their individual X, Y, Z etc. components (may become more cumbersome to type), to add the ability to edit lights that are already part of the world, and to update lights in real time - i.e. not have to select create each time you want to re-render the light (though this does not currently seem feasible due to the time the create/remove service takes). Lastly, I am very new to QT, so some of the syntax or methods used may not be the canonical ones.

luca-della-vedova commented 3 years ago

Just a quick check, do you think it would be possible to change the way the color is chosen from three numbers to a more familiar "palette" similar to what is found in image editing software? Something like this [big disclaimer I have no idea if this is very easy or very hard to do!]: image

to update lights in real time - i.e. not have to select create each time you want to re-render the light (though this does not currently seem feasible due to the time the create/remove service takes)

This would be quite interesting I think, from what I understand you mean that you can't run it at every loop iteration since the service can be quite slow (which I agree with). An alternative approach could be to cache the state of the light parameters / object pose and set a dirty bit whenever any parameter is updated, then respawn the light and clear the dirty bit. Does it make sense?

mrushyendra commented 3 years ago

I've never tried implementing a color picker, but it definitely seems doable. As for the updating of lights, I imagined something even more responsive (e.g. lights change continuously as you drag the sliders, or if you move the cube to change its pose), but I think updating them whenever an edit is finished is a good middle ground.

codebot commented 3 years ago

I think that Qt has a pre-packaged standard "color-picker" dialog box somewhere.

codebot commented 3 years ago

But that could be a separate PR later, as an improvement. This is awesome as-is IMHO

mrushyendra commented 3 years ago

I think the black circle occurs for the spotlight when the inner angle is set to a bigger value than the outer angle. Here's a screenshot of the params for a working one: Screenshot from 2020-12-04 09-27-29 I also changed the code to hide the spotlight-specific params when not needed.

luca-della-vedova commented 3 years ago

Oh that makes sense :sweat_smile: feature wise this looks good to me, let me know if you want more time to look at the automatic update seg fault issue.

mrushyendra commented 3 years ago

Pushed some additional changes that allow for the lights to be updated as you move the sliders/finish typing.

Sending create and remove requests very quickly after one another can still cause a seg fault in Ignition, I believe because of a lag between entity creation/removal and the actual rendering itself, but I believe it shouldn't happen with this plugin because the Qt signals have been chosen such that they don't fire too soon after one another.

luca-della-vedova commented 3 years ago

This is really really nice, thanks for iterating!