Unable to subscribe land callback function

I am working on creating server plugins, so I’m referring to the example code called autopilot_server.cpp. I want to add the land action, so I added “action.land()” in the main thread and subscribed land in autopilotThread like below:

auto actionServer = mavsdk::ActionServer{server_component};

actionServer.subscribe_land([&](ActionServer::Result result, bool land) {
if (result == ActionServer::Result::Success) {
std::cout << "[autopilotThread] land " << land << std::endl;
} else {
std::cout << “[autopilotThread] land failed” << std::endl;
}
});

const Action::Result land_result = action.land();
if (land_result != Action::Result::Success) {
std::cout << “Land failed!:” << land_result << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}

But I cannot see the land callback, only subscribe_takeoff() is called.

Adding how I tested it.
I followed the instructions and installed mavsdk_0.37.0_ubuntu20.04_amd64.deb.

sudo dpkg -i mavsdk_0.37.0_ubuntu20.04_amd64.deb

I tested autopilot_server below

  1. Run jmavsim_iris simulator: make px4_sitl jmavsim_iris
  2. Run autopilot_server on port 14551. It doesn’t work take off action
- auto result = mavsdkTester.add_any_connection("udp://127.0.0.1:14551"); // The server plugins 
  auto result = mavsdk.add_any_connection("udp://:14551"); // as the GCS
[09:23:34|Info ] MAVSDK version: v1.4.0-511-gfadfe22e (mavsdk_impl.cpp:23)
[09:23:34|Info ] MAVSDK version: v1.4.0-511-gfadfe22e (mavsdk_impl.cpp:23)
Connected!
[09:23:34|Debug] Initializing connection to remote system... (mavsdk_impl.cpp:692)
Connected autopilot server side!
MissionRawServer created
[09:23:34|Info ] New system on: 127.0.0.1:48408 (with system ID: 1) (udp_connection.cpp:192)
[09:23:34|Debug] New system ID: 1 Comp ID: 1 (mavsdk_impl.cpp:694)
[09:23:34|Debug] Component Autopilot (1) added. (system_impl.cpp:379)
[09:23:35|Debug] Discovered 1 component(s) (system_impl.cpp:548)
Discovered Autopilot from Client
[09:23:35|Debug] New: System ID: 245 Comp ID: 190 (mavsdk_impl.cpp:357)
[09:23:35|Debug] Component Ground station (190) added. (system_impl.cpp:379)
[09:23:35|Debug] Discovered 1 component(s) (system_impl.cpp:548)
[09:23:45|Debug] Setting interval for msg id: 245 interval_ms:1000 (telemetry_server_impl.cpp:36)
[09:23:45|Warn ] sending again after 0.500399 s, retries to do: 3  (512). (mavlink_command_sender.cpp:308)
[09:23:45|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:46|Warn ] sending again after 1.00431 s, retries to do: 2  (512). (mavlink_command_sender.cpp:308)
[09:23:46|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:46|Warn ] sending again after 1.5078 s, retries to do: 1  (512). (mavlink_command_sender.cpp:308)
[09:23:46|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:47|Error] Retrying failed (512) (mavlink_command_sender.cpp:336)
[09:23:49|Warn ] sending again after 0.504018 s, retries to do: 3  (512). (mavlink_command_sender.cpp:308)
[09:23:49|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:50|Warn ] sending again after 1.00796 s, retries to do: 2  (512). (mavlink_command_sender.cpp:308)
[09:23:50|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:50|Warn ] sending again after 1.51277 s, retries to do: 1  (512). (mavlink_command_sender.cpp:308)
[09:23:50|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:51|Debug] Falling back to gimbal protocol v1 (mission_impl.cpp:128)
[09:23:51|Error] Retrying failed (512) (mavlink_command_sender.cpp:336)
[09:23:51|Warn ] sending again after 0.507868 s, retries to do: 3  (512). (mavlink_command_sender.cpp:308)
[09:23:51|Warn ] Request was for msg ID: 280 (mavlink_command_sender.cpp:314)
[09:23:52|Warn ] sending again after 1.01202 s, retries to do: 2  (512). (mavlink_command_sender.cpp:308)
[09:23:52|Warn ] Request was for msg ID: 280 (mavlink_command_sender.cpp:314)
[09:23:52|Warn ] sending again after 1.51654 s, retries to do: 1  (512). (mavlink_command_sender.cpp:308)
[09:23:52|Warn ] Request was for msg ID: 280 (mavlink_command_sender.cpp:314)
[09:23:53|Error] Retrying failed (512) (mavlink_command_sender.cpp:336)
[09:23:53|Warn ] sending again after 0.507207 s, retries to do: 3  (512). (mavlink_command_sender.cpp:308)
[09:23:53|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:54|Warn ] sending again after 1.01047 s, retries to do: 2  (512). (mavlink_command_sender.cpp:308)
[09:23:54|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:54|Warn ] sending again after 1.51408 s, retries to do: 1  (512). (mavlink_command_sender.cpp:308)
[09:23:54|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:55|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:23:55|Error] Retrying failed (512) (mavlink_command_sender.cpp:336)
[09:23:55|Warn ] sending again, retries to do: 5 (mavlink_parameter_client.cpp:1044)
[09:23:55|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:23:56|Warn ] sending again, retries to do: 4 (mavlink_parameter_client.cpp:1044)
[09:23:56|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:23:56|Warn ] sending again, retries to do: 3 (mavlink_parameter_client.cpp:1044)
[09:23:56|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:23:57|Warn ] sending again, retries to do: 2 (mavlink_parameter_client.cpp:1044)
[09:23:57|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:23:57|Warn ] sending again after 0.501878 s, retries to do: 3  (512). (mavlink_command_sender.cpp:308)
[09:23:57|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:57|Warn ] sending again, retries to do: 1 (mavlink_parameter_client.cpp:1044)
[09:23:57|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:23:58|Warn ] sending again after 1.00566 s, retries to do: 2  (512). (mavlink_command_sender.cpp:308)
[09:23:58|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:58|Error] retrying failed (mavlink_parameter_client.cpp:1061)
Creating Mission
Uploading mission...
SystemID 
[09:23:58|Debug] Receive Mission Count in Server (mission_raw_server_impl.cpp:149)
Received Uploaded Mission!
mission_plan:
{
    mission_items: [mission_item:
{
    seq: 0
    frame: 6
    command: 16
    current: 1
    autocontinue: 1
    param1: 0.5
    param2: 1
    param3: 0
    param4: nan
    x: 473981703
    y: 85456490
    z: 10
    mission_type: 0
}, mission_item:
{
    seq: 1
    frame: 2
    command: 178
    current: 0
    autocontinue: 1
    param1: 1
    param2: 5
    param3: -1
    param4: 0
    x: 0
    y: 0
Mission uploaded.    z: 
nan
    mission_type: 0
}, mission_item:
{
    seq: 2
    frame: 2
    command: 204
    current: 0
    autocontinue: 1
    param1: 2
    param2: 0
    param3: 0
    param4: 1
    x: 0
    y: 0
    z: 2
    mission_type: 0
}, mission_item:
{
    seq: 3
    frame: 2
    command: 205
    current: 0
    autocontinue: 1
    param1: 20
    param2: 0
    param3: 60
    param4: nan
    x: 0
    y: 0
    z: 2
    mission_type: 0
}]
}
Current Mission Item Changed!
Current Item: mission_item:
{
    seq: 0
    frame: 6
    command: 16
    current: 1
    autocontinue: 1
    param1: 0.5
    param2: 1
    param3: 0
    param4: nan
    x: 473981703
    y: 85456490
    z: 10
    mission_type: 0
}
Current Mission Item Changed!
Current Item: mission_item:
[09:23:58{
    seq: 1
    frame: 2
    command: 178
    current: 0
Current:     autocontinue: 1
    param1: 1
    param2: 05
    param3: |Debug] -1
Total: 1
current: 0, total: 1 (mission_impl.cpp:1050)

    param4: 0
    x: 0
    y: 0
    z: nan
    mission_type: 0
}
Clear All Mission!
Clear Mission Request
[09:23:58|Warn ] sending again after 1.51042 s, retries to do: 1  (512). (mavlink_command_sender.cpp:308)
[09:23:58|Warn ] Request was for msg ID: 242 (mavlink_command_sender.cpp:314)
[09:23:59|Error] Retrying failed (512) (mavlink_command_sender.cpp:336)
[09:24:18|Debug] Setting interval for msg id: 33 interval_ms:1000 (telemetry_server_impl.cpp:36)
Vehicle is getting ready to arm
Altitude: 0 m
Altitude: 0 m
Vehicle is getting ready to arm
Altitude: 0 m
Altitude: 0 m
Vehicle is getting ready to arm
Altitude: 0 m
Altitude: 0 m
Vehicle is getting ready to arm
Altitude: 0 m
Altitude: 0 m
Vehicle is getting ready to arm
Altitude: 0 m
Altitude: 0 m
Vehicle is getting ready to arm
Altitude: 0 m
Altitude: 0 m
Vehicle is getting ready to arm
Altitude: 0 m
Altitude: 0 m
Altitude: 0 m
Vehicle is getting ready to arm
  1. Run autopilot_server on port 14550. It works take off action because I can see the “[autopilotThread] callback Take off 1” I added, but I cannot the land log.
- auto result = mavsdkTester.add_any_connection("udp://127.0.0.1:14550"); // The server plugins 
  auto result = mavsdk.add_any_connection("udp://:14550"); // as the GCS
[09:20:34|Info ] MAVSDK version: v1.4.0-511-gfadfe22e (mavsdk_impl.cpp:23)
[09:20:34|Info ] MAVSDK version: v1.4.0-511-gfadfe22e (mavsdk_impl.cpp:23)
Connected!
[09:20:34|Debug] Initializing connection to remote system... (mavsdk_impl.cpp:692)
Connected autopilot server side!
[09:20:34|Info ] New system on: 127.0.0.1:47188 (with system ID: 1) (udp_connection.cpp:192)
[09:20:34|Debug] New system ID: 1 Comp ID: 1 (mavsdk_impl.cpp:694)
[09:20:34|Debug] Component Autopilot (1) added. (system_impl.cpp:379)
[09:20:34|Debug] Discovered 1 component(s) (system_impl.cpp:548)
MissionRawServer created
Discovered Autopilot from Client
[09:20:34|Debug] New: System ID: 245 Comp ID: 190 (mavsdk_impl.cpp:357)
[09:20:34|Debug] Component Ground station (190) added. (system_impl.cpp:379)
[09:20:34|Info ] New system on: 127.0.0.1:18570 (with system ID: 1) (udp_connection.cpp:192)
[09:20:34|Debug] Discovered 1 component(s) (system_impl.cpp:548)
[09:20:34|Warn ] Vehicle type changed (new type: 2, old type: 0) (system_impl.cpp:222)
[09:20:38|Warn ] Ignoring unknown ping sequence (ping.cpp:58)
[09:20:44|Debug] Setting interval for msg id: 245 interval_ms:1000 (telemetry_server_impl.cpp:36)
[09:20:44|Warn ] Received ack for not-existing command: 511! Ignoring... (mavlink_command_sender.cpp:279)
[09:20:48|Warn ] Ignoring unknown ping sequence (ping.cpp:58)
[09:20:50|Debug] Falling back to gimbal protocol v1 (mission_impl.cpp:128)
[09:20:54|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:20:54|Warn ] sending again, retries to do: 5 (mavlink_parameter_client.cpp:1044)
[09:20:54|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:20:55|Warn ] sending again, retries to do: 4 (mavlink_parameter_client.cpp:1044)
[09:20:55|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:20:55|Warn ] sending again, retries to do: 3 (mavlink_parameter_client.cpp:1044)
[09:20:55|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:20:56|Warn ] sending again, retries to do: 2 (mavlink_parameter_client.cpp:1044)
[09:20:56|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:20:56|Warn ] sending again, retries to do: 1 (mavlink_parameter_client.cpp:1044)
[09:20:56|Warn ] Ignoring request_read message - param name not found: MY_PARAM (mavlink_parameter_server.cpp:369)
[09:20:57|Error] retrying failed (mavlink_parameter_client.cpp:1061)
Creating Mission
Uploading mission...
SystemID 
[09:20:57|Debug] Receive Mission Count in Server (mission_raw_server_impl.cpp:149)
Mission uploaded.Received Uploaded Mission!

mission_plan:
{
    mission_items: [mission_item:
{
    seq: 0
    frame: 6
    command: 16
    current: 1
    autocontinue: 1
    param1: 0.5
    param2: 1
    param3: 0
    param4: nan
    x: 473981703
    y: 85456490
    z: 10
    mission_type: 0
}, mission_item:
{
    seq: 1
    frame: 2
    command: 178
    current: 0
    autocontinue: 1
    param1: 1
    param2: 5
    param3: -1
    param4: 0
    x: 0
    y: 0
    z: nan
    mission_type: 0
}, mission_item:
{
    seq: 2
    frame: 2
    command: 204
    current: 0
    autocontinue: 1
    param1: 2
    param2: 0
    param3: 0
    param4: 1
    x: 0
    y: 0
    z: 2
    mission_type: 0
}, mission_item:
{
    seq: 3
    frame: 2
    command: 205
    current: 0
    autocontinue: 1
    param1: 20
    param2: 0
    param3: 60
    param4: nan
    x: 0
    y: 0
    z: 2
    mission_type: 0
}]
}
Current Mission Item Changed!
Current Item: mission_item:
{
    seq: 0
    frame: 6
    command: 16
    current: 1
    autocontinue: 1
    param1: 0.5
    param2: 1
    param3: 0
    param4: nan
    x: 473981703
    y: 85456490
    z: 10
    mission_type: 0
}
[09:20:57|Debug] current: 0, total: 1 (mission_impl.cpp:1050)
Current: 0
Total: 1
Current Mission Item Changed!
Current Item: mission_item:
{
    seq: 1
    frame: 2
    command: 178
    current: 0
    autocontinue: 1
    param1: 1
    param2: 5
    param3: -1
    param4: 0
    x: 0
    y: 0
    z: nan
    mission_type: 0
}
Clear Mission Request
Clear All Mission!
[09:20:58|Warn ] Ignoring unknown ping sequence (ping.cpp:58)
[09:21:08|Warn ] Ignoring unknown ping sequence (ping.cpp:58)
[09:21:17|Debug] Setting interval for msg id: 33 interval_ms:1000 (telemetry_server_impl.cpp:36)
Arming...
Altitude: 0 m
Altitude: 0 m
[09:21:17|Warn ] Received ack for not-existing command: 511! Ignoring... (mavlink_command_sender.cpp:279)
Taking off...
[09:21:17|Debug] Param set request: MIS_TAKEOFF_ALT with ParamValue{float:10.000000} (mavlink_parameter_server.cpp:186)
[09:21:17|Warn ] Comparison type mismatch between int32_t and float (param_value.cpp:584)
[09:21:17|Error] Got param_set with wrong type for parameter: MIS_TAKEOFF_ALT (mavlink_parameter_server.cpp:206)
[09:21:17|Warn ] Received ack for not-existing command: 400! Ignoring... (mavlink_command_sender.cpp:279)
[09:21:17|Debug] MAVLink: info: Armed by external command	 (system_impl.cpp:248)
[autopilotThread] callback Take off 1
[09:21:17|Warn ] Received ack for not-existing command: 22! Ignoring... (mavlink_command_sender.cpp:279)
[09:21:17|Debug] MAVLink: info: [logger] ./log/2023-08-14/13_21_17.ulg	 (system_impl.cpp:248)
[09:21:17|Debug] MAVLink: info: Using minimum takeoff altitude: 10.00 m	 (system_impl.cpp:248)
Altitude: 0 m
Altitude: 0 m
Altitude: 10 m
[09:21:18|Warn ] Ignoring unknown ping sequence (ping.cpp:58)
Altitude: 0.00300000002607703 m
[09:21:18|Debug] MAVLink: info: Takeoff detected	 (system_impl.cpp:248)
Altitude: 10 m
Altitude: 10 m
Altitude: 0.0020000000949949 m
Altitude: 10 m
Altitude: 10 m
Altitude: 0.0020000000949949 m
Altitude: 10 m
Altitude: 10 m
Altitude: 0.31700000166893 m
Altitude: 10 m
Altitude: 10 m
Altitude: 1.39900004863739 m
Altitude: 10 m
Altitude: 10 m
Altitude: 2.82400012016296 m
Altitude: 10 m
Altitude: 10 m
Altitude: 4.34100008010864 m
Altitude: 10 m
Altitude: 10 m
Altitude: 5.85000038146973 m
Altitude: 10 m
Altitude: 10 m
Altitude: 7.37000036239624 m
Altitude: 10 m
Altitude: 10 m
Altitude: 8.72399997711182 m
Altitude: 10 m
Altitude: 10 m