Skip to content

Commit

Permalink
hubero_interfaces - NavigationBase: velocity transformations supp…
Browse files Browse the repository at this point in the history
…ort holonomic actors [#31]
  • Loading branch information
rayvburn committed Oct 3, 2023
1 parent f4c7555 commit 2871d86
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions hubero_interfaces/include/hubero_interfaces/navigation_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,29 @@ class NavigationBase {
* @brief Transforms local velocity (typically received as velocity command) to a global coordinate system
*/
static Vector3 convertCommandToGlobalCs(const double& yaw_actor, const Vector3& cmd_vel_local) {
// slide 38 at https://www.cs.princeton.edu/courses/archive/fall11/cos495/COS495-Lecture3-RobotMotion.pdf
// Ref: 19-local-to-global-matrix-form at
// https://automaticaddison.com/how-to-describe-the-rotation-of-a-robot-in-2d/
ignition::math::Matrix3d r(
cos(yaw_actor), 0.0, 0.0,
sin(yaw_actor), 0.0, 0.0,
0.0, 0.0, 1.0
+std::cos(yaw_actor), -std::sin(yaw_actor), +0.0,
+std::sin(yaw_actor), +std::cos(yaw_actor), +0.0,
+0.0, +0.0, +1.0
);
return r * cmd_vel_local;
}

/**
* @brief Transforms a global velocity to a local/base coordinate system
*/
static Vector3 convertCommandToLocalCs(const double& yaw_actor, const Vector3& vel_global) {
// Ref: last equation in https://automaticaddison.com/how-to-describe-the-rotation-of-a-robot-in-2d/
ignition::math::Matrix3d r(
+std::cos(yaw_actor), +std::sin(yaw_actor), +0.0,
-std::sin(yaw_actor), +std::cos(yaw_actor), +0.0,
+0.0, +0.0, +1.0
);
return r * vel_global;
}

protected:
/// @brief Stores initialization indicator flag
bool initialized_;
Expand Down

0 comments on commit 2871d86

Please sign in to comment.