TrystanLea / SAPjs

Minimal user interface for OpenBEM SAP model
GNU Affero General Public License v3.0
13 stars 2 forks source link

MQTT API for remote operation of the Fabric tables (enabling a VR interface) #5

Open goatchurchprime opened 2 years ago

goatchurchprime commented 2 years ago

The easiest way to inject values into a webpage running Javascript from a completely different system is to use MQTT.

If you include the library described here: http://www.steves-internet-guide.com/using-javascript-mqtt-client-websockets/ and add in a new button and a text box (with a default) for the link to the broker, I can post snippets of JSON from somewhere else that you can easily unpack into the relevant rows of your table as they come in.

....

The external system I have in mind for generating the dimension data is this mobile VR interface I have developed for tracing up point scans acquired using the lidar in an iPhone. https://www.youtube.com/watch?v=Zr2RzsX-9hc (A Housahedron, if you will.)

It won't be hard to program my system to issue MQTT messages containing JSON packets of the fabric dimensions each time you draw, edit or specify a new wall/ceiling/floor/window element in VR (where you are working at 1:1 scale).

Realistically, with this method, we could aim to get over half of your webpage filled in (the hardest part) in under an hour of not very skilled+tedious work. The scanning of all the rooms takes 20 minutes at most. And the tracing up in VR can be pretty easy and intuitive with very little training and practice, especially when there is such an immediate feedback.

Don't underestimate the time saved by not having to go through a file save, conversion and importing process because the numbers are loading into the table as you draw up the shapes.

Also, there is a lot less wasted effort than with the SketchUp method mentioned in https://github.com/TrystanLea/SAPjs/issues/4 because there is no need to generate a water tight solid model that looks good. Only the 2D surfaces you happen to need are drawn. For the purposes of this energy model they don't have to fit together or be more than about 5% accurate.

TrystanLea commented 2 years ago

Hello Julian, good to hear from you!

That does sound interesting, I have seen some really nice results form a commercial product that does this kind of thing, I'm sure it was shared on twitter recently but I cant remember the details.

SAPjs has been very much a side project for me and has fulfilled the personal goal that I needed it for, I have no grand vision of wide adoption for this tool. My over-arching design intention for the tool is to keep-it-simple and not try to do too much. I'd be more than happy to see it forked and used within something more automated as you describe but it's probably not something I can get involved in.. I have to choose my activity carefully these days..

Have you seen https://heatpunk.co.uk/ it's a really nice tool by midsummer wholesale for heat loss calculations with a 2d floor plan builder, is that a better target for your tool perhaps?

goatchurchprime commented 1 year ago

I've put in a version here http://goatchurchprime.github.io/SAPjs/index.html

Based on this branch: https://github.com/goatchurchprime/SAPjs/tree/incoming-mqtt-api

It amounts of 100 lines of javascript hacked into the top of the index.html

Then you can drive it using these commands anywhere else:

mosquitto_pub -h mosquitto.doesliverpool.xyz -t "sapjs/vr1/json" -m '{"clear":"elements" }'

mosquitto_pub -h mosquitto.doesliverpool.xyz -t "sapjs/vr1/json" -m '{"id":"E1", "lib":"Stone wall", "l":10, "h":12 }'

In particular this works from the VR interface from this app as the walls and windows are sketched based on the iPhone lidar points scan: https://github.com/tunnelvr/tunnelvr/tree/sapjs-mqtt-communication

TrystanLea commented 1 year ago

Nice! thanks Julian! I've added a link to the readme page to point others to your work https://github.com/TrystanLea/SAPjs/blob/main/README.md