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

Add gimbal device #23382

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

StefanoColli
Copy link
Contributor

@StefanoColli StefanoColli commented Jul 10, 2024

Feature

Gimbal device to be controlled in SITL environment when using gazebo simulator (gz-garden). The device can act as a Mavlink gimbal (following Mavlink gimbal protocol v2) or as a non-Mavlink gimbal (responding to gimbal_controls messages) depending on MNT_MODE_OUT PX4 parameter.
It supports both angle and angular rate commands, it doesn't support yet the gimbal device flags (WIP).
It is meant to work with the gz_x500_gimbal model (PX4/PX4-gazebo-models#47).

Test coverage

Tested with QGC

WIP

The submodule Tools/simulation/gz is temporarily pointing to https://github.com/StefanoColli/PX4-gazebo-models waiting for
PX4/PX4-gazebo-models#47 to be merged into main.

Context

x500_gimbal2

gimbalQGCm.mp4

@lierdakil
Copy link

What's the status on this? I.e. why is it drafted? I kinda want a SITL gimbal real bad, hence asking whether this (mostly) works or if it's not ready at all.

@Jaeyoung-Lim
Copy link
Member

@lierdakil You can already try out the current status?

@StefanoColli
Copy link
Contributor Author

@lierdakil It is drafted because you would need to use my PX4-gazebo-models fork instead of the PX4 default one. But most of the functionalities are there except from the gimbal device flags as stated in the PR message

@lierdakil
Copy link

@StefanoColli thank you very much for the reply, that sounds great! I'll be trying this branch out shortly, then.

@lierdakil
Copy link

So this works great, but apparently the gimbal in the model is installed with the neutral position pointing backwards. I've rotated it 180⁰ in the model, and everything is fine, but was this intended?

@0uterspaceguy
Copy link

Cant make it work with qgc. Can you share parameters settings?

@lierdakil
Copy link

lierdakil commented Aug 17, 2024

Sorry, I didn't use qgc, I'm interfacing with it from software via mavlink.

But qgc v 4.4 has added some gimbal controls, which kind of work.

For one, there are some buttons at the top (click the joystick-looking thing to the right of the battery indicator)
image

If you've also enabled video in qgc, then "on Screen Camera Control", or at least "click to point" will work when you switch to the video feed.

image

(whether you actually have some video there is irrelevant)

That said, it seems pitch is inverted between qgc and px4, the camera very stubbornly pitches upwards instead of downwards (this may be my modifications to blame though). Also, the yaw indicator on the map is messed up, apparently the yaw angle shown is the sum of the frame's yaw and camera's yaw relative to the frame. So things are rough around the edges.

@Jaeyoung-Lim
Copy link
Member

@StefanoColli Any updates regarding this PR?

@Jaeyoung-Lim Jaeyoung-Lim mentioned this pull request Aug 26, 2024
30 tasks
@StefanoColli
Copy link
Contributor Author

StefanoColli commented Sep 13, 2024

So this works great, but apparently the gimbal in the model is installed with the neutral position pointing backwards. I've rotated it 180⁰ in the model, and everything is fine, but was this intended?

@lierdakil Are you sure about that? because in QGC I see that the gimbal in neutral position is correctly pointing forward...

@StefanoColli StefanoColli marked this pull request as ready for review September 13, 2024 15:27
@lierdakil
Copy link

lierdakil commented Sep 17, 2024

Are you sure about that?

Well, the actual video feed from the simulated camera (captured with ROS) does not point in the direction the drone flies in when the pitch stick is tilted forward. Also, the model visibly points backwards in Gazebo. When SITL first starts up, you're not looking at the front of the drone, you're looking at its butt 😅

P.S. Disclaimer: I didn't actually check the version that got eventually merged, but this was the case at the time I wrote the original comment. So take this with a grain of salt.

@hamishwillee
Copy link
Contributor

hamishwillee commented Sep 18, 2024

When this is ready can we please have some docs. Specifically and addition to https://docs.px4.io/main/en/sim_gazebo_gz/vehicles.html and to the list here: https://docs.px4.io/main/en/sim_gazebo_gz/#running-the-simulation

Also in https://docs.px4.io/main/en/sim_gazebo_gz/ a new section "Simulating a Gimbal" that explains how you set up gazebo/PX4 to use this, and how it can be tested.

What we need is enough information so that someone can run a turnkey set of instructions and then send MAVLink commands to a gimbal-protocol v2 compliant gimbal manager and drive the simulation. QGC has that implementation, at least in part, so should be a good first test point. MAVSDK too.

@anaam-wingxpand
Copy link

Are you sure about that?

Well, the actual video feed from the simulated camera (captured with ROS) does not point in the direction the drone flies in when the pitch stick is tilted forward. Also, the model visibly points backwards in Gazebo. When SITL first starts up, you're not looking at the front of the drone, you're looking at its butt 😅

P.S. Disclaimer: I didn't actually check the version that got eventually merged, but this was the case at the time I wrote the original comment. So take this with a grain of salt.

I am also seeing that the camera is pointing towards the butt of the drone. This is with the model that was merged.

@anaam-wingxpand
Copy link

anaam-wingxpand commented Nov 21, 2024

I had to add pi/2 to the yaw setpoint command to get it to "ROI at location" correctly via QGC.

In GZGimbal.cpp: publishJointCommand(_gimbal_yaw_cmd_publisher, static_cast<float>(M_PI_2) + _yaw_stp, _yaw_rate_stp, _last_yaw_stp, _yaw_min, _yaw_max, dt);

@dagar dagar self-requested a review November 22, 2024 01:45
@Perrrewi
Copy link
Contributor

When this is ready can we please have some docs. Specifically and addition to https://docs.px4.io/main/en/sim_gazebo_gz/vehicles.html and to the list here: https://docs.px4.io/main/en/sim_gazebo_gz/#running-the-simulation

Started a draft here: PX4/PX4-user_guide#3496

@Jaeyoung-Lim
Copy link
Member

@StefanoColli Any updates?

@StefanoColli
Copy link
Contributor Author

I re-based my commits on top of master and then I need to open a PR in PX4-gazebo-models to fix the orientation of the gimbal

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Dec 13, 2024

@StefanoColli Could you do it such that we can wrap this up?

Have you tested this with the QGC version that is available for the public as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants