Conversation
This Commit adds a `TimeVaryingVolumetricGrid`. The core idea is this extends `VolumetricGrid` by stepping through time. It uses template speciallization to leave the room open to custom implementations of the index. Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
ahcorde
left a comment
There was a problem hiding this comment.
If you don't have the time to generate the Python interface. Do you mind to open a issue ?
Codecov Report
@@ Coverage Diff @@
## main #456 +/- ##
=======================================
Coverage 99.69% 99.70%
=======================================
Files 75 77 +2
Lines 6912 7007 +95
=======================================
+ Hits 6891 6986 +95
Misses 21 21
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
This commit adds a container class for values also. In particular it implements the behaviour for the class `TimeVaryingVolumetricGrid<T, V, InMemorySession<T, double>>` . This class serves as a lookup table for time varying items. To construct a `TimeVaryingVolumetricGrid` it is advised to use the `InMemoryTimeVaryingVolumetricGridFactory` to construct the actual grid from a given dataset. Do not that this dataset should fit in memory.
To progress along the time axis use the `InMemorySession` object. This can be acquired using the `CreateSession` function. To set the time to be queried, step the `InMemorySession`
using the `StepTo` function. Finally to look up a value use the `LookUp` function.
## Example
```
InMemoryTimeVaryingVolumetricGridFactory<double, double> gridFactory;
for (double t = 0; t < 1; t+=0.2)
{
for (double x = 0; x < 1; x+=0.5)
{
for (double y = 0; y < 1; y+=0.5)
{
for (double z = 0; z < 1; z+=0.5)
{
gridFactory.AddPoint(t, Vector3d{x,y,z}, t);
}
}
}
}
/// Construct the grid
auto grid = gridFactory.Build();
/// Get the session cursor
auto session = grid.CreateSession();
/// Step to the correct time
auto new_sess = grid.StepTo(session, 0.5);
/// Retrieve value from given location
auto val = grid.LookUp(new_sess.value(), Vector3d{0.5, 0.5, 0.5});
```
## Other Changes in this commit
This commit also makes some changes to `VolumetricGridLookUpField`. In particular the changes allow
`VolumetricGridLookUpField` to use custom indices and support looking up in larger
index slices. There is also a new constructor for it to support the `TimeVaryingVolumetricGridLookupField`. This shouldn;t really be a problem as the `VolumetricGridField` is only available on the main branch and not in any collection yet.
## TODO
There is still a fair deal of work to do by ways of documentation and test coverage. I would also like to change the behaviour of what happens when we go out of bounds of the grid.
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
This PR generifies the index term. It also adds a constructor which is used by #456. Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
This PR generifies the index term. It also adds a constructor which is used by #456.
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
| namespace math | ||
| { | ||
| /// \brief Lookup table for a time-varying volumetric dataset. | ||
| /// This is an unimplimented template as the actual methods depend on the |
There was a problem hiding this comment.
@arjo129 typo:
| /// This is an unimplimented template as the actual methods depend on the | |
| /// This is an unimplemented template as the actual methods depend on the |
| { | ||
| InterpolationPoint1D<T> | ||
| pt1{_session.iter->first, 0}, pt2{next->first, 1}; | ||
| // If either has value interpolate using default value. |
There was a problem hiding this comment.
@arjo129 meta: ok with this behavior for a first pass, but it may not be appropriate for several use cases. Perhaps we can add a ticket to generalize this a bit (e.g. to allow constant extrapolation or simply return nullopt or whatever you can think of).
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
Signed-off-by: Arjo Chakravarty <arjo@openrobotics.org>
| } | ||
|
|
||
| /// Got nothing to interpolate. Out of bounds. | ||
| if (_interpolators[0].timeSlice.size() == 0 |
There was a problem hiding this comment.
@arjo129 FYI, safe to ignore: there's std::vector<T, Allocator>::empty too.
| { | ||
| // Get data at T=0 | ||
| auto session = timeVaryingField.CreateSession(); | ||
| auto points = timeVaryingField.LookUp(session, Vector3d{0.5, 0.5, 0.5}); |
There was a problem hiding this comment.
@arjo129 nit^2: having a const tolerance = Vector3d{0.5, 0.5, 0.5} right above may improve readability a bit.
| ASSERT_EQ(points.size(), 2); | ||
| ASSERT_EQ(points[0].time, 0); | ||
| ASSERT_EQ(points[1].time, 1); | ||
| auto res = timeVaryingField.EstimateQuadrilinear<double>( |
There was a problem hiding this comment.
@arjo129 nit: I'd think it's not necessary to specify the template parameter here? Compiler should be able to infer X from arguments.
|
@arjo129 we got some linter errors in CI |
|
Seems like homebrew is not passing for unknown reasons. |
@scpeters any ideas? We'd like to get this into |
|
@arjo129 looks like it was a hiccup. We're good to go. |
🎉 New feature
Closes #
Summary
This PR adds a
TimeVaryingVolumetricGrid. The core idea is this extendsVolumetricGridby stepping through time. It uses template speciallization to leave the room open to custom implementations of the index.Test it
Checklist
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-bymessages.