Skip to content

Commit

Permalink
Fixed multitag and version numbers
Browse files Browse the repository at this point in the history
Fixed multitag and version numbers

Was preparing other url
  • Loading branch information
laurentva committed May 31, 2017
1 parent 7c0e372 commit 26d9fec
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 32 deletions.
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
name='pypozyx',
packages=['pypozyx', 'pypozyx.definitions',
'pypozyx.structures', 'pypozyx.tests'],
version='0.2.0',
version='1.0.0',
description='Python library for Pozyx',
author='Laurent Van Acker',
author_email='[email protected]',
url='www.pozyx.io',
download_url='www.pozyx.io',
url = 'https://github.com/pozyxLabs/Pozyx-Python-library',
download_url='https://github.com/pozyxLabs/Pozyx-Python-library/archive/v1.0.tar.gz',
keywords=['pozyx', 'serial', 'positioning', 'localisation'],
classifiers=[
'Programming Language :: Python',
'Development Status :: 4 - Beta',
'Development Status :: 5 - Release',
'Intended audience :: End Users/Developers',
'Operating System :: OS independent',
'Topic :: Software Development :: Libraries :: Python Modules',
Expand Down
58 changes: 34 additions & 24 deletions tutorials/multitag_positioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
parameters and upload this sketch. Watch the coordinates change as you move your device around!
"""
from time import sleep
from time import sleep, time

from pypozyx import *
from pypozyx.definitions.registers import POZYX_EUL_HEADING
from pythonosc.osc_message_builder import OscMessageBuilder
from pythonosc.udp_client import SimpleUDPClient

Expand All @@ -33,7 +34,7 @@ def __init__(self, pozyx, osc_udp_client, tags, anchors, algorithm=POZYX_POS_ALG

def setup(self):
"""Sets up the Pozyx for positioning by calibrating its anchor list."""
print("------------POZYX MULTITAG POSITIONING V1.0 - -----------\nNOTES: \n- Parameters required:\n\t- Anchors for calibration\n\t- Tags to work with\n\n- System will manually calibration\n\n- System will auto start positioning\n- -----------POZYX MULTITAG POSITIONING V1.0 ------------\nSTART Positioning: ")
print("------------POZYX MULTITAG POSITIONING V1.1 - -----------\nNOTES: \n- Parameters required:\n\t- Anchors for calibration\n\t- Tags to work with\n\n- System will manually calibration\n\n- System will auto start positioning\n- -----------POZYX MULTITAG POSITIONING V1.1 ------------\nSTART Positioning: ")
self.setAnchorsManual()
self.printPublishAnchorConfiguration()

Expand All @@ -48,33 +49,38 @@ def loop(self):
else:
self.printPublishErrorCode("positioning", tag)

def printPublishPosition(self, position, network_id):
"""Prints the Pozyx's position and possibly sends it as a OSC packet"""
if network_id is None:
network_id = 0
s = "POS ID: {}, x(mm): {}, y(mm): {}, z(mm): {}".format("0x%0.4x" % network_id, position.x, position.y, position.z)
print(s)
if self.osc_udp_client is not None:
self.osc_udp_client.send_message(
"/position", [network_id, position.x, position.y, position.z])

def setAnchorsManual(self):
"""Adds the manually measured anchors to the Pozyx's device list one for one."""
for tag in self.tags:
status = self.pozyx.clearDevices(tag)
for anchor in self.anchors:
status &= self.pozyx.addDevice(anchor, tag)
if len(anchors) > 4:
status &= self.pozyx.setSelectionOfAnchors(POZYX_ANCHOR_SEL_AUTO, len(anchors))
self.printConfigurationResult(status, tag)
status &= self.pozyx.setSelectionOfAnchors(POZYX_ANCHOR_SEL_AUTO, len(anchors), remote_id=tag)
# enable these if you want to save the configuration to the devices.
# self.pozyx.saveAnchorIds(tag)
# self.pozyx.saveRegisters([POZYX_ANCHOR_SEL_AUTO], tag)
self.printPublishConfigurationResult(status, tag)

def printPublishConfigurationResult(self, status, tag_id):
"""Prints the configuration explicit result, prints and publishes error if one occurs"""
if tag_id is None:
tag_id = 0
if status == POZYX_SUCCESS:
print("Configuration of tag %s: success" % tag_id)
else:
self.printPublishErrorCode("configuration", tag_id)

def printPublishPosition(self, position, network_id):
"""Prints the Pozyx's position and possibly sends it as a OSC packet"""
if network_id is None:
network_id = 0
print("POS ID {}, x(mm): {pos.x}, y(mm): {pos.y}, z(mm): {pos.z}".format(
"0x%0.4x" % network_id, pos=pos))
if self.osc_udp_client is not None:
self.osc_udp_client.send_message(
"/position", [network_id, anchor_coordinates.x, anchor_coordinates.y, anchor_coordinates.z])

def printPublishErrorCode(self, operation, network_id):
"""Prints the Pozyx's error and possibly sends it as a OSC packet"""
error_code = SingleRegister()
Expand All @@ -83,10 +89,10 @@ def printPublishErrorCode(self, operation, network_id):
network_id = 0
if status == POZYX_SUCCESS:
print("Error %s on ID %s, error code %s" %
(operation, "0x%0.4x" % (network_id, str(error_code))))
(operation, "0x%0.4x" % network_id, str(error_code)))
if self.osc_udp_client is not None:
self.osc_udp_client.send_message(
"/error_%s" % [operation, network_id, error_code[0]])
"/error_%s" % operation, [network_id, error_code[0]])
else:
# should only happen when not being able to communicate with a remote Pozyx.
self.pozyx.getErrorCode(error_code)
Expand All @@ -96,10 +102,10 @@ def printPublishErrorCode(self, operation, network_id):

def printPublishAnchorConfiguration(self):
for anchor in self.anchors:
print("ANCHOR,0x%0.4x,%s" % (anchor.network_id, str(anchor.coordinates)))
print("ANCHOR,0x%0.4x,%s" % (anchor.network_id, str(anchor.pos)))
if self.osc_udp_client is not None:
self.osc_udp_client.send_message(
"/anchor", [anchor.network_id, anchor.coordinates.x, anchor.coordinates.y, anchor.coordinates.z])
"/anchor", [anchor.network_id, anchor.pos.x, anchor.pos.y, anchor.pos.z])
sleep(0.025)


Expand All @@ -112,19 +118,23 @@ def printPublishAnchorConfiguration(self):
if not remote:
remote_id = None

use_processing = False # enable to send position data through OSC
use_processing = True # enable to send position data through OSC
ip = "127.0.0.1" # IP for the OSC UDP
network_port = 8888 # network port for the OSC UDP
osc_udp_client = None
if use_processing:
osc_udp_client = SimpleUDPClient(ip, network_port)

tags = [0x0001, 0x0002, 0x0003] # remote tags
#tags = [0x6055]
tags = [0x607a]
# tags = [0x6055, 0x607a] # remote tags
# necessary data for calibration
anchors = [DeviceCoordinates(0x0001, 1, Coordinates(0, 0, 2000)),
DeviceCoordinates(0x0002, 1, Coordinates(3000, 0, 2000)),
DeviceCoordinates(0x0003, 1, Coordinates(0, 3000, 2000)),
DeviceCoordinates(0x0004, 1, Coordinates(3000, 3000, 2000))]
anchors = [DeviceCoordinates(0x6058, 1, Coordinates(0, 0, 2210)),
DeviceCoordinates(0x6005, 1, Coordinates(9200, -700, 2400)),
DeviceCoordinates(0x605C, 1, Coordinates(0, 17000, 2470)),
DeviceCoordinates(0x6027, 1, Coordinates(2700, 17000, 2470)),
DeviceCoordinates(0x682e, 1, Coordinates(2700, 2500, 2350)),
DeviceCoordinates(0x6044, 1, Coordinates(11230, 2750, 2300))]

algorithm = POZYX_POS_ALG_UWB_ONLY # positioning algorithm to use
dimension = POZYX_3D # positioning dimension
Expand Down
4 changes: 2 additions & 2 deletions tutorials/ready_to_localize.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def __init__(self, pozyx, osc_udp_client, anchors, algorithm=POZYX_POS_ALG_UWB_O

def setup(self):
"""Sets up the Pozyx for positioning by calibrating its anchor list."""
print("------------POZYX POSITIONING V1.0 -------------")
print("------------POZYX POSITIONING V1.1 -------------")
print("NOTES: ")
print("- No parameters required.")
print()
print("- System will auto start configuration")
print()
print("- System will auto start positioning")
print("------------POZYX POSITIONING V1.0 --------------")
print("------------POZYX POSITIONING V1.1 --------------")
print()
print("START Ranging: ")
self.pozyx.clearDevices(self.remote_id)
Expand Down
4 changes: 2 additions & 2 deletions tutorials/ready_to_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ def __init__(self, pozyx, destination_id, range_step_mm=1000, protocol=POZYX_RAN

def setup(self):
"""Sets up both the ranging and destination Pozyx's LED configuration"""
print("------------POZYX RANGING V1.0 - -----------")
print("------------POZYX RANGING V1.1 -------------")
print("NOTES: ")
print(" - Change the parameters: ")
print("\tdestination_id(target device)")
print("\trange_step(mm)")
print()
print("- Approach target device to see range and")
print("led control")
print("- -----------POZYX RANGING V1.0 ------------")
print("- -----------POZYX RANGING V1.1 ------------")
print()
print("START Ranging: ")

Expand Down

0 comments on commit 26d9fec

Please sign in to comment.