This commit is contained in:
Timo Volkmann 2021-01-15 12:22:04 +01:00
parent 6cda14bc32
commit 3cc6264f2a

View File

@ -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])