Skip to content
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

Elevator state is not being publish on the ground floor #2153

Closed
Voldivh opened this issue Sep 18, 2023 · 4 comments · Fixed by #2227
Closed

Elevator state is not being publish on the ground floor #2153

Voldivh opened this issue Sep 18, 2023 · 4 comments · Fixed by #2227
Assignees
Labels
bug Something isn't working

Comments

@Voldivh
Copy link
Contributor

Voldivh commented Sep 18, 2023

Environment

  • OS Version: Ubuntu Jammy
  • Source and Binary

Description

  • Expected behavior: The elevator should publish a message to it's state topic on each floor it is in.
  • Actual behavior: The elevator publish a message for all floors except the ground floor.

Steps to reproduce

  1. Run the elevator.sdf file:
gz sim elevator.sdf
  1. Subscribe to the elevator state:
gz topic -e -t /model/elevator/state
  1. Publish a floor for the elevator to go. Example:
gz topic -t "/model/elevator/cmd" -m gz.msgs.Int32 -p "data: 2"

Output

We get the expected behavior when we send the elevator to any of the upper floors:
image
However, when we send the elevator to the ground floor (gz topic -t "/model/elevator/cmd" -m gz.msgs.Int32 -p "data: 0"), we stop receiving information on the console:
image

@Voldivh Voldivh added the bug Something isn't working label Sep 18, 2023
@mjcarroll
Copy link
Contributor

This is an artifact of using protobuf. A field with a default value is also interpreted as a field that hasn't been set. In this case, the message is still being received, but the mechanism that turns it into a string assumes that field is uninitialized and doesn't output it.

There should be no impact on using the message as part of a callback (the field will still be set to zero), but if echoing on the command line is critical, we could add another field like "is set" to guarantee some output.

@Voldivh
Copy link
Contributor Author

Voldivh commented Sep 18, 2023

Interesting. I don't think it is critical to be able to echo it as long as the we still get the correct value on the subscription. My only concern is that it may confuse users that are not aware of that specific behavior. Maybe we could add a little comment at the top of the .sdf file? I can go ahead and create the appropriate PR if you agree on the "solution".

@mjcarroll
Copy link
Contributor

I think a comment would be helpful.

Or we can 1-index all of our arrays from now on. 😉

@Voldivh
Copy link
Contributor Author

Voldivh commented Sep 18, 2023

I agree, let's go with the comment for now and keep it in mind from now on.

@mjcarroll mjcarroll self-assigned this Oct 30, 2023
@mjcarroll mjcarroll moved this from Inbox to To do in Core development Oct 30, 2023
mjcarroll added a commit that referenced this issue Nov 3, 2023
Closes #2153

Signed-off-by: Michael Carroll <[email protected]>
@github-project-automation github-project-automation bot moved this from To do to Done in Core development Nov 3, 2023
mjcarroll added a commit that referenced this issue Nov 3, 2023
Closes #2153

Signed-off-by: Michael Carroll <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants