You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**GridMap / Eigen**: column-major (Fortran) by default.
5
+
-**CuPy / NumPy**: row-major (C) by default.
6
+
- Current code works but relies on implicit defaults; we should make conversions explicit to avoid silent axis/stride bugs.
7
+
8
+
## Goals
9
+
- Keep internal CuPy tensors row-major (C) for existing ops and axis semantics.
10
+
- Be explicit at boundaries (GridMap messages / bag I/O): convert to column-major when publishing, and normalize to row-major when consuming.
11
+
- Document intent in code and add minimal tests to guard behavior.
12
+
13
+
## Changes to Implement
14
+
1)**Document intent**
15
+
- In `elevation_mapping.py` near GridMap↔array helpers, add a brief note: internal arrays are C-order; GridMap expects F-order; conversions are explicit.
16
+
17
+
2)**Inbound (GridMap → NumPy/CuPy)**
18
+
- In `_grid_map_to_numpy` (uses `_extract_layout_shape`):
19
+
- Detect layout orientation via `layout.dim[0].label` (default to column-major if absent).
20
+
- For column-major inputs: `np.array(..., order='F').reshape((rows, cols), order='F')`, then `np.ascontiguousarray` for internal row-major use.
21
+
- For row-major inputs: keep `order='C'`.
22
+
- Encapsulate this in a small helper (e.g., `_grid_msg_to_array(msg, expected_order='F')`) and reuse in set_full_map/bag reads.
23
+
24
+
3)**Outbound (NumPy/CuPy → GridMap)**
25
+
- In `_numpy_to_multiarray`:
26
+
- Ensure column-major with `np.asfortranarray(data)` before flattening.
27
+
- Set `layout.dim[0].label` to indicate column-major (e.g., "column_index" consistent with Eigen).
28
+
- If internal is row-major, transpose if needed before `asfortranarray` so axes stay correct.
29
+
30
+
4)**Internal exports/imports**
31
+
- In `export_layers`, `set_full_map`, and bag I/O helpers, route through the same normalize/fortranize helpers to keep consistency everywhere.
32
+
33
+
5)**Tests**
34
+
- Add a unit test around the conversion helpers:
35
+
- Build a small grid with distinct row/col values, serialize to GridMap msg, deserialize, and assert axes/values preserved.
36
+
- Check `layout.dim[0].label` is set and respected on ingest.
37
+
38
+
6)**Runtime defaults**
39
+
- No change to `shift_map_xy` or other core ops; all changes are at message/bag boundaries.
40
+
41
+
## Notes
42
+
- This keeps existing behavior while making layout assumptions explicit and guarded by tests.
0 commit comments