07-12-2022 13:55
07-12-2022 13:55
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.
07-12-2022 13:58 - edited 07-12-2022 14:01
07-12-2022 13:58 - edited 07-12-2022 14:01
I don't think Versa 2 has an orientation sensor (gyroscope). Versa 1 and Sense do.