Pozyx Setup - theRAPTLab/gsgo GitHub Wiki

See !104

I. Set up Pozyx

  1. Set up your enterprise server.
  2. Set up wearable tags. See Pozyx Enterprise Setup in the wiki for tag configuration settings.
  3. Verify that mqtt server is sending data locally.
  4. Set up any obstruction zones for dead areas where tag tracking should not be allowed.

You should be able to go to https://app.pozyx.io/, select "Visualization" and see your anchors and active tags moving around.

II. Get MQTT Server Info

  1. Go to https://app.pozyx.io/
  2. Click "Settings"
  3. Click "Local API"
  4. Write down the "via uplink network" HOST: value, e.g.
Host: mqtt://10.1.10.185  (via uplink network)
Port: 1883

III. Set MQTT Server Info / local-settings.json

[For more info on local settings, see !171]

  1. If you haven't already done so, run npm run gem to create a local-settings.json file.
    1. npm run bootstrap; npm run build; npm run gem
    2. There should be a new local-settings.json file at gs_packages/gem-srv/config/local-settings.json
    3. CTRL-C to quit node.
  2. Edit gs_packages/gem-srv/config/local-settings.json and add a new "MQTT_URL" entry.

NOTE this is a json file so:

  • you cannot use javascript // comments. To add a comment just use a new obvious key, e.g. "\_MQTT_URL_COMMENT". The important key is "MQTT_URL", all other unknown keys are ignored.
  • both keys and values need to be wrapped in double quotes
  • you need to add a comma after each item

Here's a full example. Note how I used extra entries to provide instructions and alternatives:

{
  "_INFO": [
    "Override constants defined gsgo-settings.js and gem-settings.js in this file",
    "Settings added here can be set for your gsgo installation, and will not be",
    "committed to the gsgo repo"
  ],

  "_MQTT_URL_COMMENT": "VU Lab",
  "MQTT_URL": "10.2.191.28",

  "_VU_MQTT_URL_COMMENT": "VU Lab. To use this, replace MQTT_URL with this value.",
  "VU_MQTT_URL": "10.2.191.28",

  "_REPLAY_MQTT_URL_COMMENT": "Local MQTT Server to replay streams.  To use this, replace MQTT_URL with this value.",
  "REPLAY_MQTT_URL": "localhost"

You can also get away with just adding a single MQTT_URL entry, but depending on who's managing the server it may not be as friendly:

{
  "MQTT_URL": "10.2.191.28",
}
  1. Start node again with npm run gem
  2. The app should start and connect to the server you specified. Look for this line in the terminal:
PTRACK        1883 MQTT Connect
PTRACK        MQTT present

DEPRECATED as of 10/15/2021

    We do not yet have a locale saving storage system, so the IP address of the MQTT server is currently baked into the code.  You'll have to modify this to run locally.

    0. First fetch the branch: `git fetch&&git checkout dev-bl/pozyx && npm run bootstrap && npm run gem` -- Make sure you run bootstrap because we've added new libraries.
    1. Open `gs_packages/gem-srv/server/step-tracker.js` in a text editor.
    2. Go to line 332 (or thereabouts): `mtrack_ss = mqtt.connect('mqtt://10.1.10.185', { port: 1883 });`
    3. Change the IP address to the IP address of your local MQTT server (from II.4 above).
    4. Save the file.
    5. The server should restart, and you should see the following lines in the terminal:
    ```
    PTRACK        1883 MQTT Connect
    PTRACK        MQTT present
    ```

    If you see `MQTT Not Present` or `Can't connect` then check your Pozyx server.  Make sure you can see tags.

    If you still can't get it to work, try:
    1. Uncomment lines 326-328 (or thereabouts)
    ```
      mtrack_ss = mqtt.connect("mqtt://test.mosquitto.org", {
        port: 1883,
      });
    ```
    2. Comment out line 332 (or thereabouts):
    ```
    //   mtrack_ss = mqtt.connect('mqtt://10.1.10.185', { port: 1883 }); // Enterprise server "via uplink network" works
    ```
    3. Run gem and check for the `MQTT Connect` message.  You should be able to connect to the test server.  If you can't, then you might have firewall issues.

    Another thing you can do is review the raw entity data coming from Pozyx in the terminal.
    1. Uncomment line 233 (or thereabouts):
    `  console.log(json);`
    2. Now when you run the server, you should see the raw entity data in the terminal.
    
    PLEASE DO NOT COMMIT ANY OF THESE CHANGES!

IV. Set Transforms

Assuming you were able to successfully get the "MQTT Connect" message, start the simulation to set transforms.

  1. Go to http://localhost/app/main?model=moths
  2. Open a new window and go to http://localhost/app/tracker -- Currently this new Tracker page relies on the Main sim running to show entity inputs, so you need start Main first. IMPORTANT: DO NOT MINIMIZE "Main"! A minimized window will receive less CPU cycles, so your simulation will run very slowly and tracker will receive few updates! Keep both Tracker and Main open. It's OK to cover Main with another window.
  3. Shake your wearable tag(s) to wake them up. You should see Entities data in the lower right. You may or may not see tag-controlled moths on the screen depending on your anchor setup.

screenshot_917

  1. Developer tags ought to work as well.

Set Scale

  1. Slowly walk your wearable tag around your space, going to all of the corners of the space. As you do so watch the "BOUNDS" values. This should give you a sense of the minimum and maximum x and y values of your space. They should roughly match the values on the https://app.pozyx.io/ Visualization page (move the mouse around and look in the bottom left corner for the x/y values).
  2. The TRACKER SETUP page will give you a suggested scale value based on the width and height of your tracked area. The scale value should bring your x/y values down to between -0.5 and +0.5. The wearables seem to glitch a bit, so you might have to use some judgement to figure out the correct values. In my setup, the scale seemed to be around 0.0002 to 0.0003. If you can't see your tag-controlled moth at all, try scaling it REALLY small to get it in the space, e.g. 0.0001.
  3. Enter the suggested scale. The transforms should update immediately as you change the values, so hopefully a moth will show up (wearable tags sleep by default after about a second, so you might have to shake it again to wake it up).
  4. Walk around the space to see if the edges feel about right. If not, adjust the scale up or down. Smaller numbers will decrease the scale, larger numbers increase the scale.
  5. In my setup, I needed to use a negative x scale to flip left and right to match the screen. You can also use a negative y to flip top and bottom.

Set Rotation

  1. Walk straight up and down with a wearable. Note the angle that your moth moves. If it isn't correct, change the rotation value. E.g. if walking straight up and down results in the moth moving slightly to the left, e.g. 10 O'clock, try a rotation value of -30 degrees.
  • Positive degrees rotates counter clockwise
  • Negative degrees rotates clockwise

Set Translation

  1. Stand with the tag in the center of your tracked space. If the moth does not appear in the center of the stage, change the TranslateX and TranslateY values until it does. The units are the same mm units you see on https://app.pozyx.io.

Use Accelerometer

  1. By default, the system will use accelerometer data sent from wearable tags to dampen the jitter. You can turn this off by unchecking "Accelerometer"

Write Down the Values

  1. Walk around to test your values, adjusting any as necessary.
  2. When you are satisfied with the values, write them down so that you can restore them later.

Since we do not yet have a storage system, you'll want to note these numbers.

  1. Alternatively, you can override the default values in the code. Edit the POZYX_TRANSFORM constant's default values in gs_packages/gem-srv/src/modules/datacore/dc-inputs.ts` lines 147-151 (or thereabouts) so you don't have to re-enter them every time you reload.

PLEASE DO NOT COMMIT ANY OF THESE CHANGES!

V. Set Entity Mapping

You can define what kind of character types pozyx tags should be mapped to in the project file. There is a new parameter value isPozyxControllable that can be added to characters.

Note also that isControllable has now been renamed to isCharControllable to be more explicit.

For example, this "Fish" character type can be controlled either by Pozyx or CharControl.

export const MODEL = {
  label: 'Aquatic Ecosystem',
  bounds: {...},
  scripts: [
    {
      id: 'Fish',
      label: 'Fish',
      isCharControllable: true,
      isPozyxControllable: true,
      script: `# BLUEPRINT Fish
               ...`
    }
  ]
};

VI. Test the System

  1. Go back to the Main page.
  2. Click "GO"
  3. The predator bee should chase all moths on screen, including your wearable tag moth.
  4. Any moth that is eaten is left inert. So a wearable-controlled moth should turn transparent.

I found it rather difficult to evade a predator with the wearable in my space. The predator is just too fast.


Obstruction Zones

Pozyx will let you define obstruction zones where tags are not allowed to send data. Use this to prevent other tags from entering your space, e.g. if you have two classrooms set up next to each other. See the pozyx documentation on Defining Zones for more information on how to set that up.

Any tags in the obstruction zone will not have its data relayed by the pozyx server. From the GEM-STEP side, the tag will simply not be there.

Note however, that tags appearing at the edge of the zone may remain for quite some time before they are removed. Pozyx takes a few seconds before it'll remove the tag. And GEM-STEP also waits quite a while before it removes the tag.

The raw tag positions should match the pozyx positions, so you can use those to help define the zone. Use the "tracker" setup view on Main to monitor the positions.

screenshot_1150


Implementation Notes

  • Accelerometer -- We're using the accelerometer to dampen the jitter. See #212. While you're still, we limit how far you can move, so position jitter is less pronounced. If you're moving fast, we allow larger movements. The algorithm is a little hacky though because theoretically once you reach a steady velocity your movements will be dampened even if you're still moving. To get around that we use the small movements you make while holding the accelerometer to keep moving the entity towards its target position.
  • Sleeping Tags -- By default, tags go to sleep after 25 blinks. For some reason while asleep they sometimes emit position values that are wildly inaccurate. To squelch this, if we see any large movements (> 0.25) while the tag is relatively still (< 250 mg), we ignore it. See #114.
  • Saving settings -- As mentioned, we still need to build out the system to save locale information, including mqtt IP address and transforms.
  • We still need to spend more time playing with the Pozyx device configurations to see if we can improve performance.

TIPS

  • Pozyx suggests that you can get better positioning accuracy if you move the anchors further apart (10 - 15m).
⚠️ **GitHub.com Fallback** ⚠️