Jump to content

[1.0.4] (2015-07-04) Telemachus – Telemetry and Flight Control in the Web Browser


Rich

Recommended Posts

Is there a plan, if it's even possible, to read the resource state of a specific module? For example, fuel remaining in a certain tank?

My specific issue is one of electric charge. I can tell how much total charge is available, but not whether or not any of it is in the capsule. If the capsule is drained, but there is charge in other batteries, a landing would be very hazardous, since I would be immediately out of power as soon as I jettisoned any service parts from the capsule.

In theory, I could calculate the rate of charge / discharge and track when the last charge / discharge cycle began, and use that data to keep running tabs on how much should be available in various parts of the ship, but it's very susceptible to continuously increasing errors due to rounding etc. On the other hand, it sure is exciting not knowing :P

Link to comment
Share on other sites

@Rich, are you aware of the KerbalGIS plugin?

Alternatively fetching map content from the "local" setup might be an interesting alternative to KerbalMaps.

Especially if CustomBiomes are used as well, the "local" information would even be more correct.

Link to comment
Share on other sites

Hey Rich, brilliant mod you have! Is there the possibility that you can team up with KevinLaity for a new Telemachus page for kOS?

It has always been the plan to eventually provide a page which allows you to script you craft. Though whether that is kOS or something I cook up myself remains to be seen.

Is there a plan, if it's even possible, to read the resource state of a specific module? For example, fuel remaining in a certain tank?

My specific issue is one of electric charge. I can tell how much total charge is available, but not whether or not any of it is in the capsule. If the capsule is drained, but there is charge in other batteries, a landing would be very hazardous, since I would be immediately out of power as soon as I jettisoned any service parts from the capsule.

In theory, I could calculate the rate of charge / discharge and track when the last charge / discharge cycle began, and use that data to keep running tabs on how much should be available in various parts of the ship, but it's very susceptible to continuously increasing errors due to rounding etc. On the other hand, it sure is exciting not knowing :P

It is possible, and is something I want to do as part of the API overhaul I have planned.

btw, the kindle problem persists, I just stopped caring

Lame. Unfortunately it is difficult to debug on a device I don't have. I wish I could be of more assistance, as one of this projects mandates is to make it work on as many devices as possible.

@Rich, are you aware of the KerbalGIS plugin?

Alternatively fetching map content from the "local" setup might be an interesting alternative to KerbalMaps.

Especially if CustomBiomes are used as well, the "local" information would even be more correct.

I am aware. Fetching the tiles locally is something I have been experimenting with, and is easy enough to do for anyone inclined to try it out.

Any chance of delta v stats getting implemented? That's the only thing MechJeb provides that I actually use that Telemachus doesn't. Otherwise Telemachus is perfect.

This is planned but I am neck deep in what I am about to give a progress update on.

Development update

Well. The web socket server is working, so I just need to write the KSP data transfer protocol on top. This will simply involve some JSON parsing and a timer. Once that is done I can update the pages to use the web socket if the technology is available. What does this mean? It means more and faster data from KSP.

Link to comment
Share on other sites

Lame. Unfortunately it is difficult to debug on a device I don't have. I wish I could be of more assistance, as one of this projects mandates is to make it work on as many devices as possible.

I have a friend who writes code for Kindles, I can ask him to take a look at this if you'd like.

Well. The web socket server is working, so I just need to write the KSP data transfer protocol on top. This will simply involve some JSON parsing and a timer. Once that is done I can update the pages to use the web socket if the technology is available. What does this mean? It means more and faster data from KSP.

This is so exciting I lack words. Telemachus is really giving us the ability to turn a funny little game into a morbidly complex quagmire, much more representative of actual spaceflight. And that is smegging awesome :D

Edit:

Just noticed, f.throttle out of the API seems to be reading the position of the throttle as set by the user, and not the throttle setting sent to the engines. If I use an autopilot system to make a throttle adjustment, f.throttle still reads the old value. Confirmed this with a MechJeb2 launch, where f.throttle read 0 the whole way up.

More edit:

Also, f.throttle reads "1" when the game is paused, regardless of throttle setting. No clue if this data is Telemachus or KSP.

Edited by mjukis
Link to comment
Share on other sites

Just my two cents here, but what would be really cool would be to have recordable surface track data.

That is to say essentially a GPS locator with persistent trails that can be toggled for a given craft, so that a ground or (relatively) low altitude mission path can be shared with others later.

Link to comment
Share on other sites

random one for you rich started up today and log got spammed with this

[EXC 01:17:47.699] FileNotFoundException: Could not load file or assembly 'Telemachus, Version=1.4.12.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

...:::EDIT:::...

WTF I was not running the latest version?!?!?! WTF?!?!

ok STILL claiming im running 1.4.12.0 even after deleting the folder and then reinstalling from github

Edited by Mechrior
Link to comment
Share on other sites

Moar updates!

Our terminal system now has some advanced warnings and errors. Yay.

First picture, Flight Overview and EECOM screens, during normal operation.

The vehicle is in orbit around Mun, which means radar position and orbit data are unavailable. Telemetry however is coming in normally. The EECOM screen now also shows total consumables weight including fuel, for manual maneuver calculations.

paIkvN0.jpg

Second picture, DISTASTER STRIKES! There is something wrong with the solar panels, and the batteries have discharged. The Master Alarm is lit on both the FO and EECOM screens, and the EECOM screen shows a BAT warning.

Qh4UN2C.jpg

Third picture, now we're doomed. The batteries are empty, and as such, both screens' systems overview show that telemetry is offline. Because it's a power failure, all of the data is still coming in, but is either in error (weights, horizontal bar charts, etc.) or garbled (altitudes, container amounts, etc.) If the antenna had been destroyed or turned off manually, these would simply show no data at all. Mission Time, Universal Time and radar data (when available) however comes through regardless of antenna condition.

v3ysYe1.jpg

Edited by mjukis
Spellings
Link to comment
Share on other sites

Moar updates!

Our terminal system now has some advanced warnings and errors. Yay.

First picture, Flight Overview and EECOM screens, during normal operation.

The vehicle is in orbit around Mun, which means radar position and orbit data are unavailable. Telemetry however is coming in normally. The EECOM screen now also shows total consumables weight including fuel, for manual maneuver calculations.

http://i.imgur.com/paIkvN0.jpg

Second picture, DISTASTER STRIKES! There is something wrong with the solar panels, and the batteries have discharged. The Master Alarm is lit on both the FO and EECOM screens, and the EECOM screen shows a BAT warning.

http://i.imgur.com/Qh4UN2C.jpg

Third picture, now we're doomed. The batteries are empty, and as such, both screens' systems overview show that telemetry is offline. Because it's a power failure, all of the data is still coming in, but is either in error (weights, horizontal bar charts, etc.) or garbled (altitudes, container amounts, etc.) If the antenna had been destroyed or turned off manually, these would simply show no data at all. Mission Time, Universal Time and radar data (when available) however comes through regardless of antenna condition.

http://i.imgur.com/v3ysYe1.jpg

Hey wait, WHAT?! This looks pretty darned cool! None of the docs mention the terminal system (from my admittedly quick scan); I'd love to install just for this, how is it accessed?

Link to comment
Share on other sites

Hey wait, WHAT?! This looks pretty darned cool! None of the docs mention the terminal system (from my admittedly quick scan); I'd love to install just for this, how is it accessed?

I am not Rich, the terminal system just uses his Telemachus API to get the data. Currently it's just some python scripts that we run on a Linux machine, but if you PM me I'd be happy to hand over the very ugly source :P

Link to comment
Share on other sites

Moar updates!

Our terminal system now has some advanced warnings and errors. Yay.

First picture, Flight Overview and EECOM screens, during normal operation.

The vehicle is in orbit around Mun, which means radar position and orbit data are unavailable. Telemetry however is coming in normally. The EECOM screen now also shows total consumables weight including fuel, for manual maneuver calculations.

http://i.imgur.com/paIkvN0.jpg

Second picture, DISTASTER STRIKES! There is something wrong with the solar panels, and the batteries have discharged. The Master Alarm is lit on both the FO and EECOM screens, and the EECOM screen shows a BAT warning.

http://i.imgur.com/Qh4UN2C.jpg

Third picture, now we're doomed. The batteries are empty, and as such, both screens' systems overview show that telemetry is offline. Because it's a power failure, all of the data is still coming in, but is either in error (weights, horizontal bar charts, etc.) or garbled (altitudes, container amounts, etc.) If the antenna had been destroyed or turned off manually, these would simply show no data at all. Mission Time, Universal Time and radar data (when available) however comes through regardless of antenna condition.

