-
Notifications
You must be signed in to change notification settings - Fork 9
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
add ROS2 rgb camera plugin #24
Conversation
be4d238
to
a65d276
Compare
Source/RapyutaSimulationPlugins/Private/Sensors/ROS2CameraActor.cpp
Outdated
Show resolved
Hide resolved
Source/RapyutaSimulationPlugins/Private/Sensors/ROS2CameraComponent.cpp
Outdated
Show resolved
Hide resolved
Source/RapyutaSimulationPlugins/Private/Sensors/ROS2CameraComponent.cpp
Outdated
Show resolved
Hide resolved
Source/RapyutaSimulationPlugins/Private/Sensors/ROS2CameraComponent.cpp
Outdated
Show resolved
Hide resolved
FROSImage UROS2CameraComponent::GetData() | ||
{ | ||
SceneCaptureComponent->CaptureScene(); | ||
CaptureNonBlocking(); | ||
if(!RenderRequestQueue.IsEmpty()){ | ||
// Peek the next RenderRequest from queue | ||
FRenderRequest* nextRenderRequest = nullptr; | ||
RenderRequestQueue.Peek(nextRenderRequest); | ||
|
||
if(nextRenderRequest){ //nullptr check | ||
if(nextRenderRequest->RenderFence.IsFenceComplete()){ // Check if rendering is done, indicated by RenderFence | ||
for (int I = 0; I < nextRenderRequest->Image.Num(); I++) | ||
{ | ||
Data.data[I * 3 + 0] = nextRenderRequest->Image[I].R; | ||
Data.data[I * 3 + 1] = nextRenderRequest->Image[I].G; | ||
Data.data[I * 3 + 2] = nextRenderRequest->Image[I].B; | ||
// UE_LOG(LogTemp, Warning, TEXT("AsyncTaskDone")); | ||
} | ||
|
||
// Delete the first element from RenderQueue | ||
RenderRequestQueue.Pop(); | ||
delete nextRenderRequest; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since here we do CaptureNonBlocking()
, which means the GameThread is non-blocking, and the capturing (pixel reading from RHI) could possibly take some time before RHI returns the data.
Thus, if(nextRenderRequest->RenderFence.IsFenceComplete())
might not be instantly satisfied.
But more essentially, an instant data fetching function named GetData()
could be inevitably blocking, if users want to invoke a non-blocking version, they might want to fetch data at a later time, when it is available from RHI, after invoking CaptureNonBlocking()
?
References:
- TimmHess actually runs the fence check in a tick then do async image saving.
- Another one of async fetching style by off-loading the fence check to a thread.
Source/RapyutaSimulationPlugins/Private/Sensors/ROS2CameraActor.cpp
Outdated
Show resolved
Hide resolved
Source/RapyutaSimulationPlugins/Public/Sensors/ROS2CameraComponent.h
Outdated
Show resolved
Hide resolved
Source/RapyutaSimulationPlugins/Public/Sensors/ROS2CameraComponent.h
Outdated
Show resolved
Hide resolved
8e92762
to
94b8258
Compare
No description provided.