Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get any kind of data from UDP connection. #78

Open
maazjamshaid123 opened this issue Sep 18, 2023 · 1 comment
Open

Unable to get any kind of data from UDP connection. #78

maazjamshaid123 opened this issue Sep 18, 2023 · 1 comment

Comments

@maazjamshaid123
Copy link

Following is the code I am trying. But I don't receive any output. The drone arms when connected using 'COM6' port, but not using udp. Kindly, point out the issue.

import argparse
from pymavlink import mavutil

def arm(mav_connection, arm_command):
    # Wait for the first heartbeat
    # This sets the system and component ID of remote system for the link
    mav_connection.wait_heartbeat()
    print("Heartbeat from system (system %u component %u)" %
          (mav_connection.target_system, mav_connection.target_component))

    mav_connection.mav.command_long_send(mav_connection.target_system, mav_connection.target_component,
                                         mavutil.mavlink.MAV_CMD_COMPONENT_ARM_DISARM, 0, arm_command, 0, 1, 0, 0, 0, 0)

    msg = mav_connection.recv_match(type='COMMAND_ACK', blocking=True)
    print(msg)

    # return the result of the ACK message
    return msg.result

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Send arm/disarm commands using MAVLink protocol.')
    parser.add_argument('-c', '--connect', help="Connection string", default='udp:localhost:14550')
    parser.add_argument('-a', '--arm', type=int, choices=[0, 1], help="Arm/Disarm command", default=1)
    
    args = parser.parse_args()

    mav_connection = mavutil.mavlink_connection(args.connect)
    result = arm(mav_connection, args.arm)
    print(f'Result of arm/disarm command: {result}')
@seanrowens
Copy link

Your question is clearly about pymavlinkm which is for Python. This github repo is for a completely different Java library, dronefleet mavlink.
I suspect you may have better luck here: https://github.com/ArduPilot/pymavlink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants