Aaron/ue5/avoidopticalflowcrash (#7794)
* Avoid optical flow to crash * Reenable dvs sensor
This commit is contained in:
parent
2e02d51082
commit
d1cce75693
|
@ -129,6 +129,7 @@ void ADVSCamera::Set(const FActorDescription &Description)
|
|||
void ADVSCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTime)
|
||||
{
|
||||
TRACE_CPUPROFILER_EVENT_SCOPE(ADVSCamera::PostPhysTick);
|
||||
Super::PostPhysTick(World, TickType, DeltaTime);
|
||||
check(CaptureRenderTarget != nullptr);
|
||||
if (!HasActorBegunPlay() || IsPendingKill())
|
||||
{
|
||||
|
@ -156,11 +157,13 @@ void ADVSCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float DeltaTim
|
|||
/** DVS Simulator **/
|
||||
ADVSCamera::DVSEventArray events = this->Simulation(DeltaTime);
|
||||
|
||||
auto FrameIndex = FCarlaEngine::GetFrameCounter();
|
||||
auto DataStream = GetDataStream(*this);
|
||||
auto Buff = DataStream.PopBufferFromPool();
|
||||
DataStream.SetFrameNumber(FrameIndex);
|
||||
auto Buffer = DataStream.PopBufferFromPool();
|
||||
|
||||
// serialize data
|
||||
carla::Buffer BufferReady(carla::sensor::SensorRegistry::Serialize(*this, events, std::move(Buff)));
|
||||
carla::Buffer BufferReady(carla::sensor::SensorRegistry::Serialize(*this, events, std::move(Buffer)));
|
||||
carla::SharedBufferView BufView = carla::BufferView::CreateFrom(std::move(BufferReady));
|
||||
|
||||
// ROS2
|
||||
|
|
|
@ -31,8 +31,12 @@ void AOpticalFlowCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float
|
|||
{
|
||||
TRACE_CPUPROFILER_EVENT_SCOPE(AOpticalFlowCamera::PostPhysTick);
|
||||
auto CVarForceOutputsVelocity = IConsoleManager::Get().FindConsoleVariable(TEXT("r.BasePassForceOutputsVelocity"));
|
||||
int32 OldValue = CVarForceOutputsVelocity->GetInt();
|
||||
CVarForceOutputsVelocity->Set(1);
|
||||
int32 OldValue = 0;
|
||||
if (CVarForceOutputsVelocity)
|
||||
{
|
||||
OldValue = CVarForceOutputsVelocity->GetInt();
|
||||
CVarForceOutputsVelocity->Set(1);
|
||||
}
|
||||
|
||||
std::function<TArray<float>(void *, uint32)> Conversor = [](void *Data, uint32 Size)
|
||||
{
|
||||
|
@ -51,7 +55,19 @@ void AOpticalFlowCamera::PostPhysTick(UWorld *World, ELevelTick TickType, float
|
|||
}
|
||||
return IntermediateBuffer;
|
||||
};
|
||||
|
||||
auto FrameIndex = FCarlaEngine::GetFrameCounter();
|
||||
ImageUtil::ReadSensorImageDataAsyncFColor(*this, [this, FrameIndex](
|
||||
TArrayView<const FColor> Pixels,
|
||||
FIntPoint Size) -> bool
|
||||
{
|
||||
SendImageDataToClient(*this, Pixels, FrameIndex);
|
||||
return true;
|
||||
});
|
||||
FPixelReader::SendPixelsInRenderThread<AOpticalFlowCamera, float>(*this, true, Conversor);
|
||||
|
||||
CVarForceOutputsVelocity->Set(OldValue);
|
||||
if (CVarForceOutputsVelocity)
|
||||
{
|
||||
CVarForceOutputsVelocity->Set(OldValue);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue