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

Gimbal/Joystick: implement rate commands #12049

Merged
merged 5 commits into from
Nov 6, 2024
Merged

Gimbal/Joystick: implement rate commands #12049

merged 5 commits into from
Nov 6, 2024

Conversation

julianoes
Copy link
Contributor

This pull request changes the behaviour of the joystick Gimbal Up/Down, Left/Right commands. Instead of sending an angle and increasing that angle with a step (using repeat) we now send the angular rate.

The way it works is that we:

  1. Send the angular rate command when either button is pressed.
  2. Keep sending that command at 2 Hz to allow the autopilot to stop again with a timeout.
  3. Send a last command with rates set to zero when the button is released again.

We should probably allow a user to adjust the angular rate commanded which is currently hard-coded. I'm not sure where the right place for this would be.

Fixes #11956.

@HTRamsey
Copy link
Collaborator

HTRamsey commented Oct 30, 2024

@julianoes could you set the parent of the GimbalController to be the vehicle and then remove the deleteGimbalController() from the vehicle class? If not I can make a separate PR to do so later.

Edit: Gimbal needs a parent too

@julianoes
Copy link
Contributor Author

Feel free to add commits @HTRamsey. I'm not too sure what you mean.

@HTRamsey
Copy link
Collaborator

Okay will do. Just FYI when you do something like in this picture, it sets the vehicle as the parent of the GimbalController. When QObjects are deleted, they also delete all of their children automatically
image

@julianoes
Copy link
Contributor Author

I think that's actually on purpose:

// Gimbal controller sends message requests when receiving heartbeats, trying to find a gimbal, and it messes with this test so we disable it
vehicle->deleteGimbalController();

@HTRamsey
Copy link
Collaborator

Oh I guess that function can stay then, although the parenting stuff should still be done

This pull request changes the behaviour of the joystick Gimbal Up/Down,
Left/Right commands. Instead of sending an angle and increasing that
angle with a step (using repeat) we now send the angular rate.

The way it works is that we:
1. Send the angular rate command when either button is pressed.
2. Keep sending that command at 2 Hz to allow the autopilot to stop
   again with a timeout.
3. Send a last command with rates set to zero when the button is
   released again.

We should probably allow a user to adjust the angular rate commanded
which is currently hard-coded. I'm not sure where the right place for
this would be.
@julianoes
Copy link
Contributor Author

Done @HTRamsey.

@HTRamsey
Copy link
Collaborator

Nice thanks. QmlObjectListModel _gimbals; isn't created dynamically with a parent but since GimbalController calls _gimbals.clearAndDeleteContents() it should be fine

@Davidsastresas
Copy link
Member

Davidsastresas commented Nov 1, 2024

I will check this on the next few days, sorry, but I read that matter about making it automatically get destroyed with vehicle destructor, and that was actually a workaround to fix tests, at least in 4.4 for the way tests were done this hack was needed, I don't remember exactly the details but I wanted to mention in case you guys find the same issue. Thanks!

EDIT - I actually saw you dealt with this on the next messages. Sorry I posted this response too fast!

@Davidsastresas
Copy link
Member

Davidsastresas commented Nov 4, 2024

Good catch the gimbal parent front. It wasn't being deleted until now right? so we had memory leaks if vehicle disconnected, not huge but we had, right? EDIT - Sorry I read the whole thread and indeed we were calling that clearAndDeleteContents(), it was alright. Good catch anyway, we should be setting parents on those, Thanks!

I checked your solution for rates, very elegant as usual! I like how you managed to control the timer to avoid timeouts. I tested in SITL Ardupilot and it works great. Indeed this is much much nicer than having steps, this feels much more natural, yet you still have somehow precise control to just move a few degrees.

I added the rate used by buttons to the Settings panel in cfdadfd, only visible if we have joystick connected and active:
Screenshot from 2024-11-04 17-55-51

I was tempted of using the same speed used for click and drag, but I thought a particular setup could benefit of different rates for both, so I made a new setting for buttons specifically.

On the other commit I fixed the buttons that got broken by the QGCButton restyling, text out of sight

Having confirmed this works correctly, we should update click and drag to use rates too. I was tempted to do it now, but I remember we had some issue in android, apparently android is not processing press and release as desktop, so that was the fundamental issue with click and slide for android, so I think we can address that maybe other time in a different PR.

Thanks Holden, Julian!

@julianoes
Copy link
Contributor Author

Amazing, thanks @Davidsastresas! And great that you could test it with ArduPilot and it works!

@julianoes julianoes merged commit a022c9c into master Nov 6, 2024
7 checks passed
@julianoes julianoes deleted the pr-gimbal-rate branch November 6, 2024 08:24
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.

Gimbal manual control doesn't work
3 participants