### Dockerfile for Static Linking Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/static_linking_example/readme.rst This Dockerfile sets up the environment for the static linking example. It installs necessary dependencies and prepares the build context. ```docker FROM ubuntu:20.04 RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ cmake \ git \ wget \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Clone the ouster-sdk repository RUN git clone https://github.com/ouster-lidar/ouster-sdk.git # Build the ouster_pcap library statically WORKDIR /app/ouster-sdk RUN mkdir build && cd build \ && cmake .. -DBUILD_SHARED_LIBS=OFF \ && make ouster_pcap \ && make install # Copy the C++ example code into the container COPY ./main.cpp /app/main.cpp # Build the C++ example application, linking against the static ouster_pcap library WORKDIR /app RUN cmake -S . -B build -DCMAKE_PREFIX_PATH=/usr/local \ && cmake --build build # Set the entrypoint to run the compiled C++ application CMD ["./build/main"] ``` -------------------------------- ### Build and Run Example Script Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/shared_linking_example/readme.rst Bash script to execute the shared linking example within a containerized environment. Ensure Docker is installed and running. ```bash #!/bin/bash # Exit immediately if a command exits with a non-zero status. set -e # Build the Docker image echo "Building Docker image..." docker build -t ouster-sdk-shared-linking . # Run the Docker container and execute the example echo "Running example inside container..." docker run --rm ouster-sdk-shared-linking echo "Example finished successfully." ``` -------------------------------- ### Dockerfile for Shared Linking Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/shared_linking_example/readme.rst Dockerfile to set up the environment for building and running the shared linking example. It installs dependencies and copies necessary files. ```docker # Use a base image with C++ build tools FROM ubuntu:20.04 AS builder # Install build essentials and CMake RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ cmake \ git \ wget \ && rm -rf /var/lib/apt/lists/* # Clone the ouster-sdk repository RUN git clone https://github.com/ouster-lidar/ouster-sdk.git /ouster-sdk # Build the ouster_pcap library as a shared library WORKDIR /ouster-sdk/build RUN cmake -DBUILD_SHARED_LIBS=ON .. && make -j$(nproc) # --- Runtime Stage --- FROM ubuntu:20.04 # Install runtime dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ libssl-dev \ && rm -rf /var/lib/apt/lists/lists.old/* # Copy the built shared libraries from the builder stage COPY --from=builder /ouster-sdk/build/lib/libouster_pcap.so /usr/local/lib/ COPY --from=builder /ouster-sdk/build/lib/libouster_driver.so /usr/local/lib/ # Set the library path to include the new shared libraries ENV LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} # Copy the example executable (assuming it's built elsewhere or will be built in this stage) # For this example, we'll assume the C++ example is in the same directory as the Dockerfile # and will be compiled here. WORKDIR /app COPY ./example.cpp . # Compile the C++ example, linking against the shared libraries RUN apt-get update && apt-get install -y --no-install-recommends \ libusb-1.0-0-dev \ && rm -rf /var/lib/apt/lists/lists.old/* RUN g++ example.cpp -o example -I/ouster-sdk/include -L/ouster-sdk/build/lib -louster_pcap -louster_driver -Wl,-rpath=/ouster-sdk/build/lib # Set the command to run the example CMD ["./example"] ``` -------------------------------- ### Run Open3d Example from Command Line (Linux/macOS) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/visualizations.md Command to run the Open3d visualizer example from the command line on Linux or macOS. It requires the path to a pcap file and allows specifying a start frame and pause behavior. ```console $ python3 -m ouster.sdk.examples.open3d_example \ --pcap $SAMPLE_DATA_PCAP_PATH --start 84 --pause ``` -------------------------------- ### Run Open3d Example from Command Line (Windows) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/visualizations.md Command to run the Open3d visualizer example from the PowerShell on Windows. It requires the path to a pcap file and allows specifying a start frame and pause behavior. ```powershell PS > py -3 -m ouster.sdk.examples.open3d_example ^ --pcap $SAMPLE_DATA_PCAP_PATH --start 84 --pause ``` -------------------------------- ### Start Python Interpreter Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/quickstart.md Open an interactive Python session to follow along with the guide. Use `python3` on Linux/macOS or `py -3` on Windows. ```console $ python3 ``` ```powershell PS > py -3 ``` -------------------------------- ### Dockerfile for Shared Library Linking Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/examples/linking_examples.md This Dockerfile defines the build environment for the shared linking example. It includes stages for setting up the base system, installing dependencies, building the library, and creating the final runtime image. ```docker # ============================== BASE CONTAINER ============================== ARG BASE="ubuntu:22.04" FROM ${BASE} AS BASE_IMAGE ARG APT_PROXY="" ARG APT_MIRROR="" ENV WORKSPACE=/root RUN /bin/sh -c "if ! [ -z \"$APT_PROXY\" ]; then \ echo 'Using Proxy for APT'; \ echo 'Acquire::http::Proxy \"$APT_PROXY\";' > /etc/apt/apt.conf.d/01proxy; \ fi" RUN /bin/sh -c "if ! [ -z \"$APT_MIRROR\" ]; then \ sed -i \"s|http://archive.ubuntu.com/ubuntu|$APT_MIRROR|g\" /etc/apt/sources.list; \ sed -i \"s|http://security.ubuntu.com/ubuntu|$APT_MIRROR|g\" /etc/apt/sources.list; \ fi" RUN apt-get update \ && apt-get install -y python3 python3-venv python3-pip \ && mkdir -p $WORKSPACE/scripts/dev_script_library # ============================== BUILD STAGE ============================== FROM BASE_IMAGE AS BUILD ARG VCPKG_BINARY_SOURCES="" ENV VCPKG_BINARY_SOURCES=$VCPKG_BINARY_SOURCES COPY ./scripts/requirements.txt \ $WORKSPACE/scripts/ COPY ./scripts/dev_script_library/build_libs.py \ ./scripts/dev_script_library/context.py \ ./scripts/dev_script_library/dev_dependencies.py \ $WORKSPACE/scripts/dev_script_library/ RUN python3 -m venv $WORKSPACE/venv && \ . $WORKSPACE/venv/bin/activate && \ cd $WORKSPACE && \ python3 ./scripts/dev.py utils install-vcpkg-package-requirements && \ python3 ./scripts/dev.py utils enable-local-vcpkg ENV INSTALL_DIR="/usr/local" COPY . $WORKSPACE/ RUN cd $WORKSPACE && \ cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DBUILD_EXAMPLES=OFF \ -DBUILD_SHARED_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \ -DCMAKE_TOOLCHAIN_FILE=$WORKSPACE/.osdkv2/vcpkg/scripts/buildsystems/vcpkg.cmake . &&\ cmake --build . --parallel 4 --target install # ============================== FINAL STAGE ============================== FROM BASE_IMAGE RUN apt-get update && apt-get install -y \ build-essential \ cmake \ libeigen3-dev \ libflatbuffers-dev \ && rm -rf /var/lib/apt/lists/* ENV WORKSPACE=/root ENV INSTALL_DIR="/usr/local" COPY --from=BUILD $INSTALL_DIR $INSTALL_DIR COPY tests/pcaps/OS-2-32-U0_v2.0.0_1024x10.pcap examples/shared_linking_example/CMakeLists.txt \ examples/shared_linking_example/main.cpp $WORKSPACE/ RUN export CMAKE_PREFIX_PATH="$INSTALL_DIR" &&\ mkdir -p $WORKSPACE/build &&\ cd $WORKSPACE/build &&\ cmake $WORKSPACE && cmake --build . --parallel 4 CMD $WORKSPACE/build/pcap_test /root/OS-2-32-U0_v2.0.0_1024x10.pcap ``` -------------------------------- ### Dockerfile for C++ Example Compilation Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/compiled_in_linking_example/readme.rst This Dockerfile defines the environment for compiling the C++ example. It installs necessary dependencies and sets up the build tools. ```docker FROM ubuntu:20.04 RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ cmake \ git \ wget \ && rm -rf /var/lib/apt/lists/* # Clone the ouster-sdk repository RUN git clone https://github.com/ouster-lidar/ouster-sdk.git /ouster-sdk # Set the working directory WORKDIR /app # Create a build directory and compile the example RUN mkdir build && cd build \ && cmake .. -DBUILD_OS_DRIVER=OFF -DBUILD_TOOLS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_PYTHON_BINDINGS=OFF \ && make ouster_pcap_example \ && mv ouster_pcap_example .. # Set the entry point to run the compiled example CMD ["/app/ouster_pcap_example"] ``` -------------------------------- ### Run Example from Command Line Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/udp-packets.md Execute the `pcap_read_packets` example script from the command line, providing the path to a sample pcap file. ```console $ python3 -m ouster.sdk.examples.pcap $SAMPLE_DATA_PCAP_PATH read-packets ``` ```powershell PS > py -3 -m ouster.sdk.examples.pcap $SAMPLE_DATA_PCAP_PATH read-packets ``` -------------------------------- ### Compiled-In Linking Example Dockerfile Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/examples/linking_examples.md This Dockerfile defines the environment for building and running the compiled-in linking example. It installs dependencies, copies SDK source code, and compiles the example. ```docker ARG BASE="ubuntu:22.04" FROM ${BASE} ARG APT_PROXY="" ARG APT_MIRROR="" ENV WORKSPACE=/root RUN /bin/sh -c "if ! [ -z \"$APT_PROXY\" ]; then \ echo 'Using Proxy for APT'; \ echo 'Acquire::http::Proxy \"$APT_PROXY\";' > /etc/apt/apt.conf.d/01proxy; \ fi" RUN /bin/sh -c "if ! [ -z \"$APT_MIRROR\" ]; then \ sed -i \"s|http://archive.ubuntu.com/ubuntu|$APT_MIRROR|g\" /etc/apt/sources.list; \ sed -i \"s|http://security.ubuntu.com/ubuntu|$APT_MIRROR|g\" /etc/apt/sources.list; \ fi" RUN apt-get update \ && apt-get install -y python3 python3-venv python3-pip \ && mkdir -p $WORKSPACE/scripts/dev_script_library COPY ./scripts/dev.py ./scripts/requirements.txt \ $WORKSPACE/scripts/ COPY ./scripts/dev.py ./scripts/requirements.txt \ ./scripts/dev_script_library/build_libs.py \ ./scripts/dev_script_library/context.py \ ./scripts/dev_script_library/dev_dependencies.py \ $WORKSPACE/scripts/dev_script_library/ RUN python3 -m venv $WORKSPACE/venv && \ . $WORKSPACE/venv/bin/activate && \ cd $WORKSPACE && \ python3 ./scripts/dev.py utils install-system-packages COPY . $WORKSPACE/sdk/ COPY tests/pcaps/OS-2-32-U0_v2.0.0_1024x10.pcap examples/compiled_in_linking_example/CMakeLists.txt \ examples/compiled_in_linking_example/main.cpp $WORKSPACE/ RUN cd $WORKSPACE && \ cmake -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF . && \ cmake --build . --parallel 4 CMD $WORKSPACE/pcap_test /root/OS-2-32-U0_v2.0.0_1024x10.pcap ``` -------------------------------- ### Build Visualization Examples Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/CMakeLists.txt Adds executables for various visualization examples (viz_example, viz_mesh_example, viz_events_example, viz_screenshot_example, viz_notifications_example), linking them with ouster_client and ouster_viz. ```cmake if(TARGET OusterSDK::ouster_viz) add_executable(viz_example viz_example.cpp) target_link_libraries(viz_example PRIVATE OusterSDK::ouster_client OusterSDK::ouster_viz) add_executable(viz_mesh_example viz_mesh_example.cpp) target_link_libraries(viz_mesh_example PRIVATE OusterSDK::ouster_client OusterSDK::ouster_viz) add_executable(viz_events_example viz_events_example.cpp) target_link_libraries(viz_events_example PRIVATE OusterSDK::ouster_client OusterSDK::ouster_viz) add_executable(viz_screenshot_example viz_screenshot_example.cpp) target_link_libraries(viz_screenshot_example PRIVATE OusterSDK::ouster_client OusterSDK::ouster_viz) add_executable(viz_notifications_example viz_notifications_example.cpp) target_link_libraries(viz_notifications_example PRIVATE OusterSDK::ouster_client OusterSDK::ouster_viz) else() message(STATUS "No ouster_viz library available; skipping examples") endif() ``` -------------------------------- ### Example Plugin Structure for Dev Script CLI Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst This Python code demonstrates the structure of a plugin for the Ouster SDK Dev Script CLI. It includes defining a Click group and command, and the required `import_module` and `finalize` functions for plugin registration and setup. ```python import click import shutil import os @click.group() @click.pass_context() def my_util_group(ctx): pass @my_util_group.command() @click.pass_context() @click.option('--build-dir', default='build', help='Directory to clean.') @click.option('--artifacts-dir', default='artifacts', help='Artifacts directory to clean.') def clean(ctx, build_dir, artifacts_dir): """Clean build and artifacts directories.""" for directory in [build_dir, artifacts_dir]: if os.path.exists(directory): print(f"Removing {directory}...") shutil.rmtree(directory) else: print(f"{directory} does not exist.") def import_module(click_context): click_context.top_level_group.add_command(my_util_group) def finalize(click_context): print("Finalizing plugin setup.") ``` -------------------------------- ### Install Ouster SDK Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cli/mapping-sessions.md Installs the Ouster SDK with mapping capabilities. Use the appropriate command for your operating system. ```bash python3 install ouster-sdk ``` ```powershell PS > py -3 install ouster-sdk ``` -------------------------------- ### Build and Install Ouster SDK Python Package Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/devel.md Build an installable wheel package or install the Ouster SDK Python package directly. Ensure pip and setuptools are up-to-date and pybind11 is installed. ```bash # first, specify the path to the ouster-sdk repository $ export OUSTER_SDK_PATH= # make sure you have an up-to-date version of pip and setuptools installed $ python3 -m pip install --user --upgrade pip setuptools # install pybind11 $ python3 -m pip install pybind11 # then, build an installable "wheel" package $ python3 -m pip wheel --no-deps $OUSTER_SDK_PATH/python # or just install directly (virtualenv recommended) $ python3 -m pip install $OUSTER_SDK_PATH/python ``` -------------------------------- ### Build Client Example Executable Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/CMakeLists.txt Adds an executable for the client example and links it against the ouster_sensor library. This is conditional on the ouster_sensor library being available. ```cmake if(TARGET OusterSDK::ouster_sensor) add_executable(client_example client_example.cpp) target_link_libraries(client_example PRIVATE OusterSDK::ouster_sensor) add_executable(client_packet_example client_packet_example.cpp) target_link_libraries(client_packet_example PRIVATE OusterSDK::ouster_sensor) add_executable(config_example config_example.cpp) target_link_libraries(config_example PRIVATE OusterSDK::ouster_sensor) add_executable(zone_monitor_zone_set zone_monitor_zone_set.cpp) target_link_libraries(zone_monitor_zone_set PRIVATE OusterSDK::ouster_client OusterSDK::ouster_sensor) add_executable(zone_monitor_zone_states zone_monitor_zone_states.cpp) target_link_libraries(zone_monitor_zone_states PRIVATE OusterSDK::ouster_client OusterSDK::ouster_sensor) if(RUN_HIL_EXAMPLES) add_subdirectory(hil) endif() else() message(STATUS "No ouster_sensor library available; skipping examples") endif() ``` -------------------------------- ### Run Ouster SDK Client Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/building.md Execute the client example to connect to the sensor, capture lidar data, and write point clouds to CSV files. Specify the sensor's hostname or IP and the UDP data destination. ```console $ ./client_example ``` -------------------------------- ### Build and Run Example with Bash Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/compiled_in_linking_example/readme.rst Use this bash script to compile and run the C++ example within a Docker container. It sets up the environment and executes the build process. ```bash #!/bin/bash # Exit immediately if a command exits with a non-zero status. set -e # Build the Docker image docker build -t ouster-sdk-cpp-example . # Run the Docker container and execute the example docker run --rm ouster-sdk-cpp-example ``` -------------------------------- ### Define and Build Example Executables Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/thirdparty/sophus/examples/CMakeLists.txt This snippet defines a list of example source files and then iterates through them to create an executable for each. It ensures that each example is correctly linked against the Sophus library. ```cmake SET(EXAMPLE_SOURCES HelloSO3) FOREACH(example_src ${EXAMPLE_SOURCES}) ADD_EXECUTABLE( ${example_src} ${example_src}.cpp) TARGET_LINK_LIBRARIES( ${example_src} sophus) ENDFOREACH(example_src) ``` -------------------------------- ### Install ouster-sdk Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cli/getting-started.md Install the ouster-sdk package, which includes the ouster-cli utility, using pip. ```bash pip3 install ouster-sdk ``` -------------------------------- ### Run Example in Container Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/static_linking_example/readme.rst Use this bash script to execute the static linking example within a Docker container. It handles building and running the necessary components. ```bash #!/bin/bash # Exit immediately if a command exits with a non-zero status. set -e # Build the Docker image echo "Building Docker image..." docker build -t ouster-static-linking-example . # Run the Docker container and execute the example echo "Running example inside container..." docker run --rm ouster-static-linking-example echo "Example finished." ``` -------------------------------- ### Install ouster_sensor Target and Headers Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/ouster_sensor/CMakeLists.txt Configures the installation of the 'ouster_sensor' target, including runtime binaries and include files. It also installs the 'ouster' directory from 'include' to the installation's include path. ```cmake install(TARGETS ouster_sensor EXPORT ouster-sdk-targets RUNTIME DESTINATION bin INCLUDES DESTINATION include) install(DIRECTORY include/ouster DESTINATION include ) ``` -------------------------------- ### Get help for a specific command Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cli/getting-started.md Use the '--help' flag with any ouster-cli command to view its usage and options. This example shows how to get help for the 'viz' command within the 'source' subcommand. ```bash ouster-cli source viz --help ``` -------------------------------- ### Install ouster-sdk for Linux/macOS Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/installation.md Install the Ouster Python SDK using pip. This command installs the latest stable version of the SDK. ```bash python3 -m pip install 'ouster-sdk' ``` -------------------------------- ### Install pybind11 Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/devel.md Install pybind11 using pip. This is a prerequisite for building C++ extensions. ```console python3 -m pip install pybind11 ``` -------------------------------- ### Build and Install Ouster SDK Python Package on Windows Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/devel.md Build an installable wheel package or install the Ouster SDK Python package directly on Windows. ```powershell # then, build an installable "wheel" package PS > py -m pip wheel --no-deps "$env:OUSTER_SDK_PATH\python" # or just install directly (virtualenv recommended) PS > py -m pip install "$env:OUSTER_SDK_PATH\python" ``` -------------------------------- ### Install Targets and Directories Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/ouster_viz/CMakeLists.txt Specifies installation rules for the ouster_viz library and related assets. This ensures the library and its headers are correctly placed when the project is installed. ```cmake install(TARGETS ouster_viz glad EXPORT ouster-sdk-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib INCLUDES DESTINATION include) install(DIRECTORY include/ouster DESTINATION include) ``` -------------------------------- ### Upgrade pip and setuptools for Linux/macOS Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/installation.md Ensure you have the latest versions of pip and setuptools before installing the Ouster Python SDK. This is a prerequisite for a smooth installation. ```bash python3 -m pip install --upgrade pip setuptools ``` -------------------------------- ### Install Linux Dependencies with apt Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/building.md Use this command to install necessary build dependencies on Ubuntu 20.04+ systems. ```bash sudo apt install build-essential cmake libeigen3-dev libcurl4-openssl-dev \n libtins-dev libpcap-dev libglfw3-dev libpng-dev \n libflatbuffers-dev libceres-dev libtbb-dev libssl-dev \n libzip-dev libzstd-dev \n robin-map-dev zlib1g-dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/thirdparty/kiss-icp/eval/kitti.ipynb Installs the KISS-ICP library and plotting tools. This is a prerequisite for running the experiments. ```python # Install KISS-ICP and Plotting tools %pip install kiss-icp ipympl evo >/dev/null import os import kiss_icp import matplotlib.pyplot as plt import numpy as np from evo.tools import plot from kiss_icp.datasets import dataset_factory from kiss_icp.pipeline import OdometryPipeline %autoreload 2 %matplotlib inline %matplotlib widget ``` -------------------------------- ### Full Pose Optimizer Configuration Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cli/pose-optimizer-sessions.md An example JSON file demonstrating various supported constraint types for the Pose Optimizer. This file can be used with downloaded OSF data to run the optimizer. ```json { "key_frame_distance": 2.0, "constraints": [ { "type": "ABSOLUTE_POSE", "translation_weight": [1.0, 1.0, 1.0], "rotation_weight": 2.0, "timestamp": 411107223340, "pose": { "rx": 0, "ry": 0, "rz": 0, "x": 12, "y": 30, "z": 1.3 } }, { "type": "ABSOLUTE_POINT", "translation_weight": [1.0, 1.0, 1.0], "timestamp": 411107223370, "row": 10, "col": 100, "return_idx": 1, "absolute_position": [5.0, 2.0, 1.5] }, { "type": "POINT_TO_POINT", "translation_weight": [1.0, 1.0, 1.0], "timestamp1": 411107223370, "row1": 9, "col1": 542, "return_idx1": 1, "timestamp2": 531097181460, "row2": 5, "col2": 545, "return_idx2": 1 }, { "type": "POSE_TO_POSE", "translation_weight": [2.0, 2.0, 2.0], "rotation_weight": 2.0, "timestamp1": 411107223370, "timestamp2": 531097181460, "transformation": { "rx": -0.000396419, "ry": -0.0103704, "rz": -0.0289703, "x": 1.29628, "y": 0.61089, "z": -0.138204 } } ] } ``` -------------------------------- ### Build and Run Shared Library Example in Docker Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/examples/linking_examples.md This bash script automates the build and execution of the shared linking example within a Docker container. It handles setting up the environment, building the Docker image, and running the container. ```bash #! /bin/bash set -ex currentDir="$(cd "$(dirname "$0")" && pwd)" baseDir="$currentDir/../.." tempDir="$(mktemp -d)" VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES:-""} APT_PROXY=${APT_PROXY:-""} APT_MIRROR=${APT_MIRROR:-""} baseImage="ubuntu:22.04" if ! [ -z "$1" ]; then baseImage="$1" fi trap 'rm -rf $tempDir' EXIT trap 'echo *** ERROR on line: $LINENO exit_code: $?' ERR cd "$baseDir" pwd docker build -f "$currentDir/Dockerfile" --iidfile="$tempDir/iid" \ --network host \ --build-arg BASE="$baseImage" \ --build-arg APT_PROXY="$APT_PROXY" \ --build-arg APT_MIRROR="$APT_MIRROR" \ --build-arg VCPKG_BINARY_SOURCES="$VCPKG_BINARY_SOURCES" . docker run --rm "$(cat "$tempDir/iid")" ``` -------------------------------- ### Install ouster-sdk for Windows x64 Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/installation.md Install the Ouster Python SDK using pip on Windows. This command installs the latest stable version of the SDK. ```powershell PS > py -3 -m pip install 'ouster-sdk' ``` -------------------------------- ### Upgrade pip and setuptools for Windows x64 Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/installation.md Ensure you have the latest versions of pip and setuptools before installing the Ouster Python SDK on Windows. This is a prerequisite for a smooth installation. ```powershell PS > py -3 -m pip install --upgrade pip setuptools ``` -------------------------------- ### Install zpng Library Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/thirdparty/zpng/CMakeLists.txt Installs the zpng target, including its headers and libraries, for use by other targets or for external consumption. This ensures the library is available after installation. ```cmake install(TARGETS zpng EXPORT ouster-sdk-targets ARCHIVE DESTINATION lib INCLUDES DESTINATION include ) ``` -------------------------------- ### Install Linux Dependencies with apt Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Installs essential development tools including flex, bison, and X11 libraries on Ubuntu-based Linux distributions. ```bash sudo apt install -y flex bison libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev pkg-config build-essential ``` -------------------------------- ### Build and Install Doxygen from Source (Linux) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Steps to compile and install Doxygen from its source code. This is required if your distribution's version is below 1.10.0. ```bash tar -xvf doxygen-.src.tar.gz cd doxygen- mkdir build cd build cmake .. make sudo make install ``` -------------------------------- ### Compiled-In Linking Example Bash Script Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/examples/linking_examples.md This bash script is used to build and run the compiled-in linking example within a Docker container. It sets up the environment, builds the SDK, and executes the example. ```bash #! /bin/bash set -ex currentDir="$(cd $(dirname $0) && pwd)" baseDir=$currentDir/../.. tempDir="$(mktemp -d)" APT_PROXY=${APT_PROXY:-""} APT_MIRROR=${APT_MIRROR:-""} baseImage="ubuntu:22.04" if ! [ -z "$1" ]; then baseImage="$1" fi trap 'rm -rf $tempDir' EXIT trap 'echo *** ERROR on line: $LINENO exit_code: $?' ERR cd $baseDir pwd docker build -f $currentDir/Dockerfile --iidfile=$tempDir/iid \ --network host \ --build-arg APT_PROXY="$APT_PROXY" \ --build-arg APT_MIRROR="$APT_MIRROR" \ --build-arg BASE=$baseImage . docker run --rm $(cat $tempDir/iid) ``` -------------------------------- ### Build and Run Static Linking Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/examples/linking_examples.md Bash script to build a static shared library and link a C++ project with the ouster_pcap library within a containerized environment. It sets up temporary directories, handles cleanup, and uses Docker for building and running the example. ```bash #! /bin/bash set -ex currentDir="$(cd $(dirname $0) && pwd)" baseDir=$currentDir/../.. tempDir="$(mktemp -d)" VCPKG_BINARY_SOURCES=${VCPKG_BINARY_SOURCES:-""} APT_PROXY=${APT_PROXY:-""} APT_MIRROR=${APT_MIRROR:-""} trap 'rm -rf $tempDir' EXIT trap 'echo *** ERROR on line: $LINENO exit_code: $?' ERR cd "$baseDir" pwd docker build -f $currentDir/Dockerfile --iidfile=$tempDir/iid \ --network host \ --build-arg VCPKG_BINARY_SOURCES "$VCPKG_BINARY_SOURCES" \ --build-arg APT_PROXY "$APT_PROXY" \ --build-arg APT_MIRROR "$APT_MIRROR" . docker run --rm $(cat $tempDir/iid) ``` -------------------------------- ### Install Core Dependencies (Linux) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Installs essential build tools and static analysis tools. Ensure libclang and clang tools are version 16.0.0 or higher. ```bash sudo apt install -y cmake doxygen clang clang-tidy clang-format ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Installs the necessary Python packages for the Ouster SDK Dev Script Cli using pip. ```bash python3 -m pip install flufl.lock gitpython click tqdm libclang flake8 mypy pybind11 ``` -------------------------------- ### Build SLAM Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/CMakeLists.txt Adds the slam_example executable, conditional on the ouster_mapping library being available. ```cmake if(TARGET OusterSDK::ouster_mapping) add_executable(slam_example slam_example.cpp) ``` -------------------------------- ### Install Shared Library Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/ouster_library/CMakeLists.txt Installs the 'shared_library' if it was built and BUILD_SHARED_LIBRARY is enabled. Specifies destinations for library, archive, runtime, and include files. ```cmake if(BUILD_SHARED_LIBRARY) install(TARGETS shared_library LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION lib INCLUDES DESTINATION include) endif() ``` -------------------------------- ### Install Ouster SDK Dependencies on Debian-based Linux Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/devel.md Manually install required dependencies for building the Ouster SDK on Debian-based Linux systems using apt. ```bash $ sudo apt install build-essential cmake libeigen3-dev libcurl4-openssl-dev \ libtins-dev libpcap-dev libglfw3-dev libpng-dev \ libflatbuffers-dev libceres-dev libtbb-dev libssl-dev \ libzip-dev libzstd-dev \ robin-map-dev zlib1g-dev ``` -------------------------------- ### Link SDK Libraries for SLAM Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/CMakeLists.txt Conditionally links the Ouster SDK mapping library to the slam_example target. Includes logic to add a test if CI examples are enabled. ```cmake link_sdk_libraries_conditionally(slam_example) target_link_libraries(slam_example PRIVATE OusterSDK::ouster_mapping) if(RUN_CI_EXAMPLES) add_test(NAME slam_example COMMAND slam_example ${EXAMPLE_PCAP}) endif() else() message(STATUS "No ouster_mapping library available; skipping SLAM example") endif() ``` -------------------------------- ### Define Example PCAP and JSON Paths Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/CMakeLists.txt Sets variables for example pcap and JSON file paths, including a large pcap file from an environment variable. ```cmake set(EXAMPLE_PCAP "${CMAKE_CURRENT_LIST_DIR}/../tests/pcaps/OS-1-128_767798045_1024x10_20230712_120049.pcap") set(EXAMPLE_JSON "${CMAKE_CURRENT_LIST_DIR}/../tests/pcaps/OS-1-128_767798045_1024x10_20230712_120049.json") set(EXAMPLE_PCAP_LARGE "$ENV{TEST_DATA_DIR}/bd-data/021521_os0_warehouse2_1024_trunc.pcap") message(STATUS "EXAMPLE_PCAP_LARGE ${EXAMPLE_PCAP_LARGE}") set(EXAMPLE_OSF "${CMAKE_CURRENT_LIST_DIR}/../tests/osfs/OS-1-128_v2.3.0_1024x10_lb_n3.osf") ``` -------------------------------- ### Install KISS-ICP with all dependencies Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/thirdparty/kiss-icp/config/README.md Install the kiss-icp package along with all its optional dependencies. This command is necessary before using advanced features or custom configurations. ```sh pip install "kiss-icp[all]" ``` -------------------------------- ### Run Lidar Scan Filtering Example (Windows x64) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/lidar-scan.md Command to execute the lidar scan filtering example on Windows x64. Ensure the SENSOR_HOSTNAME environment variable is set. ```powershell PS > py -3 -m ouster.sdk.examples.core $SENSOR_HOSTNAME filter-3d-by-range-and-azimuth ``` -------------------------------- ### Check HIL Example Executables Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/hil/CMakeLists.txt This snippet checks if the required HIL example executables (client_example, client_packet_example, config_example) are available. If not, it skips HIL tests and prints a status message. ```cmake cmake_minimum_required(VERSION 3.16) if(NOT TARGET client_example OR NOT TARGET client_packet_example OR NOT TARGET config_example) message(STATUS "HIL example executables not available; skipping HIL tests") return() endif() ``` -------------------------------- ### Run Lidar Scan Filtering Example (Linux/macOS) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/lidar-scan.md Command to execute the lidar scan filtering example on Linux or macOS. Ensure the SENSOR_HOSTNAME environment variable is set. ```bash $ python3 -m ouster.sdk.examples.core $SENSOR_HOSTNAME filter-3d-by-range-and-azimuth ``` -------------------------------- ### Run Ouster PointViz Example Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/viz/viz-api-tutorial.md Launches the interactive PointViz tutorial using sample data. Ensure SAMPLE_DATA_PCAP_PATH and SAMPLE_DATA_JSON_PATH are set. ```bash python3 -m ouster.sdk.examples.viz $SAMPLE_DATA_PCAP_PATH $SAMPLE_DATA_JSON_PATH ``` -------------------------------- ### Install and Run Mypy Type Checker Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/devel.md Install and run Mypy for static type checking. This helps catch type-related errors early in development. Run Mypy on the src directory. ```console python3 -m pip install mypy python3 -m mypy src/ ``` -------------------------------- ### Set Sample Data Paths Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/index.md Define variables for the paths to sample data files. These are used throughout the examples. ```python pcap_path = '' metadata_path = '' ``` -------------------------------- ### Base Docker Image Setup Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/examples/linking_examples.md Sets up a base Ubuntu 22.04 Docker image with Python 3 and necessary development tools. It configures APT proxy and mirror if provided. ```docker # ============================== BASE CONTAINER ============================== FROM ubuntu:22.04 AS BASE_IMAGE ENV INSTALL_DIR="/usr/local" ENV WORKSPACE=/root ARG APT_PROXY="" ARG APT_MIRROR=""
RUN /bin/sh -c "if ! [ -z \"$APT_PROXY\" ]; then echo 'Using Proxy for APT'; echo 'Acquire::http::Proxy \"$APT_PROXY\";' > /etc/apt/apt.conf.d/01proxy; fi"
RUN /bin/sh -c "if ! [ -z \"$APT_MIRROR\" ]; then sed -i \"s|http://archive.ubuntu.com/ubuntu|$APT_MIRROR|g\" /etc/apt/sources.list; sed -i \"s|http://security.ubuntu.com/ubuntu|$APT_MIRROR|g\" /etc/apt/sources.list; fi"
RUN apt-get update && apt-get install -y python3 python3-venv
COPY ./scripts/dev.py ./scripts/requirements.txt \ $WORKSPACE/scripts/ COPY ./scripts/dev.py ./scripts/requirements.txt \ ./scripts/dev_script_library/build_libs.py \ ./scripts/dev_script_library/context.py \ ./scripts/dev_script_library/dev_dependencies.py \ $WORKSPACE/scripts/dev_script_library/
RUN python3 -m venv $WORKSPACE/venv \ && . $WORKSPACE/venv/bin/activate \ && python3 -m pip install -r $WORKSPACE/scripts/requirements.txt \ && cd $WORKSPACE \ && python3 ./scripts/dev.py utils install-system-packages

