pypozyx API¶
PozyxSerial¶
This also includes the serial helpers you can use to connect to the Pozyx device.
pypozyx.pozyx_serial - contains the serial interface with Pozyx through PozyxSerial.
-
class
pypozyx.pozyx_serial.
PozyxSerial
(port, baudrate=115200, timeout=0.1, write_timeout=0.1, print_output=False, debug_trace=False, show_trace=False, suppress_warnings=False)[source]¶ Bases:
pypozyx.lib.PozyxLib
This class provides the Pozyx Serial interface, and opens and locks the serial port to use with Pozyx. All functionality from PozyxLib and PozyxCore is included.
Parameters: - port (str) – Name of the serial port. On UNIX this will be ‘/dev/ttyACMX’, on Windows this will be ‘COMX’, with X a random number.
- baudrate (optional) – the baudrate of the serial port. Default value is 115200.
- timeout (optional) – timeout for the serial port communication in seconds. Default is 0.1s or 100ms.
- print_output (optional) – boolean for printing the serial exchanges, mainly for debugging purposes
- suppress_warnings (optional) – boolean for suppressing warnings in the Pozyx use, usage not recommended
- debug_trace (optional) – boolean for printing the trace on bad serial init (DEPRECATED)
- show_trace (optional) – boolean for printing the trace on bad serial init (DEPRECATED)
- Example usage:
>>> pozyx = PozyxSerial('COMX') # Windows >>> pozyx = PozyxSerial('/dev/ttyACMX', print_output=True) # Linux and OSX. Also puts debug output on.
- Finding the serial port can be easily done with the following code:
>>> import serial.tools.list_ports >>> print serial.tools.list_ports.comports()[0]
- Putting one and two together, automating the correct port selection with one Pozyx attached:
>>> import serial.tools.list_ports >>> pozyx = PozyxSerial(serial.tools.list_ports.comports()[0])
-
connectToPozyx
(port, baudrate, timeout, write_timeout)[source]¶ Attempts to connect to the Pozyx via a serial connection
-
regFunction
(address, params, data)[source]¶ Performs a register function on the Pozyx, if the address is a register function.
Parameters: - address – Register function address of function to perform.
- params – Parameters for the register function. Has to be ByteStructure-derived object.
- data – Container for the data the register function returns. Has to be ByteStructure-derived object.
Returns: POZYX_SUCCESS, POZYX_FAILURE
-
regRead
(address, data)[source]¶ Reads data from the Pozyx registers, starting at a register address, if registers are readable.
Parameters: - address – Register address to start writing at.
- data – Data to write to the Pozyx registers. Has to be ByteStructure-derived object.
Returns: POZYX_SUCCESS, POZYX_FAILURE
-
regWrite
(address, data)[source]¶ Writes data to the Pozyx registers, starting at a register address, if registers are writable.
Parameters: - address – Register address to start writing at.
- data – Data to write to the Pozyx registers. Has to be ByteStructure-derived object.
Returns: POZYX_SUCCESS, POZYX_FAILURE
-
serialExchange
(s)[source]¶ Auxiliary. Performs a serial write to and read from the Pozyx.
Parameters: s – Serial message to send to the Pozyx Returns: - Serial message the Pozyx returns, stripped from ‘D,’ at its start
- and NL+CR at the end.
-
waitForFlag
(interrupt_flag, timeout_s, interrupt=None)[source]¶ Waits for a certain interrupt flag to be triggered, indicating that that type of interrupt occured.
Parameters: - interrupt_flag – Flag indicating interrupt type.
- timeout_s – time in seconds that POZYX_INT_STATUS will be checked for the flag before returning POZYX_TIMEOUT.
- Kwargs:
- interrupt: Container for the POZYX_INT_STATUS data
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
pypozyx.pozyx_serial.
get_first_pozyx_serial_port
()[source]¶ Returns the first encountered Pozyx serial port’s identifier
-
pypozyx.pozyx_serial.
get_port_object
(device)[source]¶ Returns the PySerial port object from a given port path
-
pypozyx.pozyx_serial.
get_pozyx_ports
()[source]¶ Returns the Pozyx serial ports. Windows only. Needs driver installed
-
pypozyx.pozyx_serial.
get_pozyx_ports_windows
()[source]¶ Returns the Pozyx serial ports. Windows only. Needs driver installed
-
pypozyx.pozyx_serial.
is_correct_pyserial_version
()[source]¶ Returns whether the pyserial version is supported
Functions¶
Do a split like in the current library documentation here?
pypozyx.lib - Contains core and extended Pozyx user functionality through the PozyxLib class.
-
class
pypozyx.lib.
PozyxLib
[source]¶ Bases:
pypozyx.core.PozyxCore
Implements the functionality users expect from Pozyx, using the methods from PozyxCore to communicate and interface with Pozyx both locally and remotely. This does not limit itself to positioning, ranging, and reading the sensor data of the various Pozyx sensors, but also features an assortment of troubleshooting functions, abstractions of frequently used registers, UWB settings, etc.
Unlike the Arduino library, this isn’t divided into parts such as ‘device functions’, ‘system functions’, etc, but will be in the future. For now, the Arduino library should work as a great reference.
-
addDevice
(device_coordinates, remote_id=None)[source]¶ Adds a device to the Pozyx’s device list. Can be either a tag or anchor.
Parameters: - device_coordinates – Device’s ID, flag, and coordinates structure. DeviceCoordinates(ID, flag, Coordinates(x, y, z)) or [ID, flag, x, y, z]
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
changeDeviceCoordinates
(device_id, new_coordinates, remote_id=None)[source]¶ Changes a device’s coordinates in the Pozyx’s device list, keeping the rest of the list intact
Parameters: - device_id – ID that needs to be removed. NetworkID or integer.
- new_coordinates – new coordinates for the device
- remote_id (optional) – Remote Pozyx ID
Returns: POZYX_SUCCESS, POZYX_FAILURE
-
checkForFlagFast
(interrupt_flag, timeout_s, interrupt=None)[source]¶ A fast variant of checkForFlag, using waitForFLagFast, useful for ranging on very fast UWB settings.
Parameters: - interrupt_flag – Flag of interrupt type to check the interrupt register against.
- timeout_s – duration to wait for the interrupt in seconds
- interrupt (optional) – Container for the interrupt status register data.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
clearConfiguration
(remote_id=None)[source]¶ Clears the Pozyx’s flash memory.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
clearDevices
(remote_id=None)[source]¶ Clears the Pozyx’s device list.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
configInterruptPin
(pin_number=0, mode=0, active_high=False, latch=False, remote_id=None)[source]¶ Configures the interrupt pin via the PozyxRegisters.INTERRUPT_PIN register.
Parameters: - pin_number (optional) – The Pozyx’s pin ID. 1 to 4 on anchor, 1 to 6 on tag. 0 means no pin. SingleRegister or integer.
- mode (optional) – Push-pull (0) or pull (1). SingleRegister or integer. SingleRegister or integer.
- active_high (optional) – Is the interrupt voltage active high or low. Boolean.
- latch (optional) – Is the interrupt a short pulse or latch till read? Boolean.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
configureAnchors
(anchor_list, anchor_select=1, remote_id=None)[source]¶ Configures a set of anchors as the relevant anchors on a device
Parameters: - anchor_list (list) – Python list of either DeviceCoordinates or [ID, flag, x, y, z]
- anchor_select (optional) – How to select the anchors in positioning
- remote_id (optional) – Remote Pozyx ID
Returns: POZYX_SUCCESS, POZYX_FAILURE
-
doAnchorCalibration
(dimension, num_measurements, anchors, heights=None, remote_id=None)[source]¶ Performs automatic anchor calibration on the Pozyx.
Using manual calibration over automatic calibration is highly recommended, as this will not only be less robust to use, the results will also be worse than a carefully accurately manually measured setup. Using a laser measurer for this purpose is also adviced.
When insisting on using automatic calibration, make sure that all devices are in range and able to communicate with the device. Try ranging with all devices first, and make sure they’re on the same UWB settings.
Parameters: - dimension – Dimension for the automatic calibration. When 2.5D, make sure to pass along heights as well.
- num_measurements – Number of measurements to use in calibration. The
- anchors – List of anchor IDs that will be used in the calibration. DeviceList() or [anchor_id1, anchor_id2, …]
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doDiscovery
(discovery_type=0, slots=3, slot_duration=0.01, remote_id=None)[source]¶ Performs discovery on the Pozyx, which will let it discover other Pozyx devices with the same UWB settings in range.
Parameters: - discovery_type (optional) – Type of devices to discover, defaults to discovering the anchors. PozyxConstants.DISCOVERY_ALL_DEVICES, PozyxConstants.DISCOVERY_TAGS_ONLY are alternatives.
- slots (optional) – Number of timeslots used in attempt to discover devices. Default is 3 slots.
- slot_duration (optional) – Duration in seconds of each timeslot used in the discovery process. Default is 10 ms.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doDiscoveryAll
(slots=3, slot_duration=0.01, remote_id=None)[source]¶ Performs general discovery on the Pozyx, which will let it discover both Pozyx tags and anchors with the same UWB settings in range.
Parameters: - slots (optional) – Number of timeslots used in attempt to discover devices. Default is 3 slots.
- slot_duration (optional) – Duration in seconds of each timeslot used in the discovery process. Default is 10 ms.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doDiscoveryAnchors
(slots=3, slot_duration=0.01, remote_id=None)[source]¶ Performs anchor discovery on the Pozyx, which will let it discover Pozyx anchors with the same UWB settings in range.
Parameters: - slots (optional) – Number of timeslots used in attempt to discover devices. Default is 3 slots.
- slot_duration (optional) – Duration in seconds of each timeslot used in the discovery process. Default is 10 ms.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doDiscoveryTags
(slots=3, slot_duration=0.01, remote_id=None)[source]¶ Performs tag discovery on the Pozyx, which will let it discover Pozyx tags with the same UWB settings in range.
Parameters: - slots (optional) – Number of timeslots used in attempt to discover devices. Default is 3 slots.
- slot_duration (optional) – Duration in seconds of each timeslot used in the discovery process. Default is 10 ms.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doOptimalDiscovery
(discovery_type=2, slots=3, timeout=None)[source]¶ Performs a discovery with slot_duration optimised for the device’s UWB settings.
-
doPositioning
(position, dimension=3, height=<pypozyx.structures.generic.Data object>, algorithm=None, remote_id=None, timeout=None)[source]¶ Performs positioning with the Pozyx. This is probably why you’re using Pozyx.
This function only performs the positioning and doesn’t take care of the previous steps required to get this operational, so be sure to adhere to this checklist: - while you can perform automatic calibration, manual calibration is much more stable and reliable. - when using manual calibration, add all anchors using addDevice. - all anchors are on the same UWB settings as the device performing positioning. - if you’re using more than four anchors, be sure to set this with setSelectionOfAnchors.
Basic troubleshooting: - try to perform ranging with all devices - are you using a Coordinates object for your position? - if you perform getDeviceListSize and subsequently getDeviceIds, are these your anchors?
While in the Arduino library doRemotePositioning is used for remote ranging, this function follows the library’s convention to add remote_id as a keyword argument.
For an in-action example, check the “Ready to localize” tutorial on the Pozyx homepage(www.pozyx.io), and the ready_to_localize.py example found in this library’s tutorial folder.
Parameters: - position – Container for the positioning coordinates. Coordinates object.
- dimension (optional) – Dimension to perform positioning in. Default 3D. When 2.5D, make sure height is also passed along.
- height (optional) – Height of Pozyx in 2.5D positioning. Default 0. Either integer height or Data([height], ‘i’).
- algorithm (optional) – Algorithm set before positioning. No new algorithm is set by default.
- remote_id (optional) – Remote Pozyx ID. Local Pozyx is used when None or omitted.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doPositioningSlave
(position, timeout=None)[source]¶ Checks whether the device has positioned and if so, reads the position.
This is useful for slave devices with a controller that needs to know the device’s positions too
Parameters: position – Container for the positioning coordinates. Coordinates object. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doPositioningWithDataSlave
(positioning_data, timeout=None)[source]¶ Checks whether the device has positioned and if so, reads the position with data.
This is useful for slave devices with a controller that needs to know the device’s positions (with data) too
Parameters: positioning_data – Container for the positioning coordinates. PositioningData object. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doRanging
(destination_id, device_range, remote_id=None)[source]¶ Performs ranging with another destination device, resulting in range information.
- This is pretty straightforward, the range information consists of the following:
- the timestamp of the range measurement.
- the distance between the local / remote tag and the destination
- the RSS, which indicates the signal strength between origin and destination.
While in the Arduino library doRemoteRanging is used for remote ranging, this function follows the library’s convention to add remote_id as a keyword argument. Make sure that the destination is on the same UWB settings as this, and to pass a DeviceRange object for the device_range parameter.
For an in-action example, check the “Ready to range” tutorial on the Pozyx homepage(www.pozyx.io), and the ready_to_range.py example found in this library’s tutorial folder.
Parameters: - destination_id – Network ID of the destination, to perform ranging with. integer ID or NetworkID(ID)
- device_range – Container for device range measurement data. DeviceRange object.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
doRangingSlave
(destination_id, device_range)[source]¶ Checks whether the device has ranged and if so, reads the range.
This is useful for slave devices with a controller that needs to know the range measurements too
Parameters: - destination_id – Network ID of the destination, to perform ranging with. integer ID or NetworkID(ID)
- device_range – Container for device range measurement data. DeviceRange object.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getAcceleration_mg
(acceleration, remote_id=None)[source]¶ Obtain the Pozyx’s acceleration sensor data in mg.
Parameters: - acceleration – Container for the read data. Acceleration().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getAllSensorData
(sensor_data, remote_id=None)[source]¶ Obtains all the Pozyx’s sensor data in their default units.
Parameters: - sensor_data – Container for the read data. SensorData() or RawSensorData().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getAnchorIds
(anchors, remote_id=None)[source]¶ Obtain the IDs of the anchors in the Pozyx’s device list.
You need to make sure to know how many anchors are in the list, as an incorrect size of anchors will cause the function to fail.
Parameters: - anchors – Container for the read data. SingleRegister() or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
See also
getDeviceIds, getPositioningAnchorIds, getTagIds
-
getAnchorSelectionMode
(mode, remote_id=None)[source]¶ Obtains the Pozyx’s anchor selection mode.
Parameters: - mode – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getAngularVelocity_dps
(angular_vel, remote_id=None)[source]¶ Obtain the Pozyx’s angular velocity sensor data in dps(degrees per second).
Parameters: - angular_vel – Container for the read data. AngularVelocity().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getCalibrationStatus
(calibration_status, remote_id=None)[source]¶ Obtains the Pozyx’s calibration status.
Parameters: - calibration_status – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getConfigModeGPIO
(gpio_num, mode, remote_id=None)[source]¶ Obtain the Pozyx’s configuration mode of the selected GPIO pin.
Parameters: - gpio_num – GPIO pin number, 1 to 4.
- mode – Container for the read data. SingleRegister() or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
See also
getGPIO, getConfigPullGPIO
-
getConfigPullGPIO
(gpio_num, pull, remote_id=None)[source]¶ Obtain the Pozyx’s selected GPIO pin pull.
Parameters: - gpio_num – GPIO pin number, 1 to 4.
- pull – Container for the read data. SingleRegister() or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
See also
getGPIO, getConfigModeGPIO
-
getCoordinates
(coordinates, remote_id=None)[source]¶ Obtains the Pozyx’s coordinates. These are either set manually or by positioning.
Parameters: - coordinates – Container for the read data. Coordinates().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getDeviceCoordinates
(device_id, coordinates, remote_id=None)[source]¶ Obtain the coordinates of the device with selected ID in the Pozyx’s device list.
Parameters: - device_id – ID of desired device whose coordinates are of interest. NetworkID()
- Data (or) –
- coordinates – Container for the read data. Coordinates().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getDeviceDetails
(system_details, remote_id=None)[source]¶ Parameters: - system_details – Container for the read data. DeviceDetails.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getDeviceIds
(devices, remote_id=None)[source]¶ Obtain the IDs of all devices in the Pozyx’s device list.
You need to make sure to know how many devices are in the list, as an incorrect size of anchors will cause the function to fail. Use getDeviceListSize to know this number.
Parameters: - devices – Container for the read data. DeviceList(list_size=size)
- Data (or) –
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
See also
getAnchorIds, getTagIds, getPositioningAnchorIds
Example
>> > list_size = SingleRegister() >> > self.getDeviceListSize(list_size) >> > device_list = DeviceList(list_size=list_size[0]) >> > self.getDeviceIds(device_list) >> > print(device_list) ‘0x60A0, 0x6070, 0x6891’
-
getDeviceListSize
(device_list_size, remote_id=None)[source]¶ Obtain the size of Pozyx’s list of added devices.
Parameters: - device_list_size – Container for the read data. SingleRegister() or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getDeviceRangeInfo
(device_id, device_range, remote_id=None)[source]¶ Obtain the range information of the device with selected ID in the Pozyx’s device list.
Parameters: - device_id – ID of desired device whose range measurement is of interest. NetworkID()
- Data (or) –
- device_range – Container for the read data. DeviceRange().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getErrorCode
(error_code, remote_id=None)[source]¶ Obtains the Pozyx’s error code.
Parameters: - error_code – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getErrorMessage
(error_code)[source]¶ Returns the system error string for the given error code
Parameters: error_code – Error code for which to return the error message. int or SingleRegister Returns: string with error description See also
getErrorCode, getSystemError
-
getEulerAngles_deg
(euler_angles, remote_id=None)[source]¶ Obtain the Pozyx’s euler angles sensor data in degrees(heading, roll, pitch).
Parameters: - euler_angles – Container for the read data. EulerAngles().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getFirmwareVersion
(firmware, remote_id=None)[source]¶ Obtains the Pozyx’s firmware version.
Parameters: - firmware – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getGPIO
(gpio_num, value, remote_id=None)[source]¶ Obtain the Pozyx’s value of the selected GPIO pin, being either HIGH or LOW(physically 3.3V or 0V).
Parameters: - gpio_num – GPIO pin number, 1 to 4.
- value – Container for the read data. SingleRegister() or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
See also
getConfigPullGPIO, getConfigModeGPIO
-
getGravityVector_mg
(gravity_vector, remote_id=None)[source]¶ Obtain the Pozyx’s gravity vector sensor data in mg.
Parameters: - gravity_vector – Container for the read data. Acceleration().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getHardwareVersion
(hardware, remote_id=None)[source]¶ Obtains the Pozyx’s hardware version.
Parameters: - hardware – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getHeight
(height, remote_id=None)[source]¶ Obtains the Pozyx’s height coordinate.
Parameters: - height – Container for the read height data. Data([0], ‘i’).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getInterruptMask
(mask, remote_id=None)[source]¶ Obtains the Pozyx’s interrupt mask.
Parameters: - mask – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getLastDataLength
(data_length, remote_id=None)[source]¶ Obtain the size of the most recent data packet received by the Pozyx.
Parameters: - data_length – Container for the read data. SingleRegister() or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getLastNetworkId
(network_id, remote_id=None)[source]¶ Obtain the network ID of the last device Pozyx communicated with.
Parameters: - network_id – Container for the read data. NetworkID() or SingleRegister(size=2) or Data([0], ‘H’).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getLinearAcceleration_mg
(linear_acceleration, remote_id=None)[source]¶ Obtain the Pozyx’s linear acceleration sensor data in mg.
Parameters: - linear_acceleration – Container for the read data. LinearAcceleration() or Acceleration().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getMagnetic_uT
(magnetic, remote_id=None)[source]¶ Obtain the Pozyx’s magnetic sensor data in uT(microtesla).
Parameters: - magnetic – Container for the read data. Magnetic().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getMaxLinearAcceleration_mg
(max_linear_acceleration, remote_id=None)[source]¶ Obtain the Pozyx’s acceleration sensor data in mg.
Parameters: - max_linear_acceleration – Container for the read data. MaxLinearAcceleration.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getNetworkId
(network_id)[source]¶ Obtains the Pozyx’s network ID.
Parameters: network_id – Container for the read data. NetworkID() or SingleRegister(size=2) or Data([0], ‘H’). Returns: POZYX_SUCCESS, POZYX_FAILURE
-
getNormalizedQuaternion
(quaternion, remote_id=None)[source]¶ Obtain the Pozyx’s normalized quaternion sensor data that is required for ROS.
Parameters: - quaternion – Container for the read data. Quaternion().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getNumRegistersSaved
(remote_id=None)[source]¶ Obtains the number of registers saved to the Pozyx’s flash memory.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: The number of saved registers.
-
getNumberOfAnchors
(nr_anchors, remote_id=None)[source]¶ Obtains the Pozyx’s number of selected anchors.
Parameters: - nr_anchors – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getOperationMode
(mode, remote_id=None)[source]¶ Obtains the Pozyx’s mode of operation.
Parameters: - mode – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getPositionAlgorithm
(algorithm, remote_id=None)[source]¶ Obtains the Pozyx’s positioning algorithm.
Parameters: - algorithm – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getPositionDimension
(dimension, remote_id=None)[source]¶ Obtains the Pozyx’s positioning dimension.
Parameters: - dimension – Container the for read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getPositionError
(positioning_error, remote_id=None)[source]¶ Obtains the Pozyx’s positioning error.
Parameters: - positioning_error – Container for the read data. PositionError().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getPositionFilterData
(filter_data, remote_id=None)[source]¶ NEW! Get the positioning filter data.
Use FilterData if you want to have a ready to go container for this data.
Parameters: - filter_data – Container for filter data. SingleRegister or FilterData
- remote_id (optional) – Remote Pozyx ID.
Example
>>> pozyx = PozyxLib() # PozyxSerial has PozyxLib's functions, just for generality >>> filter_data = FilterData() >>> pozyx.getPositionFilter(filter_data) >>> print(filter_data) # "Moving average filter with strength 10" >>> print(filter_data.get_filter_name()) # "Moving average filter" >>> print(filter_data.filter_type) # "3" >>> print(filter_data.filter_strength()) # "10"
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getPositionFilterStrength
(remote_id=None)[source]¶ NEW! Get the positioning filter strength.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getPositioningAnchorIds
(anchors, remote_id=None)[source]¶ Obtain the IDs of the anchors in the Pozyx’s device list used for positioning.
You need to make sure to know how many anchors are used, as an incorrect size of anchors will cause the function to fail. Use getNumberOfAnchors to know this number.
Parameters: - anchors – Container for the read data. DeviceList(list_size=size)
- Data (or) –
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
See also
getAnchorIds, getTagIds, getDeviceIds
Example
>> > list_size = SingleRegister() >> > self.getNumberOfAnchors(list_size) >> > anchor_list = DeviceList(list_size=list_size[0]) >> > self.getPositioningAnchorIds(anchor_list) >> > print(anchor_list) ‘0x6720, 0x6811, 0x6891’
-
getPressure_Pa
(pressure, remote_id=None)[source]¶ Obtain the Pozyx’s pressure sensor data in Pa(pascal).
Parameters: - pressure – Container for the read data. Pressure or Data([0], ‘I’) (Data is DEPRECATED).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getQuaternion
(quaternion, remote_id=None)[source]¶ Obtain the Pozyx’s quaternion sensor data.
Parameters: - quaternion – Container for the read data. Quaternion().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getRangingProtocol
(protocol, remote_id=None)[source]¶ Obtains the Pozyx’s ranging protocol
Parameters: - protocol – Container for the read protocol data. SingleRegister or Data([0])
- remote_id (optional) – Remote Pozyx ID
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getSelftest
(selftest, remote_id=None)[source]¶ Obtains the Pozyx’s selftest.
Parameters: - selftest – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getSensorMode
(sensor_mode, remote_id=None)[source]¶ Obtains the Pozyx’s sensor mode.
Parameters: - sensor_mode – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getSystemError
(remote_id=None)[source]¶ Returns the Pozyx’s system error string.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: string with error description See also
getErrorCode, getErrorMessage
-
getTagIds
(tags, remote_id=None)[source]¶ Obtain the IDs of the tags in the Pozyx’s device list.
You need to make sure to know how many tags are in the list, as an incorrect size of tags will cause the function to fail.
Parameters: - tags – Container for the read data. SingleRegister() or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
See also
getDeviceIds, getAnchorIds, getPositioningAnchorIds
-
getTemperature_c
(temperature, remote_id=None)[source]¶ Obtain the Pozyx’s temperature sensor data in C(celsius).
Parameters: - temperature – Container for the read data. Temperature or Data([0], ‘b’) (DEPRECATED).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getTxPower
(txgain_db, remote_id=None)[source]¶ DEPRECATED: use getUWBGain instead. Obtains the Pozyx’s transmitter UWB gain in dB, as a float.
Parameters: - txgain_db – Container for the read data. Data([0], ‘f’).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getUWBChannel
(channel_num, remote_id=None)[source]¶ Obtains the Pozyx’s UWB channel.
Parameters: - channel_num – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getUWBGain
(uwb_gain_db, remote_id=None)[source]¶ Obtains the Pozyx’s transmitter UWB gain in dB, as a float.
Parameters: - uwb_gain_db – Container for the read data. Data([0], ‘f’).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getUWBSettings
(UWB_settings, remote_id=None)[source]¶ Obtains the Pozyx’s UWB settings.
Parameters: - UWB_settings – Container for the read data. UWBSettings().
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getUpdateInterval
(ms, remote_id=None)[source]¶ Obtains the Pozyx’s update interval.
Parameters: - ms – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
getWhoAmI
(who_am_i, remote_id=None)[source]¶ Obtains the Pozyx’s WHO_AM_I.
Parameters: - who_am_i – Container for the read data. SingleRegister or Data([0]).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
isRegisterSaved
(register_address, remote_id=None)[source]¶ Returns whether the given register is saved to the Pozyx’s flash memory.
Parameters: - register_address – Register address to check if saved
- remote_id (optional) – Remote Pozyx ID.
Returns: 1 if the register is saved, 0 if it’s not.
-
printDeviceInfo
(remote_id=None)[source]¶ Prints a Pozyx’s basic info, such as firmware.
Mostly for debugging
-
printDeviceList
(remote_id=None, include_coordinates=True, prefix='\t- ')[source]¶ Prints a Pozyx’s device list.
Parameters: Returns: None
-
remoteRegFunctionOnlyData
(destination, address, params, data)[source]¶ Performs a remote function without waiting for the acknowledgement.
Advanded custom internal use only, you’re not expected to use this unless you know what you’re doing.
-
removeDevice
(device_id, remote_id=None)[source]¶ Removes a device from the Pozyx’s device list, keeping the rest of the list intact
Parameters: - device_id – ID that needs to be removed. NetworkID or integer.
- remote_id (optional) – Remote Pozyx ID
Returns: POZYX_SUCCESS, POZYX_FAILURE
-
resetSystem
(remote_id=None)[source]¶ Resets the Pozyx device.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
saveAnchorIds
(remote_id=None)[source]¶ Saves the anchor IDs used in positioning to the Pozyx’s flash memory.
This means that upon reset, the Pozyx won’t need to be recalibrated before performing positioning.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
saveConfiguration
(save_type, registers=None, remote_id=None)[source]¶ General function to save the Pozyx’s configuration to its flash memory.
- This constitutes three different Pozyx configurations to save, and each have their specialised derived function:
- POZYX_FLASH_REGS: This saves the passed Pozyx registers if they’re writable, see saveRegisters. PozyxConstants.FLASH_SAVE_ANCHOR_IDS: This saves the anchors used during positioning, see saveAnchorIds. POZYX_FLASH_NETWORK: This saves the device list to the Pozyx device, see saveNetwork.
It is recommended to use the derived functions, as these are not just easier to use, but also more descriptive than this general save function.
DISCLAIMER: Make sure to not abuse this function in your code, as the flash memory only has a finite number of writecycles available, adhere to the Arduino’s mentality in using flash memory.
Parameters: - save_type – Type of configuration to save. See above.
- registers (optional) – Registers to save to the flash memory. Data([register1, register2, …]) or [register1, register2, …] These registers have to be writable. Saving the UWB gain is currently not working.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
saveNetwork
(remote_id=None)[source]¶ Saves the Pozyx’s device list to its flash memory.
This means that upon a reset, the Pozyx will still have the same configured device list.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
saveRegisters
(registers, remote_id=None)[source]¶ Saves the given registers to the Pozyx’s flash memory, if these are writable registers.
This means that upon reset, the Pozyx will use these saved values instead of the default values. This is especially practical when changing UWB settings of an entire network, making it unnecessary to re - set these when resetting or repowering a device.
DISCLAIMER: Make sure to not abuse this function in your code, as the flash memory only has a finite number of writecycles available, adhere to the Arduino’s mentality in using flash memory.
Parameters: - registers – Registers to save to the flash memory. Data([register1, register2, …]) or [register1, register2, …] These registers have to be writable. Saving the UWB gain is currently not working.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
saveUWBSettings
(remote_id=None)[source]¶ Saves the Pozyx’s UWB settings to its flash memory.
This means that upon a reset, the Pozyx will still have the same configured UWB settings. As of writing, PozyxRegisters.UWB_GAIN is not savable yet.
Parameters: remote_id (optional) – Remote Pozyx ID. Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setConfigGPIO
(gpio_num, mode, pull, remote_id=None)[source]¶ Set the Pozyx’s selected GPIO pin configuration(mode and pull).
Parameters: - gpio_num – GPIO pin number, 1 to 4.
- mode – GPIO configuration mode. integer mode or SingleRegister(mode)
- pull – GPIO configuration pull. integer pull or SingleRegister(pull)
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setCoordinates
(coordinates, remote_id=None)[source]¶ Set the Pozyx’s coordinates.
Parameters: - coordinates – Desired Pozyx coordinates. Coordinates() or [x, y, z].
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setGPIO
(gpio_num, value, remote_id=None)[source]¶ Set the Pozyx’s selected GPIO pin output.
Parameters: - gpio_num – GPIO pin number, 1 to 4
- value – GPIO output value, either HIGH(1) or LOW(0). Physically, 3.3V or 0V. integer value or SingleRegister(value).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setHeight
(height, remote_id=None)[source]¶ Sets the Pozyx device’s height.
Parameters: - height – Desired Pozyx height. integer height or Data([height], ‘i’).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setInterruptMask
(mask, remote_id=None)[source]¶ Set the Pozyx’s interrupt mask.
Parameters: - mask – Interrupt mask. See PozyxRegisters.INTERRUPT_MASK register. integer mask or SingleRegister(mask)
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setLed
(led_num, state, remote_id=None)[source]¶ Set the Pozyx’s selected LED state.
Parameters: - led_num – LED pin number, 1 to 4
- state – LED output state. Boolean. True = on and False = off, you can use POZYX_LED_ON and POZYX_LED_OFF instead.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setLedConfig
(config, remote_id=None)[source]¶ Set the Pozyx’s LED configuration.
Parameters: - config – LED configuration. See PozyxRegisters.LED_CONFIGURATION register. integer configuration or SingleRegister(configuration)
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setNetworkId
(network_id, remote_id=None)[source]¶ Set the Pozyx’s network ID.
If using this remotely, make sure to change the network ID to the new ID in subsequent code, as its ID will have changed and using the old ID will not work.
Parameters: - network_id – New Network ID. integer ID or NetworkID(ID) or SingleRegister(ID, size=2)
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setPositionAlgorithm
(algorithm, dimension, remote_id=None)[source]¶ Set the Pozyx’s positioning algorithm.
Note that currently only PozyxConstants.POSITIONING_ALGORITHM_UWB_ONLY and PozyxConstants.POSITIONING_ALGORITHM_TRACKING are implemented.
Parameters: - algorithm – Positioning algorithm. integer algorithm or SingleRegister(algorithm).
- dimension – Positioning dimension. integer dimension or SingleRegister(dimension).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setPositionFilter
(filter_type, filter_strength, remote_id=None)[source]¶ Set the Pozyx’s positioning filter.
Note that currently only PozyxConstants.FILTER_TYPE_MOVING_AVERAGE, PozyxConstants.FILTER_TYPE_MOVING_MEDIAN and PozyxConstants.FILTER_TYPE_FIR are implemented.
Parameters: - filter_type – Positioning filter type. Integer or SingleRegister.
- filter_strength – Positioning filter strength. Integer or SingleRegister.
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setPositioningAnchorIds
(anchors, remote_id=None)[source]¶ Set the anchors the Pozyx will use for positioning.
Parameters: - anchors – List of anchors that’ll be used for positioning. DeviceList() or [anchor_id1, anchor_id2, …]
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setRangingProtocol
(protocol, remote_id=None)[source]¶ Set the Pozyx’s ranging protocol.
Parameters: - protocol – the new ranging protocol. See PozyxRegisters.RANGING_PROTOCOL register. integer or SingleRegister(protocol)
- remote_id (optional) – Remote Pozyx ID
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setSelectionOfAnchors
(mode, number_of_anchors, remote_id=None)[source]¶ Set the Pozyx’s coordinates.
Parameters: - mode – Anchor selection mode. integer mode or SingleRegister(mode).
- number_of_anchors (int, SingleRegister) – Number of anchors used in positioning. integer nr_anchors or SingleRegister(nr_anchors).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setSensorMode
(sensor_mode, remote_id=None)[source]¶ Set the Pozyx’s sensor mode.
Parameters: - sensor_mode – New sensor mode. See PozyxRegisters.SENSORS_MODE register. integer sensor_mode or SingleRegister(sensor_mode).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setTxPower
(txgain_db, remote_id=None)[source]¶ DEPRECATED: use getUWBGain instead. Set the Pozyx’s UWB transceiver gain.
Parameters: - txgain_db – The new transceiver gain in dB, a value between 0.0 and 33.0. float gain or Data([gain], ‘f’).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setUWBChannel
(channel_num, remote_id=None)[source]¶ Set the Pozyx’s UWB channel.
If using this remotely, remember to change the local UWB channel as well to make sure you are still able to communicate with the remote device.
Parameters: - channel_num – The new UWB channel, being either 1, 2, 3, 4, 5 or 7. See PozyxRegisters.UWB_CHANNEL register. integer channel or SingleRegister(channel)
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setUWBGain
(uwb_gain_db, remote_id=None)[source]¶ Set the Pozyx’s UWB transceiver gain.
Parameters: - uwb_gain_db – The new transceiver gain in dB, a value between 0.0 and 33.0. float gain or Data([gain], ‘f’).
- remote_id (optional) – Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-
setUWBSettings
(uwb_settings, remote_id=None, save_to_flash=False)[source]¶ Set the Pozyx’s UWB settings.
If using this remotely, remember to change the local UWB settings as well to make sure you are still able to communicate with the remote device.
Parameters: uwb_settings – The new UWB settings. UWBSettings() or [channel, bitrate, prf, plen, gain_db] - Kwargs:
- remote_id: Remote Pozyx ID.
Returns: POZYX_SUCCESS, POZYX_FAILURE, POZYX_TIMEOUT
-