mavlink / mavlink2rest

mavlink2rest creates a REST server that provides mavlink information from a mavlink source
MIT License
68 stars 23 forks source link

Unable to change GPS_TYPE from 3D Fix to RTK Float #104

Open sundaram123krishnan opened 1 month ago

sundaram123krishnan commented 1 month ago

So i have my pi5 running as a base station so to inject rtk data i am using this python code,

import serial
import json
import requests
import time

serial_port = '/dev/ttyAMA0'  # Specify your serial port
baud_rate = 9600  # Specify the baud rate
mavlink_api_url = 'http://172.22.254.115:8088/v1/mavlink'  # MAVLink2REST API URL
headers = {"Content-Type": "application/json"}

ser = serial.Serial(serial_port, baudrate=baud_rate)

rtcm_buffer = []  # Buffer to hold reconstructed RTCM data

try:
    while True:
        rtcm_data = ser.read(180)  # Adjust the number of bytes to read as needed

        rtcm_data_list = list(rtcm_data)

        data_length = len(rtcm_data_list)

        payload = {
            "header": {
                "system_id": 255,
                "component_id": 1,
                "sequence": 0
            },
            "message": {
                "type": "GPS_RTCM_DATA",
                "flags": 1,
                "len": data_length,
                "data": rtcm_data_list
            }
        }

        json_payload = json.dumps(payload)

        response = requests.post(
            mavlink_api_url,
            headers=headers,
            data=json_payload
        )

        print(f"Response status code: {response.status_code}")
        print(f"Response text: {response.text}")

        time.sleep(0.1)

except KeyboardInterrupt:
    print("Stopping...")
    ser.close()

i am using neo8m gps it's receiving upto 10 satellites, i can see the GPS_RTCM_DATA mentioned in the api, but the GPS_TYPE is still 3D Fix only

sundaram123krishnan commented 1 month ago

For arming and disarming i used system id as 255 and component id as 1

sundaram123krishnan commented 1 month ago

Pls help, thx in advance

sundaram123krishnan commented 1 month ago

Sorry, i am new to this i don't know how to convert nmea to rtcm messages