GithubHelp home page GithubHelp logo

ptcrealitylab / vuforia-spatial-edge-server Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 14.0 68.69 MB

Edge Server for the Vuforia Spatial Toolbox, a shared research platform for exploring spatial computing as a community

Home Page: https://spatialtoolbox.vuforia.com

License: Mozilla Public License 2.0

HTML 0.72% JavaScript 98.83% CSS 0.33% Shell 0.06% Dockerfile 0.01% Handlebars 0.04% PowerShell 0.01%
vuforia iot server

vuforia-spatial-edge-server's Introduction

Vuforia Spatial Edge Server

The Spatial Edge Server is the backbone of the Vuforia Toolbox system. Every device in the system, from an iPhone to an industrial robot arm, will run an instance of this server. This README outlines how to install the server on larger scale devices with command line access like laptops or desktops. Running on embedded devices may require more preparation. App-specific documentation can be found in the Vuforia Toolbox iOS or Vuforia Toolbox Android repositories.

Read First

The Vuforia Spatial Toolbox and Vuforia Spatial Edge Server make up a shared research platform for exploring spatial computing as a community. This research platform is not an out of the box production-ready enterprise solution. Please read the MPL 2.0 license before use.

Join the conversations in our discourse forum if you have questions, ideas want to collaborate or just say hi.

Installation

First, install Node.js. We currently test our software on Node 12, 14, 16, and 18 with 16 being our recommended platform.

Second, clone this repository into your desired directory:

git clone https://github.com/ptcrealitylab/vuforia-spatial-edge-server.git

Next, enter the vuforia-toolbox-server directory and install all dependencies.

cd vuforia-spatial-edge-server
npm install

Now, initialize the core add-on git submodule and install its dependencies.

git submodule update --init --recursive
cd addons/vuforia-spatial-core-addon
npm install
cd ../.. # return to the main vuforia-toolbox-server directory

Finally, configure and generate a local self-signed certificate.

cp scripts/cert.conf.template scripts/cert.conf
# edit scripts/cert.conf to include your local ip address if desired
vim scripts/cert.conf
./scripts/generate_cert.sh or ./scripts/generate_cert.ps1 (for windows)

If desired, you can now add this certificate (cert.pem) to your local trusted certificate store (e.g. Keychain on macOS) to not have to manually add it to each browser's cert store. For more information on trusting on iOS, see this guide

You can now run the server using the following command:

npm start

Contributing

We highly encourage you to contribute any code changes by making pull requests on GitHub. Fork this repository using the button on the top right, make and commit your changes, then GitHub will prompt you to make a pull request.

Automated Tests

Note that we do run some automated testing to ensure that our code remains consistently styled and functional. If you want to see the results of this testing locally, you can follow this Github Actions workflow.

git clone --recurse-submodules https://github.com/ptcrealitylab/vuforia-spatial-edge-server.git
cd vuforia-spatial-edge-server
./scripts/ci.sh

The most important parts of the workflow are running the commands of scripts/ci.sh to setup (note that some repos may not be available, causing test failures locally). After this, you can run tests using the following command in your vuforia-toolbox-server folder:

npm run test

The changes and untracked files in the spatialToolbox data folder added by scripts/ci.sh must be reset in between tests. To do so, run the following:

cd spatialToolbox && git reset --hard HEAD && git clean -fd && cd ..

Debugging

If you encounter a problem while developing, you can specify the LOG_MODULES or LOG_LEVEL environment variables. LOG_MODULES will filter debug logs to a specific file or directory. LOG_LEVEL will set the minimum console level to be logged. For example, on Mac/Linux the following command will only print log messages that originate from hardware interfaces:

LOG_MODULES=interfaces node index.js

This command hides all console messages except for those made using console.error:

LOG_LEVEL=error node index.js

This command would limit messages to the gitInterface.js and envelope.js files:

LOG_MODULES=gitInterface,envelope node index.js

LOG_MODULES is a list of comma-separated file names, folder names, or keywords that are checked against each log message's originating file's path.

Windows

To specify environmental variables like LOG_MODULES and LOG_LEVEL use the following in PowerShell:

$env:LOG_MODULES="interfaces"
node index.js

Specifying Services

This is an advanced option, not meant for general use at this point in time.

To specify a list of services that will be included in the heartbeats sent from this server, run the command like so:

node server.js --services world service2 service3

The world service in particular is used to request that scans for new World Objects get sent to this server rather than other servers on the local network that do not specify this service (by default, all servers have the same priority and the user must choose among them).

Additional Server Addons

There are several useful server addons that we do not include in the base server. For example, installing the include the edge agent and remote operator addons will enable your server to act as a standalone remote operator host behind our cloud proxy. Note that the edge agent addon is currently private but will be open-sourced soon.

For each addon you want to install follow these steps, substituting the github url as necessary:

cd addons
git clone https://github.com/ptcrealitylab/vuforia-spatial-remote-operator-addon
git clone [email protected]:ptcrealitylab/vuforia-spatial-edge-agent-addon
cd vuforia-spatial-remote-operator-addon
npm install
cd .. # return to the addons directory
cd vuforia-spatial-edge-agent-addon
npm install

vuforia-spatial-edge-server's People

Contributors

afusteptc avatar benolds avatar benptc avatar carsten87 avatar dangond-ptc avatar ddgond avatar dependabot-preview[bot] avatar dependabot[bot] avatar franckol avatar georgehahn avatar hobinjk avatar hobinjk-ptc avatar kevinortman avatar ktheo-ptc avatar marcteys avatar ptc-mklaudiny avatar ptc-rdeleeuw avatar saina-rez avatar sainarez avatar steve-kx-rl avatar ultrafro-ptc avatar valentinptc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vuforia-spatial-edge-server's Issues

Enable safe restoration of objects from saved backups zips

As a user I want to make a backup of an object folder as a zip, remove that object, then later restore this object by dropping that zip into the server UI

As a developer I want that to be done safely with a whitelist of allowed files

Missing size parameter in object target file

TypeError: Cannot read property 'split' of undefined
    at /Users/James/re/vuforia-spatial-edge-server/libraries/utilities.js:294:61
    at Parser.<anonymous> (/Users/James/re/vuforia-spatial-edge-server/node_modules/xml2js/lib/parser.js:304:18)
    at emitOne (events.js:116:13)
    at Parser.emit (events.js:211:7)
    at SAXParser.onclosetag (/Users/James/re/vuforia-spatial-edge-server/node_modules/xml2js/lib/parser.js:262:26)
    at emit (/Users/James/re/vuforia-spatial-edge-server/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/Users/James/re/vuforia-spatial-edge-server/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/Users/James/re/vuforia-spatial-edge-server/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/Users/James/re/vuforia-spatial-edge-server/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/Users/James/re/vuforia-spatial-edge-server/node_modules/xml2js/lib/parser.js:323:31)

@benptc Any insight?

Implement better route for sendMessageToFrame post messages

Accidentally triggers a lot of side effects in realityObject.messageCallBacks.mainCall unless we specifically ignore messages in it that have msgContent.sendMessageToFrame !== 'undefined' (current solution).

Figure out how to not need this special exception / why the side effects were being triggered in the first place.

hardware interface writes updated node data to itself.

I think this is by design but we could do better.

Currently when you write an update to a hardware interface node, the server triggers updates to it self and links throughout the entire server.

We need to extend the readListener function with an option not to listen to write calls to it self.

Implement feature "frame sharing" for world objects

Implement the body of setFrameSharingEnabled in server.js, and associated user interface changes.

The idea is that you can have a server with a world object that is hosting shared frames.. frames that you place from the pocket onto other objects in the network would be hosted and processed by this world object (hence, this server), iff those objects exist on other servers that don't have a copy of that type of frame. The frames would still be positioned relative to the object they are placed on, but the loading and computation would occur as if it belongs to this server.

As a result, you would only have to update the realityframes of one server to update the frames placed on all objects that it is sharing with.

Create script for stripping extra dependencies from mobile server

While the mobile and normal servers now share a codebase, the deployment of the miniServer now contains a bunch of unnecessary extra code and dependencies. To limit the size of the iOS/Android apps we should create a pre-deployment script which deletes parts of node_modules, removes all the hardwareInterfaces, etc.

Trying to add new tool to an anchor object immediately after its creation -> fails (using web interface)

