Skip to content

uditray02/Isaac-Sim-PX4

Repository files navigation

Isaac-Sim-with-PX4-Swarming + Detection

Step 1 : Installation of Isaac Sim + Drone Simulator

a. Install system dependencies

# Go to the home directory
cd ~

# Create a new directory to store the Isaac Sim installation
mkdir -p isaacsim
cd isaacsim

# Download the zip file containing the Isaac Sim installation
wget https://download.isaacsim.omniverse.nvidia.com/isaac-sim-standalone-5.1.0-linux-x86_64.zip

# Unzip the file
unzip isaac-sim-standalone-5.1.0-linux-x86_64.zip

# Run the post-installation scripts
./post_install.sh
./isaac-sim.selector.sh

# Delete the zip file
rm isaac-sim-standalone-5.1.0-linux-x86_64.zip

b. Adding in .bashrc

# ---------------------------
# ISAAC SIM SETUP
# ---------------------------
# Isaac Sim root directory
export ISAACSIM_PATH="${HOME}/isaacsim"
# Isaac Sim python executable
export ISAACSIM_PYTHON="${ISAACSIM_PATH}/python.sh"
# Isaac Sim app
export ISAACSIM="${ISAACSIM_PATH}/isaac-sim.sh"

# Define an auxiliary function to launch Isaac Sim or run scripts with Isaac Sim's python
# This is done to avoid conflicts between ROS 2 and Isaac Sim's Python environment
isaac_run() {

    # ------------------
    # === VALIDATION ===
    # ------------------
    if [ ! -x "$ISAACSIM_PYTHON" ]; then
        echo "❌ IsaacSim python.sh not found at: $ISAACSIM_PYTHON"
        return 1
    fi
    if [ ! -x "$ISAACSIM" ]; then
        echo "❌ IsaacSim launcher not found at: $ISAACSIM"
        return 1
    fi

    # -------------------------
    # === CLEAN ENVIRONMENT ===
    # -------------------------
    # Unset ROS 2 environment variables to avoid conflicts with Isaac's Python 3.11
    unset ROS_VERSION ROS_PYTHON_VERSION ROS_DISTRO AMENT_PREFIX_PATH COLCON_PREFIX_PATH PYTHONPATH CMAKE_PREFIX_PATH

    # Remove ROS 2 paths from LD_LIBRARY_PATH if present
    local ros_paths=("/opt/ros/humble" "/opt/ros/jazzy" "/opt/ros/iron")
    for ros_path in "${ros_paths[@]}"; do
        export LD_LIBRARY_PATH=$(echo "$LD_LIBRARY_PATH" | tr ':' '\n' | grep -v "^${ros_path}" | paste -sd':' -)
    done

    # -----------------------------
    # === UBUNTU VERSION CHECK ===
    # -----------------------------

    if [ -f /etc/os-release ]; then
        UBUNTU_VERSION=$(grep "^VERSION_ID=" /etc/os-release | cut -d'"' -f2)
    fi

    # If Ubuntu 24.04 -> use the Isaac Sim internal ROS2 Jazzy (ROS2 Jazzy bridge)
    if [[ "$UBUNTU_VERSION" == "24.04" ]]; then
        export ROS_DISTRO=jazzy
        export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
        export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ISAACSIM_PATH}/exts/isaacsim.ros2.bridge/jazzy/lib"
        echo "🧩 Detected Ubuntu 24.04 -> Using ROS_DISTRO=jazzy"
    # If Ubuntu 22.04 -> use the Isaac Sim internal ROS2 Humble (ROS2 Humble bridge)
    else
        export ROS_DISTRO=humble
        export RMW_IMPLEMENTATION=rmw_fastrtps_cpp
        export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${ISAACSIM_PATH}/exts/isaacsim.ros2.bridge/humble/lib"
        echo "🧩 Detected Ubuntu ${UBUNTU_VERSION:-unknown} -> Using ROS_DISTRO=humble"
    fi

    # ---------------------
    # === RUN ISAAC SIM ===
    # ---------------------
    if [ $# -eq 0 ]; then
        # No args → Launch full Isaac Sim GUI
        echo "🧠 Launching Isaac Sim GUI..."
        "${ISAACSIM}"

    elif [[ "$1" == --* ]]; then
        # Arguments start with "--" → pass them to Isaac Sim executable
        echo "⚙️  Launching Isaac Sim with options: $*"
        "${ISAACSIM}" "$@"

    elif [ -f "$1" ]; then
        # First argument is a Python file → run with Isaac Sim's Python
        local SCRIPT_PATH="$1"
        shift
        echo "🚀 Running Python script with Isaac Sim: $SCRIPT_PATH"
        "${ISAACSIM_PYTHON}" "$SCRIPT_PATH" "$@"

    else
        # Unrecognized input
        echo "❌ Unknown argument or file not found: '$1'"
        echo "Usage:"
        echo "  isaac_run                 → launch GUI"
        echo "  isaac_run my_script.py    → run script with IsaacSim Python"
        echo "  isaac_run --headless ...  → launch IsaacSim with CLI flags"
        return 1
    fi
}

c. Running Isaac Sim

isaac_run --help

# Run the simulator
isaac_run

d. Installing the drone simulator(Any Drone Sim compatible with Isaac

Then add the SIMULATOR inside ISAAC SIM by going to the Extensions Tab and enabling it

Step 2 : Installation of PX4-Autopilot

a. Install the dependencies

sudo apt install git make cmake python3-pip
pip install kconfiglib jinja2 empy jsonschema pyros-genmsg packaging toml numpy future

b. Cloning and Configuration

git clone https://github.com/PX4/PX4-Autopilot.git
cd PX4-Autopilot
# Checkout to the latest stable release
git checkout v1.14.3

# Initiate all the submodules. Note this will download modules such as SITL-gazebo which we do not need
# but this is the safest way to make sure that the PX4-Autopilot and its submodules are all checked out in
# a stable and well tested release
git submodule update --init --recursive

# Compile the code in SITL mode
make px4_sitl_default none

Step 3 : Linking the Simulator permanently with Nvidia Isaac Sim

cd {$PATH_TO_SIMULATOR_INSTALLATION}
ls

#You must see:
#link_app.sh
#extensions/
#app/

chmod +x link_app.sh
./link_app.sh --path $ISAACSIM_PATH

Verify : ls -l
Run: ./app/isaac-sim.sh --ext-folder extensions --enable {name_of_the_sim}.simulator 

Step 4 : Install QGroundControl for Linux (AppImage)

Step 5 : Running IsaacSim + Simulator as StandAlone Application

cd {$PATH_TO_SIMULATOR_INSTALLATION}
isaac_run {name of the folder where your code is}/{name of the code which you want to run}

Step 6 : MAVSDK Server – Build, Install, and Run (Linux)

a. Install system dependencies

sudo apt update
sudo apt install -y \
    git cmake build-essential \
    libssl-dev protobuf-compiler \
    libprotobuf-dev libcurl4-openssl-dev

b. Building the server

cd ~
git clone https://github.com/mavlink/MAVSDK.git
cd MAVSDK

mkdir build
cd build

cmake ..
make -j$(nproc)

c. Verification

Locate mavsdk_server
find . -type f -name mavsdk_server

Expected output:
./src/mavsdk_server/mavsdk_server
(or)
./src/mavsdk_server

Python MAVSDK server location (required for MAVSDK-Python)
The server binary must exist at:
~/.local/lib/python3.10/site-packages/mavsdk/bin/mavsdk_server

If it is missing, install MAVSDK for Python:
pip3 install --user mavsdk

Verify:
~/.local/lib/python3.10/site-packages/mavsdk/bin/mavsdk_server --version

d. Running the Server

Start mavsdk_server

Example configuration:

MAVSDK gRPC port: 50040

MAVLink UDP port: 14540

Port Usage Rules

One MAVSDK server per vehicle

Each server must use a unique gRPC port

MAVLink UDP ports must match PX4 / SITL / simulator configuration

Do not mix system-built and pip-installed MAVSDK binaries

Step 7 : RUN

Run ''px4_multi_drone_isaac.py'' to get 5x drone in the world sim
Run ''takeoff-together-offboard.py'' to get all of the drones arm and takeoff in offboard mode
Run ''sequence-swarming.py'' to swarm all the drones together and drone(2/3) as the leader controlling all the drones

About

Isaac Sim Drone Programming with PX4 + ROS2

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors