Hi,
Environment : Arduplane + Python + Pymavlink + Mavlink
I am building a script that contains a chain of commands in python, which will create a flight scenario on an RC plane:
Rythm :
-
Flight phase 1
Pitch / yaw / roll / Throttle
=> Transition : when the altitude is 50 meters
-
Flight phase 2
Pitch / yaw / roll / Throttle
=> Transition : when the plane turned 90°
-
Flight phase 3
Pitch / yaw / roll /Throttle
The code is written in Python, my problem is that I don’t have enough knowledge to write these transitions “triggers” based on altitude or compass orientation data, I’m thinking of using GLOBAL_POSITION_INT
https://mavlink.io/kr/messages/common.html#GLOBAL_POSITION_INT
Here is below what I’ve done for the moment (the commands of the servos have been tested with Pymavlink commands manually)
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_SERVO,
0, # confirmation
2, # param1
1500, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_SERVO,
0, # confirmation
1, # param1
1500, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_SERVO,
0, # confirmation
3, # param1
1800, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
**** The transition I try to write : "when altitude is 50 mètres, continue to next commands****
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_SERVO,
0, # confirmation
2, # param1
1750, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_SERVO,
0, # confirmation
1, # param1
1166, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
master.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_DO_SET_SERVO,
0, # confirmation
3, # param1
2000, # param2
0, # param3
0, # param4
0, # param5
0, # param6
0) # param7
If any of you has any idea or maybe a way to help me, many thanks !
Nico