Home        Store        Learn        Blog

Setting up test computer

I am trying to set up a test setup primarily to try and learn how Mavlink works.
I have some ideas I want to try

I have a

  • rPi3
  • rPi camera
  • pixhawk
  • no other sensors connected

I have copied the companion s/w on to the rPi and ran setup up.

It doesn’t start automatically on reboot. What files are scripts do I need to add to make this work. In fact I don’t know what scripts to start to run t either

Also can I change the IP address on gGroundControl from is the same as my router and it is a pain fiddling with my network each time

Hi Alan,

For now, it’s not possible to install companion manually.

For that, you’ll need to make .companion.rc to start with the system, this will call all necessary companion components.

You can use set_default_client_ip.sh (E.g: ./set_default_client_ip.sh to set the raspberry IP address for ethernet connection. If you are running a Linux in your surface computer, you can use nmap to find the ip while scanning port 22 (E.g: nmap -p 22).

Can you use the companion image ?


I will try flashing the image onto my rPi. That hopefully will be the easiest solution.

I didn’t know where to find it

This script will require a reboot for the new ip to take effect. Also, this function is available in the web ui at

Thanks for your help.

I re flashed my rPi and it is working how I intended.

Just one further point.

What port is MavLink streaming its messages ?

I would like to connect to this data stream for further processing and logging of the data. I am writing a photogrammetry application. I am also looking at seeing if I can get a dead reackoning function working using the thruster values and the IMU.



Hi Alan,

You can take a further look in ardusub software components webpage to understand how the companion system works.
MAProxy sends the protocol using UDP in 14550.

Thanks I’ll have a look.

I am using C and UDP sockets look to be a bit different to TCPIP sockets which I have used in the past.

I can connect as a client on 14550 but can’t receive the data stream.

I’ll do some research

I think I am missing something.

  1. I assume that data is being streamed continuously on port 14550
    • no need to send any commands to the server
  2. port 14550 is used by QGroundcontrol.
    I assume only one client can access this at a time.
  3. I tried this very simple python code to see if I could connect and see data.
    I could connect (Qgroundcontrol was off) but no data was output.
import socket
serverAddressPort   = ("", 14550)
bufferSize          = 1024
# Create a UDP socket at client side
UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
msgFromServer = UDPClientSocket.recvfrom(bufferSize)
msg = "Message from Server {}".format(msgFromServer[0])
  1. I tried finding the connection code in QGroundControl but it is too obtuse to locate.

Any help would be appreciated.

Hi Alan,

You need to specify the server address and port to the socket object, looking in the socket documentation you can see the bind function.
Bind the socket to address. The socket must not already be bound. (The format of address depends on the address family — see above.)


I am assuming i connect as a client to the rpi
Ip port 14550

Or should i be the server (from my pc) and therefore use bind ?

I left out a couple of l8nes in the python code where i send a msg to 14550 and then listen for a response.

I just sent a hello string but do i need to send a proper mavlink message ?

I assume that data is being continuosly streamed from the rpi

Yes. The pi is sending data to (default), or whatever else you may have set it to.

To test that the data is coming in with the default setup, you can use the command nc -ul on your topside machine.


Thanks should be able to work it out now.

I am not using on my pc (my router address). But i will change to test.

Is it possible to set the data stream to another ip ?


Thanks for all your help i have it all working perfectly now

Just a quick clarification.

As well as reading streamed data on port 14550. Can I send data back out on the same port ? Is there a script running that listens for data on 14550 ?

I would like to try and stream GPS data (bypass nmea-receiver.py) to the pixhawk directly.

The purpose is to understand the communications between the GCS and the Pixhawk.

To do this I am using two functions.

  • mavlink_msg_gps_raw_int_pack_chan(…
  • mavlink_msg_to_send_buffer(…;
    and the write the buffer to the socket.

Hi Alan,

Yes, 14550 is a bidirectional port, mavproxy can read from it.

Now, about the GPS, you can take a look in gps-position (Sending GPS position to ROV) from ArduSub gitbook. MAVProxy will receive position data from 25100, you check the example to test it.
Also, it’s possible to send possition via pymavlink, take a look in pymavlink (Send GPS position) examples of ArduSub gitbook.

GPS_RAW_INT is the wrong message for this; this message is only for autopilot feedback/status updates on the current position. The one to use is GPS_INPUT.

I have tried sending ‘GPS_INPUT’ on port 14550 but reading message GLOBAL_POSITION_INT which I would assume is the processed EKF solution shows nothing.

I also tried sending on port 25100 but same result.

Is the socket 25100 on the ROV running as server or a client ?


What version of companion do you have? (

You can see all of the code here, this same project is in the home directory on the pi.

More specifically, you can see the code for the server here, and modify it too. Maybe add some print statements to see what’s going on.

On a pi console, you can enter screen -r nmearx to get back to the process that is started at boot. From there you can exit it, modify the script and just run it again.