AP Scheduler runs faster than anticipated

Hello there

I’m using a cube orange + with latest stable plane firmware.

I have implemented a function to send the actuators values via mavlink (send_hil_actuator_controls)

I scheduled this function using the scheduler in arduplane.cpp : SCHED_TASK(send_hil_actuator_controls, 30, 200, 49),

On the other side of mavlink is Mavproxy connected via com port and outputing data over UDP to my python script.

I have noticed that I received send_hil_actuator_controls much more than 30Hz maybe 200Hz 300Hz.
I tried to reduced the frequency by a factor of 10 :
SCHED_TASK(send_hil_actuator_controls, 3, 200, 49),

But same result on python side.

Here is a part of the python code :

def hil_actuator_listener():
    i=0
    while True:
        try:
            msg = conn.recv_match(type='HIL_ACTUATOR_CONTROLS', blocking=False)
            if msg is not None:
                i += 1
                print(i)

Anyone has a clue of what’s going on ? Is HIL_ACTUATOR_CONTROLS sent somwhere else ?

Thanks

(edit)
I measured the frequency of reception of this message it’s about 2000Hz :zany_face: HOW

if you are wondering this is the code of the function in GCS_Mavlink.cpp :

void GCS_MAVLINK_Plane::send_hil_actuator_controls()
{
    if (!plane.g.hil_enable) {
        return;
    }

    float controls[16] = {};
    uint64_t now_us = AP_HAL::micros64();

    // valeurs normalisées -4500 : 4500
    controls[0] = SRV_Channels::get_output_scaled(SRV_Channel::k_aileron);
    controls[1] = SRV_Channels::get_output_scaled(SRV_Channel::k_elevator);
    controls[2] = SRV_Channels::get_output_scaled(SRV_Channel::k_rudder);
    // valeurs normalisées -100 : 100
    controls[3] = SRV_Channels::get_output_scaled(SRV_Channel::k_throttle);
    // autres canaux disponibles si utile
    // controls[4] = SRV_Channels::get_output_scaled(SRV_Channel::k_flap) / 100.0f;

    mavlink_msg_hil_actuator_controls_send(
        chan,
        now_us,
        controls,
        MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
        0  // flags
    );
}

Update

I forgot about this old post…
The problem was coming from my python script of course :slight_smile:
It’s now very stable