I am running ArduCopter master branch V4.1.0-dev (24fccd5d) on omnibusf4pro FC. I have customised the firmware code slightly and made one custom thread running with AP_Scheduler in Copter.cpp.
I have used RC channels pwm values to fly the drone in guided mode, i have used 2 rc channels, RC7 for takeoff in guided mode & landing and RC6 for starting the mission by reading a file from SD card continuously and then sending the global coordinates data from file as waypoint navigation command in guided mode. I am updating my custom thread at 25Hz and set 200usecs maximum expected time to complete (SCHED_TASK(custom_code_loop,25,200)). But i am sending waypoint commands at 0.4sec interval or 2.5Hz.
I have run and checked these changes on SITL thoroughly, and everything works fine in SITL everytime like i want it to. But when actually trying this on omnibusf4pro FC, my drone not performing in same manner. Sometimes everything works fine but few times there has been some issues and crashes.
I am sharing logs of my last 2 flights, in first log drone performs well and completed the whole path as it suppose to. Log of first flight looks fine even though there was a GPS_glitch initially.
In second log, drone covered more than half of the path well, but closer to the end it suddenly free-fall, speed of the motors suddenly decreased in guided mode just like when someone suddenly decrease the throttle to minimum when flying drone manually. Due to free-fall, it crashed but i observed this kind of misbehaviour/free-fall couple of times in last 10-12 flights.
I did observed the logs whenever it free-falls while flying but logs don’t show up any error, only change i found when i was not running my custom code that during auto-analysis of logs Test: PM was not showing any failure or warning, but after running my custom code, there is always some WARN or FAIL. Please help finding the possible reason for this misbehaviour/free-falls.