Hello!
I apologize in advance for the possibly incorrect/inconvenient description of the problem. I’m new to this site and I might not be posting there. If that’s the case, let me know and I’ll fix it.
I have a problem reaching large pitch/roll angles when flying using the set_attitude_target command.
Symptoms: when flying at small pitch/roll angles, everything is fine, but when the angles increase to 30-40 degrees, the quadcopter loses control, does not respond to set_attitude_target commands correctly, begins to rotate with yaw acceleration, can completely turn over and yaw towards the ground. Sometimes it maintains an upright position, but at the same time it rotates by yaw and it can even be stabilized and continue to fly normally at small angles, but I do not know what it depends on. I also want to note that the quadcopter seems to respond adequately to short-term commands with large angles, but with a longer (1 second or more) flight in this position, rotation begins again.
Arducopter is V4.5.7
I am using the dronekit and gazebo library with ardupilot sitl to conduct tests.
Autopilot parameters are standard: gazebo-iris.param
There is also a flight log. I’ll try to attach it to the theme.
Here are the functions that I use to send control commands:
def send_attitude_target(vehicle, roll_angle=0.0, pitch_angle=0.0, yaw_angle=None, yaw_rate=0.0, use_yaw_rate=False, thrust=0.5):
if yaw_angle is None:
yaw_angle = vehicle.attitude.yaw
msg = vehicle.message_factory.set_attitude_target_encode(
0, # time_boot_ms
1, # Target system
1, # Target component
0b00000000 if use_yaw_rate else 0b00000100,
to_quaternion(roll_angle, pitch_angle, yaw_angle),
0, # Body roll rate in radian
0, # Body pitch rate in radian
math.radians(yaw_rate),
thrust # Thrust
)
vehicle.send_mavlink(msg)
def set_attitude(vehicle, roll_angle=0.0, pitch_angle=0.0, yaw_angle=None, yaw_rate=0.0, use_yaw_rate=False, thrust=0.5, duration=0):
send_attitude_target(vehicle, roll_angle, pitch_angle, yaw_angle, yaw_rate, use_yaw_rate, thrust)
start = time.time()
while time.time() - start < duration:
send_attitude_target(vehicle, roll_angle, pitch_angle, yaw_angle, yaw_rate, use_yaw_rate, thrust)
send_attitude_target(vehicle, 0, 0, 0, 0, True, thrust)
def to_quaternion(roll=0.0, pitch=0.0, yaw=0.0):
t0 = math.cos(math.radians(yaw * 0.5))
t1 = math.sin(math.radians(yaw * 0.5))
t2 = math.cos(math.radians(roll * 0.5))
t3 = math.sin(math.radians(roll * 0.5))
t4 = math.cos(math.radians(pitch * 0.5))
t5 = math.sin(math.radians(pitch * 0.5))
w = t0 * t2 * t4 + t1 * t3 * t5
x = t0 * t3 * t4 - t1 * t2 * t5
y = t0 * t2 * t5 + t1 * t3 * t4
z = t1 * t2 * t4 - t0 * t3 * t5
return [w, x, y, z]
** What do I want?**
I want to experiment with flying at high speeds and high pitch/roll angles using the set_attitude_target command and without gps.
Express your opinion and your assumptions. I will be very grateful for every answer. Thank you.