http://i.imgur.com/v3ysYe1.jpg

I too am very interested in using this Terminal type interface. Do you plan on releaseing it as a companion mod to this Telemachus? And if not, what will it take for you to say yes!!!

Link to comment
Share on other sites

random one for you rich started up today and log got spammed with this

[EXC 01:17:47.699] FileNotFoundException: Could not load file or assembly 'Telemachus, Version=1.4.12.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

...:::EDIT:::...

WTF I was not running the latest version?!?!?! WTF?!?!

ok STILL claiming im running 1.4.12.0 even after deleting the folder and then reinstalling from github

I have no idea what could be causing this :huh:.

Moar updates!

Our terminal system now has some advanced warnings and errors. Yay.

First picture, Flight Overview and EECOM screens, during normal operation.

The vehicle is in orbit around Mun, which means radar position and orbit data are unavailable. Telemetry however is coming in normally. The EECOM screen now also shows total consumables weight including fuel, for manual maneuver calculations.

http://i.imgur.com/paIkvN0.jpg

Second picture, DISTASTER STRIKES! There is something wrong with the solar panels, and the batteries have discharged. The Master Alarm is lit on both the FO and EECOM screens, and the EECOM screen shows a BAT warning.

http://i.imgur.com/Qh4UN2C.jpg

Third picture, now we're doomed. The batteries are empty, and as such, both screens' systems overview show that telemetry is offline. Because it's a power failure, all of the data is still coming in, but is either in error (weights, horizontal bar charts, etc.) or garbled (altitudes, container amounts, etc.) If the antenna had been destroyed or turned off manually, these would simply show no data at all. Mission Time, Universal Time and radar data (when available) however comes through regardless of antenna condition.

http://i.imgur.com/v3ysYe1.jpg

Releasing this would be cool, as I would love to see what this looks like on a bank of monitors.

I have a friend who writes code for Kindles, I can ask him to take a look at this if you'd like.

This is so exciting I lack words. Telemachus is really giving us the ability to turn a funny little game into a morbidly complex quagmire, much more representative of actual spaceflight. And that is smegging awesome :D

Edit:

Just noticed, f.throttle out of the API seems to be reading the position of the throttle as set by the user, and not the throttle setting sent to the engines. If I use an autopilot system to make a throttle adjustment, f.throttle still reads the old value. Confirmed this with a MechJeb2 launch, where f.throttle read 0 the whole way up.

More edit:

Also, f.throttle reads "1" when the game is paused, regardless of throttle setting. No clue if this data is Telemachus or KSP.

If your buddy is willing to see if the Telemachus' pages work on a Kindle, that would be most useful.

I have added your throttle observation to my list of issues to check out.

Quick Development Note - (for anyone who is interested)

I have reached the point where I have finished two key implementation details for the web socket server. The first is socket stealing. This is where the HTTP server operates as normal, and the web socket server listens in on the requests being made. If the web socket server notices a socket upgrade request, then it will steal the socket from the HTTP server and proceed with the appropriate protocol. This stealing mechanism is handy as it means the web socket server can seemingly run on the same port as the HTTP server, while existing as a separate entity.

The second implementation detail is that of the web socket service abstraction. The web socket server is constructed with services which are associated with a particular prefix, such as "/datalink". A basic echo web socket service is shown below.


class WebSocketEchoService : IWebSocketService
{

public void OpCodePing(object sender, FrameEventArgs e)
{

}

public void OpCodePong(object sender, FrameEventArgs e)
{

}

public void OpCodeText(object sender, FrameEventArgs e)
{
WebSocketFrame frame = new WebSocketFrame(ASCIIEncoding.UTF8.GetBytes("Echo: " + e.frame.PayloadAsUTF8()));
e.clientConnection.Send(frame.AsBytes());
}

public void OpCodeBinary(object sender, FrameEventArgs frameEventArgs)
{

}

public void OpCodeClose(object sender, FrameEventArgs frameEventArgs)
{

}

public IWebSocketService buildService()
{
return new WebSocketEchoService();
}
}

This abstraction will make it easy to build a KSP web socket service; this will simply accept JSON formatted protocol commands (discussed in an earlier post) through the OpCodeText(...) method, and stream data back using a method linked to a timer.

The only addition I have made to the protocol specification is the ability to adjust the rate at which data is streamed back. Such a command is shown below.


{
"rate": 1000
}

The above command would instruct the service to send updates once a second.

Edited by Rich
Link to comment
Share on other sites

Releasing this would be cool, as I would love to see what this looks like on a bank of monitors.

If your buddy is willing to see if the Telemachus' pages work on a Kindle, that would be most useful.

Do Kindles run Android? If so, count me among the interested parties, as I have a Nook HD+ that I'd love to put to work with this!

Link to comment
Share on other sites

Well the Telemachus pages work on both my stock Android devices (Nexus 7 and 5), but I think the Kindle uses a slightly custom version of Android? So I am unsure as to how Telemachus performs. Hence my need to find Kindle owners.

Link to comment
Share on other sites

Well the Telemachus pages work on both my stock Android devices (Nexus 7 and 5), but I think the Kindle uses a slightly custom version of Android? So I am unsure as to how Telemachus performs. Hence my need to find Kindle owners.

Oh I see. I was actually referring to the console pages that mjukis was showing off, but now that I'm thinking about it, there's no reason Telemachus shouldn't work just fine on my Nook's browser (Chrome) anyway! Now it's time to just get up and install this bugger! :D

Link to comment
Share on other sites

Well the Telemachus pages work on both my stock Android devices (Nexus 7 and 5), but I think the Kindle uses a slightly custom version of Android? So I am unsure as to how Telemachus performs. Hence my need to find Kindle owners.

It depends on whether you mean the Kindle Fire or the regular Kindle. The Kindle Fire is Android-based, and as such should work fine with Telemachus. However, the plain Kindle uses a custom Linux distribution with Amazon's own web browser, which has a slightly incomplete and/or outdated Javascript interpreter. I have a Kindle; I can try testing this for you tomorrow.

Link to comment
Share on other sites

I have added your throttle observation to my list of issues to check out.

Did some more observing just now. f.throttle value reads the status of the throttle as set by the pilot unless p.paused has a value other than 0. If you pause the game, retract the antenna or run out of power, f.throttle will have the same value as p.paused, regardless of pilot throttle setting, leading to some cool 2-300% throttle indications in telemetry :D

Link to comment
Share on other sites

Moar updates!

Our terminal system now has some advanced warnings and errors. Yay.

First picture, Flight Overview and EECOM screens, during normal operation.

The vehicle is in orbit around Mun, which means radar position and orbit data are unavailable. Telemetry however is coming in normally. The EECOM screen now also shows total consumables weight including fuel, for manual maneuver calculations.

http://i.imgur.com/paIkvN0.jpg

Second picture, DISTASTER STRIKES! There is something wrong with the solar panels, and the batteries have discharged. The Master Alarm is lit on both the FO and EECOM screens, and the EECOM screen shows a BAT warning.

http://i.imgur.com/Qh4UN2C.jpg

Third picture, now we're doomed. The batteries are empty, and as such, both screens' systems overview show that telemetry is offline. Because it's a power failure, all of the data is still coming in, but is either in error (weights, horizontal bar charts, etc.) or garbled (altitudes, container amounts, etc.) If the antenna had been destroyed or turned off manually, these would simply show no data at all. Mission Time, Universal Time and radar data (when available) however comes through regardless of antenna condition.

http://i.imgur.com/v3ysYe1.jpg

I cant wait to use this interface!!! When do you think it's ready?

Because we are having a gamers day at school in a few weeks and I want to play KSP using telemachus. If I could use this interface it would be sooo cool!

Link to comment
Share on other sites

Hi Richard,

Thanks for the excellent mod! I am using it to send data to an external python script that implements a Apollo guidance computer. However, to calculate orbital plane change maneuvers to match the plane of a target (say, minmus) I need to get data for the time to descending (or ascending) node.

