How to set home position

I try to set home position using mavlink command MAV_CMD_DO_SET_HOME
Command accepted and executed, but home position doesn’t changed. MAVLINK_STATUS_TEXT displays old home position. What i’m doing wrong?
mavlink_message_t msg;
mavlink_command_long_t cmd;
cmd.command = (uint16_t)MAV_CMD_DO_SET_HOME;
cmd.param1 = 1.0f;
cmd.param2 = 0.0f;
cmd.param3 = 0.0f;
cmd.param4 = 0.0f;
cmd.param5 = lat;
cmd.param6 = lon;
cmd.param7 = alt;
cmd.target_system = ProtocolIDs::mavlinkVehicleID;
cmd.target_component = ProtocolIDs::mavlinkCompID;
mavlink_msg_command_long_encode(ProtocolIDs::mavlinkSysID, ProtocolIDs::mavlinkCompID, &msg, &cmd);

PX4 Firmware: 1.5.5

I have changed cmd.param1 = 0 but nothing

Not sure where you’re sending it from, but cmd.target_component might be wrong. Try 0 or 1 there.

Problem solved. cmd.target_component = 1, cmd.target_system = 1. Thanks!

One more question: what is the altitude of this command? Absolute (AMSL) or relative (AGL)? There is no information on this in the documentation.

Hello @DmitryDemidov , do you know how if it is possible to set home position for the drone trhough mavsdk? And if you don’t know it, could you explain to me how did you set your home position and where do you introduce those cmd.commands? Thanks in advance!!

Hi! I several years do not develop UAVs and unfortunately I can’t help with these issues.

Did you find out the answer?