Skip to main content

MAVLink Bridge

Prerequisites

  • JetCore carrier board with a compatible NVIDIA Jetson module (e.g., Jetson Nano, Xavier NX, Orin).
  • MAVLink-compatible device (e.g., a drone, GCS, or MAVLink-enabled autopilot).
  • Serial-to-USB adapter or a direct UART-to-USB connection (if using a serial connection to the MAVLink device).
  • MAVLink library installed on your Jetson.
  • Ubuntu Linux (Jetson platform) with JetPack SDK installed.

  1. Hardware Connections

    1. Connecting via UART (Serial):
      • Connect your MAVLink device (e.g., drone flight controller) to the UART port on the JetCore via a serial-to-USB adapter.
      • Typically, connect the TX and RX pins from the MAVLink device to the RX and TX pins on JetCore.
      • Ensure a common ground (GND) is connected between devices.
    2. Using USB Connection:
      • If the MAVLink device supports USB communication (e.g., Pixhawk), simply connect it directly to a USB port on the JetCore device.

    1. Install MAVLink Libraries: MAVLink communication is handled by the MAVLink library, and you’ll need a library to interact with the MAVLink protocol. For Python, install pymavlink:

      pip install pymavlink
    2. Install MAVProxy (Optional): MAVProxy is a command-line tool for interacting with MAVLink devices. Install it with:

      sudo apt install mavproxy

    1. Configure the MAVLink Bridge: The MAVLink bridge typically connects the JetCore to the MAVLink system (drone or GCS) over a serial interface. To establish the connection, run the following command with the correct serial device and baud rate:

      mavproxy.py --master=/dev/ttyUSB0 --baudrate 57600
      • Replace /dev/ttyUSB0 with the appropriate serial port for your connection, and adjust the --baudrate to match the MAVLink device's settings (common baud rates are 57600 or 115200).
    2. Check Connection:

      • Once the connection is established, you should see MAVLink messages flowing. The command-line interface will display logs and allow you to send commands to the drone or MAVLink system.
    3. Forward MAVLink to GCS or Another Device (Optional): You can forward the MAVLink data from your JetCore to a Ground Control Station (GCS) or other devices. For example, to forward MAVLink to a GCS over UDP, you can use:

      mavproxy.py --master=/dev/ttyUSB0 --baudrate 57600 --out=udp:192.168.1.100:14550
      • Replace 192.168.1.100 with the IP address of your GCS and 14550 with the correct port number.

  1. If you want to write custom applications for interacting with the MAVLink device, you can use pymavlink or other MAVLink libraries: https://github.com/mavlink/mavlink
    1. Example Python Code: Here is a simple example of how to connect and communicate with a MAVLink device using pymavlink:

      from pymavlink import mavutil

      # Connect to MAVLink device over serial or UDP
      connection = mavutil.mavlink_connection('/dev/ttyUSB0', baud=57600)

      # Wait for heartbeat
      connection.wait_heartbeat()
      print("Heartbeat from system (ID: {})".format(connection.target_system))

      # Send a command (example: requesting GPS data)
      connection.mav.request_data_stream_send(connection.target_system, connection.target_component, mavutil.mavlink.MAV_DATA_STREAM_ALL, 1, 1)
    2. Monitor MAVLink Data: Use mavlink or mavproxy to monitor data, check system status, or receive telemetry:

      mavproxy.py --master=/dev/ttyUSB0 --baudrate 57600 --logfile mavlink_log.txt

  1. Troubleshooting

    1. No Connection:

      • Check the physical connections, especially the serial or USB links.
      • Verify the baud rate settings of the MAVLink device and JetCore match.
      • Ensure the correct device path (e.g., /dev/ttyUSB0) is specified.
    2. MAVLink Messages Not Received: Ensure you are receiving a heartbeat from the MAVLink device. You can check this by using:

      mavproxy.py --master=/dev/ttyUSB0 --baudrate 57600
      • Look for heartbeat messages in the terminal.
    3. Data Latency:

      • If you experience delays, try increasing the baud rate (e.g., 115200) or check for network issues if you're using UDP.