How do I send RTK data from my base station to ArduPilot

I am running a Orange Cube Flight Controller with HERE3 GPS antenna and receiver module.

Currently the system is attached to a companion computer raspberry. Which I am running Mavproxy and Mavsdk.

I have a GPS RTK base station from Beitian Brand.

How do I send the RTK GPS correction from my base station to the ardupilot in the flight controller using either Mavlink or Mavsdk?

1 Like

You need to run mission planner, mavproxy, or mavros on the computer with the RTK basestation.
And you need to establish a mavlink connection between that computer and your vehicle

Currently I am able to transmit the data from my rtk base station to my companion computer. But the question is how do I send this data to the flight controller? Is it possible to do so with Mavlink?

Yes, of course it is possible to do so with Mavlink. You do understand that mavlink is a communication protocol and not a software right?

I already listed the softwares you can use to do it. I advise you to use mavproxy on the companion computer.


Yes I understand about Mavproxy and Mavlink. Thanks for pointing me to the right direction. This is what I am asking for.

I read here command 123 and 233. What is the difference between both?


GPS_RTCM_DATA ( #233 )

Use #233 it allows longer RTCM messages (required when you use multiconstelation GNSS, and when you have good reception)
#123 is deprecated and will be removed at some point

Hi Thanks for the advice.

Now I have a problem. My base station, I would recieve the RTCM data in original form in Binary.
We transmit the RTCM data in binary to my companion computer and tries to upload it into the flight controller.

def send_rtcm(rtcm):
1, # autopilot system id
1, # autopilot component id
233, # command id,
0, # confirmation
rtcm,0,0,0,0,0 # unused parameters for this command
it comes with this error.

struct.error: required argument is not a float

I tried to use struct.unpack() into various format. But to no avail? How can I do this?

There is no need to reinvent the wheel. Just look at how mavproxy does it.

I had tried to send in a single byte it works fine and its accepted but when I send a chunk of it it comes with error. I am just curious exactly the format for data in command 233.
The 180 mean 180bytes? How is the data formatted? Because sending a chuck of 180 integer is just a chunk of numbers don’t make sense as a chuck of numbers together is 1 int.

All I need is just to know how this data is formatted. How does this [180] works?

data uint8_t[180] RTCM message (may be fragmented)

I tried using your code. but it also comes with the error.

return self.mpstate.master()

TypeError: ‘property’ object is not callable

I realised that there is absolutely no way which I can send the rtcm param using mavsdk or pymavlink as the command long option can only send 1 param in 1 values.The only way is through direct mavlink.

I understand the structure of a mavlink message. But what I just don’t figure out over the last 2 days would be uint8_t[180] in the mavlink common command. What does this [180] means? Meaning 180 bytes in this param?

in #147 battery status, there are 2 param with these.??? .

yes, it is a normal 180 bytes array.

Thanks for enlightening.

But as I input the data. The data is in binary.

It comes with this error. Do you know how I can solve this?

return MAVLink_message.pack(self, mav, 35, struct.pack(’<BB180B’, self.flags, self.len,[0],[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23],[24],[25],[26],[27],[28],[29],[30],[31],[32],[33],[34],[35],[36],[37],[38],[39],[40],[41],[42],[43],[44],[45],[46],[47],[48],[49],[50],[51],[52],[53],[54],[55],[56],[57],[58],[59],[60],[61],[62],[63],[64],[65],[66],[67],[68],[69],[70],[71],[72],[73],[74],[75],[76],[77],[78],[79],[80],[81],[82],[83],[84],[85],[86],[87],[88],[89],[90],[91],[92],[93],[94],[95],[96],[97],[98],[99],[100],[101],[102],[103],[104],[105],[106],[107],[108],[109],[110],[111],[112],[113],[114],[115],[116],[117],[118],[119],[120],[121],[122],[123],[124],[125],[126],[127],[128],[129],[130],[131],[132],[133],[134],[135],[136],[137],[138],[139],[140],[141],[142],[143],[144],[145],[146],[147],[148],[149],[150],[151],[152],[153],[154],[155],[156],[157],[158],[159],[160],[161],[162],[163],[164],[165],[166],[167],[168],[169],[170],[171],[172],[173],[174],[175],[176],[177],[178],[179]), force_mavlink1=force_mavlink1)
IndexError: bytearray index out of range

The data which printed out when print(bytearray(data))

my code is as follows
data = bytearray(buf)
lng = len(data)
the_connection.mav.gps_rtcm_data_send(flags, lng, data)

I found the answer

I think I found the answer, I need to fill up 180bytes but the data only had much lesser bytes. The way I did was fill the entire bytearray with empty items to 180

data = list(data)
buf = bytearray(data)
lng = len(buf)
fill = 180 - lng
the_connection.mav.gps_rtcm_data_send(flags, lng, buf)

Seems to not return any error.

1 Like

If you are already running Mavproxy then why not just use the DGPS module? This module expects raw RTCM data on UDP port 13320 and forwards it to Ardupilot. You can include the appropriate commands to automatically start the DGPS module in the command line when you launch Mavproxy. A typical setup might use socat to forward data from a serial port to UDP (or TCP to UDP if required). We have successfully used this in the past. I would recommend setting up your base station to only send the required messages and at a reasonable rate. We use GPS, GLONASS, Beidou and Galileo and receive corrections at 1Hz. This represents ~3-4Kbps. It is easy to send a lot more information than required which can flood your connection to the vehicle.

1 Like

@Josephjj all the problems that you are having are solved in the MavProxy DGPS module. Please follow the instructions from @jimovonz and use it.

Yea I did tries to alter the code but to no avail.

Anyway, I comb thru mavproxy documentation and found that I can actually load the module on start up. Maybe I would try that instead.

That is what we have been saying all the time. Just use mavproxy, do not write/change the source code!

After ALOT of research around the web for the right programming. After a number of test. At last I got it working. It’s frustrating that there is little comprehensive details on this but I guess not many people really need this at all.
Now firstly you need the base to send out right data. I did mine using here+ and sending out RTCM3.
I tried to send using the DGPS module in mavproxy. IT DOESN"T WORK. Nothing. Drone is having 3d fix. not RTK.
I did write my own python script to read data and to be sent. and the Mavlink command explanation is just too simple to understand. So I did some research online. And found the answer. Anyone needs it can ask me I will share it later.
Finally I gotten RTK float. Its not RTK Fixed. I found out its because there is not enough similar satellite between base and client to compare. I get it, the place I am testing isn’t exactly ideal with an open sky.
Anyway now it all works.

1 Like

Please do share it now, not latter.