I have looked through the source for Telemachus to try to understand how the mod gets its info from KSP, but I am at a loss on how this works (I don't know C# at all, but have managed to pick some of it up from reading sources).

I was wondering if you could please help me to modify Telemachus to expose this information over the web API?

Thanks,

Tim

Link to comment
Share on other sites

Did some more observing just now. f.throttle value reads the status of the throttle as set by the pilot unless p.paused has a value other than 0. If you pause the game, retract the antenna or run out of power, f.throttle will have the same value as p.paused, regardless of pilot throttle setting, leading to some cool 2-300% throttle indications in telemetry :D

I have observed this strange behaviour also and I will see what I can do about :D

Hi Richard,

Thanks for the excellent mod! I am using it to send data to an external python script that implements a Apollo guidance computer. However, to calculate orbital plane change maneuvers to match the plane of a target (say, minmus) I need to get data for the time to descending (or ascending) node.

I have looked through the source for Telemachus to try to understand how the mod gets its info from KSP, but I am at a loss on how this works (I don't know C# at all, but have managed to pick some of it up from reading sources).

I was wondering if you could please help me to modify Telemachus to expose this information over the web API?

Thanks,

Tim

If you can show me how to calculate the time to ascending node then I will be able to add it easily. If not, to the internet I go!

Brief Development Note

I have completed the KSP web socket service; that is, it works but I still need to test it thoroughly and convert the existing pages to use this new feature.

Edited by Rich
Link to comment
Share on other sites

If you can show me how to calculate the time to ascending node then I will be able to add it easily. If not, to the internet I go!

Hi Richard,

Thanks for your reply. I have dug out this snippet from the MechJeb sources:


//Computes the delta-V and time of a burn to match planes with the target orbit. The output burnUT
//will be equal to the time of the first descending node with respect to the target after the given UT.
//Throws an ArgumentException if o is hyperbolic and doesn't have a descending node relative to the target.

public static Vector3d DeltaVAndTimeToMatchPlanesDescending(Orbit o, Orbit target, double UT, out double burnUT)
{
burnUT = o.TimeOfDescendingNode(target, UT);
Vector3d desiredHorizontal = Vector3d.Cross(target.SwappedOrbitNormal(), o.Up(burnUT));
Vector3d actualHorizontalVelocity = Vector3d.Exclude(o.Up(burnUT), o.SwappedOrbitalVelocityAtUT(burnUT));
Vector3d desiredHorizontalVelocity = actualHorizontalVelocity.magnitude * desiredHorizontal;
return desiredHorizontalVelocity - actualHorizontalVelocity;
}

And


//Computes the delta-V and time of a burn to match planes with the target orbit. The output burnUT
//will be equal to the time of the first ascending node with respect to the target after the given UT.
//Throws an ArgumentException if o is hyperbolic and doesn't have an ascending node relative to the target.

public static Vector3d DeltaVAndTimeToMatchPlanesAscending(Orbit o, Orbit target, double UT, out double burnUT)
{
burnUT = o.TimeOfAscendingNode(target, UT);
Vector3d desiredHorizontal = Vector3d.Cross(target.SwappedOrbitNormal(), o.Up(burnUT));
Vector3d actualHorizontalVelocity = Vector3d.Exclude(o.Up(burnUT), o.SwappedOrbitalVelocityAtUT(burnUT));
Vector3d desiredHorizontalVelocity = actualHorizontalVelocity.magnitude * desiredHorizontal;
return desiredHorizontalVelocity - actualHorizontalVelocity;
}

EDIT: also found this:


//Returns the next time at which a will cross its descending node with b.
//For elliptical orbits this is a time between UT and UT + a.period.
//For hyperbolic orbits this can be any time, including a time in the past if
//the descending node is in the past.
//NOTE: this function will throw an ArgumentException if a is a hyperbolic orbit and the "descending node"
//occurs at a true anomaly that a does not actually ever attain

public static double TimeOfDescendingNode(this Orbit a, Orbit b, double UT)
{
return a.TimeOfTrueAnomaly(a.DescendingNodeTrueAnomaly(, UT);
}

EDIT 2: found some more maybe relevant stuff:


//Gives the true anomaly (in a's orbit) at which a crosses its descending node
//with b's orbit.
//The returned value is always between 0 and 360.

public static double DescendingNodeTrueAnomaly(this Orbit a, Orbit
{
return MuUtils.ClampDegrees360(a.AscendingNodeTrueAnomaly( + 180);
}

and from MuUtils:


public static double ClampDegrees360(double angle)
{
angle = angle % 360.0;
if (angle < 0) return angle + 360.0;
else return angle;
}

Hope this helps.

Tim

Edited by ttb
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...