Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Activating Orientation and Gyroscope sensor readings

Hello, I am attempting to read gyro and orientation sensor data. For example on the orientation sensor:

 

if (OrientationSensor) {
const orientation = new OrientationSensor({ frequency: 1 });
orientation.addEventListener("activate", () => {
console.log("Activated OR");
});
orientation.addEventListener("reading", () => {
console.log("Please get to reading");
console.log(
`Orientation Reading: \
timestamp=${orientation.timestamp}, \
[${orientation.quaternion[0]}, \
${orientation.quaternion[1]}, \
${orientation.quaternion[2]}, \
${orientation.quaternion[3]}]`
);
orientationData.text = JSON.stringify({
quaternion: orientation.quaternion ? orientation.quaternion.map(n => n.toFixed(1)) : null
});
});
sensors.push(orientation);
orientation.start();
} else {
orientationLabel.style.display = "none";
orientationData.style.display = "none";
}

I think that I have onactivate setup correctly so that once the sensor becomes activated than the event listener should fire off. This tells me that the orientation sensor is never activating and I'm not quite sure what I'm doing wrong here. Any help would be appreciatied, I am currently developing for the versa 2.

Best Answer
0 Votes
1 REPLY 1

I don't think Versa 2 has an orientation sensor (gyroscope). Versa 1 and Sense do.

Peter McLennan
Gondwana Software
Best Answer