Skip to content

This PR refactors DQ's default constructor #71

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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ffasilva
Copy link
Member

Hi @dqrobotics/developers,

This PR removes DQ's obsolete constructor with default double parameters and adds a new default constructor that takes no arguments, as discussed in #68. The implementation follows Murilo's clever workaround to deprecate the construction, namely:

DQ() noexcept;

[[deprecated("Consider explicitly initializing dual quaternions using the "
             "operators DQ::i_, DQ::j_, DQ::k_, DQ::E_. Alternatively, "
             "use the constructor DQ::DQ(const VectorXd& v) instead.")]]
explicit DQ(const double& q0,
            const double& q1=0.0,
            const double& q2=0.0,
            const double& q3=0.0,
            const double& q4=0.0,
            const double& q5=0.0,
            const double& q6=0.0,
            const double& q7=0.0) noexcept;

Additionally, this PR refactored the internal classes to comply with the new constructor and avoid deprecation warning spam from the library, e.g.,

DQ_MobileBase::DQ_MobileBase()
{
    // -- frame_displacement_ = DQ(1);
    frame_displacement_ = DQ((Matrix<double,8,1>() << 1,0,0,0,0,0,0,0).finished());
}

Usage

#include <dqrobotics/DQ.h>

DQ_robotics::DQ x;
cout << "x = " << x << endl;
x = 0

Kind regards,
Frederico

@mmmarinho mmmarinho self-assigned this May 19, 2025
@mmmarinho
Copy link
Member

Hi @ffasilva,

This is nice. I think this mostly fixes the problem, but with this, the cpp version of the library would become the most verbose way possible of writing scalars (as if cpp isn't verbose enough by itself). Using 1 as an example, we previously could write

DQ one(1); 

would become, as you correctly noticed,

auto one = DQ((Matrix<double,8,1>() << 1,0,0,0,0,0,0,0).finished());

Do you think we could work around that with a std::initializer_list constructor? For instance, so that we could do

DQ one({1}); //1
DQ p({1,2,3}); //i_ + 2*j_ + 3*k_
DQ r({0,1,0,0}); //j_

This might require some combinations of creating this new initializer list and further modifying the previous constructor in the way I suggested in #68.

@ffasilva
Copy link
Member Author

Hi @mmmarinho,

I'm also not entirely happy with how verbose it is to initialize scalars now. Thanks for the suggestion! I'm marking this PR as a draft while I check it.

Kind regards,
Frederico

@ffasilva ffasilva marked this pull request as draft May 19, 2025 14:01
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.

2 participants