From 3cc6264f2a52cfb29da51180a1e137a00c5455cf Mon Sep 17 00:00:00 2001 From: Timo Volkmann Date: Fri, 15 Jan 2021 12:22:04 +0100 Subject: [PATCH] comments --- static/scripts/indicators.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/static/scripts/indicators.js b/static/scripts/indicators.js index 57b9732..b3c77f8 100644 --- a/static/scripts/indicators.js +++ b/static/scripts/indicators.js @@ -53,6 +53,8 @@ scene.add(pointLight); cube.position.x = 0 cube2.position.x = 0 + + // calibration globals let manCalibration = new THREE.Euler( 0, 0, 0, 'XYZ' ) let calibrationRot = new THREE.Quaternion() @@ -62,6 +64,7 @@ let calYaw = 0 let quaternionOffset = document.getElementById("quaternionOffset") +// function to set current cube rotation from sensor data with respect to calibration function renderTCP(x, y, z) { let calibration = new THREE.Quaternion().setFromEuler(manCalibration) let eul = new THREE.Euler( x, y, z, 'YXZ' ); @@ -73,6 +76,7 @@ function renderTCP(x, y, z) { renderer.render(scene, camera); } +// function to set current cube rotation from sensor data function renderSerial(x, y, z) { let eul = new THREE.Euler( x, y, z, 'YXZ' ); // XYZ XZY YZX YXZ ZXY ZYX @@ -137,9 +141,9 @@ function calibrate(evt) { let dif = new THREE.Euler().setFromQuaternion( diff ) console.log("OLD:","pitch", old.x * 180/Math.PI, "yaw", old.y * 180/Math.PI, "roll", old.z * 180/Math.PI) console.log("DIFF:","pitch", dif.x * 180/Math.PI, "yaw", dif.y * 180/Math.PI, "roll", dif.z * 180/Math.PI) - calPitch = dif.x // * 180/Math.PI - calYaw = dif.y // * 180/Math.PI - calRoll = dif.z // * 180/Math.PI + calPitch = dif.x + calYaw = dif.y + calRoll = dif.z calibrationRot = diff } document.getElementById("deleteCalibration").onclick = delCalibration @@ -172,6 +176,7 @@ let altimeter = $.flightIndicator('#altimeter', 'altimeter', options); let airspeedLabel = document.getElementById("airspeedLabel") let altitudeLabel = document.getElementById("altitudeLabel") +// function to set analog indictors from current sensor data function setIndicatorsTcp(sensordata) { let q = new THREE.Euler().setFromQuaternion( cube2.quaternion, 'YXZ' ) // XYZ XZY YZX YXZ ZXY ZYX @@ -185,6 +190,7 @@ function setIndicatorsTcp(sensordata) { } } +// function to set analog indictors from current sensor data function setIndicatorsSer(sensordata) { if (sensordata.Orientation[0] !== 0 && sensordata.Orientation[1] !== 0) { attitudeSer.setPitch(sensordata.Orientation[0])