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

Fix and improve ROS visualization #285

Merged
merged 14 commits into from
Mar 25, 2024

Conversation

nachovizzo
Copy link
Collaborator

First of all, now I can finally enjoy reading the implementation. Without the spaghetti if/else/if/else trying to guess which transformation should be applied.

My approach here was to replicate the same as we do in the Python visualizer.:

self.target.transform(np.linalg.inv(pose))

The new logic is as follows:

  • When debugging using ROS, everything happens in an ego-centric world, from the sensor's point of view
  • Since the KISS-ICP local map is on the odometric coordinate frame, we need to apply the last ego-centric pose to bring it back to the lidar frame.
  • This allowed for further simplification

The only caveat is that, if we DO NOT PUBLISH to the tf tree, then only the trajectory will be on a different reference frame and would look odd in the viz. The rest is still fine. Since this is something we never used, need, we don't have in Python, I figured out that's worth disabling it by default.
image

The rest I think is all improvement so far

NOTE I haven't changed the implementation of KISS, just the visualization utilities for ROS

Simplify implementation by debugging in an ego-centric way always.

Since the KISS-ICP internal map is on the global coordinates, fetch the
last ego-centric pose and apply it to the map. Seen from the
cloud_frame_id (which is the sensor frame) everything should always work
in terms of visualization, no matter the multi-sensor setup.
This actually makes the visualization closer to the Python visualizer
In the case where we are not computing the poses in an egocentric world
(base_frame != "") and we are not publishing to the TF tree, then the
visualization wouldn't make sense. Therefore, disable it by default
If someone doesn't have that particular frame defined, then the
visualization won't work. Leave this default
@benemer
Copy link
Member

benemer commented Mar 3, 2024

Since this is something we never used, need, we don't have in Python, I figured out that's worth disabling it by default.

But showing the point clouds and the full trajectory is something we can show in the Python visualizer or I am getting it wrong? Or are you talking about the default in the visualizer?

@nachovizzo
Copy link
Collaborator Author

Since this is something we never used, need, we don't have in Python, I figured out that's worth disabling it by default.

But showing the point clouds and the full trajectory is something we can show in the Python visualizer or I am getting it wrong? Or are you talking about the default in the visualizer?

You are right, it's something we can show on the Python side. Here it's always populating this infinitely wrong path which I don't think it has an application on the ROS side of things. The path can also be seen in RVIZ by just clicking in the odometry topic, which we don't have in Python

@nachovizzo nachovizzo added the ros label Mar 5, 2024
nachovizzo and others added 6 commits March 18, 2024 10:54
* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.
* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>
Copy link
Collaborator

@tizianoGuadagnino tizianoGuadagnino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nachovizzo as a general comment not strictly related to the issue (which looks good as far as I saw), would it make sense to always publish the tf (a.k.a. we remove the publich_odom_tf_ flag) ?

@nachovizzo
Copy link
Collaborator Author

@nachovizzo as a general comment not strictly related to the issue (which looks good as far as I saw), would it make sense to always publish the tf (a.k.a. we remove the publich_odom_tf_ flag) ?

@tizianoGuadagnino Sadly no. No because it doesn't make sense, but rather due to a limitation of tf. Assume the transformation you want to publish is already present in the tree, and then publishing it from Kiss will create some conflicts.

I always wonder if we should go back to the hacky "alias" tf we had, just to publish a completely disconnected tree to make sure we control that.

On the other hand, we also have a strong limitation with rviz. Since, the visualization frame can't be variable, and thus is hardcoded. I'd prefer to do like we do in the python visualizer and see everything from the lidar eyes, but rviz forbid us to do so

@tizianoGuadagnino
Copy link
Collaborator

Ok, now it is clear why, I didn't think about that.

I have mixed feelings about the alias, although I really like the idea of having a bit more control on the tf tree, even if it requires some hacks. Maybe it is something worth discussing offline with @benemer .

Anyways, from my side, we can merge this.

@tizianoGuadagnino tizianoGuadagnino self-requested a review March 25, 2024 09:46
@nachovizzo
Copy link
Collaborator Author

I also have mixed feelings, especially because it adds a ton of code that is virtually necessary. But all these problems are to avoid a user launching the pipeline and seeing a black screen because we couldn't guess 🔮 the frame_id from who knows which lidar is being used.

Complicated tasks to tackle in my opinion if we want to stay generic and don't force the user to read 5 pages of documentation on how to configure rviz

@tizianoGuadagnino tizianoGuadagnino merged commit 0c6f99d into main Mar 25, 2024
17 checks passed
@tizianoGuadagnino tizianoGuadagnino deleted the AUTO-2217_revise_tf_tree_clouds branch March 25, 2024 12:42
tizianoGuadagnino added a commit to 02alexander/kiss-icp that referenced this pull request Mar 25, 2024
* Fix this madness

Simplify implementation by debugging in an ego-centric way always.

Since the KISS-ICP internal map is on the global coordinates, fetch the
last ego-centric pose and apply it to the map. Seen from the
cloud_frame_id (which is the sensor frame) everything should always work
in terms of visualization, no matter the multi-sensor setup.

