-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add inverse for CartesianPose and define operators explicitely #158
Changes from all commits
a016f7e
d3e31dc
a5d16fb
d75c356
bc1d463
da46390
8cca183
97bd5f6
b8822f4
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 |
---|---|---|
|
@@ -7,9 +7,11 @@ | |
|
||
#include "state_representation/space/cartesian/CartesianPose.hpp" | ||
#include "state_representation/space/cartesian/CartesianState.hpp" | ||
#include "state_representation/space/cartesian/CartesianWrench.hpp" | ||
|
||
namespace state_representation { | ||
class CartesianPose; | ||
class CartesianWrench; | ||
|
||
/** | ||
* @class CartesianTwist | ||
|
@@ -132,7 +134,28 @@ class CartesianTwist : public CartesianState { | |
* @param twist CartesianTwist to multiply with | ||
* @return the current CartesianTwist multiplied by the CartesianTwist given in argument | ||
*/ | ||
CartesianTwist operator*(const CartesianTwist& twist) const; | ||
[[deprecated]] CartesianTwist operator*(const CartesianTwist& twist) const; | ||
|
||
/** | ||
* @brief Overload the * operator | ||
* @param state CartesianState to multiply with | ||
* @return the current CartesianTwist multiplied by the CartesianState given in argument | ||
*/ | ||
[[deprecated]] CartesianState operator*(const CartesianState& state) const; | ||
|
||
/** | ||
* @brief Overload the * operator | ||
* @param state CartesianPose to multiply with | ||
* @return the current CartesianTwist multiplied by the CartesianPose given in argument | ||
*/ | ||
[[deprecated]] CartesianPose operator*(const CartesianPose& 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. why do you need to deprecate this one? It was actually never implemented explicitly before. I think you can just deprecate the one with state and leave off the other ones otherwise you introduce also some forward declaration for wrench that is not needed 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. ok I think I understand that you need those to mark them as removed, as you don't want to deprecate the 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. Yes indeed, thats what you also said, if we explicitly implement one, we need to do all of them :) |
||
|
||
/** | ||
* @brief Overload the * operator | ||
* @param state CartesianWrench to multiply with | ||
* @return the current CartesianTwist multiplied by the CartesianWrench given in argument | ||
*/ | ||
[[deprecated]] CartesianWrench operator*(const CartesianWrench& wrench) 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 as above |
||
|
||
/** | ||
* @brief Overload the += operator | ||
|
@@ -228,6 +251,12 @@ class CartesianTwist : public CartesianState { | |
*/ | ||
Eigen::VectorXd data() const; | ||
|
||
/** | ||
* @brief Compute the inverse of the current CartesianTwist | ||
* @return the inverse corresponding to b_S_f (assuming this is f_S_b) | ||
*/ | ||
CartesianTwist inverse() const; | ||
|
||
/** | ||
* @brief Compute the norms of the state variable specified by the input type (default is full twist) | ||
* @param state_variable_type the type of state variable to compute the norms on | ||
|
@@ -250,6 +279,13 @@ class CartesianTwist : public CartesianState { | |
*/ | ||
friend std::ostream& operator<<(std::ostream& os, const CartesianTwist& twist); | ||
|
||
/** | ||
* @brief Overload the * operator with a CartesianState | ||
* @param state the state to multiply with | ||
* @return the CartesianTwist provided multiplied by the state | ||
*/ | ||
friend CartesianTwist operator*(const CartesianState& state, const CartesianTwist& twist); | ||
|
||
/** | ||
* @brief Overload the * operator with a scalar | ||
* @param lambda the scalar to multiply with | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,12 @@ | |
#pragma once | ||
|
||
#include "state_representation/space/cartesian/CartesianState.hpp" | ||
#include "state_representation/space/cartesian/CartesianPose.hpp" | ||
#include "state_representation/space/cartesian/CartesianTwist.hpp" | ||
|
||
namespace state_representation { | ||
class CartesianPose; | ||
class CartesianTwist; | ||
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 as for the twist so I don't think this is needed |
||
/** | ||
* @class CartesianWrench | ||
* @brief Class to define wrench in cartesian space as 3D force and torque vectors | ||
|
@@ -124,7 +128,28 @@ class CartesianWrench : public CartesianState { | |
* @param wrench CartesianWrench to multiply with | ||
* @return the current CartesianWrench multiplied by the CartesianWrench given in argument | ||
*/ | ||
CartesianWrench operator*(const CartesianWrench& wrench) const; | ||
[[deprecated]] CartesianWrench operator*(const CartesianWrench& wrench) const; | ||
|
||
/** | ||
* @brief Overload the * operator | ||
* @param state CartesianState to multiply with | ||
* @return the current CartesianWrench multiplied by the CartesianState given in argument | ||
*/ | ||
[[deprecated]] CartesianState operator*(const CartesianState& state) const; | ||
|
||
/** | ||
* @brief Overload the * operator | ||
* @param state CartesianPose to multiply with | ||
* @return the current CartesianWrench multiplied by the CartesianPose given in argument | ||
*/ | ||
[[deprecated]] CartesianPose operator*(const CartesianPose& pose) const; | ||
|
||
/** | ||
* @brief Overload the * operator | ||
* @param state CartesianWrench to multiply with | ||
* @return the current CartesianWrench multiplied by the CartesianTwist given in argument | ||
*/ | ||
[[deprecated]] CartesianTwist operator*(const CartesianTwist& twist) const; | ||
|
||
/** | ||
* @brief Overload the += operator | ||
|
@@ -206,6 +231,12 @@ class CartesianWrench : public CartesianState { | |
*/ | ||
Eigen::VectorXd data() const; | ||
|
||
/** | ||
* @brief Compute the inverse of the current CartesianWrench | ||
* @return the inverse corresponding to b_S_f (assuming this is f_S_b) | ||
*/ | ||
CartesianWrench inverse() const; | ||
|
||
/** | ||
* @brief Compute the norms of the state variable specified by the input type (default is full wrench) | ||
* @param state_variable_type the type of state variable to compute the norms on | ||
|
@@ -228,10 +259,17 @@ class CartesianWrench : public CartesianState { | |
*/ | ||
friend std::ostream& operator<<(std::ostream& os, const CartesianWrench& wrench); | ||
|
||
/** | ||
* @brief Overload the * operator with a CartesianState | ||
* @param state the state to multiply with | ||
* @return the CartesianWrench provided multiplied by the state | ||
*/ | ||
friend CartesianWrench operator*(const CartesianState& state, const CartesianWrench& wrench); | ||
|
||
/** | ||
* @brief Overload the * operator with a scalar | ||
* @param lambda the scalar to multiply with | ||
* @return the CartesianWrench provided multiply by lambda | ||
* @return the CartesianWrench provided multiplied by lambda | ||
*/ | ||
friend CartesianWrench operator*(double lambda, const CartesianWrench& wrench); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,18 @@ CartesianPose CartesianPose::operator*(const CartesianPose& pose) const { | |
return this->CartesianState::operator*(pose); | ||
} | ||
|
||
CartesianState CartesianPose::operator*(const CartesianState& state) const { | ||
return this->CartesianState::operator*(state); | ||
} | ||
|
||
CartesianTwist CartesianPose::operator*(const CartesianTwist& twist) const { | ||
return this->CartesianState::operator*(twist); | ||
} | ||
|
||
CartesianWrench CartesianPose::operator*(const CartesianWrench& wrench) const { | ||
return this->CartesianState::operator*(wrench); | ||
} | ||
|
||
CartesianPose& CartesianPose::operator*=(double lambda) { | ||
this->CartesianState::operator*=(lambda); | ||
return (*this); | ||
|
@@ -123,6 +135,10 @@ Eigen::VectorXd CartesianPose::data() const { | |
return this->get_pose(); | ||
} | ||
|
||
CartesianPose CartesianPose::inverse() 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. why not use the CartesianState::inverse() and then downcast the return back to a pose? it would prevent some code duplication, and I would say the few extra linear operations are not hugely costly. It's also how the other operators are working anyway |
||
return this->CartesianState::inverse(); | ||
} | ||
|
||
std::ostream& operator<<(std::ostream& os, const CartesianPose& pose) { | ||
if (pose.is_empty()) { | ||
os << "Empty CartesianPose"; | ||
|
@@ -144,6 +160,10 @@ std::ostream& operator<<(std::ostream& os, const CartesianPose& pose) { | |
return os; | ||
} | ||
|
||
CartesianPose operator*(const CartesianState& state, const CartesianPose& pose) { | ||
return state.operator*(pose); | ||
} | ||
|
||
CartesianPose operator*(double lambda, const CartesianPose& pose) { | ||
return pose * lambda; | ||
} | ||
|
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.
The
CartesianState inverse() const
is not deleted in this header, which means this new declaration is hiding the base method. It would be safer to delete the base inverse method in this header as well.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.
If I add the line
to the CartesianPose header, I cannot build state_representation anymore
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.
Ah ok, my bad. Then instead you should mark the CartesianState::inverse as virtual and explicitly override the derived version here.
This should work because the return type of the derived function is a co-variant (the derived class) of the base function (the base class).
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.
No, that doesn't work unfortunately... Even though it should...
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.
Actually, there are other functions like that (the
copy
one) that are not defined virtual or deleted but that hide the CartesianState function