Hello team,
First of all, thank you for this great tool and for making it open source!
I have a simple question: have you considered introducing support for logging Eigen::VectorXd?
In my own fork, I implemented this in a very straightforward way:
inline RegistrationID LogChannel::registerValue(const std::string& prefix,
const Eigen::VectorXd* value)
{
return registerValueImpl(prefix, ValuePtr(value), {});
}
and
inline ValuePtr::ValuePtr(const Eigen::VectorXd* vect)
: v_ptr_(vect)
, type_(GetBasicType<double>()) // element type
, type_index_(typeid(Eigen::VectorXd)) // identifies the "container type"
, memory_size_(sizeof(double)) // element size (consistent with containers)
, is_vector_(true)
{
serialize_impl_ = [vect](SerializeMe::SpanBytes& buffer) -> void {
const uint32_t n = static_cast<uint32_t>(vect->size());
SerializeMe::SerializeIntoBuffer(buffer, n);
// contiguous block of doubles
const size_t bytes = static_cast<size_t>(n) * sizeof(double);
if(bytes > 0)
{
std::memcpy(buffer.data(), vect->data(), bytes);
buffer.trimFront(bytes);
}
};
get_size_impl_ = [vect]() -> size_t {
return sizeof(uint32_t) + static_cast<size_t>(vect->size()) * sizeof(double);
};
}
There may be some caveats that I’m not aware of. In any case, I’m open to discussion and happy to create a PR if you think this would be useful.
Regarding Eigen compatibility in general, we could also add a CMake option to enable or disable building with Eigen support.
Let me know what you think.
Cheers
Hello team,
First of all, thank you for this great tool and for making it open source!
I have a simple question: have you considered introducing support for logging Eigen::VectorXd?
In my own fork, I implemented this in a very straightforward way:
and
There may be some caveats that I’m not aware of. In any case, I’m open to discussion and happy to create a PR if you think this would be useful.
Regarding Eigen compatibility in general, we could also add a CMake option to enable or disable building with Eigen support.
Let me know what you think.
Cheers