### Run Python Script Example with PDM Source: https://github.com/zabertech/zaber-examples/blob/main/examples/_template/README.md This sequence of bash commands demonstrates how to navigate to an example directory, install dependencies using PDM, and then execute the main script defined in pyproject.toml using PDM's run command. ```bash cd src/ pdm install --dev pdm run ``` -------------------------------- ### Running Zaber Motion Tracking Example (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_tracking/README.md Provides the shell commands required to execute the motion tracking example script after installing dependencies and configuring the serial port. It assumes `pdm` is installed and the current directory is the project root. ```shell cd examples/motion_tracking/ pdm install pdm run example ``` -------------------------------- ### Run ZML Script with PDM Source: https://github.com/zabertech/zaber-examples/blob/main/examples/util_pyinstaller/README.md These commands navigate to the example directory, install project dependencies using `pdm install`, and then execute the main script (`main.py`) using `pdm run example`. This sequence sets up the necessary environment and runs the script directly from the source code within the virtual environment managed by pdm. ```shell cd examples/util_pyinstaller/ pdm install pdm run example ``` -------------------------------- ### Running the Tiling Script with PDM Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_tiling_basler_camera/README.md Provides the necessary shell commands to change directory to the script location, install project dependencies using pdm, and execute the main example script. ```Shell cd src/microscope_tiling_basler_camera/ pdm install pdm run example ``` -------------------------------- ### Installing Node.js dependencies (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Installs the Node.js dependencies required by the `check_examples` script, specifically `markdownlint-cli2`. This command should be run in the script's directory after navigating there. ```Shell npm install ``` -------------------------------- ### Install pipenv for Python Example Source: https://github.com/zabertech/zaber-examples/blob/main/examples/hid_joystick/README.md Installs or updates the `pipenv` tool using the Python executable. `pipenv` is used to manage the virtual environment and dependencies for the Python example. ```Shell py -m pip install -U pipenv ``` -------------------------------- ### Running Zaber Stage GUI (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_pyqt6/README.md Provides the shell commands required to navigate to the example directory, install project dependencies using pdm, and execute the main Python script to launch the GUI. Ensure pdm is installed and configured. ```Shell cd examples/gui_pyqt6/ pdm install pdm run example ``` -------------------------------- ### Installing Python development dependencies (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Installs the Python dependencies specified in the `pyproject.toml` file for the `check_examples` script, including development dependencies. This command uses PDM to manage the virtual environment and packages. ```Shell pdm install --dev ``` -------------------------------- ### Install Python Dependencies with Pipenv Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Installs the necessary Python packages for the project using pipenv, based on the `Pipfile`. Run this command once before starting the server. ```shell python3 -m pipenv install ``` -------------------------------- ### Install Python Dependencies with PDM Source: https://github.com/zabertech/zaber-examples/blob/main/examples/_template/README.md This bash command uses the PDM package manager to install the project's dependencies, including development dependencies, as specified in the pyproject.toml file. ```bash pdm install --dev ``` -------------------------------- ### Installing PDM Dependencies (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Command to install all dependencies, including development dependencies, specified in the pyproject.toml using PDM. ```Shell pdm install --dev ``` -------------------------------- ### Running OpenCV Stitching Example (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_tiling_basler_camera/README.md This command executes the provided stitching example script using the PDM package manager. It loads example tile images from `./img/example_tiles`, runs the OpenCV stitcher with the default configuration, and saves the newly stitched file as `stitching_example.png`. ```Shell pdm run stitching-example ``` -------------------------------- ### Run Python Joystick Control Script Source: https://github.com/zabertech/zaber-examples/blob/main/examples/hid_joystick/README.md Navigates to the Python example directory, installs project dependencies using `pipenv`, and then executes the main Python script (`scanning.py`) within the `pipenv` virtual environment. ```Shell cd src/microplate-scanning-basic/python pipenv install pipenv run python scanning.py ``` -------------------------------- ### Installing Pipenv on Mac (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Recommended command to install Pipenv using Homebrew on macOS. ```Shell brew install pipenv ``` -------------------------------- ### Running Zaber Motion Input Shaping Examples Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_input_shaping/README.md This shell script demonstrates how to navigate to the example directory, install dependencies using pipenv, and execute the main Python demo scripts for input shaping and vibration measurement. ```Shell cd src/motion_input_shaping pipenv install pipenv run python shaping_demo.py pipenv run python measure_vibration_demo.py pipenv run python shaping_comparison_demo.py ``` -------------------------------- ### Build ZML Executable (Linux/macOS) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/util_pyinstaller/README.md These commands navigate to the example directory, install project dependencies using `pdm install`, and then execute the shell script `build.sh`. The `build.sh` script contains the PyInstaller command tailored for Linux or macOS to create the standalone executable for the Zaber Motion Library script on these platforms. ```shell cd examples/util_pyinstaller/ pdm install ./build.sh ``` -------------------------------- ### Installing Pipenv on Windows (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Recommended command to install or upgrade Pipenv using pip for the current user on Windows. ```Shell py -m pip install --user --upgrade pipenv ``` -------------------------------- ### Setting up Python Environment with Pipenv Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_focus_map/README.md These commands set up the Python virtual environment using pipenv, navigate to the project directory, and install the necessary dependencies listed in the Pipfile. ```Shell python3 -m pip install -U pipenv ``` ```Shell cd src/microscope_focus_map ``` ```Shell pipenv install ``` -------------------------------- ### Installing Pipenv on Linux (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Recommended command to install or upgrade Pipenv using pip for the current user on Linux. ```Shell python3 -m pip install --user --upgrade pipenv ``` -------------------------------- ### Build ZML Executable (Windows) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/util_pyinstaller/README.md These commands navigate to the example directory, ensure dependencies are installed using `pdm install`, and then execute the Windows batch file `build.bat`. The `build.bat` script typically contains the PyInstaller command to create the standalone executable for the Zaber Motion Library script on Windows. ```shell cd examples/util_pyinstaller/ pdm install .\build.bat ``` -------------------------------- ### Installing pdm via pip (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Installs or upgrades the PDM (Python Development Manager) tool globally for the current user using pip. PDM is required for managing Python dependencies and virtual environments for the script. ```Shell pip install --user --upgrade pdm ``` -------------------------------- ### Initializing PDM Project (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Command to initialize a new PDM project in a directory, creating necessary files like pyproject.toml. ```Shell pdm init ``` -------------------------------- ### Checking all examples (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Executes the `check_examples` script via PDM to perform checks on all example directories within the project. This command runs the full suite of checks. ```Shell pdm check all ``` -------------------------------- ### Displaying check script help (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Shows the usage options and available commands for the `check_examples` script when executed via PDM. This is useful for understanding how to use the script with different arguments. ```Shell pdm check --help ``` -------------------------------- ### Running the COM Port Scan Script with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/util_com_port_scan/README.md Provides the necessary shell commands to execute the COM port scanning script. It includes changing the directory to the script's location, installing project dependencies using PDM, and running the main example script. ```shell cd examples/util_com_port_scan/ pdm install pdm run example ``` -------------------------------- ### Setting up Environment with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/self_test_direct_encoder_stage/README.md Navigates to the project directory and installs the necessary dependencies using the PDM package manager. ```shell cd examples/self_test_direct_encoder_stage/ pdm install ``` -------------------------------- ### Configure Script Entry Point in pyproject.toml (TOML) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/_template/python_pdm/README.md Manually adds a script entry point configuration to the pyproject.toml file under the [tool.pdm.scripts] section, mapping the 'hello' command to the 'main' function in 'src.python_pdm.hello'. ```TOML [tool.pdm.scripts] hello = {call = "src.python_pdm.hello:main"} ``` -------------------------------- ### Checking a specific example (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Executes the `check_examples` script via PDM to perform checks on a single, specified example directory. Replace `` with the name of the target example directory. ```Shell pdm check ``` -------------------------------- ### Initialize PDM Project (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/_template/python_pdm/README.md Initializes a new PDM project in the current directory, creating necessary configuration files like pyproject.toml. ```Shell pdm init ``` -------------------------------- ### Cloning the Zaber Examples Repository Source: https://github.com/zabertech/zaber-examples/blob/main/README.md This command clones the Zaber community code examples repository from GitHub to your local machine, allowing you to access and use the code examples. ```Shell git clone https://github.com/zabertech/zaber-examples.git ``` -------------------------------- ### Navigate to Calibration Example Directory (Interactive) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Changes the current directory to the location of the 2D calibration example scripts before running the interactive version. ```Shell cd examples/calibration_2d ``` -------------------------------- ### Navigating to script directory (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Changes the current directory to the location of the `check_examples` script within the project structure. This is necessary before installing Node.js and Python dependencies for the script itself. ```Shell cd tools/check_examples ``` -------------------------------- ### Add Production Dependency with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/_template/python_pdm/README.md Adds the 'zaber-motion' package as a production dependency to the PDM project, updating pyproject.toml and installing the package. ```Shell pdm add zaber-motion ``` -------------------------------- ### Run Configured Script with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/_template/python_pdm/README.md Executes the script configured with the name 'hello' in the pyproject.toml file using the PDM run command. ```Shell pdm run hello ``` -------------------------------- ### Install Project Dependencies (Interactive) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Installs the project dependencies listed in the Pipfile using pipenv for the interactive script. ```Shell pipenv install ``` -------------------------------- ### Listing examples to be checked (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Executes the `check_examples` script via PDM to list the example directories that would be included in a check run. This helps in understanding the scope of the check command. ```Shell pdm check list ``` -------------------------------- ### Navigate to Calibration Example Directory Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Changes the current directory to the location of the 2D calibration example scripts. ```Shell cd examples/calibration_2d ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Installs the project dependencies listed in the Pipfile using pipenv within a virtual environment. ```Shell pipenv install ``` -------------------------------- ### Example Directory Name: Microplate Scanning Basic Source: https://github.com/zabertech/zaber-examples/blob/main/docs/example-subdirectory-naming.md An example of a subdirectory name following the `_` convention, using the 'microplate' category and 'scanning_basic' as the example name. This demonstrates how the example name part can also contain underscores. ```Directory Naming microplate_scanning_basic ``` -------------------------------- ### Run Basic Bilinear Calibration Demo Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Executes the non-interactive calibration script specifically for the basic bilinear interpolation example. ```Shell pipenv run python calibrate.py basic ``` -------------------------------- ### Selecting COM Port, Protocol, and Camera Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_high_throughput_scanning/README.md Illustrates the initial setup steps in the main script, involving selecting the serial port for device connection and choosing the desired scan protocol and camera configuration defined in the config file. ```Python # Example setup code snippet # from zaber_motion import Library # from config import SERIAL_PORT, PROTOCOL, CAMERAS # Library.enable_device_db_store() # with Library.open_serial_port(SERIAL_PORT) as port: # device_list = port.detect_devices() # # ... further setup using PROTOCOL and CAMERAS ``` -------------------------------- ### Start the Flask Web Server Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Executes the `main.py` Flask application within the pipenv managed environment, starting the web server that controls the Zaber device. ```bash python3 -m pipenv run python main.py ``` -------------------------------- ### Activating Pipenv Shell (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Command to spawn a shell with the Pipenv virtual environment activated, allowing execution of installed packages directly. ```Shell pipenv shell ``` -------------------------------- ### Configuring Pipfile for Older Zaber Motion Library (TOML) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Example Pipfile content showing how to include OS-specific bindings for Zaber Motion Library versions prior to 5.2.0 to ensure cross-platform compatibility. ```TOML [packages] zaber-motion = "*" zaber-motion-bindings-darwin = {version = "*", markers = "platform_system == 'Darwin'"} zaber-motion-bindings-windows = {version = "*", markers = "platform_system == 'Windows'"} zaber-motion-bindings-linux = {version = "*", markers = "platform_system == 'Linux'"} ``` -------------------------------- ### Example Directory Name: Microplate Scanning High Speed Source: https://github.com/zabertech/zaber-examples/blob/main/docs/example-subdirectory-naming.md Another example of a subdirectory name following the `_` convention, using the 'microplate' category and 'scanning_high_speed' as the example name. This further illustrates the use of underscores within the example name part. ```Directory Naming microplate_scanning_high_speed ``` -------------------------------- ### Example Directory Name: Microscope Autofocus Source: https://github.com/zabertech/zaber-examples/blob/main/docs/example-subdirectory-naming.md An example of a subdirectory name following the `_` convention, using the 'microscope' category and 'autofocus' example name. This name adheres to the rule of using only lowercase letters and underscores. ```Directory Naming microscope_autofocus ``` -------------------------------- ### Add Development Dependencies with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/_template/python_pdm/README.md Adds development tools like black, pylint, pydocstyle, and mypy as development dependencies to the PDM project. ```Shell pdm add --dev black pylint pydocstyle mypy ``` -------------------------------- ### Checking changed examples (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Executes the `check_examples` script via PDM to perform checks only on example directories that have been changed. This is useful for faster checks during development. ```Shell pdm check changed ``` -------------------------------- ### Repository Directory Structure Overview Source: https://github.com/zabertech/zaber-examples/blob/main/docs/directory-structure.md Visual representation of the main directories and files within the zaber-examples repository, illustrating the hierarchical layout. ```plaintext zabertech/zaber-examples/ │ ├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── .github/ │ └── workflows │ └──check_examples.yml │ ├── docs/ │ ├── CONTRIBUTING.md │ ├── cpp.md │ ├── csharp.md │ ├── directory-structure.md │ ├── example-subdirectory-naming.md │ ├── java.md │ ├── matlab.md │ ├── pull-requests.md │ ├── python.md │ ├── readme-guidelines.md │ ├── typescript.md │ ├── virtual-environment.md │ └── img/ │ ├── examples/ │ ├── _template/ │ │ ├── README.md │ │ ├── cpp/ │ │ ├── csharp/ │ │ ├── img/ │ │ ├── javascript/ │ │ ├── python_pdm/ │ │ └── python_pipenv/ │ │ │ ├── categoryname1_example_name1/ │ ├── categoryname1_example_name2/ │ ├── category_name2_another_example/ │ ├── ... │ └── _/ │ ├── README.md │ ├── csharp/ │ │ ├── ... │ │ └── ... │ ├── img/ │ └── python/ │ ├── Pipfile │ ├── Pipfile.lock │ └── main.py │ └── tools/ └── check_examples ├── README.md ├── check.py └── ... ``` -------------------------------- ### Linting documentation markdown files (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Executes the `check_examples` script via PDM to specifically lint all markdown files located in the `/docs/` subdirectory using `markdownlint-cli2`. ```Shell pdm check docs ``` -------------------------------- ### Adding Zaber Motion Library with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Command to add the zaber-motion package as a production dependency using PDM. ```Shell pdm add zaber-motion ``` -------------------------------- ### Install pipenv dependency Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_input_shaping/README.md This command uses the Python package installer, pip, to install or update pipenv globally. Pipenv is used in this project to manage the virtual environment and project dependencies listed in the Pipfile. ```sh python3 -m pip install -U pipenv ``` -------------------------------- ### Run Microplate Scanning Script with pipenv Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microplate_scanning_basic/README.md These commands navigate to the script directory, install the project dependencies listed in Pipfile using pipenv, and then execute the main Python script within the managed virtual environment. ```Shell cd src/microplate_scanning_basic pipenv install pipenv run python scanning.py ``` -------------------------------- ### Running the PVT Sequence Generation Script (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Navigates to the script directory, installs project dependencies using pipenv, and then executes the `generate_pvt_sequence.py` script within the pipenv virtual environment. ```Shell cd src/pvt_parameter_generation pipenv install pipenv run python generate_pvt_sequence.py ``` -------------------------------- ### Install pipenv Dependency Manager Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microplate_scanning_basic/README.md This command installs or upgrades pipenv, which is used to manage the virtual environment and project dependencies for the microplate scanning script. ```Shell python3 -m pip install -U pipenv ``` -------------------------------- ### Running default check command (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Executes the default check command defined in the `pyproject.toml` file for the `check_examples` script. This is typically the main entry point for running the script's checks. ```Shell pdm check ``` -------------------------------- ### Install Pipenv Dependency Manager Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Installs or updates the pipenv package manager using pip, which is required to manage the project's virtual environment and dependencies. ```Shell python3 -m pip install -U pipenv ``` -------------------------------- ### Running PDM Script (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Command to execute a script defined in the [scripts] section of pyproject.toml using PDM. ```Shell pdm run ``` -------------------------------- ### Adding Development Dependencies with Pipenv (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Command to add common development tools (linters, type checker) as development dependencies using Pipenv. ```Shell pipenv install --dev black pylint pydocstyle mypy ``` -------------------------------- ### Adding Focus Logic in Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_tiling_basler_camera/README.md Illustrates the location within the image capture loop where custom focus adjustment logic can be inserted, using the current x, y coordinates. ```Python # ... for idx_x, point in enumerate(grid_row): plate.move_absolute( Measurement(point[0], Units.LENGTH_MICROMETRES), Measurement(point[1], Units.LENGTH_MICROMETRES), ) # focus objective here given x, y coordinates here # ... ``` -------------------------------- ### Adding Development Dependencies with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python-virtual-environment.md Command to add common development tools (linters, type checker) as development dependencies using PDM. ```Shell pdm add --dev black pylint pydocstyle mypy ``` -------------------------------- ### Launching QT Designer (Linux/MacOS Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_pyqt6/README.md Command to launch the QT Designer application from the virtual environment on Linux or MacOS. This tool is used for visually editing the user interface file (`ui_raw.ui`). Requires PyQt6-tools to be installed. ```Shell .venv/bin/pyqt6-tools designer ``` -------------------------------- ### Installing pipenv Dependency (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Installs or updates the `pipenv` package manager using pip for Python 3. This is required to manage the project's virtual environment and dependencies listed in the Pipfile. ```Shell python3 -m pip install -U pipenv ``` -------------------------------- ### Creating Permanent GitHub Code Snippet Link (Markdown) Source: https://github.com/zabertech/zaber-examples/blob/main/docs/readme-guidelines.md This snippet demonstrates the correct format for creating a permanent link to a specific range of lines within a file on GitHub. It emphasizes using a specific commit hash instead of a branch name and enclosing the URL in angle brackets. ```Markdown ``` -------------------------------- ### Test ZML Executable (Linux/macOS) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/util_pyinstaller/README.md This command executes the standalone application `main` located in the `dist` directory. This executable was previously built using PyInstaller for Linux or macOS and includes the Python script and necessary dependencies, allowing it to be run without a separate Python installation or virtual environment. ```shell ./dist/main ``` -------------------------------- ### Test ZML Executable (Windows) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/util_pyinstaller/README.md This command executes the standalone application `main.exe` located in the `dist` directory. This executable was previously built using PyInstaller and includes the Python script and necessary dependencies, allowing it to be run without a separate Python installation or virtual environment. ```shell .\dist\main.exe ``` -------------------------------- ### Launching QT Designer (Windows Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_pyqt6/README.md Command to launch the QT Designer application from the virtual environment on Windows. This tool is used for visually editing the user interface file (`ui_raw.ui`). Requires PyQt6-tools to be installed. ```Shell .venv\Scripts\pyqt6-tools.exe designer ``` -------------------------------- ### Linting the check script itself (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/tools/check_examples/README.md Executes the `check_examples` script via PDM to perform linting or checks on the script's own source code. This ensures the script itself adheres to coding standards. ```Shell pdm check self ``` -------------------------------- ### Executing the Scan Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_high_throughput_scanning/README.md Describes calling the `execute_scan` function to initiate the scanning process. This function moves the stage to the defined origin and starts executing the buffered motion instructions to scan the sample. ```Python # Example function call to start the scan # execute_scan() ``` -------------------------------- ### Initializing pvt.Segment in Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Create a pvt.Segment instance by specifying the start and end pvt.Point objects. This class represents a continuous trajectory between the two points and allows sampling position, velocity, or acceleration at intermediate times. ```python segment = pvt.Segment(point4, point5) ``` -------------------------------- ### Generate PVT Sequence from Velocity-Time Data - Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Illustrates the use of the static method `pvt.Sequence.generate_positions` to initialize a PVT sequence from lists of time and velocity data. The method generates positions, aiming for continuous acceleration. Start and end velocities are assumed zero if not specified. ```python time = [0, 1, 2] velocities = [4, 5, 6] sequence = pvt.Sequence.generate_positions(time, velocities) ``` -------------------------------- ### Generate PVT Sequence from Position-Time Data - Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Demonstrates how to create a PVT sequence instance using the static method `pvt.Sequence.generate_velocities`. This method takes lists of time and position data and generates corresponding velocities, ensuring continuous acceleration at segment transitions. Velocities at the start and end points are set to zero if not explicitly provided. ```python time = [0, 1, 2] position = [4, 5, 6] sequence = pvt.Sequence.generate_velocities(time, position) ``` -------------------------------- ### Run Non-Interactive Calibration Script Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Executes the main non-interactive calibration script using pipenv, demonstrating the algorithm and visualization. ```Shell pipenv run python calibrate.py ``` -------------------------------- ### Create Desktop Entry for Client App Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Configures a `.desktop` file to add the web client application to the Raspbian menu. It launches the client in fullscreen mode using Chromium browser. ```ini [Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Terminal=false Exec=/usr/bin/chromium-browser --app=http://localhost:8080 --start-fullscreen Name=Move Client ``` -------------------------------- ### Create Desktop Entry for Server App Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Configures a `.desktop` file to add the server application to the Raspbian menu. It runs the Python server in a terminal window using pipenv. Remember to update the `Path` to your project directory. ```ini [Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Terminal=true Exec=python3 -m pipenv run python main.py Path=/home/zaber/code/gui_raspberrypi_touch Name=Move Server ``` -------------------------------- ### Running the Focus Map Script Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_focus_map/README.md This command executes the main Python script 'focus_map.py' within the pipenv virtual environment. Optional arguments can be added to specify the number of points. ```Shell pipenv run python focus_map.py ``` -------------------------------- ### Build ZML Script with PyInstaller (Windows) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/util_pyinstaller/README.md This command uses PyInstaller to package the `main.py` script into a single executable (`--onefile`). It explicitly includes the Zaber Motion Library Windows DLL (`zaber-motion-core-windows-amd64.dll`) as a binary dependency, placing it in the `zaber_motion_bindings` directory within the executable bundle. This is crucial for the packaged application to find and load the ZML core library. ```ps1 pyinstaller --onefile --add-binary ".venv\Lib\site-packages\zaber_motion_bindings\zaber-motion-core-windows-amd64.dll;zaber_motion_bindings" main.py ``` -------------------------------- ### Run Interactive Calibration Script Source: https://github.com/zabertech/zaber-examples/blob/main/examples/calibration_2d/README.md Executes the interactive calibration script using pipenv, connecting to Zaber devices via the specified serial port (e.g., COM1). ```Shell pipenv run python interactive.py COM1 ``` -------------------------------- ### Open Web Client in Chromium Browser Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Launches the web interface in Chromium browser's app mode, providing the user interface to interact with the Zaber device via the running server. ```bash chromium-browser --app=http://localhost:8080 ``` -------------------------------- ### Configuring Scan Protocol and Camera Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_high_throughput_scanning/README.md Describes how to configure scan parameters like sample dimensions, position, magnification, scan mode (TDI, area, continuous), and camera details by editing the `config.py` file. This involves setting the serial port and defining scan protocol and camera specifications. ```Python # Example configuration settings in config.py # SERIAL_PORT = '/dev/ttyUSB0' # PROTOCOL = 'TDI' # CAMERAS = { # 'BFS-200S6C-M': { # 'pixel_size_um': 3.45, # 'sensor_height_px': 2048, # 'max_fps': 240 # } # } ``` -------------------------------- ### Format Python Code with Black Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python.md Command to run the Black code formatter with an overridden line length of 100 characters on a specified Python file to ensure consistent code style. ```Shell black -l100 ``` -------------------------------- ### Check Python Docstrings with Pydocstyle Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python.md Command to run Pydocstyle on a Python file to check compliance with docstring conventions, particularly those outlined in PEP 257, ensuring documentation readability. ```Shell pydocstyle ``` -------------------------------- ### Initializing ShapedAxis and Plant (Python) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_input_shaping/README.md This code demonstrates how to create instances of the Plant and ShapedAxis classes. The Plant instance is configured with the target vibration's resonant frequency and damping ratio. The ShapedAxis instance is initialized with an Axis or Lockstep object and the configured Plant instance. ```Python plant = Plant(resonant_frequency, damping_ratio) shaped_axis_var = ShapedAxis(axis, plant) ``` -------------------------------- ### Initialize Geometric Path - Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Shows how to create an instance of the `pvt.GeometricPath` class. The constructor requires an array (list) of position sequences, where each inner list corresponds to the positions along a specific dimension, defining an N-D path. ```python x_positions = [1, 2, 3] y_positions = [4, 5, 6] path = pvt.GeometricPath([x_positions, y_positions]) ``` -------------------------------- ### Importing PVT Helper Module (Python) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Imports the `pvt.py` file as a module, making its classes and functions available under the `pvt` namespace. This is necessary to use the helper utilities for creating and manipulating PVT sequences. ```Python import pvt ``` -------------------------------- ### Initializing pvt.Sequence from Points in Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Initialize a pvt.Sequence instance by providing a list of pvt.Point objects. This creates a continuous path by defining segments between consecutive points. ```python sequence = pvt.Sequence([point1, point2, point3, point4, point5]) ``` -------------------------------- ### Initializing Plant and ShapedAxisStream Classes (Python) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_input_shaping/README.md Creates an instance of the `Plant` class specifying the target resonant frequency and damping ratio. Then, initializes the `ShapedAxisStream` class instance, linking it to a Zaber `Axis` or `Lockstep` instance, the `plant` object, a shaper type (defaulting to ZV), and an optional stream ID. ```Python plant = Plant(resonant_frequency, damping_ratio) shaped_axis_var = ShapedAxisStream(axis, plant, ShaperType.ZV, stream_id) ``` -------------------------------- ### Lint Python Code with Pylint Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python.md Command to execute the Pylint static code analyzer with its default configuration on a specific Python file to identify errors, enforce coding standards, and detect code smells. ```Shell pylint ``` -------------------------------- ### Initializing Zaber Microscope and Camera (Python) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_autofocus/README.md This snippet initializes the connection to the Zaber microscope via a specified serial port and connects to the Teledyne FLIR camera using the Simple Pyspin library. It establishes communication channels required for controlling the Z-axis motor and capturing images. ```Python import zaber_motion.serial as zm_serial import simple_pyspin connection = zm_serial.Connection.open_serial_port(microscope_serial_port) device_list = connection.detect_devices() z_axis = device_list[0].get_axis(1) # Assuming Z axis is axis 1 cam = simple_pyspin.Camera() cam.init() ``` -------------------------------- ### Import Visualization Functions - Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Provides the standard Python import statement needed to use the plotting functions available in the `visualization.py` file, including `plot_pvt_trajectory`, `plot_pvt_path`, and `plot_path_and_trajectory`. ```python from visualization import plot_pvt_trajectory, plot_pvt_path, plot_path_and_trajectory ``` -------------------------------- ### Initializing pvt.Sequence by Appending Points in Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Alternatively, initialize an empty pvt.Sequence and add points sequentially using the `append_point()` method. This builds the sequence segment by segment. ```python sequence = pvt.Sequence() sequence.append_point(point1) sequence.append_point(point2) sequence.append_point(point3) sequence.append_point(point4) sequence.append_point(point5) ``` -------------------------------- ### Generating Snake Motion Profile Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_high_throughput_scanning/README.md Explains how to call the `generate_snake` function with the chosen protocol and scanning speed to calculate the fastest scan direction and store the necessary motion instructions onto the stage's onboard buffer. ```Python # Example function call to generate motion profile # generate_snake(PROTOCOL, scanning_speed) ``` -------------------------------- ### Generating a Focus Map (Optional) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_high_throughput_scanning/README.md Mentions the `generate_focus_map` function as an extra utility. This function can be used to create a randomized focus map for testing purposes, which can later be replaced by a map generated from a 5-point focus interpolation. ```Python # Example function call to generate a test focus map # generate_focus_map() ``` -------------------------------- ### Type Check Python Code with Mypy Source: https://github.com/zabertech/zaber-examples/blob/main/docs/python.md Command to run the Mypy static type checker with strict configuration on a Python file to verify type hints and catch potential type errors before runtime. ```Shell mypy --strict ``` -------------------------------- ### Initializing pvt.Point in Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Initialize an instance of the pvt.Point class by providing vectors for position and velocity, along with the absolute time. The dimension is automatically inferred from the position vector size. ```python position = [1, 2] velocity = [3, 4] time = 5 point = pvt.Point(position, velocity, time) ``` -------------------------------- ### Initializing pvt.Sequence from Position Data in Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Create a pvt.Sequence from raw position data using the static method `pvt.Sequence.generate_times_and_velocities()`. This method automatically generates time and velocity parameters based on a trapezoidal speed profile. ```python x_positions = [1, 2, 3] y_positions = [4, 5, 6] sequence = pvt.Sequence.generate_times_and_velocities([x_positions, y_positions]) ``` -------------------------------- ### Importing ShapedAxis and Plant Classes (Python) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_input_shaping/README.md This snippet shows the necessary import statements in Python to use the ShapedAxis and Plant classes for input shaping functionality. ```Python from shaped_axis import ShapedAxis from plant import Plant ``` -------------------------------- ### Add Flask Endpoint for Relative Move Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Implements a new Flask route (`/move-1mm`) that handles POST requests. It instructs the horizontal axis of the connected Zaber device to move 1 mm relative to its current position. ```py @app.post("/move-1mm") def move_1mm() -> flask.ResponseReturnValue: """Move by 1 mm.""" device.get_axis(HORIZONTAL_AXIS).move_relative(1, "mm") return ("", 204) ``` -------------------------------- ### Importing ShapedAxisStream Class and Dependencies (Python) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_input_shaping/README.md Imports the `ShapedAxisStream` class, the `ShaperType` enumeration, and the `Plant` class from their respective modules. These imports are required to initialize and use the `ShapedAxisStream` class for input-shaped moves. ```Python from shaped_axis_stream import ShapedAxisStream from zero_vibration_stream_generator import ShaperType from plant import Plant ``` -------------------------------- ### Add HTML Button for Move Action Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Creates an HTML button element. When the button is pressed, it triggers a JavaScript function `action()` with the argument `'move-1mm'`, intended to call the corresponding server endpoint. ```html ``` -------------------------------- ### Running Accuracy Self Test with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/self_test_direct_encoder_stage/README.md Executes the accuracy self-test script for the configured Zaber DE stage using the PDM run command. ```shell pdm run accuracy ``` -------------------------------- ### Running Settling Time Self Test with PDM (Shell) Source: https://github.com/zabertech/zaber-examples/blob/main/examples/self_test_direct_encoder_stage/README.md Executes the settling-time self-test script for the configured Zaber DE stage using the PDM run command. ```shell pdm run settling-time ``` -------------------------------- ### Initializing pvt.Sequence from CSV in Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/motion_pvt_sequence_generation/README.md Generate a pvt.Sequence directly from data in a CSV file using the static method `pvt.Sequence.from_csv()`. The CSV can contain position, position-time, or position-velocity-time data. ```python sequence = pvt.Sequence.from_csv("sample_data/position_data/spiral_2d.csv") ``` -------------------------------- ### Set Serial Port Environment Variable Source: https://github.com/zabertech/zaber-examples/blob/main/examples/gui_raspberrypi_touch/README.md Configures the `PORT` environment variable, which the server uses to identify the serial port connected to the Zaber device. Update the path to match your system's port. ```bash export PORT=/dev/ttyUSB0 ``` -------------------------------- ### Main Autofocus Scan Loop - Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_autofocus/README.md Implements the primary control loop for the autofocus process. It iterates through a range of positions, captures an image at each step, calculates a focus score, and tracks the position that yields the highest score. ```python best_focus_score = 0 best_focus_position = None # Assume 'axis' is a Zaber device axis object # Assume 'step_size_mm' is defined # Assume 'num_steps' is defined # Assume 'capture_image()' function exists # Assume 'calculate_focus_score(image)' function exists initial_position = axis.get_position() # Or some starting point # Loop through positions for i in range(num_steps): current_position = initial_position + i * step_size_mm axis.move_absolute(current_position) axis.wait_until_idle() image = capture_image() current_score = calculate_focus_score(image) if current_score > best_focus_score: best_focus_score = current_score best_focus_position = current_position # After loop, move to best position if best_focus_position is not None: axis.move_absolute(best_focus_position) axis.wait_until_idle() ``` -------------------------------- ### Calculate Image Focus Score (Variance of Laplacian) - Python Source: https://github.com/zabertech/zaber-examples/blob/main/examples/microscope_autofocus/README.md Calculates a quantitative focus score for a given image using the variance of the Laplacian. This technique is sensitive to edges; a higher variance indicates sharper edges and thus a better focus. ```python import cv2 import numpy as np def calculate_focus_score(image): # Convert to grayscale if not already if len(image.shape) == 3: gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) else: gray = image # Apply filtering (e.g., Gaussian blur) - Optional but often helpful # blurred = cv2.GaussianBlur(gray, (5, 5), 0) # Example filter # Compute the Laplacian # Use CV_64F for higher precision, especially for variance calculation laplacian = cv2.Laplacian(gray, cv2.CV_64F) # Compute the variance of the Laplacian variance = np.var(laplacian) return variance ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.