Copter in SITL rotates uncontrollable along the yaw

Copter in SITL rotates uncontrollable along the yaw when low throttle is applied, and the PWM on servo1-4 also starts jumping, what could it be? And how can i fix it?

Hi @VasilkovskiiVS,

I think you’re using gazebo but we need a lot more information to help. Which wiki page did you look at to get this going?

BTW, I’ve moved your topic to the 4.6 category

Hello, yes, I use Gazebo in conjunction with ardupilot. I made my own model of the copter, then adjusted its physics, saw that the drone was spinning. I decided to see how Iris behaves, I installed it according to these instructions, as a result, using the basic parameters of Iris and with the remote control connected via MAVProxy, with a small throttle, the pwm on the motors starts jumping, and the copter starts spinning around its yaw axis.
I have attached a video recording of the screen in the archive.

instruction:
udo apt update
sudo apt upgrade -y

sudo apt install -y git python3-pip python3-matplotlib python3-lxml python3-pyparsing python3-serial
openjdk-11-jdk ant protobuf-compiler libtool make g++ automake autotools-dev autoconf

git clone GitHub - ArduPilot/ardupilot: ArduPlane, ArduCopter, ArduRover, ArduSub source
cd ardupilot
git submodule update --init --recursive
echo “export PATH=$PATH:$HOME/ardupilot/Tools/autotest” >> ~/.bashrc
echo “export PATH=/usr/lib/ccache:$PATH” >> ~/.bashrc
source ~/.bashrc

(Because of Ubuntu 24.04):
cd ~/ardupilot
python3 -m venv env
source env/bin/activate

(after that MAVproxy):
sudo apt-get install python3-dev python3-opencv python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml python3-pygame
pip3 install PyYAML mavproxy
echo ‘export PATH=“$PATH:$HOME/.local/bin”’ >> ~/.bashrc

(and some libs like setuptools, etc.)
python3 -m pip install setuptools

(start command)
gz sim -v4 -r iris_runway.sdf

./Tools/autotest/sim_vehicle.py -v ArduCopter -f gazebo-iris --model JSON --map --console --mavproxy-args=“–load-module=joystick”

@VasilkovskiiVS, is the issue with the standard iris with gimbal model (no modifications)? The only difference I can see is that a joystick is enabled. It would be helpful to see the console output from mavproxy, and commands entered (very hard to tell on the video). It may be that there are competing commands coming from mission planner, the external joystick, and the mavproxy session hosted by sim_vehicle.

If you just run sim_vehicle.py (no MP), and drop the joystick, does the copter behave correctly i.e.

STABILIZE> mode guided
GUIDED> arm throttle
GUIDED> takeoff 10
GUIDED> rc 3 1500
GUIDED> loiter 
LOITER> 

Okay, thanks, I’ll try it today, but this problem is very visible when flying in ACRO mode, I thought it was my model, but the problem starts even on the original IRIS.
The problem itself is noticeable if you just fly up high and release the throttle handle to 0, as soon as the throttle approaches 0, the ardupilot plugin causes the copter to spin around the yaw axis. For comparison, I conducted similar tests with the PX4 SITL, in it the copter just falls to the ground, as in real life (the PWM also jumps), but there is no rotation.

Video recording with comparison is also available on GOOGLE Disk:

So the test is

  • Takeoff and ascend to some fixed altitude
  • Set throttle low
  • Observe behaviour
  • Repeat for various modes

You expect the copter to fall without rotating, and something else is happening.

The behaviour difference is most likely due to the approach used to model motors and props (LiftDrag plugin vs MultiCopterMotorModel). The latter can be set up in ArduPilot as well, so not really a SITL issue as such if this is the cause, but a different approach to the physics modelling.

yes, that’s right, because my model has more thrust, so I often use low thrust, and in flight I can catch this rotation effect.

Should I run the test that you wrote above in Loiter and so on?

Also I didn’t find any information, how I can use MultiCopterMotorModel with ardupilot SITL. Do you have any instructions?

I made a test according to your scheme.:

  1. I started with the joystick, leaving only the throttle channel in yaml (to remove the influence of noise from other channels):
    a) raised the copter in guided mode and lowered the throttle value to 0 in Loiter mode (fell normally);
    b) raised the copter in guided mode and lowered the throttle value to 0 in Acro mode (fell normally);
    c) raised the copter in guided mode and lowered the throttle value to some small value in Acro mode (started rotation).

  2. I started it without the joystick:
    a) raised the copter in guided mode and lowered the rc3 value to 1000 in Loiter mode (fell normally);
    b) raised the copter in guided mode and lowered the rc3 value to 1000 in Acro mode (fell normally);
    c) raised the copter in guided mode and lowered the rc3 value to 1150 in Acro mode (started rotation).

What’s why I think that problem isn’t in joystick. This problem only occurs with small throttle values. This effect is observed in ACRO and STABILIZE mode.

Video of the test at the link: https://drive.google.com/file/d/1mFZScIY6GSwDlBft7k__Nk4t6pAJhkHR/view?usp=drive_link

Hi @VasilkovskiiVS,

If the throttle is pulled to zero while in Acro mode then it’s going to fall to the ground. I wonder why it matters if it rotates or not? In real life it would tumble, spinning in various axis

