-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release_2.16.0.0' into main
- Loading branch information
Showing
31 changed files
with
579 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule depthai-core
updated
48 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import cv2 | ||
import depthai as dai | ||
import time | ||
import math | ||
|
||
print("Warning! Flashing IMU firmware can potentially soft brick your device and should be done with caution.") | ||
print("Do not unplug your device while the IMU firmware is flashing.") | ||
print("Type 'y' and press enter to proceed, otherwise exits: ") | ||
if input() != 'y': | ||
print("Prompt declined, exiting...") | ||
exit(-1) | ||
|
||
# Create pipeline | ||
pipeline = dai.Pipeline() | ||
|
||
# Define sources and outputs | ||
imu = pipeline.create(dai.node.IMU) | ||
xlinkOut = pipeline.create(dai.node.XLinkOut) | ||
|
||
xlinkOut.setStreamName("imu") | ||
|
||
# enable ACCELEROMETER_RAW at 500 hz rate | ||
imu.enableIMUSensor(dai.IMUSensor.ACCELEROMETER_RAW, 500) | ||
# enable GYROSCOPE_RAW at 400 hz rate | ||
imu.enableIMUSensor(dai.IMUSensor.GYROSCOPE_RAW, 400) | ||
# it's recommended to set both setBatchReportThreshold and setMaxBatchReports to 20 when integrating in a pipeline with a lot of input/output connections | ||
# above this threshold packets will be sent in batch of X, if the host is not blocked and USB bandwidth is available | ||
imu.setBatchReportThreshold(1) | ||
# maximum number of IMU packets in a batch, if it's reached device will block sending until host can receive it | ||
# if lower or equal to batchReportThreshold then the sending is always blocking on device | ||
# useful to reduce device's CPU load and number of lost packets, if CPU load is high on device side due to multiple nodes | ||
imu.setMaxBatchReports(10) | ||
|
||
# Link plugins IMU -> XLINK | ||
imu.out.link(xlinkOut.input) | ||
|
||
imu.enableFirmwareUpdate(True) | ||
|
||
# Pipeline is defined, now we can connect to the device | ||
with dai.Device(pipeline) as device: | ||
|
||
def timeDeltaToMilliS(delta) -> float: | ||
return delta.total_seconds()*1000 | ||
|
||
# Output queue for imu bulk packets | ||
imuQueue = device.getOutputQueue(name="imu", maxSize=50, blocking=False) | ||
baseTs = None | ||
while True: | ||
imuData = imuQueue.get() # blocking call, will wait until a new data has arrived | ||
|
||
imuPackets = imuData.packets | ||
for imuPacket in imuPackets: | ||
acceleroValues = imuPacket.acceleroMeter | ||
gyroValues = imuPacket.gyroscope | ||
|
||
acceleroTs = acceleroValues.timestamp.get() | ||
gyroTs = gyroValues.timestamp.get() | ||
if baseTs is None: | ||
baseTs = acceleroTs if acceleroTs < gyroTs else gyroTs | ||
acceleroTs = timeDeltaToMilliS(acceleroTs - baseTs) | ||
gyroTs = timeDeltaToMilliS(gyroTs - baseTs) | ||
|
||
imuF = "{:.06f}" | ||
tsF = "{:.03f}" | ||
|
||
print(f"Accelerometer timestamp: {tsF.format(acceleroTs)} ms") | ||
print(f"Accelerometer [m/s^2]: x: {imuF.format(acceleroValues.x)} y: {imuF.format(acceleroValues.y)} z: {imuF.format(acceleroValues.z)}") | ||
print(f"Gyroscope timestamp: {tsF.format(gyroTs)} ms") | ||
print(f"Gyroscope [rad/s]: x: {imuF.format(gyroValues.x)} y: {imuF.format(gyroValues.y)} z: {imuF.format(gyroValues.z)} ") | ||
|
||
if cv2.waitKey(1) == ord('q'): | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.