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

Follow model in gz GUI #22808

Merged
merged 2 commits into from
Aug 21, 2024
Merged

Follow model in gz GUI #22808

merged 2 commits into from
Aug 21, 2024

Conversation

Jaeyoung-Lim
Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim commented Feb 27, 2024

Solved Problem

When running the simulation in gz, the model is not being followed by default.

@frede791 FYI

Solution

Start gz with a follow mode engaged to the model

Changelog Entry

For release notes:

Feature/Bugfix Gazebo gui follows model by default

Alternatives

We could also create a custom plugin to follow the model

Test coverage

make px4_sitl gz_x500

Screencastfrom02-27-2024104558AM-ezgif com-video-to-gif-converter

Context

@Jaeyoung-Lim Jaeyoung-Lim added the Sim: gazebo Gazebo simulator (gz) label Feb 27, 2024
@Jaeyoung-Lim Jaeyoung-Lim changed the title Follow model in gz Follow model in gz GUI Feb 27, 2024
@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Feb 27, 2024

@frede791 I kind of liked the dramatic rotation, but as you wish :)

The vehicle is a bit too small to see what is going on with 6 m (fo example control surfaces actuating), but we can keep it like that until gazebosim/gz-gui#515 is in

@Jaeyoung-Lim Jaeyoung-Lim force-pushed the pr-gz-camera-follow branch 3 times, most recently from 7cbb84c to 81e8303 Compare March 2, 2024 06:21
@frede791
Copy link
Contributor

frede791 commented Mar 2, 2024

@Jaeyoung-Lim It doesn't latch onto the model for me. I still have to click "follow" for the model to actually be tracked from the requested camera perspective.

Copy link
Contributor

@frede791 frede791 left a comment

Choose a reason for hiding this comment

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

The stringmsg doesn't seem to refer to the specific model that it is supposed to attach to in the way the old version had it.

src/modules/simulation/gz_bridge/GZBridge.cpp Outdated Show resolved Hide resolved
src/modules/simulation/gz_bridge/GZBridge.cpp Outdated Show resolved Hide resolved
src/modules/simulation/gz_bridge/GZBridge.hpp Outdated Show resolved Hide resolved
@Jaeyoung-Lim
Copy link
Member Author

The stringmsg doesn't seem to refer to the specific model that it is supposed to attach to in the way the old version had it.

Could you elaborate?

@frede791
Copy link
Contributor

frede791 commented Mar 2, 2024

In your previous version you used PX4_SIM_MODEL:

gz service -s /gui/follow --reqtype gz.msgs.StringMsg --reptype gz.msgs.Boolean --timeout 2000 --req "data: \"${PX4_SIM_MODEL#*gz_}_0\""

Since the call is now in GzBridge it is now set in the follow_msg, but it doesn't seem to be working correctly on my machine.

@Jaeyoung-Lim
Copy link
Member Author

@frede791 Have you tried changing the sleep just to see if it is working?

The problem is that the follow service seems to always return true, even if the model does not exist in gz sim

This commit makes the gz bridge follow the spawned model

F
Update src/modules/simulation/gz_bridge/GZBridge.cpp

Co-authored-by: Frederik Markus <80588263+frede791@users.noreply.github.com>
Cleanup
@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Aug 16, 2024

@frede791 @dagar I have removed the timeouts and detect whether the scene is created by checking if it is possible to query a scene message.

@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/px4-sync-q-a-aug-21-2024/40268/2

@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/px4-sync-q-a-aug-21-2024/40268/1

@dagar dagar merged commit ae16556 into main Aug 21, 2024
96 checks passed
@dagar dagar deleted the pr-gz-camera-follow branch August 21, 2024 15:41
@dakejahl
Copy link
Contributor

dakejahl commented Aug 21, 2024

unused variable
image
and sim throws an error
image

@Claudio-Chies
Copy link
Contributor

unused variable image and sim throws an error image

jup, I have the same issue

@dirksavage88
Copy link
Contributor

dirksavage88 commented Sep 21, 2024

Shows errors but still works despite the error printout
#23705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sim: gazebo Gazebo simulator (gz)
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

[Bug] px4_sitl gz_standard_vtol spawns with camera under the world
7 participants