[Custom firmware] SCHED_LOOP_RATE not set to 400

Code:


A slightly modified AC 3.5.1
Files changed:

  • libraries/AC_AttitudeControl/AC_AttitudeControl_Heli.cpp
  • libraries/AC_AttitudeControl/AC_AttitudeControl_Heli.h
  • libraries/AP_Motors/AP_MotorsHeli_Dual.cpp
  • libraries/AP_Motors/AP_MotorsHeli_Dual.h

Board: Pixhawk 2.1
Compiler: Make on Win10
Symptoms:
-Using px4-v3, very slow parameters getting (~1minute per param) or won’t connect or won’t boot at all and will prevent PC from discovering the Pixhawk.
I tried using AUTO port scan and it connected with 9600 baud.
-Using px4-v2, Connect fine but MP keeps saying “Check firmware or FRAME_CLASS”.
FRAME_CLASS is set to 11
https://github.com/ArduPilot/ardupilot/blob/Copter-3.5/libraries/AP_Motors/AP_Motors_Class.h#L40

3.4.5 version worked fine

Update: The problem seems to be with default parameters but still no real solution.

It will only works when upgrading from previously working 3.4.5 firmware.
A clean install (by installing Rover/Plane then install Copter) will lead to symptoms above.
Resetting to default parameters also lead to the same result.

Very similar to this: [Solved] Pixhawk2.1 slow down [custom firmware] but worse.

Edit: Just in case anyone willing to try for me, link to my .px4 firmware file(s).

Edit 2: Tried waiting for “getting param” which took about an hour and found that SCHED_LOOP_RATE was at 50.

So the real question here is: why doesn’t it use default values hard-coded in config.h(correction: AP_Scheduler.h) ?
# define MAIN_LOOP_RATE 400

Pitt,
I don’t know if you realize but the SCHED_LOOP_RATE defaults are set in the AP_Scheduler library. It is based off of the requested build type.

If APM_BUILD_TYPE(APM_BUILD_ArduCopter) || APM_BUILD_TYPE(APM_BUILD_ArduSub)
define SCHEDULER_DEFAULT_LOOP_RATE 400
else
define SCHEDULER_DEFAULT_LOOP_RATE 50
endif

It is interesting that it is not setting it properly in 3.5 but it seems to be ok for your code in 3.4. It appears that this parameter was available in 3.4. Sorry that I’m not much help. Just thought I’d point that out.

1 Like

Thanks for correcting.

This also happened to me once with 3.4 code but as far as I know, only SCHED_LOOP_RATE is affected.
I managed to change the parameter back to 400 after waiting for an hour and it’s back to normal speed.
More likely compiler issue.

However, something else is broken in the heli_dual code that all servo outputs are over-responsive.
I need to lower CYC_MAX from 1800 to 500, old PIDs become unflyable.

I’ll be staying with 3.4 now. :frowning_face: