Hi, I am currently working on simulating a Lidar sensor on UE. However, I am facing a problem where I could not obtain the time when the laser pulse is being sent and the time when the collision happened. I need the time difference to calculate the distance.
Can anyone please help me with this? Thank you so much!
Try adding two datetime variables. Set the first to “Now”, then fire your laser (simulate travel time), then on collision set the second datetime to “Now”. You will have a snapshot of the start and impact. Then just subtract them to get the travel time.
How are you simulating travel time? Iine traces are instantaneous. You could get the distance from the line trace directly (no need for time calculations). From the out hit drag and break. Then you can get the hit location, origin location and use the distance (vector) node to get the distance between them.
The aim of my project is to study the physics behaviour of a ToF lidar, so I have to simulate the sensor according to how it works in the real world.
I am using the projectile as my laser pulse and I want to get the time when the laser pulse hits something, in order for me to get the time difference.
I’ll try the DateTime variable that you suggested. Thank you!
If you are using unreal 5 with it’s new blueprint variable suggestions then you might encounter a bug where you cannot subtract datetime from datetime. If this is the case then go into editor preferences => blueprint editor settings and turn off “Enable type promotion”.
In the case of a projectile then the first datetime will the the spawning of the projectile, and the second would be once it hit it’s target. If you need the data in the lidar actor then you would need to pass the collision datetime back the the main lidar actor.
If you are constantly spawning projectiles at a set interval you would probably need a pooling system to recycle the projectiles instead of constantly spawning & destroying them. (It can impact performance over time)
Alright, thank you so much for your suggestion, it really helps me a lot!
Made an example project in 5.0.3
I think line traces would be better. Lidars use lasers so it’s the speed of light. Nothing moves faster so a line trace by channel would probably be fine.
With projectiles you will have to set an absurd speed that may fail the collision test even with “CCD” enabled on the light trace (has a collision sphere)
OFC in the project the traces are slowed down but you can see the basic mechanic.
Edit: Oh and you probably need to add the car velocity to the projectile so it doesn’t lag behind at higher speeds. Getting a bit late here & coffee is not working anymore ;).
OMG, thank you so much, I really appreciate it! You helped me a lot, thanks
line trace version, now with sample count (number of rays), splay angle, vert min & max angle and min and max trace distance.
Go into the lidar trace bp and the config portion sets most parameters
This is exactly what I need. Thank you so much, hope you have a nice day!
Likewise. Have a great day. Best of luck with your project.
Thank you! However, there is an error with the latest file saying that the car variable is private and not accessible in sportscar_pawn blueprints. So, I could not play it.
Click on the car variable and in its details of the lidar trace bp & just uncheck private. Should fix the error.
Alright, got it thanks!
Hi 3dRaven, I’m sorry to trouble you again, but I have some queries on the pooling system. Cause I was actually trying out your examples by opening a new file and follow what you did to see how did you do it. But my output from GetActorOfClass in Lidar was nothing and I got an error “Accessed None trying to reach property Pooler”.
You need to put the pooler bp actor into the scene. The engine should find it and assign the class on play then.