-
Notifications
You must be signed in to change notification settings - Fork 30
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
fix geodesic for SO(2) #408
Changes from 16 commits
8d6485d
83d885a
eaae064
d56674f
75b8ee3
4e80b34
bc9eaae
94971e5
2aaaf18
413e4c6
c065eaa
0ddd98b
b8106f7
45bd5a3
e49ce19
9329c6f
c75fbe8
8de5b8f
bc60aa3
847f1a3
e41999f
17d044e
fa5d475
91556bf
3daa903
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 |
---|---|---|
|
@@ -18,44 +18,7 @@ class SO2 : virtual public StateSpace | |
{ | ||
public: | ||
/// State in SO(2), a planar rotation. | ||
class State : public StateSpace::State | ||
{ | ||
public: | ||
/// Constructs the identity element. | ||
State(); | ||
|
||
~State() = default; | ||
|
||
/// Constructs a state from a rotation angle. | ||
/// | ||
/// \param _angle rotation angle | ||
explicit State(double _angle); | ||
|
||
/// Gets state as a rotation angle. | ||
/// | ||
/// \return rotation angle | ||
double getAngle() const; | ||
|
||
/// Sets state to a rotation angle. | ||
/// | ||
/// \param _angle rotation angle | ||
void setAngle(double _angle); | ||
|
||
/// Gets state as an Eigen transformation. | ||
/// | ||
/// \return Eigen transformation | ||
Eigen::Rotation2Dd getRotation() const; | ||
|
||
/// Sets state it an Eigen transformation. | ||
/// | ||
/// \param _rotation Eigen transformation | ||
void setRotation(const Eigen::Rotation2Dd& _rotation); | ||
|
||
private: | ||
double mAngle; | ||
|
||
friend class SO2; | ||
}; | ||
class State; | ||
|
||
using StateHandle = SO2StateHandle<State>; | ||
using StateHandleConst = SO2StateHandle<const State>; | ||
|
@@ -71,78 +34,108 @@ class SO2 : virtual public StateSpace | |
/// \return new \c ScopedState | ||
ScopedState createState() const; | ||
|
||
/// Gets state as a rotation angle. | ||
/// Returns state as a rotation angle. | ||
/// | ||
/// \param _state input state | ||
/// \return rotation angle | ||
double getAngle(const State* _state) const; | ||
/// \param[in] state State. | ||
double toAngle(const State* state) const; | ||
|
||
/// Sets state to a rotation angle. | ||
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. Nit: Let's update the description something like "Sets state from a rotation angle.". |
||
/// | ||
/// \param _state input state | ||
/// \param _angle rotation angle | ||
void setAngle(State* _state, double _angle) const; | ||
/// \param[in] angle Rotation angle. | ||
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. Can we specify the range for |
||
/// \param[out] state State corresponding to angle | ||
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. Nit: Let's order the argument docstring as the corresponding arguments are ordered. |
||
void fromAngle(State* state, double angle) const; | ||
|
||
/// Gets state as an Eigen transformation. | ||
/// Returns state as an Eigen transformation. | ||
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. Nit: |
||
/// | ||
/// \param _state input state | ||
/// \return Eigen transformation | ||
Eigen::Rotation2Dd getRotation(const State* _state) const; | ||
/// \param[in] state State | ||
Eigen::Rotation2Dd toRotation(const State* state) const; | ||
|
||
/// Sets state it an Eigen transformation. | ||
/// | ||
/// \param _state input state | ||
/// \param _rotation Eigen transformation | ||
void setRotation(State* _state, const Eigen::Rotation2Dd& _rotation) const; | ||
/// \param[in] rotation Eigen transformation. | ||
/// \param[out] state State corresponding to rotation. | ||
void fromRotation(State* state, const Eigen::Rotation2Dd& rotation) 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. Let's order the docstring as the argument listed. |
||
|
||
// Documentation inherited. | ||
std::size_t getStateSizeInBytes() const override; | ||
|
||
// Documentation inherited. | ||
StateSpace::State* allocateStateInBuffer(void* _buffer) const override; | ||
StateSpace::State* allocateStateInBuffer(void* buffer) const override; | ||
|
||
// Documentation inherited. | ||
void freeStateInBuffer(StateSpace::State* _state) const override; | ||
void freeStateInBuffer(StateSpace::State* state) const override; | ||
|
||
// Documentation inherited. | ||
void compose( | ||
const StateSpace::State* _state1, | ||
const StateSpace::State* _state2, | ||
StateSpace::State* _out) const override; | ||
const StateSpace::State* state1, | ||
const StateSpace::State* state2, | ||
StateSpace::State* out) const override; | ||
|
||
// Documentation inherited. | ||
void getIdentity(StateSpace::State* _out) const override; | ||
void getIdentity(StateSpace::State* out) const override; | ||
|
||
// Documentation inherited. | ||
void getInverse( | ||
const StateSpace::State* _in, StateSpace::State* _out) const override; | ||
const StateSpace::State* in, StateSpace::State* out) const override; | ||
|
||
// Documentation inherited. | ||
std::size_t getDimension() const override; | ||
|
||
// Documentation inherited. | ||
void copyState( | ||
const StateSpace::State* _source, | ||
StateSpace::State* _destination) const override; | ||
const StateSpace::State* source, | ||
StateSpace::State* destination) const override; | ||
|
||
/// Exponential mapping of Lie algebra element to a Lie group element. The | ||
/// tangent space is parameterized a rotation angle. | ||
/// | ||
/// \param _tangent element of the tangent space | ||
/// \param[out] _out corresponding element of the Lie group | ||
/// \param[in] tangent Element of the tangent space | ||
/// \param[out] out Corresponding element of the Lie group | ||
void expMap( | ||
const Eigen::VectorXd& _tangent, StateSpace::State* _out) const override; | ||
const Eigen::VectorXd& tangent, StateSpace::State* out) const override; | ||
|
||
/// Log mapping of Lie group element to a Lie algebra element. The tangent | ||
/// space is parameterized as a rotation angle. | ||
/// | ||
/// \param _in element of this Lie group | ||
/// \param[out] _tangent corresponding element of the tangent space | ||
/// \param[in] in Element of this Lie group | ||
/// \param[out] tangent Corresponding element of the tangent space | ||
void logMap( | ||
const StateSpace::State* _in, Eigen::VectorXd& _tangent) const override; | ||
const StateSpace::State* in, Eigen::VectorXd& tangent) const override; | ||
|
||
/// Print the angle represented by the state | ||
void print(const StateSpace::State* _state, std::ostream& _os) const override; | ||
void print(const StateSpace::State* state, std::ostream& os) const override; | ||
}; | ||
|
||
class SO2::State : public StateSpace::State | ||
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. It seems |
||
{ | ||
public: | ||
/// Constructs a state from a rotation angle. | ||
/// | ||
/// \param[in] angle Rotation angle | ||
explicit State(double angle = 0.0); | ||
|
||
~State() = default; | ||
|
||
/// Returns state as a rotation angle. | ||
double toAngle() 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. Nit: Let's inform that the range of the return angle. |
||
|
||
/// Sets state to a rotation angle. | ||
/// | ||
/// \param[in] angle Rotation angle | ||
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, specify the range for |
||
void fromAngle(double angle); | ||
|
||
/// Returns state as an Eigen transformation. | ||
Eigen::Rotation2Dd toRotation() const; | ||
|
||
/// Sets state given an Eigen transformation. | ||
/// | ||
/// \param[in] rotation Eigen transformation | ||
void fromRotation(const Eigen::Rotation2Dd& rotation); | ||
|
||
private: | ||
double mAngle; | ||
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. Nit: Please add docstring. |
||
|
||
friend class SO2; | ||
}; | ||
|
||
} // namespace statespace | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,9 @@ double SO2Angular::distance( | |
const aikido::statespace::StateSpace::State* _state2) const | ||
{ | ||
// Difference between angles | ||
double diff = mStateSpace->getAngle( | ||
double diff = mStateSpace->toAngle( | ||
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. Nit: Are we correcting the variable names in this PR or not? ( 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. I was doing it only in the |
||
static_cast<const statespace::SO2::State*>(_state1)) | ||
- mStateSpace->getAngle( | ||
- mStateSpace->toAngle( | ||
static_cast<const statespace::SO2::State*>(_state2)); | ||
diff = std::fmod(std::fabs(diff), 2.0 * M_PI); | ||
if (diff > M_PI) | ||
|
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.
Nit: Let's describe the return angle is in the range of
(-pi, pi]
.