-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Behaviour of output trigger #9810
Comments
Hi @xc-racer99 RS2_OPTION_INTER_CAM_SYNC_MODE will set a camera to be a Master camera when set to 1 and the camera will therefore transmit a trigger pulse. A camera that is set to '2' will be a Slave that listens out for a trigger pulse on every frame and performs a depth-frame capture that is timestamp-synced with the Master camera if it recognizes the pulse. When RS2_OPTION_OUTPUT_TRIGGER_ENABLED is set to '1', a trigger is output from the camera to any external device on every depth frame. When the 400 Series launched in late 2017 (some time before hardware sync and Inter Cam Sync Mode was later introduced) there was a small amount of documentation about directly using the GPIO pins on the camera. The official version of that old documentation is now long-obsolete and unavailable but I found it at another source and have recreated the page below in case it helps with your particular situation with RS2_OPTION_OUTPUT_TRIGGER_ENABLED Output Trigger
Timestamp from external sensors
You can mix and match GPIO streams with other types of streams: you are free to use frame queues or callbacks, you can configure the stream directly or using The table below is taken from page 52 of the current edition of the data sheet document for the 400 Series cameras. I would not expect a RealSense RGB stream to have an influence on either RS2_OPTION_INTER_CAM_SYNC_MODE or RS2_OPTION_OUTPUT_TRIGGER_ENABLED, except when using RS2_OPTION_INTER_CAM_SYNC_MODE with a slave camera that has been set to Inter Cam Sync Mode '3' (Full Slave). An alternative method of syncing depth and RGB of two cameras that has been discussed in the past and does not involve a sync trigger has been to use frame metadata, as described in #2186 |
But when exactly does this trigger pulse start? Does it start simultaneously with the very first frame or does it start first? Is it synced with RGB or depth? Is it semi-random? The slave option isn't really applicable to our use case.
Yes, this appears to be exactly what we want, except it doesn't appear that the first frame line up with the first pulse. I've found #8171 with similar issues.
Yes, I've investigated a variant of this as well (note that the stream name is now
Well, based on the oscilloscope, it definitely does have an effect :) The above images are not one-offs, they are fairly repeatable.
Unfortunately, this is too low resolution for us - even 2ms of skew between frame and encoder data is not good enough. Other issues that I've found and read through here on GitHub are: |
In regard to your question But when exactly does this trigger pulse start? - in #2474 a RealSense team member advises that the trigger is generated at the end of exposure in the original mode 1 and 2 hardware sync system. They add though that "when triggering externally, the trigger pulse aligns with the frame start". |
Correct, I understand where in relation to the exposure the pulse occurs. However, when in stream process do these start occurring? Experimentally, there appear to be a few pulses that are emitted with no corresponding frame. Ie
And unfortunately, it doesn't appear that there are always 2 extra pulses at the start. |
As you noted at the beginning of this case, an apparently similar phenomenon is discussed at #8171 where it is mentioned that trigger behaviour performs as expected in the RealSense Viewer but not when using their own code. You can test this yourself in the Viewer by enabling an option called Output Trigger Enabled that is disabled by default, and setting Inter Cam Sync Mode to '1'. The 'Output Trigger Enabled' option, when enabled, should generate a trigger from the camera to an external device once per frame. |
I'm trying to use the GPIO stream, but I can't seem to figure out how to read it. I always seem to get
When using the following code
or variants thereof with different width/height or stream indexes. Based on 28371bc it looks like this is only possible when using the tracking add-on on a bare board? I don't believe an HID device is being created for the raw D435 (ie not the D435i). The only place in the code I can see referencing the GPIO stream is the HID device is at https://github.com/IntelRealSense/librealsense/blob/master/src/sensor.cpp#L788 but this is within a check for the sensor name being "custom". So it looks like this feature wouldn't work even on the D435i, although I don't have one to test with. |
The Couldn't resolve requests message suggests that the problem is with the config instruction for GPIO. Have you tried it with RS2_STREAM_GPIO1, 0, 0, 0 like the obsolete documentation suggested, with a '1' after RS2_STREAM_GPIO? You could also try a simpler form of the instruction:
Given that RS2_STREAM_GPIO is listed in the SDK documentation but the script comes from obsolete documentation, I would also consider the possibility that this format is supported in the SDK but now not exposed to the end-user to access through SDK scripting. Yes, D435i (as an IMU-equipped camera) is classified as a HID device whilst D435 would not be. I believe the aspect of 28371bc that you are quoting refers to early plans at the late-2017 launch of RealSense to allow a Tracking Module board to be attached. These plans were dropped, and the D435i model with an included IMU was launched in late 2018. So the reference in the document is obsolete. |
Yes, I've tried all sorts of variants of 1's and 0's here along with the simpler form. They all ended up with the same error. I suspect this just isn't supported any more. |
And to clarify - |
Thanks very much for the Git history information. |
I apologize for the delay in responding further. Do you require further assistance with this case, please? Thanks! |
Issue hasn't been resolved - but it looks like this has reached a dead-end and that the sensor outputs an indeterminate number of pulses before actually capturing and that the GPIO stream isn't functional on the D435. So I'll close this issue. |
Thanks very much @xc-racer99 for the update. |
Issue Description
We are trying to sync the realsense with an external encoder and obtain depth and colour frames in a known location. We previously tried genlock (see #9528) but have now switched to having the realsense output a pulse on its sync pin (ie pin 5) with RS2_OPTION_INTER_CAM_SYNC_MODE set to 1 (ie master). We are using the pipeline API with colour, depth, and infrared 1 streams enabled, all at 30 fps. The colour sensor has auto exposure priority disabled and both sensors have a fixed exposure - this is an attempt to keep the depth and colour synchronized based on the comments found at #8726 (comment)
Experimentally, we've found that the first infrared frame usually, but not always, lines up with the third pulse from the realsense. When this works, it works perfectly. I'd estimated 90% of the time this happens. When it doesn't, everything is thrown off such that the results are unusable for our purposes. So we've also experimented with setting RS2_OPTION_OUTPUT_TRIGGER_ENABLED to 1 instead. With this, we've been unable to find a "magic number" of frames to correlate encoder data with frames.
Breaking out the oscilloscope, here's the waveforms that we've found.
RGB streaming, RS2_OPTION_INTER_CAM_SYNC_MODE = 1, then depth started
(note the ~40ms gap between the first two pulses with the expected 33ms gap afterwards)
RGB streaming, RS2_OPTION_OUTPUT_TRIGGER_ENABLED = 1, then depth started
(note the two pulses in quick succession at the start, then the usual 33ms gap)
RGB not streaming, RS2_OPTION_INTER_CAM_SYNC_MODE = 1, then depth started
(note that this is the same as when RGB was streaming)
RGB not streaming, RS2_OPTION_OUTPUT_TRIGGER_ENABLED = 1, then depth started
(note the even 33ms gap between all pulses)
(side note - I've been unable to test this last situation in our application as it has the RGB stream heavily embedded and will need a bit of work to remove it for testing just the infrared/depth streams).
So the questions boil down to:
The text was updated successfully, but these errors were encountered: