View Single Post
  #118  
Old 06-06-2016, 04:04 PM
SteinHDan SteinHDan is offline
Green Horn
 
Join Date: Sep 2015
Location: Oslo, Norway
Posts: 188
SteinHDan is on a distinguished road
Default Re: 90 ton 1/14 metal excavator scratch build w/embedded PC

You can try the visualization on your own PC by clicking on this link:
- http://d1t2tbzmskak12.cloudfront.net...ion/index.html




To view the client source code, just click "View source" on the web page.

The web page will try to connect to the excavator using the local IP address 192.168.0.107:8001. If it isn't able to connect, it will just play some random movements. Only computers on my network will be able to connect to my excavator, so you all will see the random movements.


On the excavator (the server in this case) I run these few lines to broadcast the positions to all clients that connect:

Code:
var ws = require("nodejs-websocket")
var server = ws.createServer().listen(8001);
setInterval(function() {
    server.connections.forEach(function (conn) {
        conn.sendText(JSON.stringify({bucket: state.bucket.pos, stick: state.stick.pos }));
    })
}, 40);
That's all there is to it!

Best regards,
Stein :-)
Reply With Quote