Git Product home page Git Product logo

cesium-lg's People

Contributors

abhishekvp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cesium-lg's Issues

slave: fix up yaw offset for vertical fov.

add this to slaves to account for vertical fov.
this is my shortcut for 16:9 galaxy screens, but really the browser document width and height should be queried and used for this.

  var displayAspectRatio = 16/9; // height/width - query dom for this
  viewer.camera.frustum.fov = toRadians(CONFIG.slaveHorizFOV * displayAspectRatio);

this will also need to be reset on browser window size change.

sample-config.js put in linebreaks, neaten it up.

neaten up the line breaks and formatting so it's easier to read.
change the intro comment.

//Rename this file to config.js and replace BingMapsKey with your key

var CONFIG = {
 wsURI : 'ws://10.237.10.1:8081',
 BingMapsKey : 'YOUR BING MAPS API KEY',
 camSigFigures : 10e6,
 slaveHorizFOV : 25,
 masterFOV : 25
 NODE_SERVER_IP: 'localhost',
 NODE_SERVER_PORT: 8081,
 UDP_PORT:21567,
 UDP_HOST: 'localhost'
};

node server.js: add receiving Google Earth UDP viewsync packets for camera pose

Add UDP packet listening and sending to the nodejs relay service, so it can send & respond to Google Earth viewsync UDP packets.

And translate between Cesium ViewSync and Earth ViewSync formats. In the first instance, I'd like to try using a Google Earth master to control Cesium slaves and get a better idea how responsive the slaves are.

add terrainProvider to Slave

In the Slave viewer setup app the AGI terrain provider...

            terrainProvider : new Cesium.CesiumTerrainProvider({
               url:'http://assets.agi.com/stk-terrain/world',
               requestWaterMask: true })

At some point we'll need to handle switching between different terrain providers (ellipisoid, VTK) as well.
But start by getting one in there to start with.

add Bing Maps Aeriel with Labels imagery

Hi, another layer to add..

    var bingMapsAerialWithLabels = new Cesium.BingMapsImageryProvider({
        url: 'http://dev.virtualearth.net',
        mapStyle: Cesium.BingMapsStyle.AERIAL_WITH_LABELS
    });

messaging types don't use a string?

For the message type need come up with some message type identifier that isn't a string.

At the moment "ge-cam" or "state" appears as literal string in the packet. I was hoping protobuf would encode this more efficiently. At the moment it still takes up a bunch of bytes when it should be less than 1.

Using some constants would be fine. TYPE.cam = 0; TYPE.status = 1; TYPE.gecam=2 ?
Or another idea?

tcpdump output...

18:25:04.232393 IP 10.237.10.1.8081 > 10.237.10.71.50687: Flags [P.], ack 1, win 123, length 76
    0x0000:  4500 0074 4284 4000 4006 cdde 0aed 0a01  E..tB.@.@.......
    0x0010:  0aed 0a47 1f91 c5ff 089e d0d5 75fd cdd1  ...G........u...
    0x0020:  5018 007b 2a88 0000 c24a 003e 00c1 ff0a  P..{*....J.>....
    0x0030:  0667 652d 6361 6d11 4680 20bd 05bb 6540  .ge-cam.F.....e@
    0x0040:  1985 63ca 050c aa43 c021 5200 fd50 096b  ..c....C.!R..P.k
    0x0050:  a240 29e3 88a1 f9b4 0bf6 3f31 0370 ddcd  .@).......?1.p..
    0x0060:  4ce7 c6bf 396b 3ce6 78f6 892f 3f00 0000  L...9k<.x../?...
    0x0070:  ffff 0200 

server.js: maintain count of active clients (not just maximum id)

In server.js wsServer.on() maintain count of active client count. So I can tell if I have the right number of slaves connected...

    var clientWSCount = 0, activeWSClientCount = 0;
    var wsClients = {};

    wsServer.on("connection", function(socket) { // Port 8081

        //Keep count of all connected clients
        var id = clientWSCount++;
        activeWSClientCount++;
        //Store connection object for each of the clients
        wsClients[id] = socket;
        console.log((new Date()) + ' Connection accepted [' + id + '], Active clients '+ activeWSClientCount);
...
 socket.on("close", function(reasonCode, description) {
            delete wsClients[id];
            activeWSClientCount--;
            console.log((new Date()) + ' Peer ' + id + ' disconnected. Still have '+activeWSClientCount+' clients');
        })

idea: camera pose heartbeat from nodejs relayer every 1 second

Hi, sending the current camera pose as heartbeat every second would be useful.
Particularly when Slave Cesiums restart and we want them to quickly re-sync to the current camera pose... they may restart when there are no camera updates happening.

I'm not sure whether to do this from the Cesium Master or from the server.js relay.

If the camera pose comes from Google Earth viewsync then it makes more sense for the nodejs relay to send the heartbeat.

Heartbeart time should be a CONFIG setting

CONFIG.cameraSyncHeartBeat = 1000; // (in milliseconds)

idea: simplify camera pose to lat/long/alt (like GE)

If we settle on using lat,long,alt,heading,pitch,roll for camera pose then we have a single handler for camera, rather than the two at the moment.

In Cesium Master we'll use camera.positionCartographic['longitude'], etc.

Leave the Cesium camera.position.x,y,z code in there, just commented out?

I'm not sure what the camera.position.xyz values are more or less useful than lat,long,alt?

server.js: simplify startup messaging

var server = app.listen(argv.port, argv.public ? undefined : NODE_SERVER_IP, function() {
    console.log('Cesium development server running on '+server.address().address+':'+ server.address().port);
    if (argv.public) {
        console.log('Be aware this server is listening on all interfaces');
    }
});

Add UI elements to Cesium Master for toggling features like Fog, etc.

On the Cesium Master add UI elements for toggling the state of some things we can use to test that slaves are following.

eg.
TerrainProviders - there's a selection see first Cesiumjs.org demo
Fog - viewer.fog.enabled = true/false
Lighting - viewer.scene.enableLighting = true/false
WaterMasks - flag for terrain loading
Terrain Shadowing -

I'll add more as I find or think of them.

getAspectRatio didn't work for me.

I'm not sure why you need to check for greatest common divisor?
With 16:9 screen.width is still the horizontal and screen.height the vertical.

This worked...

        function getAspectRatio() {
        return screen.height / screen.width;
        }

hmm... probably should be width / height, and then divide the HorizFov in the clients.

protobuf internal message for pose and state

I think a more complex protobuf will be needed...
eg.

message CesiumSync {
  required int32 msgtype =1;
  optional CameraPose pose = 2;
  optional State state = 3;
  message CameraPose { 
    required sint32 lon;
    ... lat, alt, heading, pitch, roll all required
   }
  message State { // viewer state
     optional boolean fog = 1;
     optional boolean lighting = 2;
     optional string ImageryProvider = 3;  // "Bing.ROAD"
     optional string TerrainProvider = 4; // "STK"
     optional boolean showDebugFPS = 5;
     ...
  }
}

server.js: cast to String() and only construct send string once.

this...

UDPserver.on('message', function (message, remote) {
    var msgArray = String(message).split(',');
    var lat = msgArray[1];
    var lon = msgArray[2];
    var alt = msgArray[3];
    var hdg = msgArray[4]*Math.PI/180;
    var pitch = (msgArray[5] - 90)*Math.PI/180;
    var roll = msgArray[6]*Math.PI/180;
    var wsMesg = '{"msg-type":"ge-cam", "lon":'+lon+',"lat":'+lat+',"ht":'+alt+',"heading":'+hdg+',"pitch":'+pitch+',"roll":'+roll+'}
';

    for(var i in wsClients){
    wsClients[i].send(wsMesg);
    }

reconnectingwebsocket for arraybuffer

Hi, this seems to work for me when switching back to the using reconnectingws library...

var ws = new ReconnectingWebSocket(CONFIG.wsURI, null, { binaryType: 'arraybuffer' } );
// ws.binaryType = "arraybuffer";

server.js: send & receive protobuf message as UDP broadcast

I'd like to use UDP broadcast between the Master server.js and Slave(s) server.js.

Actually the 'server.js' will be more like 'bridge.js' :)

Master Cesium > [websocket] > node server.js > [udp broadcast] > slaves node server.js > [websocket] > Slave Cesium

This is becasue the camera pose updates are time critical, and sending them as TCP websocket in a loop one at a time is introducing jitter. We can eliminate that jitter by sending a SINGLE UDP broadcast from the Master which will be picked up by the slaves.

This is going to need to be on a different port to Google Earth.

server.js check for duplicate GE cam strings before sending

In server.js in the UDP GoogleEarth cam function, save 'msgToWSClients' and check that it is different from the last GE message. We don't need to transmit duplicate camera poses.

This will be a bit like the 'lastCamStr' in the Master.

update: protobuf using signed ints for camera pose.

server.js:

    UDPserver.on('message', function(message, remote) {

        var viewsync = String(message).split(',');

        var s = new CesiumSync();
        s.msgtype = 2;
        s.lat = Math.round(parseFloat(viewsync[1]) * 10e5);
        s.lon = Math.round(parseFloat(viewsync[2]) * 10e5);
        s.alt = Math.round(parseFloat(viewsync[3]) * 100);
        s.heading = Math.round(util.toRadians(parseFloat(viewsync[4])) * 10e4);
        s.pitch = Math.round(util.toRadians((parseFloat(viewsync[5]) - 90)) * 10e4);
        s.roll = Math.round(util.toRadians(parseFloat(viewsync[6])) * 10e3);

        var thisSync = s.toBuffer();

        if (thisSync != lastGESync) {
                lastGESync = thisSync;

                for (var i in wsClients) {
                    wsClients[i].send(thisSync);
                }

            // UDPclient.send(thisSync,0,thisSync.length,CONFIG.CesiumSyncPort,CONFIG.CesiumSyncHost);
        }
    });

cesiumsync.proto:

message CesiumSync {
    required int32 msgtype = 1;
    optional sint32 lon = 2;
    optional sint32 lat = 3;
    optional sint32 alt = 4;
    optional sint32 heading = 5; 
    optional sint32 pitch = 6;
    optional sint32 roll = 7;
    optional bool lighting = 8;
}

updates to Slave-Client.html:

function handleGECam(camVals) {

            var px = camVals.lon / 10e5,
                py = camVals.lat / 10e5,
                pz = camVals.alt / 100,
                heading = camVals.heading / 10e4,
                pitch = camVals.pitch / 10e4,
                roll = camVals.roll / 10e3;
...

server.js UDP loop - create the client message once!

There is no reason to create the client message every iteration. It's the same message.
Do it once before the loop and then just send it to each client.
See code in the previous issue that was closed.

for(var i in wsClients){
//if(clients[i]!=connection)
var lat = msgArray[1];
var lon = msgArray[2];
var alt = msgArray[3];
var heading = msgArray[4]_Math.PI/180;
var pitch = (msgArray[5] - 90)_Math.PI/180;
var roll = msgArray[6]*Math.PI/180;

            wsClients[i].send('{"msg-type":"ge-cam", "lon":'+lon+',"lat":'+lat+',"ht":'+alt+',"heading":'+heading+',"pitch":'+pitch+',"roll":'+roll+'}');

            }

websocket messaging efficiency: try protobufs or arraybuffers

To make the websocket messaging more efficient we need to move away from sending stringified JSON objects and only transmit the minimal information needed and in the most effective manner we can think of (given gsoc time!).

I suggest investigating google protobuf or javascript arraybuffers.

Master/Slave: config module warning

I'm not sure using the same config for both nodejs and browser js clients is working very well.

Need a better way of doing a shared config, or give up and have separate config.

The cesium client have this warning...

ReferenceError: module is not defined

node server.js: add relaying functionality not just echo

Change the echo server to act as a relay.
Most the camera sync messages there's no reason to send a packet BACK to the master, it just adds latency.
You can use a particular URI path like /relay/ for this
or have the master send a message like 'IAmMaster' to switch off echo for that client.

server.js: add sending Earth viewsync UDP packet for camera pose from Cesium

(low priority)

Take the Cesium Master camera pose and broadcast it as UDP in viewsync format.
Just camera pose to start with, don't worry about timers.

Will need config for network address to send on, also config for whether this is a unicast send or broadcast (i think).
Will need config for udp socket number

add GridImagery provider.

Hi, add GridImagery provider it's a nice low data imagery provider.

var GridImageryProvider = new Cesium.GridImageryProvider({cells:8, glowWidth:0});

no geocoder needed on slave

By default the slave doesn't need a geocoder UI.

The default Slave UI should be empty, just a cesium globe.

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.