-
Notifications
You must be signed in to change notification settings - Fork 14
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
This PR adds the class DQ_FreeFlyingRobot() #58
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
(C) Copyright 2023 DQ Robotics Developers | ||
|
||
This file is part of DQ Robotics. | ||
|
||
DQ Robotics is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
DQ Robotics is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with DQ Robotics. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
Contributors: | ||
|
||
1. Bruno Vilhena Adorno ([email protected]) | ||
Responsible for the original implementation in file DQ_FreeFlyingRobot.m | ||
https://github.com/dqrobotics/matlab/pull/66/commits | ||
|
||
2. Juan Jose Quiroz Omana ([email protected]) | ||
Created this file. | ||
*/ | ||
|
||
#pragma once | ||
#include <dqrobotics/robot_modeling/DQ_Kinematics.h> | ||
|
||
namespace DQ_robotics | ||
{ | ||
|
||
class DQ_FreeFlyingRobot: public DQ_Kinematics | ||
{ | ||
protected: | ||
|
||
void _invalid_signature(const std::string& msg) const; | ||
|
||
public: | ||
DQ_FreeFlyingRobot(); | ||
|
||
//Virtual method overloads (DQ_Kinematics) | ||
virtual DQ fkm (const VectorXd&) const override; | ||
virtual DQ fkm (const VectorXd&, const int&) const override; | ||
virtual MatrixXd pose_jacobian(const VectorXd&, const int&) const override; | ||
virtual MatrixXd pose_jacobian_derivative(const VectorXd& q, | ||
const VectorXd& q_dot, | ||
const int& to_ith_link) const override; | ||
|
||
|
||
|
||
|
||
DQ fkm(const DQ& pose) const; | ||
MatrixXd pose_jacobian(const DQ& pose) const; | ||
MatrixXd pose_jacobian_derivative(const DQ& pose_derivative) const; | ||
|
||
}; | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/** | ||
(C) Copyright 2023 DQ Robotics Developers | ||
|
||
This file is part of DQ Robotics. | ||
|
||
DQ Robotics is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
DQ Robotics is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
|
||
You should have received a copy of the GNU Lesser General Public License | ||
along with DQ Robotics. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
Contributors: | ||
|
||
1. Bruno Vilhena Adorno ([email protected]) | ||
Responsible for the original implementation in file DQ_FreeFlyingRobot.m | ||
https://github.com/dqrobotics/matlab/pull/66/commits | ||
|
||
2. Juan Jose Quiroz Omana ([email protected]) | ||
Created this file. | ||
*/ | ||
|
||
#include <dqrobotics/robot_modeling/DQ_FreeFlyingRobot.h> | ||
|
||
namespace DQ_robotics | ||
{ | ||
|
||
/** | ||
* @brief Constructor of the DQ_FreeFlyingRobot() class. | ||
*/ | ||
DQ_FreeFlyingRobot::DQ_FreeFlyingRobot() | ||
{ | ||
dim_configuration_space_ = 8; | ||
} | ||
|
||
|
||
/** | ||
* @brief Internal method to handle invalid signatures. This method | ||
* throws an exception with the following message: | ||
* | ||
* "This signature is not supported in this class. " | ||
* msg + ", where pose is a unit dual quaternion, which " | ||
* "represents the free-flying robot configuration. " | ||
* | ||
* @param msg Message to provide the valid signature. Ex: | ||
* | ||
* auto msg = std::string("Use fkm(pose)"); | ||
* _invalid_signature(msg); | ||
*/ | ||
void DQ_FreeFlyingRobot::_invalid_signature(const std::string &msg) const | ||
{ | ||
throw std::runtime_error(std::string("This signature is not supported in this class. ") + | ||
msg + std::string(", where pose is a unit dual quaternion, which ")+ | ||
std::string("represents the free-flying robot configuration. ")); | ||
} | ||
|
||
|
||
DQ DQ_FreeFlyingRobot::fkm(const VectorXd&) const | ||
{ | ||
_invalid_signature(std::string("Use fkm(pose)")); | ||
return DQ(1); | ||
} | ||
|
||
|
||
DQ DQ_FreeFlyingRobot::fkm(const VectorXd&, const int&) const | ||
{ | ||
_invalid_signature(std::string("Use fkm(pose)")); | ||
return DQ(1); | ||
} | ||
|
||
MatrixXd DQ_FreeFlyingRobot::pose_jacobian(const VectorXd&, const int&) const | ||
{ | ||
_invalid_signature(std::string("Use pose_jacobian(pose)")); | ||
return Eigen::MatrixXd::Zero(2,2); | ||
} | ||
|
||
MatrixXd DQ_FreeFlyingRobot::pose_jacobian_derivative(const VectorXd&, const VectorXd&, const int&) const | ||
{ | ||
_invalid_signature(std::string("Use pose_jacobian_derivative(pose_derivative). " | ||
"pose_derivative denotes the time derivative of pose")); | ||
return Eigen::MatrixXd::Zero(2,2); | ||
} | ||
|
||
|
||
/** | ||
* @brief This method returns the free-flying robot pose. | ||
* @param pose The unit dual quaternion that represents | ||
* the free-flying robot configuration. | ||
* @return pose The free-flying robot pose. | ||
*/ | ||
DQ DQ_FreeFlyingRobot::fkm(const DQ& pose) const | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment for |
||
{ | ||
return pose; | ||
} | ||
|
||
/** | ||
* @brief This method returns the pose Jacobian J that satisfies | ||
* | ||
* x_dot = J*twist, | ||
* | ||
* where x_dot is the time derivative of the unit dual quaternion | ||
* that represents the free-flying robot pose, and twist = vec8(csi), | ||
* where csi satisfies the dual quaternion propagation equation | ||
* xdot = (1/2)*csi*x. | ||
* | ||
* @param pose The unit dual quaternion that represents | ||
* the free-flying robot configuration. | ||
* @return The desired pose Jacobian. | ||
*/ | ||
MatrixXd DQ_FreeFlyingRobot::pose_jacobian(const DQ &pose) const | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for the comment below. However, this method is in CPP currently NOT compatible with the other derived classes. Would it instead be expecting a
|
||
{ | ||
return haminus8(0.5*pose); | ||
} | ||
|
||
|
||
/** | ||
* @brief This method returns the pose Jacobian derivative of J, where | ||
* J is the pose Jacobian that satisfies | ||
* | ||
* x_dot = J*twist, | ||
* | ||
* where x_dot is the time derivative of the unit dual quaternion | ||
* that represents the free-flying robot pose, and twist = vec8(csi), | ||
* where csi satisfies the dual quaternion propagation equation | ||
* xdot = (1/2)*csi*x. | ||
* | ||
* @param pose The unit dual quaternion that represents | ||
* the free-flying robot configuration. | ||
* @param pose_derivative The time derivative of the robot configuration. | ||
* @return The desired pose Jacobian derivative. | ||
*/ | ||
MatrixXd DQ_FreeFlyingRobot::pose_jacobian_derivative(const DQ &pose_derivative) const | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This it not yet available in MATLAB? It needs to show up there first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mmmarinho No, it's not. Like several implementations related to Jacobian derivatives that are currently implemented only in the C++ version, I added it and proposed a numerical test in ` in this PR. However, I understand your point. I'm going to propose the pose_jacobian_derivative method in Matlab first, as suggested. =) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @juanjqo and @mmmarinho, This is undesirable. Why are those implementations appearing in the C++ version and not in MATLAB? This only causes confusion and potential for code divergence in the long run. All the best, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @bvadorno, I agree. Several methods were added to the C++ (master branch) version in the last months for internal developments. Some of them are related to the Jacobian derivatives. This indeed created a divergence between both versions of the DQ Robotics. However, this issue was discussed internally in our meetings, and we defined several tasks to fix it. Such tasks are summarized in the Best regards, Juancho There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
{ | ||
return haminus8(0.5*pose_derivative); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add that documentation @bvadorno mentioned in MATLAB, as it might be useful here too.
It can be on the description of the method, after the
@brief
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmmarinho thank you for your feedback. I'm going to implement the required modifications once the @dqrobotics/developers team reaches an agreement or consensus about the DQ_FreeFlyingRobot() class.