How to set/get home using Mavlink commands

I am using set_home_position to change the location to which the copter will return when RTL is initiated. However, this doesn’t work well (works only after several attempts of transmit the command in auto mode and not in position hold). are there limitations of using this command?

Regarding MAV_CMD_GET_HOME_POSITION - in HOME_POSITION it says that it can be requested by sending GET_HOME, however, there is no get_home in the mavlink messages list, and no implementation in the mavlink git files. I also found references to this command in arducopter discussions… Can someone clarify or suggest alternatives to finding out if set_home has updated the home position?


I have a PR in place which adds a test for setting the home position - it
may or may not help:

We do attempt to support MAV_CMD_GET_HOME_POSITION - is it not working for

“We do attempt to support MAV_CMD_GET_HOME_POSITION - is it not working for

Its not that it doesn’t work - I can’t even try. There is no implementation in the Mavlink git files of this message and no documentation in the mavlink command page

OK, I think I am starting to get it. I was looking for a MAVlink message, while “MAV_CMD_GET_HOME_POSITION” is a MAVLink Command (and not a message). is it possible to find a C library the encodes MAVLink Commands?

generate it yourself using pymavlink.

1 Like


The MAV_CMD_GET_HOME_POSITION can be sent within a COMMAND_LONG message and then the autopilot should reply with a HOME_POSITION message. It should actually send the HOME_POSITION in response to the SET_HOME_POSITION command being accepted as well.

As a side note, I have started improving slightly the documentation on AP’s mavlink interface and it mentions the set-home-position support but it’s still got a long way to go.

1 Like

So I am sending SET_HOME_POSITION in a loop every 2sec. For a long time I don’t get HOME_POSITION response (a few minutes), and than for some reason I start getting the response continuously (every 2 secs). Any thoughts why this is happening? Are there any restrictions of when the Arducopter can handle SET_HOME_POSITION?


@endrew, yes, I think that AP won’t start publishing a home position until the EKF has a good position estimate. The reason is that Copter checks that the home position is not too far from it’s actual position (reported by the EKF). So while the EKF doesn’t have a position estimate it can’t do that check so it ignores the set-home command.

One thing that may or may not be important - the “home” is simply where the vehicle will return to. It is not used internally by Copter as the “origin” for any navigation calculations. Separately AP has an “EKF origin” which can also be set but normally doesn’t need to be unless you’re doing non-GPS navigation.

1 Like

Lots of them :slight_smile:

One thing you should be looking for is the ack or nack for your command.

You might check the autotest for this feature: