-
Notifications
You must be signed in to change notification settings - Fork 277
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
Add Light Usercommand and include Light parameters in the componentInspector #482
Conversation
…spector Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
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.
Did a first pass 👍
Mind adding a test to test/integration/user_commands.cc
?
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
…obotics/ign-gazebo into ahcorde/feature/lights
Signed-off-by: ahcorde <[email protected]>
} | ||
|
||
this->iface->ecm->SetChanged(entity, | ||
components::Pose::typeId, ComponentState::OneTimeChange); |
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.
what is there is no new pose? i.e. lightMsg->has_pose()
is false. Should we still call SetChanged
on components::Pose
?
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.
This call is able to change the light
properties and the pose
src/rendering/RenderUtil.cc
Outdated
const components::Pose *_pose)->bool | ||
{ | ||
this->entityPoses[_entity] = _pose->Data(); | ||
this->entityLights[_entity] = _light->Data(); |
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.
I'm thinking of making this more efficient. Currently we are populating entityLights
for all lights in the scene and going through the update process every iteration. Even though we check to see if any light properties have changed, there is still a bit of computation overhead every iteration. In an upcoming environment we are creating, we plan to put in a few hundred lights so this may add up.
How about we handle light requests similar to pose commands by adding a new components::LightCmd
? When the light service request is received, we create a LightCmd
component and attach it to the light entity in UserCommands, e.g. see WorldPoseCmd
creation here. In RenderUtil, we will instead be looping through entities with components::LightCmd
:
_ecm.Each<components::LightCmd>(
[&](const Entity &_entity,
const components::LightCmd *_light) -> bool
this->entityLights[_entity] = _light->Data();
...
We then remove the components::LightCmd
from the entity afterwards to indicate that we've processed the cmd, e.g. see removing WorldPoseCmd
here
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.
@iche033 I added most of your feedback, but I'm not sure where I should remove the LightCmd. The worldPoseCmd is remove in Physics, but where is the right place to remove these cmds? renderutils.cc?
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.
@iche033 I removed the LightCmd, I had to convert the const-EntityComponentManager vriable in to a non-const EntityComponentManager variable to be able to remove the LightCmd. is this correct ?
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.
hmm I see. UpdateFromECM
is called in the PostUpdate function in the sensors
system on the server side in the sensors system, which gets a const ref EntityComponentManager
. The physics system is able to remove the component as it's done in Update function which has a mutable reference to ECM. We may have to create a new UpdateECM
function in RenderUtil and call it from a new Update
function (which also needs to be added) in sensors
system.
On the gui side, the UpdateFromECM is called in a function that has a mutable reference to ECM. So we should be able to just do UpdateECM()
and followed by UpdateFromECM
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.
Signed-off-by: ahcorde <[email protected]>
Signed-off-by: ahcorde <[email protected]>
@chapulina can you try this patch ? --- a/src/EntityComponentManager.cc
+++ b/src/EntityComponentManager.cc
@@ -809,6 +809,9 @@ void EntityComponentManagerPrivate::SetRemovedComponentsMsgs(Entity &_entity,
// Find the entity in the message
auto entIter = _msg.mutable_entities()->find(_entity);
+ if (entIter == _msg.mutable_entities()->end())
+ return;
+
auto it = this->removedComponents.find(_entity);
for (uint64_t i = 0; i < nEntityKeys; ++i)
{ |
Signed-off-by: ahcorde <[email protected]>
I added the patch in the last commit with another segfault |
friendly ping @iche033 and @chapulina |
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.
Thanks for iterating! I can't reproduce the weird behaviour and crash anymore. Feel free to merge once the last final details have been addressed. Be sure to also sign all commits for DCO.
Thanks! 💡
Signed-off-by: ahcorde <[email protected]>
6a372e2
to
a3f74a5
Compare
* Added light tutorial and example Signed-off-by: ahcorde <[email protected]> * Added some feedback Signed-off-by: ahcorde <[email protected]> * Split tutorial in two Signed-off-by: ahcorde <[email protected]> * remove ids from tutorial Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * update tutorial Signed-off-by: ahcorde <[email protected]> Co-authored-by: Louise Poubel <[email protected]> Signed-off-by: ahcorde <[email protected]>
a3f74a5
to
71623c3
Compare
I add a new service called
/world/lights/config
to be able to change the configuration of a light. This was added in the UserCommand system plugin.As you can see in the gif the configuration can be changed in the Component Inspector.
Signed-off-by: ahcorde [email protected]