Rapid throttle oscillations in SITL

Hi all, first time on the forum, but I haven’t found this question being asked here yet. Any help would be much appreciated

I am building a physics model for Ardupilot to operate a drone in. I’m using SITL with JSON to send position, velocity, acceleration, attitude and gyro information to Ardupilot, and it sends back “throttle demand”, expressed as a number between 1100 and 1900. Based on the documentation here, this is meant to tell the physics model how hard the throttle is working from 0 to 100%. I convert it to a voltage and feed it to the motors.

I have run into a few consistent problems I’m still unable to solve.

  1. The main one is that in every mode apart from STABILIZE, the throttle jumps rapidly from 0 to 1. You can see it in the picture, on a mission planner graph, where I attempt to autotune the drone. The red line represent ThI (throttle input) which goes between 2 and -1.5, and the green is ThO, what actually passes on to my physics model, i.e. it’s truncated to 0 and 1 and looks like one solid block of signal.

  1. This jump in throttle demand is way too fast for the motor in my physics model. In order to get the picture above, I have set the motor inductance to 0.01H and propeller inertia to 1e-6, which gives unrealistic propeller accelerations of 1e3-1e4 rad/s/s as they follow the changes in the throttle. If either value is higher, the drone begins to yaw from side to side in a strange way, shown here in this gif, where it is in loiter mode but yaws strongly: https://drive.google.com/file/d/1P0bwxDhTqzgG3ZdQWLcZq1fmJRfqF6-j/view?usp=sharing

  2. I have struggled to tune my drone. Manual tuning doesn’t seem to give any good results and autotune says that it’s successful but none of the parameters change, even after refreshing the parameter screen.

Flight log is here: https://drive.google.com/file/d/1a5eS28WOq933jKrw6-6MQWf5_Dd-4MIo/view?usp=sharing

A handful. But if anyone can give any hints or answers I would be very grateful!

I’ve solved this. It was happening due to problems with acceleration polarity in my physics model though they weren’t easy to detect. 0.01H is a normal inductance for a motor I think. After these two adjustments everything worked including autotune