Skip to content
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

Track object with radar postprocess input test #311

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f0ce4bf
Implement sub-sampling in raytracing code (#277)
prybicki Apr 24, 2024
02c0516
Add node for radar object tracking (#280)
PawelLiberadzki Apr 25, 2024
c8ea5a1
Feature/fault injection (#281)
PiotrMrozik May 6, 2024
a62de0d
Integration with radar udp publisher (#282)
msz-rai May 6, 2024
01ea29b
Implement sub-sampling reduction kernels (#284)
prybicki May 10, 2024
c4ab95d
Add API call to configure beam divergence (#283)
prybicki May 15, 2024
323d983
Add object tracking to RadarTrackObjectsNode (#288)
PawelLiberadzki May 22, 2024
c632a10
Architectural changes to support multi-return feature (#285)
prybicki May 23, 2024
d23a43e
Add missing MR API call declaration (#289)
prybicki May 23, 2024
f9b6a43
Compute XYZ in MR based on distance, not XYZ samples (#295)
prybicki Jun 5, 2024
9cdcaea
Add MR test (#290)
nebraszka Jun 5, 2024
922246a
Update MR beam model - distinct vertical/horizontal divergence (#297)
nebraszka Jun 7, 2024
4bdc9b6
Update multi-return sampling parameters to (3,19) (#299)
prybicki Jun 11, 2024
6e7435f
Add initial support for object classification in RadarTrackObjectsNode.
PawelLiberadzki Jun 7, 2024
5613984
Add API call for setting radar object classes.
PawelLiberadzki Jun 10, 2024
0fd52b5
Update radar track objects tests to handle object ids.
PawelLiberadzki Jun 10, 2024
b58ad2d
Add safety static_cast.
PawelLiberadzki Jun 10, 2024
6c66642
Make fixes based on the review.
PawelLiberadzki Jun 11, 2024
fe0afff
Prevent underflow in loop condition (#308)
nebraszka Jun 13, 2024
bb367b1
Add handling nan radial speeds in radar nodes (#309)
PawelLiberadzki Jun 17, 2024
40539f7
Tracking reflector with radar postprocess input test
nebraszka Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implement sub-sampling in raytracing code (#277)
* Implement sub-sampling in raytracing code

* Review fixes
prybicki authored Apr 24, 2024
commit f0ce4bf1d6e5509fe2ea779f1faac5caa24a319e
9 changes: 9 additions & 0 deletions include/rgl/api/core.h
Original file line number Diff line number Diff line change
@@ -382,6 +382,15 @@ typedef enum : int32_t
RGL_FIELD_DYNAMIC_FORMAT = 13842,
} rgl_field_t;

/**
* Kinds of return type for multi-return LiDAR output.
*/
typedef enum : int32_t
{
RGL_RETURN_TYPE_FIRST = 0,
RGL_RETURN_TYPE_LAST = 1,
} rgl_return_type_t;

/**
* Helper enum for axis selection
*/
28 changes: 28 additions & 0 deletions src/gpu/MultiReturn.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2024 Robotec.AI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <RGLFields.hpp>

#define MULTI_RETURN_BEAM_VERTICES 8
#define MULTI_RETURN_BEAM_CIRCLES 2
#define MULTI_RETURN_BEAM_SAMPLES (1 + (MULTI_RETURN_BEAM_VERTICES * MULTI_RETURN_BEAM_CIRCLES))

struct MultiReturnPointers
{
Field<IS_HIT_I32>::type* isHit;
Field<XYZ_VEC3_F32>::type* xyz;
Field<DISTANCE_F32>::type* distance;
};
7 changes: 6 additions & 1 deletion src/gpu/RaytraceRequestContext.hpp
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@

#include <optix.h>
#include <RGLFields.hpp>
#include <gpu/MultiReturn.hpp>

struct RaytraceRequestContext
{
@@ -38,7 +39,7 @@ struct RaytraceRequestContext
const int* ringIds;
size_t ringIdsCount;

const float* rayTimeOffsets;
const float* rayTimeOffsetsMs;
size_t rayTimeOffsetsCount;

OptixTraversableHandle scene;
@@ -61,5 +62,9 @@ struct RaytraceRequestContext
Field<ELEVATION_F32>::type* elevation;
Field<NORMAL_VEC3_F32>::type* normal;
Field<INCIDENT_ANGLE_F32>::type* incidentAngle;

// Multi-Return
float beamHalfDivergence;
MultiReturnPointers mrSamples;
};
static_assert(std::is_trivially_copyable<RaytraceRequestContext>::value);
285 changes: 161 additions & 124 deletions src/gpu/optixPrograms.cu

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions src/graph/NodesCore.hpp
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
#include <gpu/nodeKernels.hpp>
#include <CacheManager.hpp>
#include <GPUFieldDescBuilder.hpp>
#include <gpu/MultiReturn.hpp>


struct FormatPointsNode : IPointsNodeSingleInput
@@ -143,6 +144,38 @@ struct RaytraceNode : IPointsNode

std::unordered_map<rgl_field_t, IAnyArray::Ptr> fieldData; // All should be DeviceAsyncArray

struct MultiReturnFields
{
MultiReturnFields(StreamBoundObjectsManager& arrayMgr)
: isHit(DeviceAsyncArray<Field<IS_HIT_I32>::type>::create(arrayMgr)),
xyz(DeviceAsyncArray<Field<XYZ_VEC3_F32>::type>::create(arrayMgr)),
distance(DeviceAsyncArray<Field<DISTANCE_F32>::type>::create(arrayMgr))
{}
void resize(size_t size)
{
isHit->resize(size, false, false);
xyz->resize(size, false, false);
distance->resize(size, false, false);
}
MultiReturnPointers getPointers()
{
return MultiReturnPointers{
.isHit = isHit->getWritePtr(),
.xyz = xyz->getWritePtr(),
.distance = distance->getWritePtr(),
};
}
DeviceAsyncArray<Field<IS_HIT_I32>::type>::Ptr isHit;
DeviceAsyncArray<Field<XYZ_VEC3_F32>::type>::Ptr xyz;
DeviceAsyncArray<Field<DISTANCE_F32>::type>::Ptr distance;
};


MultiReturnFields mrSamples = MultiReturnFields{arrayMgr};
MultiReturnFields mrFirst = MultiReturnFields{arrayMgr};
MultiReturnFields mrLast = MultiReturnFields{arrayMgr};


template<rgl_field_t>
auto getPtrTo();

9 changes: 8 additions & 1 deletion src/graph/RaytraceNode.cpp
Original file line number Diff line number Diff line change
@@ -65,6 +65,11 @@ void RaytraceNode::enqueueExecImpl()
data->resize(raysNode->getRayCount(), false, false);
}

// TODO(prybicki): don't update this when not needed
mrSamples.resize(MULTI_RETURN_BEAM_SAMPLES * raysNode->getRayCount());
mrFirst.resize(raysNode->getRayCount());
mrLast.resize(raysNode->getRayCount());

// Even though we are in graph thread here, we can access Scene class (see comment there)
const Mat3x4f* raysPtr = raysNode->getRays()->asSubclass<DeviceAsyncArray>()->getReadPtr();
auto sceneAS = Scene::instance().getASLocked();
@@ -92,7 +97,7 @@ void RaytraceNode::enqueueExecImpl()
.rayRangesCount = rayRanges.has_value() ? (*rayRanges)->getCount() : defaultRange->getCount(),
.ringIds = ringIds.has_value() ? (*ringIds)->asSubclass<DeviceAsyncArray>()->getReadPtr() : nullptr,
.ringIdsCount = ringIds.has_value() ? (*ringIds)->getCount() : 0,
.rayTimeOffsets = timeOffsets.has_value() ? (*timeOffsets)->asSubclass<DeviceAsyncArray>()->getReadPtr() : nullptr,
.rayTimeOffsetsMs = timeOffsets.has_value() ? (*timeOffsets)->asSubclass<DeviceAsyncArray>()->getReadPtr() : nullptr,
.rayTimeOffsetsCount = timeOffsets.has_value() ? (*timeOffsets)->getCount() : 0,
.scene = sceneAS,
.sceneTime = Scene::instance().getTime().value_or(Time::zero()).asSeconds(),
@@ -112,6 +117,8 @@ void RaytraceNode::enqueueExecImpl()
.elevation = getPtrTo<ELEVATION_F32>(),
.normal = getPtrTo<NORMAL_VEC3_F32>(),
.incidentAngle = getPtrTo<INCIDENT_ANGLE_F32>(),
.beamHalfDivergence = 0.0f, // TODO: provide API to set externally
.mrSamples = mrSamples.getPointers(),
};

requestCtxDev->copyFrom(requestCtxHst);
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ set(RGL_TEST_FILES
src/synchronization/graphThreadSynchronization.cpp
src/synchronization/testKernel.cu
src/scene/incidentAngleTest.cpp
src/graph/multiReturnTest.cpp
)

if (RGL_BUILD_ROS2_EXTENSION)
40 changes: 40 additions & 0 deletions test/src/graph/multiReturnTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <helpers/commonHelpers.hpp>
#include "math/Mat3x4f.hpp"
#include "helpers/lidarHelpers.hpp"
#include "RGLFields.hpp"
#include "helpers/testPointCloud.hpp"
#include "helpers/sceneHelpers.hpp"

class GraphMultiReturn : public RGLTest
{};

TEST_F(GraphMultiReturn, basic)
{
rgl_node_t useRays = nullptr, raytrace = nullptr, lidarPose = nullptr, compact = nullptr, yield = nullptr;
std::vector<rgl_field_t> mrFields = {IS_HIT_I32, DISTANCE_F32, XYZ_VEC3_F32, INTENSITY_F32, ENTITY_ID_I32};

std::vector<rgl_mat3x4f> rays = {Mat3x4f::identity().toRGL()};
rgl_mat3x4f lidarPoseTf = Mat3x4f::TRS({1, 2, 3}, {0, 30, 0}).toRGL();

rgl_entity_t cube = makeEntity();
rgl_mat3x4f cubeTf = Mat3x4f::TRS({0, 0, 0}, {0, 0, 0}, {10, 10, 10}).toRGL();
EXPECT_RGL_SUCCESS(rgl_entity_set_pose(cube, &cubeTf));

EXPECT_RGL_SUCCESS(rgl_node_rays_from_mat3x4f(&useRays, rays.data(), rays.size()));
EXPECT_RGL_SUCCESS(rgl_node_rays_transform(&lidarPose, &lidarPoseTf));
EXPECT_RGL_SUCCESS(rgl_node_raytrace(&raytrace, nullptr));
EXPECT_RGL_SUCCESS(rgl_node_points_compact_by_field(&compact, RGL_FIELD_IS_HIT_I32));
EXPECT_RGL_SUCCESS(rgl_node_points_yield(&yield, mrFields.data(), mrFields.size()));

EXPECT_RGL_SUCCESS(rgl_graph_node_add_child(useRays, lidarPose));
EXPECT_RGL_SUCCESS(rgl_graph_node_add_child(lidarPose, raytrace));
EXPECT_RGL_SUCCESS(rgl_graph_node_add_child(raytrace, compact));
EXPECT_RGL_SUCCESS(rgl_graph_node_add_child(compact, yield));

EXPECT_RGL_SUCCESS(rgl_graph_run(useRays));

TestPointCloud pc = TestPointCloud::createFromNode(yield, mrFields);
EXPECT_EQ(pc.getPointCount(), 1);

EXPECT_RGL_SUCCESS(rgl_graph_destroy(useRays));
}