# Pymavlink SET\_POSITION\_TARGET with velocity

**URL:** <https://discuss.bluerobotics.com/t/pymavlink-set-position-target-with-velocity/12839>\
**Category:** Blue Robotics Software\
**Tags:** ardusub, pymavlink, positioning\
**Created:** [August 29, 2022, 10:03pm UTC](https://discuss.bluerobotics.com/t/pymavlink-set-position-target-with-velocity/12839 "2022-08-29T22:03:48Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![EliotBR](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.bluerobotics.com/eliotbr/32/6937_2.png) [@EliotBR](https://discuss.bluerobotics.com/u/EliotBR)\
**Post date:** [September 1, 2022, 4:48am UTC](https://discuss.bluerobotics.com/t/pymavlink-set-position-target-with-velocity/12839/4 "2022-09-01T04:48:11Z")

</div>

We did a bit of testing and digging today, and found that using `SET_POSITION_TARGET_*` [requires using Guided mode](https://github.com/ArduPilot/ardupilot/blob/Sub-4.1/ArduSub/GCS_Mavlink.cpp#L663), which in its current implementation requires having both a position estimate and a position target. When setting just velocity targets the [initialisation process](https://github.com/ArduPilot/ardupilot/blob/Sub-4.1/ArduSub/control_guided.cpp#L191) includes [setting the position target to its current position](https://github.com/ArduPilot/ardupilot/blob/Sub-4.1/libraries/AC_AttitudeControl/AC_PosControl.cpp#L499-L501).

In a simulated vehicle (which includes a GPS signal) we were able to use the velocity target mode, but it moved a short distance before slowing and stopping, presumably reaching an equilibrium between trying to maintain a constant non-zero velocity while also trying to maintain a constant position.

We were able to get accelerometer-only position estimates (on a Navigator, not simulated) to at least occur internally by setting `EK3_SRC1_POSXY`, `EK3_SRC1_VELXY` and `EK3_SRC1_VELZ` from “GPS” to “None”, and [setting a global origin](http://mavlink.io/en/messages/common.html#SET_GPS_GLOBAL_ORIGIN), but from what we could tell the internal position estimates were not being output over MAVLink (via the `AHRS2`, `GLOBAL_POSITION_INT`, and `GPS_RAW_INT` messages that were being sent), so there’s not an obvious way to feed back the current position as the vehicle moves and allow the position target to be updated.

We’ll try to do some more testing, but at this stage while we _in principle_ agree that it should be at least _allowed_ to try to maintain velocity without a position sensor, it seems there are some aspects of the current implementation that are stopping that from happening. It’s also very possible that even if we manage to enable it, the velocity estimates from integrated accelerometer data will be far too noisy to have usable performance.

If we can find a reasonably simple way of enabling it then we’ll try to do so (it would be nice to at least have the option, in case “poor performance” is still “good enough” for some use-cases), but we’ll have to see how complicated and time consuming that is to do.

---

_[View the full topic](https://discuss.bluerobotics.com/t/pymavlink-set-position-target-with-velocity/12839)._