``` -------------------------------- ### Access Specific LidarScan by Index Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/quickstart.md Access a specific LidarScan from an indexed ScanSource using its numerical index. This example shows how to get the 10th scan and the last scan. ```python >>> print(source[10][0].frame_id) ``` ```python >>> print(source[-1][0].frame_id) ``` -------------------------------- ### Initialize and Run Open3d Visualizer Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/visualizations.md This snippet shows how to initialize the Open3d visualizer, add point cloud and coordinate axes geometries, configure rendering options, set up the camera, and run the visualization loop. It requires Open3d to be installed. ```python import open3d as o3d import numpy as np # Assuming xyz is a numpy array with shape (N, 3) containing point cloud data # and source is an opened file handle for a pcap file. # create point cloud and coordinate axes geometries cloud = o3d.geometry.PointCloud( o3d.utility.Vector3dVector(xyz.reshape((-1, 3)))) # type: ignore axes = o3d.geometry.TriangleMesh.create_coordinate_frame( 1.0) # type: ignore # initialize visualizer and rendering options vis = o3d.visualization.Visualizer() # type: ignore vis.create_window() vis.add_geometry(cloud) vis.add_geometry(axes) ropt = vis.get_render_option() ropt.point_size = 1.0 ropt.background_color = np.asarray([0, 0, 0]) # initialize camera settings ctr = vis.get_view_control() ctr.set_zoom(0.1) ctr.set_lookat([0, 0, 0]) ctr.set_up([1, 0, 0]) # run visualizer main loop print("Press Q or Escape to exit") vis.run() vis.destroy_window() source.close() ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Installs the Homebrew package manager on macOS, a prerequisite for installing other dependencies. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Verify Doxygen Installation (Linux) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Checks the installed version of Doxygen after manual installation or system update. ```bash doxygen --version ``` -------------------------------- ### Verify ouster-sdk installation on Linux/macOS Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/installation.md Check if the ouster-sdk package is successfully installed by listing all installed Python packages. Look for 'ouster-sdk' in the output. ```bash python3 -m pip list ``` -------------------------------- ### Visualize Sample Data with ouster-cli Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/sample-data.md Use this command to visualize downloaded `.pcap` data with associated `.json` metadata. Ensure you have the ouster-sdk installed. ```bash $ ouster-cli source [--meta $SAMPLE_DATA_JSON_PATH] $SAMPLE_DATA_PCAP_PATH viz ``` -------------------------------- ### Install KISS-ICP Python Package Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/thirdparty/kiss-icp/README.md Install the KISS-ICP Python package using pip. After installation, you can run the pipeline using the `kiss_icp_pipeline` command. ```sh pip install kiss-icp ``` ```sh kiss_icp_pipeline --help ``` -------------------------------- ### Verify ouster-sdk installation on Windows x64 Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/installation.md Check if the ouster-sdk package is successfully installed by listing all installed Python packages. Look for 'ouster-sdk' in the output. ```powershell PS > py -3 -m pip list ``` -------------------------------- ### Build Lidar Scan and Representations Examples Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/CMakeLists.txt Creates executables for lidar_scan_example and representations_example, linking them with ouster_client and ouster_pcap. Includes CI tests if RUN_CI_EXAMPLES is enabled. ```cmake if(TARGET OusterSDK::ouster_pcap) add_executable(lidar_scan_example lidar_scan_example.cpp helpers.cpp) target_link_libraries(lidar_scan_example PRIVATE OusterSDK::ouster_client OusterSDK::ouster_pcap) if(RUN_CI_EXAMPLES) add_test(NAME lidar_scan_example COMMAND lidar_scan_example ${EXAMPLE_PCAP} ${EXAMPLE_JSON}) endif() add_executable(representations_example representations_example.cpp helpers.cpp) target_link_libraries(representations_example PRIVATE OusterSDK::ouster_client OusterSDK::ouster_pcap) if(RUN_CI_EXAMPLES) add_test(NAME representations_example COMMAND representations_example ${EXAMPLE_PCAP} ${EXAMPLE_JSON}) endif() else() message(STATUS "No ouster_pcap library available; skipping examples") endif() ``` -------------------------------- ### Build OSF Reader and Writer Examples Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/examples/CMakeLists.txt Defines executables for osf_reader_example and osf_writer_example, linking them with the ouster_osf library. Includes CI tests if RUN_CI_EXAMPLES is enabled. ```cmake if(TARGET OusterSDK::ouster_osf) add_executable(osf_reader_example osf_reader_example.cpp) target_link_libraries(osf_reader_example PRIVATE OusterSDK::ouster_osf) if(RUN_CI_EXAMPLES) add_test(NAME osf_reader_example COMMAND osf_reader_example ${EXAMPLE_OSF}) endif() add_executable(osf_writer_example osf_writer_example.cpp) target_link_libraries(osf_writer_example PRIVATE OusterSDK::ouster_osf) if(RUN_CI_EXAMPLES) add_test(NAME osf_writer_example COMMAND osf_writer_example test_output.osf) endif() else() message(STATUS "No ouster_osf library available; skipping examples") endif() ``` -------------------------------- ### View SLAM Command Help Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cli/mapping-sessions.md Displays available options for configuring the SLAM algorithm parameters. ```bash ouster-cli source / slam --help ``` -------------------------------- ### Install macOS Dependencies with brew Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/building.md Install required build dependencies on macOS using Homebrew. ```bash brew install cmake pkg-config eigen curl libtins glfw libpng flatbuffers libomp ceres-solver robin-map openssl@3 tbb zstd libzip zlib ``` -------------------------------- ### Verify Installation Versions (Windows) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Checks the installed versions of CMake, Doxygen, Clang, Clang-Tidy, and Clang-Format in a Windows terminal. ```powershell cmake --version doxygen --version clang --version clang-tidy --version clang-format --version ``` -------------------------------- ### Build Ouster C++ SDK with CMake Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/cpp/building.md Standard commands to configure and build the Ouster C++ SDK and its examples using CMake. Ensure you replace `` with the actual path to the source directory. ```bash mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON cmake --build . -- -j$(nproc) ``` -------------------------------- ### Install Ouster PCAP Target and Headers Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/ouster_pcap/CMakeLists.txt Installs the ouster_pcap library target and its associated header files to the appropriate locations. ```cmake install(TARGETS ouster_pcap EXPORT ouster-sdk-targets RUNTIME DESTINATION bin INCLUDES DESTINATION include) install(DIRECTORY include/ouster DESTINATION include) ``` -------------------------------- ### Install Ouster SDK Dependencies on macOS Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/devel.md Install required dependencies for building the Ouster SDK on macOS using Homebrew. ```bash $ brew install cmake pkg-config eigen curl libtins glfw libpng flatbuffers libomp ceres-solver robin-map openssl@3 tbb zstd libzip zlib ``` -------------------------------- ### Install macOS Dependencies with Homebrew Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Installs core development dependencies like bison, pkg-config, and flex using Homebrew on macOS. ```bash brew install bison pkg-config flex ``` -------------------------------- ### Getting Sensor Count via `sensor_info` Length Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/migration/migration-0.14.0-0.15.0.md The `ScanSource.sensors_count` attribute is deprecated. Use `len(ScanSource.sensor_info)` to get the number of sensors. ```python # Old code: num_sensors = scan_source.sensors_count # New code: num_sensors = len(scan_source.sensor_info) ``` -------------------------------- ### Run Visualizer with PCAP Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/visualizations.md Launches the Ouster visualizer with a pcap file. Optionally include metadata for richer visualization. ```bash $ ouster-cli source $SAMPLE_DATA_PCAP_PATH [--meta $SAMPLE_DATA_JSON_PATH] viz ``` -------------------------------- ### Install macOS Development Tools with Homebrew Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/scripts/README.rst Installs CMake, Doxygen, LLVM (including clang tools), and Infer on macOS using Homebrew. ```bash brew install cmake doxygen llvm infer ``` -------------------------------- ### Zone Monitor Emulation Setup (Python) Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/reference/zone_monitor.md Initialize the Zone Monitor emulator in Python. This feature allows testing Zone Monitor configurations without a physical sensor. Note: C++ SDK does not currently support emulation. ```python import numpy as np from ouster.sdk import open_source from ouster.sdk.core import FieldClass from ouster.sdk.zone_monitor import EmulatedZoneMon, ZoneSet source = open_source(args.source) if not args.zone_set: zone_set = source.sensor_info[0].zone_set assert zone_set is not None, "Sensor does not have a ZoneSet configured" else: zone_set = ZoneSet(args.zone_set) zone_set.render(source.sensor_info[0]) emulator = EmulatedZoneMon(zone_set) emulator.live_zones = [0, 1, 2, 3] ``` -------------------------------- ### Run Visualizer with Sensor Source: https://github.com/ouster-lidar/ouster-sdk/blob/master/docs/python/examples/visualizations.md Launches the Ouster visualizer with a live sensor. This command auto-configures the UDP destination for the sensor. ```bash $ ouster-cli source $SENSOR_HOSTNAME viz ```