Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fixed websocket test merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
richardbunt committed Jul 4, 2015
2 parents 968ca67 + 3aca130 commit 33d5e25
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 24 deletions.
88 changes: 64 additions & 24 deletions Telemachus/src/DataLinkHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,64 +1130,112 @@ public NavBallDataLinkHandler(FormatterProvider formatters)
registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel);
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.findWorldCenterOfMass());
return result.eulerAngles.y;
},
"n.heading", "Heading", formatters.Default, APIEntry.UnitType.DEG));
"n.heading2", "Heading", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel);
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.findWorldCenterOfMass());
return (result.eulerAngles.x > 180) ? (360.0 - result.eulerAngles.x) : -result.eulerAngles.x;
},
"n.pitch", "Pitch", formatters.Default, APIEntry.UnitType.DEG));
"n.pitch2", "Pitch", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel);
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.findWorldCenterOfMass());
return (result.eulerAngles.z > 180) ?
(result.eulerAngles.z - 360.0) : result.eulerAngles.z;
},
"n.roll", "Roll", formatters.Default, APIEntry.UnitType.DEG));
"n.roll2", "Roll", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel);
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.findWorldCenterOfMass());
return result.eulerAngles.y;
},
"n.rawheading", "Raw Heading", formatters.Default, APIEntry.UnitType.DEG));
"n.rawheading2", "Raw Heading", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel);
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.findWorldCenterOfMass());
return result.eulerAngles.x;
},
"n.rawpitch", "Raw Pitch", formatters.Default, APIEntry.UnitType.DEG));
"n.rawpitch2", "Raw Pitch", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel);
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.findWorldCenterOfMass());
return result.eulerAngles.z;
},
"n.rawroll", "Raw Roll", formatters.Default, APIEntry.UnitType.DEG));
"n.rawroll2", "Raw Roll", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.rootPart.transform.position);
return result.eulerAngles.y;
},
"n.heading", "Heading calculated using the position of the vessels root part", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.rootPart.transform.position);
return (result.eulerAngles.x > 180) ? (360.0 - result.eulerAngles.x) : -result.eulerAngles.x;
},
"n.pitch", "Pitch calculated using the position of the vessels root part", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.rootPart.transform.position);
return (result.eulerAngles.z > 180) ?
(result.eulerAngles.z - 360.0) : result.eulerAngles.z;
},
"n.roll", "Roll calculated using the position of the vessels root part", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.rootPart.transform.position);
return result.eulerAngles.y;
},
"n.rawheading", "Raw Heading calculated using the position of the vessels root part", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.rootPart.transform.position);
return result.eulerAngles.x;
},
"n.rawpitch", "Raw Pitch calculated using the position of the vessels root part", formatters.Default, APIEntry.UnitType.DEG));

registerAPI(new PlotableAPIEntry(
dataSources =>
{
Quaternion result = updateHeadingPitchRollField(dataSources.vessel, dataSources.vessel.rootPart.transform.position);
return result.eulerAngles.z;
},
"n.rawroll", "Raw Roll calculated using the position of the vessels root part", formatters.Default, APIEntry.UnitType.DEG));
}

#endregion

#region Methods

//Borrowed from MechJeb2
private Quaternion updateHeadingPitchRollField(Vessel v)
private Quaternion updateHeadingPitchRollField(Vessel v, Vector3d CoM)
{
Vector3d CoM, north, up;
Vector3d north, up;
Quaternion rotationSurface;

CoM = v.findWorldCenterOfMass();

up = (CoM - v.mainBody.position).normalized;

north = Vector3d.Exclude(up, (v.mainBody.position + v.mainBody.transform.up *
Expand All @@ -1198,14 +1246,6 @@ private Quaternion updateHeadingPitchRollField(Vessel v)
Quaternion.Inverse(v.GetTransform().rotation) * rotationSurface);
}

/*private double calculatePitch(Vessel v)
{
Vector3d worldUp = (v.CoM - v.mainBody.position).normalized;
double angle = Vector3d.Angle(worldUp, v.transform.up);
return worldUp.x - v.transform.up.x < 0 ? angle : -angle;
}*/

#endregion
}

Expand Down
8 changes: 8 additions & 0 deletions WebPages/WebPagesTest/src/websockets-telemachus.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
doAttitudeStressTest();
}

function doStressRollTest() {
doSend(JSON.stringify({ "+": ["n.roll", "n.pitch", "n.heading"], "rate": 10 }));
}

function doStressRollRootTest() {
doSend(JSON.stringify({ "+": ["n.rollRoot", "n.pitchRoot", "n.headingRoot"], "rate": 10 }));
}

function doStressTest() {
doSend(JSON.stringify({ "+": ["v.name", "v.body", "v.brakeValue", "v.gearValue", "v.rcsValue", "v.lightValue", "v.sasValue"], "rate": 100 }));
}
Expand Down

0 comments on commit 33d5e25

Please sign in to comment.