Skip to content

Add eigen support - #67

Open
PepMS wants to merge 6 commits into
PickNikRobotics:mainfrom
PepMS:add_eigen_support
Open

PepMS wants to merge 6 commits into
PickNikRobotics:mainfrom
PepMS:add_eigen_support

Conversation

@PepMS

@PepMS PepMS commented Jan 22, 2026

Copy link
Copy Markdown

As discussed in #66 , this PR adds the possibility to log Eigen::VectorXd objects.

Adding Eigen compatibility is configurable through cmake variables and the use of preprocessor directives inside the code.

@henrygerardmoore
henrygerardmoore self-requested a review January 22, 2026 18:19
RegistrationID registerValue(const std::string& name, const std::array<T, N>* value);

#if DATA_TAMER_EIGEN_SUPPORT
RegistrationID registerValue(const std::string& prefix, const Eigen::VectorXd* value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @PepMS, how are you doing?

Thank you very much for this PR, it's really helpful.

I have my 2 cents comment on this work.
I would believe that using the ground rules for Eigen for passing Eigen object into functions would be beneficial here.
Either using templates or Eigen::Ref.

See: https://libeigen.gitlab.io/eigen/docs-5.0/TopicFunctionTakingEigenTypes.html

My comment applies for the full PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@PepMS any plans on continuing this PR?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@MaximilienNaveau yes, indeed. Sorry for not having done this before. I'll try to allocate some time to continue that during this week.

@PepMS

PepMS commented Sep 15, 2026

Copy link
Copy Markdown
Author

I just pushed my changes @MaximilienNaveau. Here's a recap

  • I used the templated approach — see values.hpp. It adds support for Eigen::Matrix and Eigen::Array objects, both fixed and dynamic size.
  • I added a static_assert restricting it to vector-like types. Matrices could be supported too, but then we would have no information about the ordering of the elements.
  • I explicitly reject registering views and expressions (blocks, maps, refs).
  • I added tests in tests/eigen_tests.cpp: schema shape for fixed vs dynamic size, a round-trip through the parser, a dynamic vector resized between snapshots, and parity with the equivalent std::array / std::vector.

This PR has been developed with the support of Claude.

@MaximilienNaveau MaximilienNaveau left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Some packaging issue at first glance,
@henrygerardmoore as you are targeted as the main reviewer, could you start the CI so we see the sanity?

ValuePtr() = default;

template <typename T, bool = true>
template <typename T, std::enable_if_t<!IsEigenType<T>, bool> = true>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is IsEigenType<> defined is the Eigen include is not loaded?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

IsEigenType<> evaluates to true whenever the type T is an object from the Eigen library. Otherwise is false.

If Eigen is not included IsEigenType defaults to false.

Here: https://github.com/PickNikRobotics/data_tamer/pull/67/changes/BASE..73fedd4e9c1f30df781fc964339cf8d91f9d2217#diff-d7946cad3c50605c63a784c0197e38a8e5fee1901efe4290f3514a062c7837bbR33

@MaximilienNaveau MaximilienNaveau Sep 15, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I missed it!
Sorry for that!!

endif()
endif()

option(DATA_TAMER_EIGEN_SUPPORT "Enable Eigen support" ON)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job but see below the option to mcap make the package.xml needing the mcap_vendor as well as a dependency.

Hence you need to add Eigen to the package.xml as well. And you need to update the conanfile.py as well to declare eigen3 there as well. Pick the version of Eigen that is default on the lowest version of the OS. i.e. ros2 humble meaning Ubunut22.04. I will let you find the proper Eigen version for this.

endif()

option(DATA_TAMER_EIGEN_SUPPORT "Enable Eigen support" ON)
if (DATA_TAMER_EIGEN_SUPPORT)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An additional comment here, we would need a CI that build with/without the different options.
Maybe it's a bit brute force and you actually set the option to ON by default so I guess it's ok, but did you try to build with the option OFF on a fresh build?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants