hbldh / Pozyx-Python-library

The Python library to work with the pozyx accurate indoor positioning system

Home Page:https://www.pozyx.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pozyx-Python-library

The unofficial release of the Python library (Beta version) to work with the pozyx indoor positioning system

This library works with both Python 2 and 3.

Prerequisites:

  • Download and install Python. On Windows, make your life easier and make sure Python is in your PATH. A recommended install is therefore the Anaconda Suite by Continuum. If you're going to follow the tutorials, you'll need to install Python 3 for the python-osc support.
  • Install the PySerial package. If you have pip installed, you can do this by writing pip install pyserial in your command line interface (cmd on Windows).
  • Windows only install ST's virtual COM driver

Installing this package.

As it's not yet available on PyPi, you will have to install the library from source like this:

  • Download the library as a zip file, or clone it in a folder.
  • After changing your command window's working directory to the extracted/cloned folder, perform python setup.py install

PyPozyx is now installed. To check whether it is: if you followed all the steps correctly, and know which port your Pozyx is on, the following code should work:

from pypozyx import *
port = 'COMX' # on UNIX systems this will be '/dev/ttyACMX'
p = PozyxSerial(port)

If your port is correct and the serial connection to the Pozyx isn't used by other software, this will run without any errors.

But! How do I know what port my Pozyx is on?

You can see the COM ports on your system easily using Python with: python -c "from pypozyx import *;list_serial_ports()"

Documentation and examples

You can find the Python tutorials on our site. You probably got here from the getting started page

There is currently a lack of documentation, unlike for the Arduino library. For now, these pointers and pages should be helpful:

  • All functions that exist in the Arduino library, also exist in the Python library under the same name and functionality, so most of the Arduino Library Documentation is transformable to this. The major difference is that you don't ever again need to pass along the length of the data you're reading/writing. This is taken care of by the library:
  • The Data and SingleRegister classes take care of this. eg. to read out the WhoAmI register, appending to the test code above.
whoami = SingleRegister()
pozyx.regRead(POZYX_WHO_AM_I, whoami) # which is pozyx.getWhoAmI(whoami)
  • SingleRegister(value=0, size=1, signed=1) is basically an instance Data([0], 'B'), which functions as a single uint8_t. If you want to make your custom data, for a single register you can adapt the size and signed parameters, and for larger data structures you can use your own data formats. Data([0]*3, 'BHI'), for example, creates a structure of 1 uint8_t, uint16_t and uint32_t. Writing and reading data using this example as a parameter will automatically read/write 7 bytes worth of data. To specify your own data formats, check the struct package documentation for Python 3 or Python 2.

More usage examples can be found in the useful and examples folders of the repository.

About

The Python library to work with the pozyx accurate indoor positioning system

https://www.pozyx.io

License:GNU Lesser General Public License v3.0


Languages

Language:Python 100.0%