Acces to QGC from host machine

Hello everyone!
First - here is what I have to work with:

  • Windows 10 host machine
  • xUbuntu 18.04 Virtual Box guest machine that has installed on it:
    • QGC
    • PX4 software and gazebo simulation running
  • A little python script that sends and recieves GPS data to and from QGC

My main mission is to get this script run from my host machine so that guest machine would have only QGC and gazebo running.

The connection to QGC looks like this:

connection_string = '127.0.0.1:14540'
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--connect", help="connection string")
args = parser.parse_args()
if args.connect:
    connection_string = args.connect

So far I managed to establish SSH session via PyCharm, but I ran into a problem that I need to open another debug window on my host, so this soultion does not work for me.

Right now I’m browsing through the Net and trying to figure something out but I get really confused with all those addresses, ports and connections because I’m super unfamiliar with this and I honestly could use some help.
Thank you in advance.

Please describe how networking is configured for the VM (i.e. NAT, Bridged, Host-only, etc).
Just in case, here’s a description of networking in VirtualBox, in particular the networking modes.

So far I managed to establish SSH session via PyCharm

In addition, please show what SSH command you’re using in this case.

Right now networking for the VM is set for NAT with 2 port forwarding rules: with ports that are 2222 for host and 22 for guest and 14550 ports for both.
SSH I set with PyCharm integrated manager i.e. via deployment.
I’ll attach a screenshot of my settings here:
изображение_2020-12-16_092853
изображение_2020-12-16_093017

Thank you for answering as well.

One thing, if not a typo, port is different from what you’ve forwarded in VBox (14540 vs 14550)

In addition, you assign a default value to connection_string but it could be changed if command line argument --connect is used.
Are you overriding such default value?
If so, what’s the command line command you’re using?

Yeah, there is a typo. The port should be 14550.
And I’m not using any command lines in particular except of those that start the simulation itself.

Ok, it’s usually preferable to copy/paste actual source code from your program/script…

So now that the scenario is described, what’s the problem you’re facing?

I did paste from my actual script, but I forgot I changed the port afterwards. I do apologize.

The problem is simple: I cannot connect to VM with running gazebo and QGC with this script from my host machine. Although I can run this script from exact VM and from my host but only if I deplot the script to the VM which does not work for me at the moment since I’ve been quested with another task that should be running only on my host.

I’d suggest you to verify connectivity from the host to VM before going on.
From host, you may want to try netcat to see if you can reach the VM port:

netcat -u 127.0.0.1 14550

in addition, you may want to use Wireshark to capture/inspect the network traffic ton confirm what’s going on in the host-VM network

Well I figured everything by myself. Thank for trying to help me though.
In case you are interested - I managed to change default target address in mavlink_main.cpp file to my VM address (192.168.56.1) and that solved my problem.

Glad you consider your issue solved.

However, it looks like your current scenario VM address (192.168.56.1) (which is a typical Host-only NIC address in VBox) is a bit different from the initial description (NAT mode for networking).
In addition, having to change mavlink_main.cpp and re-build if the underlying network configuration changes doesn’t seem versatile (I’d expect to use a config file instead).