How to connect PX4 within a Docker with Airsim on Windows

I’m new to aerial robotics, so please correct me if I use the wrong terms anywhere.

I am trying to get PX4 to connect to airsim. So, I first changed the settings accordingly.

    "SeeDocsAt": "",
    "SettingsVersion": 1.2,
    "SimMode": "Multirotor",
    "Vehicles": {
        "PX4": {
            "VehicleType": "PX4Multirotor",
            "UseSerial": false,
            "UseTcp": true,
            "TcpPort": 4560,
            "ControlPort": 14580,
            "params": {
                "NAV_RCL_ACT": 0,
                "NAV_DLL_ACT": 0,
                "LPE_LAT": 47.641468,
                "LPE_LON": -122.140165,
                "COM_OBL_ACT": 1

To run the docker container I used the following command:

docker run -it --privileged \
    -v ~/src/Firmware:/src/firmware:rw \
    -p \
--name=px px4io/px4-dev-ros-melodic

Once in the container, I did

cd /src/firmware
make px4_sitl none_iris

Everything worked smoothly to the point where PX4 is waiting for airsim to accept the connection on TCP port 4560.

Upon running airsim, encountered the following error:

Waiting for TCP connection on port 4560, local IP
Accepting TCP socket failed, is another instance running?
TcpClientPort socket bind failed with error:10048

How can I fix this?

On the docker side of things, I first tried connecting to a python listener inside the container using telnet on the outside.
The listener said it is receiving the connection from on a port in the 39000s (changes every time).
So I think some way to deal with this to change the default TCP port PX4 uses to communicate with a simulator
Also, am I using the right make command for this?


Is your issue resolved?
I am facing a similar issue, please share the solution is the issue is resolved