multiple (moving) Reference frame displayed - #1
Conversation
Enable visualization of 3D coordinate systems by parsing 4x4 homogeneous matrices from specified JSON keypaths. Extracts origin and axis vectors, logging them as colored arrows to Rerun. Supports flat [16] and nested [[4],[4],[4],[4]] array formats.
There was a problem hiding this comment.
Pull request overview
This PR adds support for visualizing multiple moving reference frames in Rerun by interpreting configured JSON keypaths as 4×4 homogeneous transformation matrices and logging them as 3D axis arrows.
Changes:
- Introduces a new
_hmat_keypathsconfiguration list and loads it from plugin params. - Adds per-sample parsing of 4×4 (or flat[16]) matrices and logs X/Y/Z axis arrows at the matrix translation.
- Adds a scaling parameter (
h_scale, used with a default) to control axis arrow length.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (const auto &keypath : _hmat_keypaths) { | ||
| json::json_pointer ptr(dot_to_pointer(keypath)); | ||
| const auto &mat = data[ptr]; | ||
| cout << mat.dump(2); |
| _rec->log("frame/" + keypath, | ||
| rerun::Arrows3D::from_vectors({ | ||
| rerun::Vector3D{(float)m[0]*ax_len, (float)m[4]*ax_len, (float)m[8]*ax_len}, // X | ||
| rerun::Vector3D{(float)m[1]*ax_len, (float)m[5]*ax_len, (float)m[9]*ax_len}, // Y | ||
| rerun::Vector3D{(float)m[2]*ax_len, (float)m[6]*ax_len, (float)m[10]*ax_len}, // Z | ||
| }) | ||
| .with_origins({origin, origin, origin}) | ||
| .with_colors({ | ||
| rerun::Color(255, 40, 40), // X = red | ||
| rerun::Color( 40, 220, 40), // Y = green | ||
| rerun::Color( 40, 40, 255), // Z = blue | ||
| }) | ||
| .with_labels({"X", "Y", "Z"}) | ||
| ); |
| // In set_params, add a new param: | ||
| //_params["hmat_keypaths"] = json::array(); // list of keypaths to 4x4 matrices | ||
|
|
||
| // Load in set_params: | ||
| _hmat_keypaths.clear(); | ||
| if (_params.contains("hmat_keypaths") && _params["hmat_keypaths"].is_array()) { | ||
| std::cout << "\ntrovato hmat " << _params["hmat_keypaths"].size() << "\n"; | ||
| for (const auto &path : _params["hmat_keypaths"]) | ||
| { | ||
| std::cout << "\nvaluto\n"; | ||
| if (path.is_string()){ | ||
| cout << "\naggiunto\n"; | ||
| _hmat_keypaths.push_back(path.get<std::string>()); | ||
| cout << "\naggiunto\n"; | ||
| }else{ | ||
| cout << "\nnon aggiunto\n"; | ||
| } | ||
| } | ||
| } |
|
Before merging, the feature needs to be documented in the |
|
Additionally, it makes little sense to pass via JSON 4x4 matrices when only 7 values (angles, position and scale) are used independently. Better and simpler to use a predefined schema. |
|
Also consider Copilot comments, specifically regarding debug print (in Italian!) that ought to be removed |
No description provided.