ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Copter: allow position with only alt without lat long in SET_POSITION…

Open shiv-tyagi opened this issue 2 years ago • 4 comments

…_TARGET_GLOBAL_INT

Fixes #20393 This allows user to send only alt as position target without specifying the lat and long values. The lat and long values are set to current location.

I've tested it on SITL and it worked fine. The copter ascended to the specified altitude at current location if lat and long values passed in SET_POSITION_TARGET_GLOBAL_INT are both zero.

@rmackay9 Could you please review this PR?

shiv-tyagi avatar Apr 26 '22 20:04 shiv-tyagi

Can anyone please review this?

shiv-tyagi avatar May 21 '22 12:05 shiv-tyagi

Hi @shiv-tyagi, txs for this. I think though that this isn't quite right for two reasons:

  • the type_mask field should be used to specify whether the lat,lon are consumed or not. This change uses an alternative which is to provide zero lat and lon
  • if the lat and lon are not provided then we should use the current target lat, lon not the vehicle's current lat,lon. The reason is that every time the set-position-target-global-int was sent it would cause a small amount of drift because it would essentially lock in the current position error.

rmackay9 avatar May 23 '22 03:05 rmackay9

Thanks @rmackay9 for reviewing this. I have changed the approach as asked by you. The new changes are as follows:-

  • position is ignored if and only if all lat lng and alt ignore bits are set. If alt ignore bit is not set, we don't ignore the position.
  • lat lng is ignored if ignore posX and posY bits are set.
  • If lat lng is ignored, we try to get current target. If we get the target, we use the lat and lng from that target and set the new destination with new alt.
  • If we fail to get current alt (which might happen if current target is not set), we use current location lat lng for the new destination.

I have tested it of above cases and its working good. Can you please tell if this is inline with your expectations or am I getting something wrong? Thanks!

shiv-tyagi avatar May 23 '22 14:05 shiv-tyagi

I gave it a test on sitl and its working great. If latlng has to be ignored, the copter proceeds towards current target (or current loc if curr target is not available) at the alt specified in mavlink message. Similarly if alt has to be ignored, the vehicle proceed towards the target specified in mavlink message at current target (or current loc) alt.

shiv-tyagi avatar Jun 12 '22 13:06 shiv-tyagi

@rmackay9 Can you please have a look on this PR once again and let me know if its mergeable?

shiv-tyagi avatar Oct 13 '22 18:10 shiv-tyagi