You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with Rosetta for autonomous flies with MAVIC AIR 2S. The goal is to perform a 180-degree yaw turn after takeoff. I have seen that the CONDITION_YAW command is implemented, but it does not seem to execute as expected when flying indoors without a GPS signal.
Takeoff and landing are functioning correctly, but the drone does not perform the yaw turn.
frompymavlinkimportmavutilimporttimeconnection_string='udp:xxx.xxx.x.xx:xxxxx'print(f"Connecting to vehicle on: {connection_string}")
try:
# Create the MAVLink connection objectmaster=mavutil.mavlink_connection(connection_string)
# Wait for a heartbeat to confirm the connectionprint("Waiting for heartbeat from the vehicle...")
master.wait_heartbeat()
print(f"Heartbeat received from system {master.target_system}, component {master.target_component}")
# Function to set the flight mode of the dronedefset_mode(mode):
"""Change the flight mode of the drone."""mode_id=master.mode_mapping()[mode]
master.mav.set_mode_send(
master.target_system,
mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
mode_id
)
# Confirm the mode changewhileTrue:
msg=master.recv_match(type='HEARTBEAT', blocking=True)
ifmsg.custom_mode==mode_id:
print(f"Mode successfully set to {mode}.")
break# Function to command the drone to take offdeftakeoff(target_altitude):
print(f"Taking off to {target_altitude:.2f} meters...")
# Send takeoff commandmaster.mav.command_long_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_CMD_NAV_TAKEOFF,
0,
0, 0, 0, 0, 0, 0, # Unused parameters0
)
time.sleep(1)
whileTrue:
# Request altitude datamaster.mav.request_data_stream_send(
master.target_system,
master.target_component,
mavutil.mavlink.MAV_DATA_STREAM_POSITION,
1, # Frequency (Hz)1# Enable stream
)
# Wait for altitude datamsg=master.recv_match(type='GLOBAL_POSITION_INT', blocking=True)
ifnotmsg:
print("Not height message")
continuecurrent_alt=msg.relative_alt/1000.0# Convert millimeters to metersprint(f"Current Altitude: {current_alt:.2f} m")
# Log metadata# Stop when near target altitudeifcurrent_alt>= (target_altitude*0.5):
print("Target altitude reached.")
breaktime.sleep(.5)
defyaw_turn(target_heading=180, direction=1, is_relative=1):
# Send orientation commandmaster.mav.command_long_send(
master.target_system, # system IDmaster.target_component, # component IDmavutil.mavlink.MAV_CMD_CONDITION_YAW,
0, # Confirmationtarget_heading, # param1: Degrees0, #yaw_speed, # param2: Velocitydirection, # param3: Directionis_relative, # param4: Absolut or relative0, 0, 0# param5-param7: Not used
)
time.sleep(5)
if__name__=="__main__":
set_mode('GUIDED') # Set mode to GUIDED before armingprint("Starting photo capture with altitude metadata...")
takeoff(1.5) # Execute takeoffyaw_turn(180)
# Command the drone to landset_mode('LAND')
print("Drone landing...")
exceptKeyboardInterrupt:
print("Mission interrupted by user.")
exceptExceptionase:
print(f"An error occurred: {e}")
finally:
print("Closing MAVLink connection.")
if'master'inlocals():
master.close()
Any idea why the drone is not turning in yaw? I'm new to developing this type of application. Sorry :)
Drone Model
DJI MAVIC AIR 2S
The text was updated successfully, but these errors were encountered:
Describe the bug
I am working with Rosetta for autonomous flies with MAVIC AIR 2S. The goal is to perform a 180-degree yaw turn after takeoff. I have seen that the CONDITION_YAW command is implemented, but it does not seem to execute as expected when flying indoors without a GPS signal.
Takeoff and landing are functioning correctly, but the drone does not perform the yaw turn.
Any idea why the drone is not turning in yaw? I'm new to developing this type of application. Sorry :)
Drone Model
The text was updated successfully, but these errors were encountered: