Offboard mode

Hi.

I am creating my own app in C# to control pixhawk autopilot by using MAVLink commands and keyboard. This app is connected with my Engineer’s thesis. I can established connection with autopilot and receive mavlink messages. I can also change flight modes and send basic commands like takeoff, land etc.

My main goal is to steer drone via keyboard without RC controller. I found that it is possible using offboard mode.
https://docs.px4.io/master/en/flight_modes/offboard.html

There are some conditions to change mode to offboard which I have to meet. How I am doing that:
And I want to add that now I am using px4_sitl jmavsim with udp connection.

  1. Start receiving udp messages from autopilot.
  2. Start sending heartbeat at 1Hz to pixhawk with AUTOPILOT1 flag.
  3. Arm pixhawk via DO_ARM_DISARM message.
  4. Take off via TAKEOFF message or DO_SET_MODE message with mode TAKEOFF
  5. Start sending SET_POSITION_TARGET_LOCAL_NED message with velocities with 500 ms interval.
       public static void SendVelocities(float vx, float vy, float vz)
    {
        MAVLink.mavlink_set_position_target_local_ned_t c = new MAVLink.mavlink_set_position_target_local_ned_t();
        c.time_boot_ms = 0;
        c.target_system = SystemId;
        c.target_component = ComponentId;
        c.coordinate_frame = (byte)MAVLink.MAV_FRAME.LOCAL_NED;
        c.type_mask = 0b0000111111000111;
        c.x = float.NaN;
        c.y = float.NaN;
        c.z = float.NaN;
        c.vx = vx;
        c.vy = vy;
        c.vy = vz;
        c.afx = float.NaN;
        c.afy = float.NaN;
        c.afz = float.NaN;
        c.yaw = float.NaN;
        c.yaw_rate = float.NaN;

        Communication.Send(MAVLink.MAVLINK_MSG_ID.SET_POSITION_TARGET_LOCAL_NED, c);
    }

Velocities are mapped from keyboard. I am using QWEASD.

  1. Set DO_SET_MODE message with OFFBOARD mode.

After point 6. I am receiving COMMAND_ACK that it is TEMPORARILY_REJECTED.

What am I doing wrong? Where the error is with my scheme of thinking?