-
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
Inconsistent Accel stream in Unity C# #12250
Comments
Hi @thomaskole Does the problem still occur if you set a lower Accel framerate, please? D455 cameras manufactured before mid 2022 can be set to '63' as a minimum framerate, whilst D455 manufactured after mid 2022 do not support 63 and instead have '100' as their minimum. If you are only using one infrared stream (the left one by default) then you should not need to set an index of '1' for Infrared and can leave its index as '0'. The recommended camera firmware version for SDK 2.54.2 is 5.15.1.0. You can update to this version in the 2.54.2 version of the RealSense Viewer. The 5.13.0.55 firmware that you currently have installed is the recommended version for the older SDK versions 2.50.0 and 2.51.1. |
Just updated the firmware. |
I've tried importing just the Intel.RealSense.unitypackage into an empty Unity project. |
Is the Intel.RealSense.unitypackage file that you imported the one from the 2.54.2 assets list, please? https://github.com/IntelRealSense/librealsense/releases/tag/v2.54.2 |
yes, it is. |
Does IMU work normally on its own if the depth and infrared profiles are not used? There is a known phenomenon where a program can work fine without IMU, or with IMU only, but once IMU and other types of stream (such as depth, color and IMU) are used simultaneously then problems can occur. A solution to this is to use callbacks, like in the C# scripting at #11111 |
If I use a callback:
I receive exactly 16 samples on start, then nothing: It does not matter if the RsDevice component is enabled. |
If I disable and re-enable the "RSGyro" script, I get new samples. I can do this a few times, then unity crashes silently without crash report. |
One RealSense user at #9278 (comment) took the approach of removing all profiles from RsDevice and said that this caused all 4 stream types (depth, color, infrared, IMU) to be enabled. What happens to your RSGyro script if there are no profiles listed in RsDevice? |
As stated above:
Even with just the gyro script, and no "RsDevice" component (either disabled or not in the scene at all), I get the behavior as explained above. |
It appears that you are disabling RsDevice (which handles the enabling and streaming of RealSense stream profiles) and having your RSGyro script define the streams and start the pipeline instead. It might be better to insert your ProcessAccelFrame void into the RsDevice script file and let RsDevice handle the camera control via the defined profiles. |
Actually, it looks as though once OnEnable calls the ProcessAccelFrame void, the contents of ProcessAccelFrame would only run once and then stop because it would be a one-shot void instead of a looping one like Update(). So if you want ProcessAccelFrame to loop and generate results continuously then you might want to add Correction: it looks as though ProcessAccelFrame runs once as a one-shot and then jumps to the ProcessGyro void. But I see no way for ProcessGyro to loop or for ProcessAccelFrame to run more than once. |
Is that not what the When the
|
pipeline.start will start the camera and publish the streams. It should only be called once when the script is run and not be within a loop. Once it is called, the streams will be continuously active until pipeline.stop is called. The streams will be continuously active. But ProcessGyro will be non-looping and only be run each time that it is called. So if ProcessGyro was called 16 times then it would only run the Vector3 instruction 16 times, one for each call of the function name. |
I think there is a misunderstanding.
Am I wrong to assume that this callback ( What's happening now is that this callback is called 16 times, not by me but by the realsense stream. |
If a RealSense script uses callbacks then typically the word callback will be inserted in the brackets of the pipeline start line so that the script knows that it is a callback script. For example:
My knowledge of callback programming (and also advanced Unity programming) is admittedly limited though, unfortunately. |
I've done a bit more testing, and I think I'm getting closer to the solution: Let's focus only on the callback:
This works. The output of f.Profile.Format ( Introducing the
This gives the result as before - 16 updates, then nothing. I tried a marshall operation, like suggested here:
This seems to work (though more testing is needed). |
It's great to hear that you made very significant progress. I look forward to a further update after your testing. |
After a few seconds the editor crashes. This is what's found in the Editor log:
So, it seems pretty broken. |
That error message does not seem to have occurred before in relation to RealSense. Googling for it indicates that it occurs in non-RealSense projects too. Here is an example case. |
I think the implication here is that the fault can be inside a DLL, and I suspect the realsense DLL to be at fault. |
There is another example of C# marshal code at #2996 (comment) which was provided shortly before MotionFrame support was added to the SDK. |
I'm using an identical marshal operation. My marhsal: But instead of using If I don't use a callback but |
So the current situation is that the program works fine if marshal code is used instead of MotionFrame? |
No, the current situation is that when a marshall is used, the application crashes after a few seconds. |
As a problem with MotionFrame was also previously reported in #11111 I will highlight the issue to my Intel RealSense colleagues. However, if a bug in MotionFrame is confirmed then it would not immediately resolve your issue unfortunately due to the time required to develop a fix and then release it in a future version of the RealSense SDK. |
Thanks for confirming and relaying the information. Right now, this bug forms a serious problem in our production, as we are not able to use the IMU at all. Thanks again for your time! |
You are very welcome. Thanks very much for your patience. I have communicated the urgency of the issue to my colleagues and will let you know as soon as I receive feedback. |
After consulting with my colleagues, an official internal Intel bug report has been created so that this issue can be investigated further by the RealSense team, and I have added an Enhancement label to this issue to signify that it should be kept open. |
Hi, are there any updates on this issue? |
Hi @thomaskole An official Intel internal bug report was created about this issue so that it can be investigated by the RealSense team, but there is no new information to report at this time unfortunately. |
Hi @thomaskole The current latest SDK version 2.55.1 made some changes to the Accel stream of the IMU. Are you able to test 2.55.1 to check whether the changes make a difference to the MotionFrame() issue in Unity, please? |
It seems to work. I have upgraded the realsense to firmware version 5.16.0.1, and the unitypackage to 2.55.1. We will test this a little further but so far, so good! |
That's great to hear. I look forward to your next report after tests. Good luck! :) |
Hi @thomaskole Do you have an update about this case that you can provide, please? Thanks! |
Issue Description
When using the latest Realsense SDK in Unity, I can't get the Accel data behaving correctly.
I have the following snippet:
To listen to Accel data.

This is the RSDevice:
What happens is that when the device is enabled, for the first 1-5 seconds, data streams in, and then it keeps outputting the same value.
So, new samples do come in via rs.OnNewSample, but the value that's put out is stuck.
The depth and IR work just fine.
In RealsenseViewer, it keeps working too.
No errors or warnings show up in Unity. What could be the problem here?
The text was updated successfully, but these errors were encountered: