Skip to content

Commit

Permalink
Add support for ZED SDK 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Rousseau committed Apr 4, 2024
1 parent 8b6c86f commit dc0e554
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 17 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion exts/sl.sensor.camera/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[package]
# Semantic Versioning is used: https://semver.org/
version = "1.0.3"
version = "1.1.0"

# Lists people or organizations that are considered the "authors" of the package.
authors = ["Stereolabs"]
Expand Down
5 changes: 4 additions & 1 deletion exts/sl.sensor.camera/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.0.3] - 2024-02-28
## [1.1.0] - 2024-04-04
- Add support for ZED SDK 4.1

## [1.0.3] - 2024-02-16
- Add FPS and resolution parameters in Isaac Sim GUI
- Add throttling of data fetch to improve performance on low FPS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
},
"serial_number": {
"type": "uint",
"description": "Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 20976320, 29123828, 25626933, 27890353, 25263213, 21116066, 27800035, 27706147",
"description": "Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 40976320, 41116066, 49123828, 45626933, 47890353, 45263213, 47800035, 47706147",
"metadata": {
"uiName": "Serial number"
},
"default" : 20976320
"default" : 40976320
},
"use_system_time": {
"type": "bool",
Expand Down
15 changes: 10 additions & 5 deletions exts/sl.sensor.camera/sl/sensor/camera/nodes/SlCameraStreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import copy
from sl.sensor.camera.ogn.SlCameraStreamerDatabase import SlCameraStreamerDatabase

STREAM_PORT = 30000
LEFT_CAMERA_PATH = "/base_link/ZED_X/CameraLeft"
RIGHT_CAMERA_PATH = "/base_link/ZED_X/CameraRight"
IMU_PRIM_PATH = "/base_link/ZED_X/Imu_Sensor"
Expand Down Expand Up @@ -226,7 +225,11 @@ def compute(db) -> bool:
streamer_params.serial_number = serial_number
streamer_params.port = port
streamer_params.codec_type = 1
db.internal_state.pyzed_streamer.init(streamer_params)

init_error = db.internal_state.pyzed_streamer.init(streamer_params)
if not init_error:
carb.log_error(f"Failed to initialize the ZED SDK streamer with serial number {serial_number}.")
return False

# set state to initialized
carb.log_info(f"Streaming camera {db.internal_state.camera_prim_name} at port {port} and using serial number {serial_number}.")
Expand All @@ -239,6 +242,7 @@ def compute(db) -> bool:
ts : int = 0
if db.internal_state.initialized is True:
left, right = None, None
# Get simulation time in seconds
current_time = db.internal_state.core_nodes_interface.get_sim_time()

# Reset last_timestamp between different play sessions
Expand Down Expand Up @@ -276,13 +280,14 @@ def compute(db) -> bool:
if db.internal_state.start_time == -1:
carb.log_info(f"{db.internal_state.camera_prim_name} - Starting stream to the ZED SDK")
if db.internal_state.start_time == -1 or current_time < db.internal_state.last_timestamp:
db.internal_state.start_time = int(time.time() * 1000)
db.internal_state.start_time = int(time.time_ns())
carb.log_info(f"{db.internal_state.camera_prim_name} - Setting initial streaming time stamp to: {db.internal_state.start_time}")
ts = int(db.internal_state.start_time + current_time * 1000)

ts = int(db.internal_state.start_time + current_time * 1000000000)

# override with system time
if db.internal_state.override_simulation_time:
ts = int(time.time() * 1000)
ts = int(time.time_ns())

# fetch IMU data if the imu prim is there - this check allows user to basically delete
# their IMUand still have access to the image functionality without issues in Isaac Sim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SlCameraStreamerDatabase(og.Database):
('inputs:exec_in', 'execution', 0, 'ExecIn', 'Triggers execution', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''),
('inputs:resolution', 'token', 0, 'Resolution', 'Camera stream resolution. Can be either HD1080, HD720 or VGA', {ogn.MetadataKeys.DEFAULT: 'HD720'}, True, "HD720", False, ''),
('inputs:fps', 'uint', 0, 'FPS', 'Camera stream frame rate. Can be either 60, 30 or 15', {ogn.MetadataKeys.DEFAULT: '30'}, True, '30', False, ''),
('inputs:serial_number', 'uint', 0, 'Serial number', 'Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 20976320, 29123828, 25626933, 27890353, 25263213, 21116066, 27800035, 27706147', {ogn.MetadataKeys.DEFAULT: '20976320'}, True, 20976320, False, ''),
('inputs:serial_number', 'uint', 0, 'Serial number', 'Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 40976320, 41116066, 49123828, 45626933, 47890353, 45263213, 47800035, 47706147', {ogn.MetadataKeys.DEFAULT: '40976320'}, True, 40976320, False, ''),
('inputs:streaming_port', 'uint', 0, 'Streaming port', 'Streaming port - unique per camera', {ogn.MetadataKeys.DEFAULT: '30000'}, True, 30000, False, ''),
('inputs:use_system_time', 'bool', 0, 'Use system time', 'Override simulation time with system time for image timestamps', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''),
])
Expand All @@ -56,7 +56,7 @@ def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttr
super().__init__(context, node, attributes, dynamic_attributes)
self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={})
self._batchedReadAttributes = [self._attributes.exec_in, self._attributes.resolution, self._attributes.fps, self._attributes.serial_number, self._attributes.streaming_port, self._attributes.use_system_time]
self._batchedReadValues = [0, "HD720", "30", 20976320, 30000, False]
self._batchedReadValues = [0, "HD720", "30", 40976320, 30000, False]

@property
def camera_prim(self) -> og.BundleContents:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Streams ZED camera data to the ZED SDK
sl.sensor.camera.ZED_Camera Inputs
----------------------------------
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Name | Type | Default | Required? | Descripton |
| Name | Type | Default | Required? | Description |
+========================+===========+=================+===========+============================================================================================================================================================================================================+
| inputs:camera_prim | bundle | None | **Y** | ZED Camera prim used to stream data |
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand All @@ -54,11 +54,11 @@ sl.sensor.camera.ZED_Camera Inputs
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| | __default | 0 | | |
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inputs:serial_number | uint | 20976320 | **Y** | Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 20976320, 29123828, 25626933, 27890353, 25263213, 21116066, 27800035, 27706147 |
| inputs:serial_number | uint | 40976320 | **Y** | Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 40976320, 41116066, 49123828, 45626933, 47890353, 45263213, 47800035, 47706147 |
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| | uiName | Serial number | | |
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| | __default | 20976320 | | |
| | __default | 40976320 | | |
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| inputs:streaming_port | uint | 30000 | **Y** | Streaming port - unique per camera |
+------------------------+-----------+-----------------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
self.assertTrue(test_node.get_attribute_exists("inputs:serial_number"))
attribute = test_node.get_attribute("inputs:serial_number")
db_value = database.inputs.serial_number
expected_value = 20976320
expected_value = 40976320
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def OmniGraph "TestGraph"
custom uint inputs:exec_in = 0 (
docs="""Triggers execution"""
)
custom uint inputs:serial_number = 20976320 (
docs="""Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 20976320, 29123828, 25626933, 27890353, 25263213, 21116066, 27800035, 27706147"""
custom uint inputs:serial_number = 40976320 (
docs="""Serial number (identification) of the camera to stream, can be left to default. It must be of one of the compatible values: 40976320, 41116066, 49123828, 45626933, 47890353, 45263213, 47800035, 47706147"""
)
custom uint inputs:streaming_port = 30000 (
docs="""Streaming port - unique per camera"""
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit dc0e554

Please sign in to comment.