Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/python/projectairsim/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"jsonlines",
"Shapely",
"azure-storage-blob",
"open3d==0.16.*"
"open3d>=0.16.0"
]

[project.optional-dependencies]
Expand Down
26 changes: 18 additions & 8 deletions client/python/projectairsim/src/projectairsim/lidar_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from argparse import ArgumentError
import multiprocessing as mp
import time

import numpy as np
import open3d as o3d
Expand All @@ -24,8 +25,8 @@ def __init__(self):
class SetViewBoundsRequest:
"""Class for requesting the display loop recalculate the view bounds"""

def __init__(self):
pass
def __init__(self, view_bounds):
self.view_bounds = view_bounds

class ViewChangeRequest:
"""Class for making a view change request to the display loop"""
Expand Down Expand Up @@ -96,7 +97,7 @@ def __init__(
if (view == self.VIEW_CUSTOM) and (
not lookat_xyz or not view_front or not view_up
):
raise ArgumentError(
raise ValueError(
"LidarDisplay: View is VIEW_CUSTOM but one or more of lookat_xyz,"
" view_front, or view_up arguments are missing"
)
Expand All @@ -116,7 +117,7 @@ def __init__(
self.PLASMA_PALLETE.shape[0],
)
else:
raise ArgumentError("LidarDisplay: Invalid color_intensity_range")
raise ValueError("LidarDisplay: Invalid color_intensity_range")

def set_view_preset(self, view: int, lookat_xyz=None):
if view == self.VIEW_TOPDOWN:
Expand All @@ -138,11 +139,11 @@ def set_view_preset(self, view: int, lookat_xyz=None):
self.lookat_xyz = [0.0, 0.0, 5.0] if not lookat_xyz else lookat_xyz
self.view = view
elif view == self.VIEW_CUSTOM:
raise ArgumentError(
raise ValueError(
"VIEW_CUSTOM is not valid here--call set_view_custom() instead"
)
else:
raise ArgumentError(f"Unrecognized preset view ID {view}")
raise ValueError(f"Unrecognized preset view ID {view}")

if self.running:
self.control_q.put(
Expand Down Expand Up @@ -366,13 +367,22 @@ def display_loop(self):
self.set_view()

# Do Open3D processing
self.o3d_vis.poll_events()
self.o3d_vis.update_renderer()
if self.window_created:
# check if window is still open
if not self.o3d_vis.poll_events():
self.running = False
break
self.o3d_vis.update_renderer()

# Cap frame rate to reduce CPU usage and avoid issues with DWM/WGL on Windows
time.sleep(0.01)

except KeyboardInterrupt:
pass # Just exit normally

finally:
if self.window_created:
self.o3d_vis.destroy_window()
self.window_created = False

def receive(self, lidar_data):
Expand Down
14 changes: 7 additions & 7 deletions docs/client_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

A Python client uses the following to communicate with the Project AirSim simulation server:

- Python 3.7-3.9, 64-bit
- Python 3.7 or newer, 64-bit
- **[pynng](https://github.com/codypiersall/pynng)** nanomsg-next-gen wrapper pip package

### Setting Up the Client on **Windows**

1. Install Python 3.7-3.9 for Windows. There are many options for installing Python, but one recommended way is to:
1. Install Python 3.7 or newer for Windows. There are many options for installing Python, but one recommended way is to:

- Download the official **[Windows installer for Python](https://www.python.org/downloads/windows/)**. Please note that the 64-bit version is required.

Expand All @@ -21,12 +21,12 @@ A Python client uses the following to communicate with the Project AirSim simula

2. Activate the Python environment to use with Project AirSim.

If you don't have a suitable Python environment yet, do the following. Here, we assume we're using Python 3.8 installed in the directory `C:\Python38`, but use the version and directory of your installation of Python:
If you don't have a suitable Python environment yet, do the following. Use the version and directory of your installation of Python:

A) Install `virtualenv` and create a new environment (here named `airsim-venv` but you may choose any convenient name):

C:\Python310\python -m pip install virtualenv
C:\Python310\python -m venv C:\path\to\airsim-venv
python -m pip install virtualenv
python -m venv C:\path\to\airsim-venv

B) Activate your environment:

Expand Down Expand Up @@ -72,9 +72,9 @@ A Python client uses the following to communicate with the Project AirSim simula

### Setting Up the Client on **Linux**

1. Install Python 3.7-3.9 to your system:
1. Install Python 3.7 or newer to your system:

Ubuntu 20.04 comes with Python 3.8, but Project AirSim requires additional packages:
Ubuntu 20.04 comes with Python 3.8, while newer versions like Ubuntu 24.04 come with Python 3.12:

sudo apt install python3-dev python3-venv

Expand Down