Servers by jDrones

Cannot persuade Arducopter to takeoff using my companion computer. No obvious cause

I have a Pixhawk running the latest Ardupilot (actually a custom version with a handful of GCS_SEND_TEXT statements in) connected to a companion computer (my laptop) over a wireless telemetry link. I cannot get the thing to takeoff, and all my messages sent to Ardupilot seem identical to those as done by Mission Planner and QGroundControl (both these GCSs make my drone takeoff).

I am doing this:

  1. Wait for heartbeat from autopilot. Store the system and component ID.
  2. Request streaming of all data types (REQUEST_DATA_STREAM). Make sure I get MAVLINK_MSG_ID_LOCAL_POSITION_NED and MAVLINK_MSG_ID_GLOBAL_POSITION_INT.
  3. Send MAV_CMD_NAV_GUIDED_ENABLE to enable offboard mode.
  4. Set COPTER_MODE_GUIDED i.e. guided flight mode.
  5. Arm the autopilot. Arming switch is also enabled BTW.
  6. Send MAV_CMD_NAV_TAKEOFF
    com.confirmation = true;
    com.param3 = (float) 0; // param3 : horizontal navigation by pilot acceptable
    com.param7 = (float) 100; // param7 : altitude [metres]
  7. Nothing happens. No props turn. It auto-disarms after a few seconds.

I am able to verify that the drone is armed and in guided flight mode as expected and that it has GPS lock. I have also tried setting the system time and sending 1Hz heartbeats, although neither of these are necessary to my knowledge.

I have looked at the source code and put a few GCS_SEND_TEXT statements in to help me check the flow of code. I am seeing ModeGuided::do_user_takeoff_start being called correctly and the function runs all the way through.
I have a feeling that the reason for failure is related to either

set_throttle_takeoff();
or
auto_takeoff_set_start_alt();

but as there is no feedback from these function I am a little stuck.

Please can some Arduboffin help me debug this? I am at a loose end. :frowning:

Many thanks.

Well, I solved this. I was sending MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_VELOCITY messages too soon after takeoff. SMH.

Servers by jDrones