Position Command in MAVProxy


#1

I am implementing a simple python code to send commands to the drone through pymavlink. so far I have completed to takeoff my drone and land.

import sys
from pymavlink import mavutil
import time

# Create the connection
master = mavutil.mavlink_connection('tcp:127.0.0.1:5762')
# Wait a heartbeat before sending commands
master.wait_heartbeat()

# Arm
# master.arducopter_arm() or:
master.mav.command_long_send(
    master.target_system,
    master.target_component,
    mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM,
    0,
    1, 0, 0, 0, 0, 0, 0)

# wait until arming confirmed (can manually check with master.motors_armed())
print("Waiting for the vehicle to arm")
master.motors_armed_wait()
print('Armed!')

master.mav.command_long_send(
    master.target_system,
    master.target_component,
    mavutil.mavlink.MAV_CMD_NAV_TAKEOFF,
    0,
    0, 0, 0, 0, 0, 0, 2)

time.sleep(10)

master.mav.command_long_send(
    master.target_system,
    master.target_component,
    mavutil.mavlink.MAV_CMD_NAV_LAND,
    0,
    0, 0, 0, 0, 0, 0, 0)

But however, I want to move my drone forward in 2m or other direction with meters. for example in the MAVProxy terminal, we can type position 2 0 0. likewise.

Annotation%202021-07-26%20162423

How to implement position command in MAVProxy using pymavlink.

Thank you.


#2

Perhaps this will help?

https://ardupilot.org/dev/docs/copter-commands-in-guided-mode.html