Repository navigation
Bring data from a field's original CRS into its own frame - #259
Merged
Gonzalo-Mier merged 2 commits intoNov 16, 2026
Merged
Gonzalo-Mier merged 2 commits into
Gonzalo-Mier merged 2 commits into
Conversation
Transform can take a result out of a field's frame but has no way back in, so a start pose or a set of rows given in the field's original CRS has to be converted and moved by the caller. The function added here hands its input back, so the tests are red on the numbers: a field never transformed only loses its reference point, and a field taken to UTM has to give back the border it holds itself.
Convert from the field's previous CRS to its own and take out the reference point, the inverse of transformToPrevCRS. A field that was never transformed has no previous CRS, so only the reference point goes, which is what a caller in a local cartesian frame needs.
Member
|
Thank you @u33549! Nice PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Transformcan take a result out of a field's frame:transformToPrevCRSadds the reference point back and converts to the CRS the field came in, for a route, a path, a swath, a strip and their collections. There is no way back in. Data that arrives next to a field, such as the robot's start pose or a set of crop rows, comes in the field's original CRS, while the field works in its own CRS with the reference point taken out. Every caller converts and subtracts by hand.opennav_coveragedoes it in two places:toFieldFramefor the start pose, andtransformRowsWithRefwithremoveRowsRefPointfor the rows ofopennav_row_coverage. The row pair dates from 2023, so this is not a gap only one caller ran into.The API
It converts from
getPrevCRS()togetCRS()and takes outgetRefPoint(). A field that was never transformed has no previous CRS; then only the reference point is taken out, which is what a caller in a local cartesian frame needs. The caller no longer has to tell the two cases apart, the field already knows which one it is in.Both overloads share one body, built from what
Transformand the geometry types already have:transform<T>(t, from, to)andT - Point.Overloads rather than a template.
transformToPrevCRSis written per type, so its inverse is too. It also keeps the function reachable from Python: the existingtransform<T>template has no%templateinFields2Cover.iand cannot be called from Python today.Two types.
PointandLineStringare the two the callers above need. AMultiPointoverload would mirrortransformMultiPointWithFieldRef; I left it out until there is a caller, but it is one line if you would rather have it now.The name mirrors
transformToPrevCRS. Happy to change it iftransformFromPrevCRSor something else reads better to you.Tests
transform_test.cpp:convert_to_field_crs_without_prev_crs: a field never transformed,(5, 5)maps to(0, 0)and(10, 8)to(5, 3), compared exactly.convert_to_field_crs: a field inEPSG:4326taken to UTM. Its border, run through the new function, has to come out as the border the field itself holds, since both went through the same projection. Also: the first corner maps to(0, 0), the input line is unchanged, and the point goes back out to where it started through the existingtransformwith the reference point.The GPS comparisons cannot be exact and use a tolerance close to what was measured: the field added its reference point back before projecting, which rounds in the last digit (4e-14 m against the border, 4e-9 m at the corner, where two UTM northings of about 5.7e6 m are subtracted).
transform_test.pychecks both cases from Python.The first commit adds the tests with a body that hands its input back unchanged, so they fail on the numbers; the second fills it in. C++ 374 tests, Python 120, all passing.