I was thinking it would be nice to get confirmation that the drone has received my MAVLINK_MSG_SET_POSITION_TARGET_POSITION message to send the drone to a particular location. I request that message using MAV_CMD_SET_MESSAGE_INTERVAL in my start up code.
Unfortunately, I never receive the MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT which I was expecting to get. This would hopefully tell me that the drone had updated its target to fly to.
I had a look at the Arducopter source code and found this in GCS_Mavlink.cpp:
I would like to add that I found my code had a mistake so it did not explicitly request the MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT message, however based on what you said, I should be seeing this message regardless.
It was doing a takeoff to 10m followed by ascent to position target another 5m up and finally an attempt to set an attitude target. To be honest, there was only one position+yaw target set (with type mask set to only allow position i.e. POSITION_TARGET_TYPEMASK_VELOCITY_IGNORE | POSITION_TARGET_TYPEMASK_ACCELERATION_IGNORE | POSITION_TARGET_TYPEMASK_YAW_RATE_IGNORE) but still I did not see the Position_Target_Global_Int messages.
Thank you for your work on that pull request. It makes sense to have it enabled during GUIDED mode, especially since you can request position targets so why not receive confirmation of them?
I know that it is possible to receive POSITION_TARGET_LOCAL_NED when in GUIDED mode, for instance, so your pull request makes sense.
Are you able to receive the POSITION_TARGET_LOCAL_NED messages if you request them?
Possibly, the reason you aren’t getting that message is that terrain data is still pending download and thus is not available to convert the altitude frame. This means we don’t send Position_Target_Global_Int messages. Not 100% on this though as I can’t replicate the behavior in SITL.
Maybe try ensuring the terrain data is available by downloading it from the server for your locale?
With my drone sitting on the ground unarmed, I only get MAVLINK_MSG_ID_GLOBAL_POSITION_INT and MAVLINK_MSG_ID_LOCAL_POSITION_NED messages. Do I need to be in GUIDED mode or flying to get the POSITION_TARGET messages?
Yes, you must be in GUIDED to get POSITION_TARGET_LOCAL messages.
POSITION_TARGET_GLOBAL_INT is available in other modes RTL (all submodes but Landing), Smart_RTL (similar to landing), Auto, Follow, and Guided (when in WP mode, Pos control mode)
Have you tried using your code in SITL?? That is what I would do next.
Okay, I did some more flying today and it seems that MAVLINK_MSG_ID_POSITION_TARGET_GLOBAL_INT must be explicitly requested. At least that is what I am seeing in GUIDED mode. I do get the message when I ask for it.
I am potentially seeing a discrepancy in the position target fields vs what I request. This may be an issue with float truncation maybe. I’m not sure yet.