* Now is safe to disable this by default

* Simplify, borrow the header from the input pointcloud msg

This actually makes the visualization closer to the Python visualizer

* Disable path/odom visualization by default

In the case where we are not computing the poses in an egocentric world
(base_frame != "") and we are not publishing to the TF tree, then the
visualization wouldn't make sense. Therefore, disable it by default

* Changed my mind

If someone doesn't have that particular frame defined, then the
visualization won't work. Leave this default

* Move responsability of handling tf frames out of Registration (PRBonn#288)

* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.

* merge conflicts :0

* Remove unnecessary exposed utility function from ROS API (PRBonn#289)

* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>

* too many merges

* Merge Rviz and Python colors

* Just make the default construction more clear

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>
tizianoGuadagnino added a commit to 02alexander/kiss-icp that referenced this pull request Mar 25, 2024
tizianoGuadagnino added a commit that referenced this pull request Mar 25, 2024
* Fix this madness

Simplify implementation by debugging in an ego-centric way always.

Since the KISS-ICP internal map is on the global coordinates, fetch the
last ego-centric pose and apply it to the map. Seen from the
cloud_frame_id (which is the sensor frame) everything should always work
in terms of visualization, no matter the multi-sensor setup.

* Now is safe to disable this by default

* Simplify, borrow the header from the input pointcloud msg

This actually makes the visualization closer to the Python visualizer

* Disable path/odom visualization by default

In the case where we are not computing the poses in an egocentric world
(base_frame != "") and we are not publishing to the TF tree, then the
visualization wouldn't make sense. Therefore, disable it by default

* Changed my mind

If someone doesn't have that particular frame defined, then the
visualization won't work. Leave this default

* Move responsability of handling tf frames out of Registration (#288)

* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.

* merge conflicts :0

* Remove unnecessary exposed utility function from ROS API (#289)

* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>

* too many merges

* Merge Rviz and Python colors

* Just make the default construction more clear

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>
tizianoGuadagnino added a commit that referenced this pull request Mar 25, 2024
* Fix bug where point would match with random point

* Use closest neightbor distance

* Switch order

* Refactor ROS parametrization (#282)

* Move ros params from launch file to YAML

* Reuse arguments for debug clouds

* Rename odometry_node to kiss_icp_node

odometry is way to generic

* Rename node agin

* Voxel size is optional paramter

* Reads better like this

* New parameter proposal

* Add odometry covariance to ros node (#283)

* Add fixed covariance to odometry msg

* Add default value just in case

* pre-commit

* Expose number of icp iterations in ros (#292)

* Expose registration params to ROS node

* More merge conflicts

* Default to multithread

* Revert "Refactor ROS parametrization (#282)"

This reverts commit 7b8b095.

* Fix and improve ROS visualization (#285)

* Fix this madness

Simplify implementation by debugging in an ego-centric way always.

Since the KISS-ICP internal map is on the global coordinates, fetch the
last ego-centric pose and apply it to the map. Seen from the
cloud_frame_id (which is the sensor frame) everything should always work
in terms of visualization, no matter the multi-sensor setup.

* Now is safe to disable this by default

* Simplify, borrow the header from the input pointcloud msg

This actually makes the visualization closer to the Python visualizer

* Disable path/odom visualization by default

In the case where we are not computing the poses in an egocentric world
(base_frame != "") and we are not publishing to the TF tree, then the
visualization wouldn't make sense. Therefore, disable it by default

* Changed my mind

If someone doesn't have that particular frame defined, then the
visualization won't work. Leave this default

* Move responsability of handling tf frames out of Registration (#288)

* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.

* merge conflicts :0

* Remove unnecessary exposed utility function from ROS API (#289)

* Move responsability of handling tf frames out of Registration

Since with this new changes PublishOdometry is the only member that
requieres to know the user specified target-frame, it is not necesary to
handle all this bits.

This makes the implementation cleaner, easier to read and reduces the
lines of code. Now RegisterFrame is a simple callback as few months ago
one can read in seconds.

* typo

* Easier to read

* We need this for LookupTransform

* Remove unused variable

* Revert "Remove unused variable"

This reverts commit 424ee90.

* Remove unnecessary check

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary exposed utility function from ROS API"

This reverts commit 23cd7ef.

* Remove unnecessary exposed utility function from ROS API

With this change this function is not exposed (which was never the
intention to) to the header. This way we can also "hide" this into a
private unnamed namesapces and benefit from inlining the simple function
into the translation unit

* Revert "Remove unnecessary check"

This reverts commit d1dcb48.

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>

* too many merges

* Merge Rviz and Python colors

* Just make the default construction more clear

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>

* Revert "Fix and improve ROS visualization (#285)"

This reverts commit 20797de.

---------

Co-authored-by: tizianoGuadagnino <frevo93@gmail.com>
Co-authored-by: Benedikt Mersch <benedikt.mersch@gmail.com>
Co-authored-by: Ignacio Vizzo <ignaciovizzo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants