Walabot API
All you need to know to create a Walabot Application
Walabot Python API Documentation

The Walabot library now supports Python, with its own Python API module for both Python 2 and 3, and makes it incredibly easy to take your first steps in developing Walabot applications. Importing WalabotAPI To use the WalabotAPI module in your Python code, you must import the module. You have two options for this: you can install WalabotAPI as a Python package, or you can import the Python file WalabotAPI.py into your specific script, using its file location.

Installing WalabotAPI as a Package

You must have both Python and pip installed.

On Windows

In the Command Prompt, enter:

python -m pip “C:/Program Files/Walabot/WalabotSDK/python/WalabotAPI-1.0.21.zip”

On Linux

python -m pip “/usr/share/walabot/python/WalabotAPI-1.0.21.tar.gz”

Once you have installed the package, simply import the package in your Python code using: import WalabotAPI

Importing WalabotAPI by Location

It is recommended to use the built-in imp.load_source() to load the module easily.

For Windows

from imp import load_source
WalabotAPI = load_source(‘WalabotAPI’,
‘C:/Program Files/Walabot/WalabotSDK/python/WalabotAPI.py’)

For Linux

from imp import load_source
WalabotAPI = load_source(‘WalabotAPI’,
‘/usr/share/walabot/python/WalabotAPI.py’)

Getting Started

Module Initialization

Before using any other Walabot calls, you must call WalabotAPI.Init(). The Python API is using the ‘low-level’ library for C++ (WalabotAPIWindows.dll on Windows and libWalabotAPI.so on Linux).

In order to direct the Python API to the library you need to use the WalabotAPI.Init() function and pass it the path to the library. Moving the library file is not recommended. In case you do move it, you can pass Init() the new path to the library, e.g.:

WalabotAPI.Init(“C:/MyCode/MyWalabotProject/WalabotAPIWindows.dll”)

Using Walabot Functions

Every function in the C++ API has a corresponding function in the Python API module which is designed to match the Python language flow. It is advised to look at the Python examples to fully understand how to use them. A detailed documentation about all available functions is given below, and can also be found using Python’s help() function.

Calling functions example

As an example, the original Walabot_GetStatus() function which is implemented as such in the C++ example code:

res = Walabot_GetStatus(&appStatus, &calibrationProcess);

Should be written in Python as such:

appStatus, calibrationProcess = WalabotAPI.GetStatus()

Handling Exceptions

Unlike the C++ functions, the functions in Python does not return WALABOT_RESULT. The Python module will raise WalabotError in case it encounters one. You can catch those errors and act accordingly. A table of the possibles WalabotError’s is given below.

WalabotError fields

message: A short generic description of the occurred error. code: The occurred error code, can simplify the debugging process. extended: A code used internally, for Walabot developers. Available Errors And Codes

  • WALABOT_ERR_INVALID_PORT_DEFINITION = 1
  • WALABOT_ERR_TOO_MANY_SAMPLES = 2
  • WALABOT_ERR_RECORDING_THREAD_ALREADY_RUNNING = 3
  • WALABOT_ERR_RECORDING_WITHOUT_APPLY_SETTINGS = 4
  • WALABOT_ERR_READ_WITHOUT_APPLY_SETTINGS = 5
  • WALABOT_ERR_INVALID_PAGE_INDEX = 6
  • WALABOT_ERR_INVALID_TXRX_PAIR = 7
  • WALABOT_ERR_AMBIGUOUS_TXRX_PAIR = 8
  • WALABOT_ERR_PORTGROUP_INDEX_OUT_OF_BOUNDS = 9
  • WALABOT_ERR_RX_PORT_OUT_OF_BOUNDS = 10
  • WALABOT_ERR_NO_DATA = 11
  • WALABOT_ERR_USB_READ_FAILURE = 12
  • WALABOT_PARAMETER_NOT_FOUND = 13
  • WALABOT_OUT_OF_RANGE = 14
  • WALABOT_READONLY_PARAMETER = 15
  • WALABOT_ERR_ARENA_SIZE_TOO_BIG = 16
  • WALABOT_DD_ERR_USB_DEVICE_WENT_DOWN = 17
  • WALABOT_ERR_INVALID_PARAMETER = 18
  • WALABOT_INSTRUMENT_NOT_FOUND = 19
  • WALABOT_BUFFER_TOO_SMALL = 20
  • WALABOT_INVALID_ARRAY_SIZE = 21
  • WALABOT_INVALID_PROFILE = 22
  • WALABOT_ERR_NO_IMAGE = 23
  • WALABOT_ERR_GENERAL = 24
  • WALABOT_ERR_PROTOCOL = 0x00010000
  • WALABOT_ERR_DEVICE_STORAGE = 0x00020000
  • WALABOT_ERR_DB = 0x00030000
  • WALABOT_ERR_USB = 0x00040000
  • WALABOT_ERR_SEQ = 0x00050000
  • WALABOT_ERR_SCHEDULER = 0x00070000
  • WALABOT_ERR_HW_PLAN = 0x00080000
  • WALABOT_ERR_MULTI_CHIP = 0x00090000
  • WALABOT_ERR_REC_PLAN = 0x000A0000
  • WALABOT_ERR_NULL_OBJECT = 0x000B0000
  • WALABOT_ERR_IN_COMPILER = 0x000C0000
  • WALABOT_ERR_IN_INITIALIZATION = 0x000D0000
  • WALABOT_ERR_SETTING_FOLDER = 0x000E0000
  • WALABOT_ERR_LOG = 0x000F0000
  • WALABOT_GENERAL_ERROR = 0x000F0000 + 1

Debugging Example

The following example can be used in order to test that there is a connected Walabot: try:

WalabotAPI.ConnectAny()

except WalabotError as err:

if err.message == WalabotAPI.WALABOT_INSTRUMENT_NOT_FOUND:
print('Please connect your Walabot')

Module ‘Constants’

The C++ enums are available as simply ‘constants’ variables and are corresponding to them. For example: PROF_SENSOR is accessible in Python simply as WalabotAPI.PROF_SENSOR. Available ‘Constants’

  • For APP_PROFILE:
  • PROF_SHORT_RANGE_IMAGING
  • PROF_SENSOR
  • PROF_SENSOR_NARROW
  • For APP_STATUS:
  • STATUS_DISCONNECTED
  • STATUS_CONNECTED
  • STATUS_IDLE
  • STATUS_SCANNING
  • STATUS_CALIBRATING
  • For FILTER_TYPE:
  • FILTER_TYPE_NONE
  • FILTER_TYPE_DERIVATIVE
  • FILTER_TYPE_MTI
  • For TARGET_TYPE:
  • TARGET_TYPE_UNKNOWN
  • TARGET_TYPE_PIPE Custom Types The Python API implements the original C++ structs as namedtuples.
    Available Types AntennaPair:
  • (int) txAntenna
  • (int) rxAntenna ImagingTarget
  • (TARGET_TYPE) type
  • (double) angleDeg
  • (double) xPosCm
  • (double) yPosCm
  • (double) zPosCm
  • (double) widthCm
  • (double) amplitude SensorTarget
  • (double) xPosCm
  • (double) yPosCm
  • (double) zPosCm
  • (double) amplitude Custom Types Example WalabotAPI.GetImagingTargets() function returns a list of ImagingTarget type.
    You can access the width of the first element in this list with targets[0].widthCm. Example Code: InWallApp
    from __future__ import print_function # WalabotAPI works on both Python 2 and 3.
    from sys import platform
    from os import system
    from imp import load_source
    WalabotAPI = load_source('WalabotAPI',
    'C:/Program Files/Walabot/WalabotSDK/bin/Win32/WalabotAPI.py')
    WalabotAPI.Init()
    def PrintSensorTargets(targets):
    system('cls' if platform == 'win32' else 'clear')
    if targets:
    for i, target in enumerate(targets):
    print (('Target #{}:\ntype: {}\nangleDeg: {}\nx: {}\ny: {}\nz: {}'+
    '\nwidth: {}\namplitude: {}\n').format(i + 1, target.type,
    target.angleDeg, target.xPosCm, target.yPosCm, target.zPosCm,
    target.widthCm, target.amplitude))
    else:
    print ('No Target Detected')
    def InWallApp():
    # WalabotAPI.SetArenaX - input parameters
    xArenaMin, xArenaMax, xArenaRes = -3, 4, 0.5
    # WalabotAPI.SetArenaY - input parameters
    yArenaMin, yArenaMax, yArenaRes = -6, 4, 0.5
    # WalabotAPI.SetArenaZ - input parameters
    zArenaMin, zArenaMax, zArenaRes = 3, 8, 0.5
    # Configure Walabot database install location (for windows)
    WalabotAPI.SetSettingsFolder()
    # 1) Connect: Establish communication with walabot.
    WalabotAPI.ConnectAny()
    # 2) Configure: Set scan profile and arena
    # Set Profile - to Short-range.
    WalabotAPI.SetProfile(WalabotAPI.PROF_SHORT_RANGE_IMAGING)
    # Set arena by Cartesian coordinates, with arena resolution
    WalabotAPI.SetArenaX(xArenaMin, xArenaMax, xArenaRes)
    WalabotAPI.SetArenaY(yArenaMin, yArenaMax, yArenaRes)
    WalabotAPI.SetArenaZ(zArenaMin, zArenaMax, zArenaRes)
    # Walabot filtering disable
    WalabotAPI.SetDynamicImageFilter(WalabotAPI.FILTER_TYPE_NONE)
    # 3) Start: Start the system in preparation for scanning.
    WalabotAPI.Start()
    # calibrates scanning to ignore or reduce the signals
    WalabotAPI.StartCalibration()
    while True:
    appStatus, calibrationProcess = WalabotAPI.GetStatus()
    # 5) Trigger: Scan (sense) according to profile and record signals
    # to be available for processing and retrieval.
    WalabotAPI.Trigger()
    # 6) Get action: retrieve the last completed triggered recording
    targets = WalabotAPI.GetImagingTargets()
    rasterImage, sliceDepth, power = WalabotAPI.GetRawImageSlice()
    # print targets found
    PrintSensorTargets(targets)
    # 7) Stop and Disconnect.
    WalabotAPI.Stop()
    WalabotAPI.Disconnect()
    print ('Terminate successfully')
    if __name__ == '__main__':
    InWallApp()