4

I'm a beginner of Cesium and Javascript code. I need to create the orbit of a satellite (ESEO) around the globe. The satellite have to move according to SGP4 model. How can I create it in Cesium sandcastle? I'm in trouble because I'm not finding any tutorials or examples online that explain how to do it. Right now I have only positioned the ground station where I want on the globe.

var viewer = new Cesium.Viewer ('cesiumContainer', {
    scene3DOnly: false,
    selectionIndication: false,
    baseLayerPicker: true
                                });

Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI4ODY0ZjkwMy03YmZlLTRlNGEtYmNhOS0xMDBlZGVmNDRkZGMiLCJpZCI6OTE4MSwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU1MzYxMjM5Mn0.aYYX1f1MQfg9zLFu0vnP3A56Neo4Y_N3G2O5tuTS0XM';

// Enable lighting based on sun/moon positions
viewer.scene.globe.enableLighting = true;

//Stazione di terra
var entity = viewer.entities.add({
  position: Cesium.Cartesian3.fromDegrees(12.04, 44.23),
  ellipse : {
    semiMinorAxis : 150000.0,
    semiMajorAxis : 150000.0,
    material : Cesium.Color.YELLOW.withAlpha(0.5)
  }
});
var ellipse = entity.ellipse;
ellipse.material = new Cesium.GridMaterialProperty({
  color : Cesium.Color.YELLOW,
  cellAlpha : 0.2,
  lineCount : new Cesium.Cartesian2(8, 8),
  lineThickness : new Cesium.Cartesian2(2.0, 2.0)
});


var GroundStation = viewer.entities.add({
    name : 'Ground Station',
    position : Cesium.Cartesian3.fromDegrees(12.07, 44.23),
    point : {
        pixelSize : 5,
        color : Cesium.Color.RED,
        outlineColor : Cesium.Color.WHITE,
        outlineWidth : 2
    },
    label : {
        text : 'Ground Station',
        font : '14pt monospace',
        style: Cesium.LabelStyle.FILL_AND_OUTLINE,
        outlineWidth : 2,
        verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
        pixelOffset : new Cesium.Cartesian2(0, -9)
    }
});

  • 1
    It's unlikely there would be a tutorial for something quite so specific. But it sounds like basically it's a mathematical model. So there should be some algorithm or calculation to do. Computers are good at maths, and most programming languages, including JavaScript, have lots of maths functions and operators you can use, you just need to look them up. I would first plan out your calculations on paper, and then try to work out how you would make the code perform each calculation, step by step. It's unlikely anyone here will help you until you've at least tried to start it yourself – ADyson Apr 06 '19 at 09:06
  • I've already done the mathemtical model but the problem now is just create the orbit on cesium sandcastle. I don't know how to visualize the paths and the satellite movements on it – Francesco Mazzeo Apr 06 '19 at 09:16
  • So you want to make a graphical display of it, rather than just calculations? I'm not sure that was clear in the question. Have you done the basics of this Cesium tool to work out how to make simple shapes etc? – ADyson Apr 06 '19 at 09:49
  • Yes, the first problem is create a generical orbit using paramethres like period, semi-axis major, eccentricity...like an STK scenario. I'd like to display the path and a point, wich represent the satellite, moving on it. How I've already said, I'm a beginner of Cesium and Javascript, I'm trying to learn using tutorials and examples but about this I couldn't find anyhing. – Francesco Mazzeo Apr 06 '19 at 09:53
  • I used these tutorials on cesium js page: https://cesium.com/docs/ – Francesco Mazzeo Apr 06 '19 at 10:02
  • this has to be the final result but with only one satellite, ESEO. https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=CZML.html&label=All – Francesco Mazzeo Apr 06 '19 at 10:19
  • Can you show the code you have written so far, even if it's simple. Then we have a starting point. I would say though, if you are only just starting JavaScript this is a very complicated thing to begin with. Maybe try and get comfortable with the language using some simpler exercises first? – ADyson Apr 06 '19 at 10:33
  • //Ground station var entity = viewer.entities.add({ position: Cesium.Cartesian3.fromDegrees(12.04, 44.23), ellipse : { semiMinorAxis : 150000.0, semiMajorAxis : 150000.0, material : Cesium.Color.YELLOW.withAlpha(0.5) } }); – Francesco Mazzeo Apr 06 '19 at 10:40
  • var ellipse = entity.ellipse; ellipse.material = new Cesium.GridMaterialProperty({ color : Cesium.Color.YELLOW, cellAlpha : 0.2, lineCount : new Cesium.Cartesian2(8, 8), lineThickness : new Cesium.Cartesian2(2.0, 2.0) }); – Francesco Mazzeo Apr 06 '19 at 10:40
  • var GroundStation = viewer.entities.add({ name : 'Ground Station', position : Cesium.Cartesian3.fromDegrees(12.07, 44.23), point : { pixelSize : 5, color : Cesium.Color.RED, outlineColor : Cesium.Color.WHITE, outlineWidth : 2 }, – Francesco Mazzeo Apr 06 '19 at 10:40
  • label : { text : 'Ground Station', font : '14pt monospace', style: Cesium.LabelStyle.FILL_AND_OUTLINE, outlineWidth : 2, verticalOrigin : Cesium.VerticalOrigin.BOTTOM, pixelOffset : new Cesium.Cartesian2(0, -9) } }); – Francesco Mazzeo Apr 06 '19 at 10:41
  • Please put your code into the body of your question and format it so it's clear and easy to read. Comments are not the place for it. And please also explain what the code achieves so far, and any bugs you have noticed. Thanks – ADyson Apr 06 '19 at 10:44
  • I tryed to use a path or a polyline to draw the orbit but than I'm not able to put a point over it and let it move – Francesco Mazzeo Apr 06 '19 at 10:45
  • Ok. Can you move the code into the question as requested please. It's unreadable how it is now. – ADyson Apr 06 '19 at 11:51
  • If you're generating SGP4 results on the client (in JavaScript), generally you want to create a Cesium Entity whose position is set to a [SampledPositionProperty](http://c1200610-00.stk.com/Cesium/Build/Documentation/SampledPositionProperty.html) that has been initialized with SGP4 results. If the SGP4 calc happens on the server, you can write to a CZML stream with a project like czml-writer, to get that data into a client-side Entity. – emackey Apr 08 '19 at 19:37

2 Answers2

3

When people draw orbits in Cesium, they usually use polylines instead of the ellipse entity that you use.

Link to polyline/polyline collection: https://cesiumjs.org/Cesium/Build/Documentation/Polyline.html

Now with regards to SGP4, this propagator takes in a NORAD two-line element. So if you have your orbital parameters you can create your own TLE. This should be pretty easy to do in an external python program and writing it to a JSON file which can be read into javascript and then passed to the propagator. For more info about TLEs, wikipedia has a good description of how it is formatted.

TLE info: https://en.wikipedia.org/wiki/Two-line_element_set

For the actual SGP4 implementation, there is a Satellite.js package whose github is linked below. They are able to properly implement a propagator that takes in NORAD TLE's and spits out trajectory information.

Satellite.js github: https://github.com/shashwatak/satellite-js

I am pretty sure you have to convert the TLE into different parameters you pass into the satellite-js module which propagates it.

When you are doing this, I highly recommend creating a worker thread for the code to execute because of the heavy overhead. You do not want to have all your mathematical heavylifting being done along with the graphical rendering of Cesium.

Another note of importance: You absolutely should not need to use SGP4 if you can avoid it. You should create your own propagator that fits the needs of your project. Orbit determination can be tricky but is much better practice than using a propagator meant for NORAD satellite tracking.

aaastro
  • 171
  • 6
3

You can look at this project for a demonstration of some of the items listed in aaastro's answer.

jspredict

You can also checkout this great paper and supporting source for further explanations on TLE, SGP4, Cesium.

Spacemission

Visualization of Orbital Debris with Cesium and Satellite-js

hmcmurray
  • 81
  • 2