I looked into why:

We need to call utilities.writeObject(objectLookup, objectName, objectID) to store the mapping of objectName->ID immediately when the object gets created. Currently it waits for you to add a target image or restart the server. Otherwise, utilities.readObject(objectName) returns null so the tool doesn't know which object to attach to (in if (req.body.action === 'new') of webServer.post(objectInterfaceFolder, ...)

Implement initial add-on system

Move frames, nodes, hardwareInterfaces, and logic blocks to a secondary package as described in https://github.com/ptcrealitylab/vuforia-toolbox-documentation/blob/master/make%20tools/makeTools.md

This includes the userinterface's nodes and vuforia-toolbox-apps' frames

  • Move frames into vuforia-spatial-core-addon
  • Move nodes into vuforia-spatial-core-addon
  • Move hardwareInterfaces into vuforia-spatial-core-addon
  • Move logic blocks into vuforia-spatial-core-addon
  • Do something with inactiveLogicBlocks
  • Test loading from addons/vuforia-spatial-core-addon
  • Test loading from ~/vuforia-spatial/addons/vuforia-spatial-core-addon
  • Figure out what to do about interfaces requiring hardwareAPI
  • Enable loading frames from multiple sources
  • Enable loading nodes from multiple sources
  • Enable loading hardwareInterfaces from multiple sources
  • Enable loading logicBlocks from multiple sources
  • Test loading from multiple sources

Anchors and non-anchors store object.json in different locations

Anchors store data at spatialToolbox/object.json and non-anchors store data at spatialToolbox/.identity/object.json. This becomes an issue when creating a non-anchor, since the first step requires creating it as an anchor before it gets a target applied to it, causing the server to read from both locations and advertise heartbeats for both objects.

Check socket connections

Look at socket open/closing/deletion across object lifecycle. Verify that state transitions are properly respected and everything is bug-free.

Toolbox Crashes when network interface changes

  1. Load the Toolbox the first time with wifi off
  2. Close the Toolbox
  3. change the Wifi to on.
  4. Play around with Airplane mode and Wifi on / off

App crashes when we add new tools to the world object.

Why?
The server saves the default network interface at start.
When the network setting change (for example the network interface is removed) the server has an undefined state for its network interface. Hence the Server crashes the app.

How to solve?
Wifi should be the primary network interface to use. We need to check if the network interface is undefined and switch to the one that is available. Once Wifi becomes available again, we need to switch back. At any given moment. IP for the server can not be undefined.

whereAmI - Feature

New attribute for objects, tools and nodes. If true on any object, tool, node the toolbox will show a guidance system to show where it is.

Redesign interface for creating HumanPoseObjects using a factory

I think this whole thing would be simpler as
var HumanPoseObjectFactory = require('./libraries/HumanPoseObject');;
var HumanPoseObject = HumanPoseObjectFactory.create({ips, version, protocol, Frame, Node});
then have HumanPoseObjectFactory look something like

class HumanPoseObjectFactory {
    static create(attributes) {
        return function() {
            let baseObj = this; // Here `this` refers to the blank object allocated by calling the function with new , you could overwrite it with just {} instead
            Object.assign(baseObj, attributes);
            HumanPose.prototype.constructor.apply(baseObj, arguments);
            return baseObj;
        }
    }
}

This would allow you to still do var x = new HumanPoseObject(blah);

The alternative, slightly more idiomatic way to do this would be to make it look like this instead:

class HumanPoseObjectFactory {
    constructor(baseAtrributes) {
        this.baseAttributes = baseAttributes;
    }

    create() {
        let baseObj = Object.assign({}, this.baseAttributes);
        HumanPose.prototype.constructor.apply(baseObj, arguments);
        return baseObj;
    }
}

then later do

var { HumanPoseObjectFactory } = require('...');
var humanPoseObjectFactory = new HumanPoseObjectFactory({stuff});

// ....
var humanPose = humanPoseObjectFactory.create(human, pose, things);

With either of these you could give create the proper arguments list of the HumanPoseObject constructor to aid syntax completion and all that good stuff.

Originally posted by @hobinjk-ptc in #15

Update the README

Pretty obsolete at this point, we should write something nice prior to the end February.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.