The copter rotates not when the throttle value is 0, but when it’s close to 0 like 1150. This problem makes it difficult to fly with these throttle values, because at any random moment during flight in SITL in stabilize or acro mode, the copter can start rotating around the yaw axis, and if you suddenly give it throttle, it immediately stops.
Above, I simply described a quick way to test this issue.
If you have instructions how to connect a MultiCopterMotorModel plugin, I’d be grateful, as this effect isn’t observed there.
Otherwise, let’s fix it somehow. If necessary, I can record a video showing how this occurs in flight.

I’ll note that in real-life in acro and stabilize flight modes, I often use low throttle values, and I wanted to enter my copter model and its parameters into SITL, but I discovered this effect, which I couldn’t remove using parameters and coefficients. That’s why I created this topic.

Hi @VasilkovskiiVS,

It might help to enable AirMode which will keep the motors running even if the throttle is zero.

Also if you’re attempting to control the vehicle from an external process (e.g a companion computer) then it’s better to use Guided mode rather than RC inputs. We have a wiki page here with all the various controls available. I’m afraid that we don’t support rate modes in Guided mode (see SET_ATTITUDE_TARGET on the above linked page) but we could add that if you need it.

I tried AirMode, but the effect remains.
Regarding RC inputs, I’m not trying to control them from an external device, only from my tx12. I’m currently working on a student project using ArduPilot, SITL, and Unity to create a universal simulator with both graphics and open source code. I’d really like to fly in the simulator in Acro and Stabilize modes with the same parameters and effects as in real life, but this effect ruins the current version.
So, if there’s no solution to this problem using LiftDrug, could you please provide information on how to reconnect SITL to MultiCopterMotorModel plugin?

UPD:
I have implemented support for MultiCopterMotorModel plugin, but the effect can still be obtained, I am looking for other solution

UPD2.
Switching to MultiCopterMotorModel, I started tracking what exactly comes from SITL. Eventually, I discovered that in the Stabilize and Acro modes, a small value comes to one of the motors with low gas, similar to the value during the start of the motors. Because of this, it turns out that a difference in thrust and torque begins to form between the engines, as a result of which the copter rotates, I think. The same effect is observed in SITL PX4, so this is most likely a very old bug.
Is this analysis correct? Or am I wrong?
@rhys would be glad if you could tell me, thank you in advance.

Also I have video with this bug:

@VasilkovskiiVS, a thought, the issue could be a result of the joint (velocity) controller in Gazebo. This controller attempts to set the motor’s angular velocity to a desired set point. This is not really how motors work - an ESC provides power and the motor spin at a rate governed by the power provided and the opposing drag torque from the prop blades.

I made a modification to the joint controller plugin to allow the joints to freewheel (so when dropping the throttle the motors will not be force braked to a particular velocity): JointController: allow braking to be disabled in force mode by srmainwaring · Pull Request #2971 · gazebosim/gz-sim · GitHub. I used this to model auto-rotation in a trad helicopter, but it may help solve this problem for a multi-copter at low throttle.

You’ll need to use the lift drag plugin set up with the ArduPilot plugin forwarding commands to the joint controllers (not how the iris is currently set up). If you could provide a mavproxy command sequence and dataflash log that would allow me to replicate the behaviour you are trying to capture, I can try to replicate.

Thanks for the reply, I will try to record the logs tomorrow and switch to the version without the MultiCopterMotorModel. When it’s done, I’ll send everything here.

Note, the default D terms are a little high - a better tune is:

ATC_RAT_PIT_D 0.001
ATC_RAT_RLL_D 0.001

With the default values of 0.003600 there is an oscillation. A plot of

graph SERVO_OUTPUT_RAW.servo1_raw SERVO_OUTPUT_RAW.servo2_raw SERVO_OUTPUT_RAW.servo3_raw SERVO_OUTPUT_RAW.servo4_raw

will show this. So the effect could also be poor attitude tune.

I’ve got the changed model set up now - what throttle are you setting to see this behaviour, and are there any other parameter or model changes?

Update:

With a couple of changes (params + joint controller mod), I can switch to stabilize at altitude, drop the throttle low (rc 3 1001), and the copter drops to the ground maintaining attitude. No yaw issue. So one or both these changes seems to provide a solution. This using the LiftDrag plugin for the props…

Modified model attached. Will need to run Gazebo Jetty for the <disable_braking> option in the Joint Controller plugin.
model.sdf.zip (1.4 KB)

Ok - fairly sure it’s the motor braking introducing the instability. Repeating with <disable_braking>0</disable_braking> there is a loss of attitude control (because the props will be forced to nearly stop / cannot freewheel). The tune helps, but is not the cause.

I have recorded logs with MultiCopterMotorModel and LiftDrag, please look at them, in both cases I got this bug.

I tried your sdf, but it doesn’t work:
[Wrn] [JointController.cc:285] Failed to find joint [iris_with_standoffs::rotor_0_joint]
[Wrn] [JointController.cc:285] Failed to find joint [iris_with_standoffs::rotor_1_joint]
[Wrn] [JointController.cc:285] Failed to find joint [iris_with_standoffs::rotor_2_joint]
[Wrn] [JointController.cc:285] Failed to find joint [iris_with_standoffs::rotor_3_joint]

I created a copy of the iris_with_ardupilot folder, named it iris_with_ardupilot_1, and inserted your model there.

I also specified iris_with_ardupilot_1 in iris_runway. Maybe I did something wrong.