# STK CZML Stream Problem - Not Smooth (Please Halp!)

**URL:** <https://community.cesium.com/t/stk-czml-stream-problem-not-smooth-please-halp/7938>\
**Category:** CesiumJS\
**Created:** [January 25, 2019, 2:15am UTC](https://community.cesium.com/t/stk-czml-stream-problem-not-smooth-please-halp/7938 "2019-01-25T02:15:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RG1](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/rg1/32/2103_2.png) [@RG1](https://community.cesium.com/u/RG1)\
**Post date:** [January 25, 2019, 2:15am UTC](https://community.cesium.com/t/stk-czml-stream-problem-not-smooth-please-halp/7938/1 "2019-01-25T02:15:00Z")

</div>

I’m still having trouble trying to get a smooth animation of my satellite in Cesium. Some direction would be appreciated. I did contact AGI since we pay for the support and upgrades on our licenses but I guess they don’t do support for Cesium but they suggested I messed with the forwardExtrapolation but that doesn’t seem to work either. \*I can’t seem to highlight the CZML packet code syntax - sorry.

I’m streaming CZML packets to Cesium that I collect from STK when (STK) animation is also running. Since the multiplier is not really one-to-one with Cesium’s multiplier and I don’t want to sit there forever at a multiplier of x1, I increase the multiplier on STK and in the CZML packet, I obtain the current time from STK and send it across via in the CZML packet with other data such as position and quaternions.

As you can see from the video attachment, time is updating kind of okay I guess, but the satellite in question has some jerky motion that is driving me nuts. I tried various interpolation algorithms and degrees, set the current time a little bit in the future and less for the position and quaternion data but to no avail, still jerky. I’m also using Gabby’s suggestion code here and my CZML packet data is also listed below. Let me know if you all see something wrong/stupid that I did and let me know if you have questions or more code. Thank you!

var clock = viewer.clock;  
var lastUpdated = clock.currentTime;  
clock.onTick.addEventListener(function() {  
var dt = Cesium.JulianDate.secondsDifference(clock.currentTime, lastUpdated);  
if (dt \>= 1.0) {  
// Add a new sample position  
lastUpdated = clock.currentTime;

```
}

```

});

///////////////////////////////////////////////////////////////

// FIRST CZML PACKET GENERATION

///////////////////////////////////////////////////////////////

public static void CZML\_Packet\_1()

{

RootObject1 JsonRoot1 = new RootObject1();

JsonRoot1.id = “document”;

JsonRoot1.name = “CesiumTest”;

JsonRoot1.version = “1.0”;

Clock JsonClock = new Clock();

JsonClock.interval = “2018-08-30T18:00:00Z/2018-09-06T18:00:00Z”;

string startInterval = “2018-08-30T18:00:00Z”;

JsonClock.currentTime = currentSTKtime;

JsonClock.multiplier = 3.2;

JsonClock.range = “LOOP\_STOP”;

JsonClock.step = “SYSTEM\_CLOCK\_MULTIPLIER”;

JsonRoot1.clock = JsonClock;

CZML\_JSON\_1 = JsonConvert.SerializeObject(JsonRoot1);

///////////////////////////////////////////////////////////////

}

///////////////////////////////////////////////////////////////

// SECOND CZML PACKET GENERATION

///////////////////////////////////////////////////////////////

public static void CZML\_Packet\_2()

{

// SECOND CZML PACKET

RootObject JsonRoot = new RootObject();

JsonRoot.id = “Satellite/ButtSat”;

JsonRoot.availability = “2018-08-30T18:00:00Z/2018-09-06T18:00:00Z”;

JsonRoot.name = “ButtSat”;

Orientation JsonOrientation = new Orientation();

JsonOrientation.interpolationAlgorithm = “HERMITE”;

JsonOrientation.interpolationDegree = 2;

JsonOrientation.extrapolationType = "HOLD ";

JsonOrientation.forwardExtrapolationType = “HOLD”;

JsonOrientation.forwardExtrapolationDuration = 0;

JsonOrientation.backwardExtrapolationDuration = 0;

JsonOrientation.backwardExtrapolationType = “HOLD”;

string startInterval = “2018-08-30T18:00:00Z”;

JsonOrientation.epoch = startInterval;

// SECOND CZML PACKET WITH QUATERNION DATA

if (FlagStop2 == 0)

{

dbQuat.Add(secSincEpoch);

dbQuat.Add(ATD\_QEST\_CBI2BDY0);

dbQuat.Add(ATD\_QEST\_CBI2BDY1);

dbQuat.Add(ATD\_QEST\_CBI2BDY2);

dbQuat.Add(ATD\_QEST\_CBI2BDY3);

[//Console.WriteLine](https://Console.WriteLine)(flagCZMLquat);

FlagStop2 = 1;

}

JsonOrientation.unitQuaternion = dbQuat;

JsonRoot.orientation = JsonOrientation;

// SECOND CZML PACKET WITH POSITION DATA

Position JsonPosition = new Position();

JsonPosition.interpolationAlgorithm = “LAGRANGE”;

JsonPosition.interpolationDegree = 7;

JsonPosition.forwardExtrapolationDuration = 0;

JsonPosition.extrapolationType = “HOLD”;

JsonPosition.referenceFrame = “FIXED”;

JsonPosition.forwardExtrapolationType = “HOLD”;

JsonPosition.backwardExtrapolationDuration = 0;

JsonPosition.backwardExtrapolationType = “HOLD”;

JsonPosition.epoch = startInterval;

if (FlagStop3 == 0)

{

dbPos.Add(secSincEpoch);

dbPos.Add(EPH\_POS\_CBIX);

dbPos.Add(EPH\_POS\_CBIY);

dbPos.Add(EPH\_POS\_CBIZ);

FlagStop3 = 1;

}

JsonPosition.cartesian = dbPos;

JsonRoot.position = JsonPosition;

// SECOND CZML PACKET WITH SHOW DATA

SOLIS\_CMD\_TLM.Show JsonShow = new SOLIS\_CMD\_TLM.Show();

JsonShow.interval = “2018-08-30T18:00:00Z/2018-09-06T18:00:00Z”;

JsonShow.boolean = true;

// SECOND CZML PACKET WITH LEADTIME DATA

SOLIS\_CMD\_TLM.LeadTime JsonLeadTime = new SOLIS\_CMD\_TLM.LeadTime();

JsonLeadTime.interval = “2018-08-30T18:00:00Z/2018-09-06T18:00:00Z”;

JsonLeadTime.epoch = startInterval;

List dbNumber = new List();

dbNumber.Add(10);

dbNumber.Add(10);

dbNumber.Add(10);

dbNumber.Add(10);

JsonLeadTime.number = dbNumber;

// SECOND CZML PACKET WITH TRAILTIME DATA

SOLIS\_CMD\_TLM.TrailTime JsonTrailTime = new SOLIS\_CMD\_TLM.TrailTime();

JsonTrailTime.interval = “2018-08-30T18:00:00Z/2018-09-06T18:00:00Z”;

JsonTrailTime.epoch = startInterval;

[//JsonTrailTime.epoch](https://JsonTrailTime.epoch) = Ces\_rt;

List dbNumber1 = new List();

dbNumber1.Add(10);

dbNumber1.Add(10);

dbNumber1.Add(10);

dbNumber1.Add(10);

JsonTrailTime.number = dbNumber1;

// SECOND CZML PACKET WITH COLOR2 DATA

SOLIS\_CMD\_TLM.Color2 JsonColor2 = new SOLIS\_CMD\_TLM.Color2();

List lstRGBA = new List();

lstRGBA.Add(0);

lstRGBA.Add(255);

lstRGBA.Add(255);

lstRGBA.Add(255);

JsonColor2.rgba = lstRGBA;

// SECOND CZML PACKET WITH SOLID COLOR DATA

SOLIS\_CMD\_TLM.SolidColor JsonSolidColor = new SOLIS\_CMD\_TLM.SolidColor();

JsonSolidColor.color = JsonColor2;

// SECOND CZML PACKET WITH MATERIAL DATA

SOLIS\_CMD\_TLM.Material JsonMaterial = new SOLIS\_CMD\_TLM.Material();

JsonMaterial.solidColor = JsonSolidColor;

// SECOND CZML PACKET WITH PATH DATA

SOLIS\_CMD\_TLM.Path JsonPath = new SOLIS\_CMD\_TLM.Path();

List lstShow = new List();

lstShow.Add(JsonShow);

JsonPath.show = lstShow;

JsonPath.width = 2;

JsonPath.material = JsonMaterial;

[//JsonPath.resolution](https://JsonPath.resolution) = 1200;

JsonPath.resolution = 3;

List lstLeadTime = new List();

lstLeadTime.Add(JsonLeadTime);

List lstTrailTime = new List();

lstTrailTime.Add(JsonTrailTime);

JsonPath.leadTime = lstLeadTime;

JsonPath.trailTime = lstTrailTime;

// MODEL DATA

SOLIS\_CMD\_TLM.Model JsonModel = new SOLIS\_CMD\_TLM.Model();

JsonModel.gltf = “[https://assets.agi.com/models/ikonos.gltf](https://assets.agi.com/models/ikonos.gltf)”;

[//JsonModel.gltf](https://JsonModel.gltf) = “…/…/SampleData/models/CesiumSpace/ikonos.gltf”;

JsonModel.scale = 1;

JsonModel.runAnimations = false;

JsonModel.show = true;

// COLOR DATA

SOLIS\_CMD\_TLM.Color JsonColor = new SOLIS\_CMD\_TLM.Color();

List lstRGBA1 = new List();

lstRGBA1.Add(255);

lstRGBA1.Add(0);

lstRGBA1.Add(0);

lstRGBA1.Add(255);

JsonColor.rgba = lstRGBA1;

// EYEOFFSET DATA

SOLIS\_CMD\_TLM.EyeOffset JsonEyeOffset = new SOLIS\_CMD\_TLM.EyeOffset();

List lstCartesian = new List();

lstCartesian.Add(0);

lstCartesian.Add(0);

lstCartesian.Add(0);

JsonEyeOffset.cartesian = lstCartesian;

// PIXEL OFFSET

SOLIS\_CMD\_TLM.PixelOffset JsonPixelOffset = new SOLIS\_CMD\_TLM.PixelOffset();

List lstCartesian1 = new List();

lstCartesian1.Add(0);

lstCartesian1.Add(0);

JsonPixelOffset.cartesian2 = lstCartesian1;

// BILLBOARD DATA

SOLIS\_CMD\_TLM.Billboard JsonBillboard = new SOLIS\_CMD\_TLM.Billboard();

JsonBillboard.color = JsonColor;

JsonBillboard.eyeOffset = JsonEyeOffset;

JsonBillboard.horizontalOrigin = “CENTER”;

JsonBillboard.image = “data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAjSURBVChTYyAa/EcDUGEIgIphAKg0XRSAAFQMDqDChAADAwDC13+BJ+0oDwAAAABJRU5ErkJgggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==”;

JsonBillboard.pixelOffset = JsonPixelOffset;

JsonBillboard.scale = 1;

JsonBillboard.show = true;

JsonBillboard.verticalOrigin = “CENTER”;

// FILL COLOR DATA

SOLIS\_CMD\_TLM.FillColor JsonFillColor = new SOLIS\_CMD\_TLM.FillColor();

List lstRGBA\_FillColor = new List();

lstRGBA\_FillColor.Add(0);

lstRGBA\_FillColor.Add(255);

lstRGBA\_FillColor.Add(255);

lstRGBA\_FillColor.Add(255);

JsonFillColor.rgba = lstRGBA\_FillColor;

// OUTLINE COLOR DATA

SOLIS\_CMD\_TLM.OutlineColor JsonOutlineColor = new SOLIS\_CMD\_TLM.OutlineColor();

List lstRGBA\_OutlineColor = new List();

lstRGBA\_OutlineColor.Add(0);

lstRGBA\_OutlineColor.Add(0);

lstRGBA\_OutlineColor.Add(0);

lstRGBA\_OutlineColor.Add(255);

JsonOutlineColor.rgba = lstRGBA\_OutlineColor;

// PIXELOFFSET2 DATA

SOLIS\_CMD\_TLM.PixelOffset2 JsonPixelOffset2 = new SOLIS\_CMD\_TLM.PixelOffset2();

List lstRGBA\_PixelOffset2 = new List();

lstRGBA\_PixelOffset2.Add(5);

lstRGBA\_PixelOffset2.Add(-4);

JsonPixelOffset2.cartesian2 = lstRGBA\_PixelOffset2;

// LABEL DATA

SOLIS\_CMD\_TLM.Label JsonLabel = new SOLIS\_CMD\_TLM.Label();

JsonLabel.fillColor = JsonFillColor;

JsonLabel.font = “21pt Lucida Console”;

JsonLabel.horizontalOrigin = “LEFT”;

JsonLabel.outlineColor = JsonOutlineColor;

JsonLabel.outlineWidth = 2;

JsonLabel.pixelOffset = JsonPixelOffset2;

JsonLabel.scale = 0.5;

JsonLabel.show = true;

JsonLabel.style = “FILL\_AND\_OUTLINE”;

JsonLabel.text = “BLAHSat”;

JsonLabel.verticalOrigin = “CENTER”;

TLMvalue tlmval = new TLMvalue();

tlmval.value = OPW\_BATTPWR;

// CUSTOM TELEMETRY

//BatteryTLM btrTLM = new BatteryTLM();

[//btrTLM.mnemonic](https://btrTLM.mnemonic) = “OPW\_BATTPWR”;

[//btrTLM.tlmval](https://btrTLM.tlmval) = tlmval;

// ADDING MORE TO THE ROOTOBJECT

JsonRoot.label = JsonLabel;

JsonRoot.billboard = JsonBillboard;

JsonRoot.model = JsonModel;

JsonRoot.path = JsonPath;

CZML\_JSON\_2 = JsonConvert.SerializeObject(JsonRoot);

FlagStop2 = 0;

FlagStop3 = 0;

flagCZMLquat = flagCZMLquat + 1;

flagCZMLpos = flagCZMLpos + 1;

flagCZML = flagCZML + 5;

}

}

[Test.mp4](https://community.cesium.com/uploads/short-url/hO6XewTHiUgRHmljm8kXU0dolRJ.mp4) (1.53 MB)

---

<div class="post-metadata">

**Author:** ![RG1](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/rg1/32/2103_2.png) [@RG1](https://community.cesium.com/u/RG1)\
**Post date:** [January 25, 2019, 11:01pm UTC](https://community.cesium.com/t/stk-czml-stream-problem-not-smooth-please-halp/7938/2 "2019-01-25T23:01:20Z")

</div>

Finally found the problem.  
For some reason the times (current time, interval times, time-tag values) were getting duplicated when sending the CZML packets.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [January 28, 2019, 12:50pm UTC](https://community.cesium.com/t/stk-czml-stream-problem-not-smooth-please-halp/7938/3 "2019-01-28T12:50:20Z")

</div>

Sorry I didn’t get a chance to look at this, but I’m glad you figured it out, and thanks for posting your solution!
