merge control stack from easter testing into main#706
Conversation
…ht be a bit wonky
…ht be a bit wonky
…backstepping controller, tuned the adaptive dp backstepping controller a bit for nautilus not yet finished. Added roll back into the controllable parameters, it looks good for now.
…nu/vortex-auv into feat/solver-and-drone-sim-tests
… Vortex wiki and link it in README. Began changing variable names and adding neccesary functionality in vortex-utils
vortexuser
left a comment
There was a problem hiding this comment.
first round of reviews
...t_backs_controller_quat/include/dp_adapt_backs_controller_quat/dp_adapt_backs_controller.hpp
Show resolved
Hide resolved
...t_backs_controller_quat/include/dp_adapt_backs_controller_quat/dp_adapt_backs_controller.hpp
Outdated
Show resolved
Hide resolved
...s_controller_quat/include/dp_adapt_backs_controller_quat/dp_adapt_backs_controller_utils.hpp
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/include/dp_adapt_backs_controller_quat/typedefs.hpp
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller.cpp
Outdated
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_utils.cpp
Outdated
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_utils.cpp
Outdated
Show resolved
Hide resolved
…o reduce scope. Got rid of magic numbers and made everything initializable and easy to configure. Fixed readme.
…ing_controler_to_quaternion
…verythin the control stack depends on from easter testing in one commit
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_ros.cpp
Outdated
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_ros.cpp
Outdated
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_ros.cpp
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_ros.cpp
Outdated
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_ros.cpp
Outdated
Show resolved
Hide resolved
control/dp_adapt_backs_controller_quat/src/dp_adapt_backs_controller_ros.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
is this controller going to be used? If so, maybe clean it up a bit. A lot of unused includes, outdated types/not using common types from vortex utils, redefinitions of existing utils functions
There was a problem hiding this comment.
yes pid controllah was pretty 🔥
| void print_eta(const types::Eta& eta) { | ||
| spdlog::info("Eta values:"); | ||
| auto pos = eta.pos_vector(); | ||
| auto ori = eta.ori_quaternion(); | ||
| spdlog::info("Position - North: {}, East: {}, Down: {}", pos[0], pos[1], | ||
| pos[2]); | ||
| spdlog::info("Orientation - w: {}, x: {}, y: {}, z: {}", ori.w(), ori.x(), | ||
| ori.y(), ori.z()); | ||
| } | ||
|
|
||
| void print_nu(const types::Nu& nu) { | ||
| spdlog::info("Nu values:"); | ||
| auto v = nu.to_vector(); | ||
| spdlog::info("Linear Speed - u: {}, v: {}, w: {}", v(0), v(1), v(2)); | ||
| spdlog::info("Angular Speed - p: {}, q: {}, r: {}", v(3), v(4), v(5)); | ||
| } | ||
|
|
||
| void print_vect_6d(const types::Vector6d& vec) { | ||
| spdlog::info("Vector6d values:"); | ||
| for (int i = 0; i < 6; ++i) { | ||
| spdlog::info("Element[{}]: {}", i, vec[i]); | ||
| } | ||
| } | ||
|
|
||
| void print_J_transformation(const types::J_transformation& J) { | ||
| spdlog::info("J_transformation:"); | ||
|
|
||
| spdlog::info("R (3x3) elements:"); | ||
| for (int i = 0; i < J.R.rows(); ++i) { | ||
| for (int j = 0; j < J.R.cols(); ++j) { | ||
| spdlog::info("R[{},{}] = {}", i, j, J.R(i, j)); | ||
| } | ||
| } | ||
|
|
||
| spdlog::info("T (4x3) elements:"); | ||
| for (int i = 0; i < J.T.rows(); ++i) { | ||
| for (int j = 0; j < J.T.cols(); ++j) { | ||
| spdlog::info("T[{},{}] = {}", i, j, J.T(i, j)); | ||
| } | ||
| } | ||
|
|
||
| spdlog::info("Combined Matrix (7x6) elements:"); | ||
| auto M = J.as_matrix(); | ||
| for (int i = 0; i < M.rows(); ++i) { | ||
| for (int j = 0; j < M.cols(); ++j) { | ||
| spdlog::info("M[{},{}] = {}", i, j, M(i, j)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void print_Jinv_transformation(const types::Matrix6x7d& J_inv) { | ||
| spdlog::info("J_pseudo_inverse (6x7):"); | ||
| for (int i = 0; i < J_inv.rows(); ++i) { | ||
| std::string row; | ||
| row.reserve(128); | ||
| row += "["; | ||
| for (int j = 0; j < J_inv.cols(); ++j) { | ||
| row += std::to_string(J_inv(i, j)); | ||
| if (j < J_inv.cols() - 1) | ||
| row += ", "; | ||
| } | ||
| row += "]"; | ||
| spdlog::info("{}", row); | ||
| } | ||
| } |
There was a problem hiding this comment.
Why are these still here? We added those to debug the weird behavior last year, not to be used on main
| types::Eta error = error_eta(eta, eta_d); // calculate eta error | ||
|
|
There was a problem hiding this comment.
This comment doesnt add very much
There was a problem hiding this comment.
Goes for the rest of the comments in this file too
| types::Vector6d error_6; | ||
| error_6 << error.x, error.y, error.z, error.qx, error.qy, error.qz; |
There was a problem hiding this comment.
Minor, but having the 6 in the variable name doesnt really do any good, especially when there no longer is references to the 7 sized vector anymore. Also, would probably benefit from adding updated utility functions for the 6 dof quat maths
| types::Eta eta_convert_from_ros_to_eigen( | ||
| const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg) { | ||
| const geometry_msgs::msg::PoseWithCovariance& msg) { | ||
| types::Eta eta; | ||
| eta.pos << msg->pose.pose.position.x, msg->pose.pose.position.y, | ||
| msg->pose.pose.position.z; | ||
| eta.ori.w() = msg->pose.pose.orientation.w; | ||
| eta.ori.x() = msg->pose.pose.orientation.x; | ||
| eta.ori.y() = msg->pose.pose.orientation.y; | ||
| eta.ori.z() = msg->pose.pose.orientation.z; | ||
| eta.x = msg.pose.position.x; | ||
| eta.y = msg.pose.position.y; | ||
| eta.z = msg.pose.position.z; | ||
| eta.qw = msg.pose.orientation.w; | ||
| eta.qx = msg.pose.orientation.x; | ||
| eta.qy = msg.pose.orientation.y; | ||
| eta.qz = msg.pose.orientation.z; | ||
|
|
||
| return eta; | ||
| } | ||
|
|
||
| types::Nu nu_convert_from_ros_to_eigen( | ||
| const geometry_msgs::msg::TwistWithCovarianceStamped::SharedPtr msg) { | ||
| const geometry_msgs::msg::TwistWithCovariance& msg) { | ||
| types::Nu nu; | ||
| nu.linear_speed << msg->twist.twist.linear.x, msg->twist.twist.linear.y, | ||
| msg->twist.twist.linear.z; | ||
| nu.angular_speed << msg->twist.twist.angular.x, msg->twist.twist.angular.y, | ||
| msg->twist.twist.angular.z; | ||
| nu.u = msg.twist.linear.x; | ||
| nu.v = msg.twist.linear.y; | ||
| nu.w = msg.twist.linear.z; | ||
| nu.p = msg.twist.angular.x; | ||
| nu.q = msg.twist.angular.y; | ||
| nu.r = msg.twist.angular.z; | ||
|
|
||
| return nu; | ||
| } |
| callback_handle_ = this->add_on_set_parameters_callback(std::bind( | ||
| &PIDControllerNode::parametersCallback, this, std::placeholders::_1)); |
| this->declare_parameter<double>("Kp_x", 1.0); | ||
| this->declare_parameter<double>("Kp_y", 1.0); | ||
| this->declare_parameter<double>("Kp_z", 1.0); | ||
| this->declare_parameter<double>("Kp_roll", 1.0); | ||
| this->declare_parameter<double>("Kp_pitch", 1.0); | ||
| this->declare_parameter<double>("Kp_yaw", 1.0); | ||
| this->declare_parameter<double>("Ki_x", 0.1); | ||
| this->declare_parameter<double>("Ki_y", 0.1); | ||
| this->declare_parameter<double>("Ki_z", 0.1); | ||
| this->declare_parameter<double>("Ki_roll", 0.1); | ||
| this->declare_parameter<double>("Ki_pitch", 0.1); | ||
| this->declare_parameter<double>("Ki_yaw", 0.1); | ||
| this->declare_parameter<double>("Kd_x", 0.1); | ||
| this->declare_parameter<double>("Kd_y", 0.1); | ||
| this->declare_parameter<double>("Kd_z", 0.1); | ||
| this->declare_parameter<double>("Kd_roll", 0.1); | ||
| this->declare_parameter<double>("Kd_pitch", 0.1); | ||
| this->declare_parameter<double>("Kd_yaw", 0.1); |
There was a problem hiding this comment.
Would personally drop default values
| std::vector<double> Kp_vec = { | ||
| this->get_parameter("Kp_x").as_double(), | ||
| this->get_parameter("Kp_y").as_double(), | ||
| this->get_parameter("Kp_z").as_double(), | ||
| this->get_parameter("Kp_roll").as_double(), | ||
| this->get_parameter("Kp_pitch").as_double(), | ||
| this->get_parameter("Kp_yaw").as_double(), | ||
| }; | ||
| std::vector<double> Ki_vec = { | ||
| this->get_parameter("Ki_x").as_double(), | ||
| this->get_parameter("Ki_y").as_double(), | ||
| this->get_parameter("Ki_z").as_double(), | ||
| this->get_parameter("Ki_roll").as_double(), | ||
| this->get_parameter("Ki_pitch").as_double(), | ||
| this->get_parameter("Ki_yaw").as_double(), | ||
| }; | ||
| std::vector<double> Kd_vec = { | ||
| this->get_parameter("Kd_x").as_double(), | ||
| this->get_parameter("Kd_y").as_double(), | ||
| this->get_parameter("Kd_z").as_double(), | ||
| this->get_parameter("Kd_roll").as_double(), | ||
| this->get_parameter("Kd_pitch").as_double(), | ||
| this->get_parameter("Kd_yaw").as_double(), | ||
| }; | ||
|
|
||
| types::Vector6d Kp_vec_eigen(Kp_vec.data()); | ||
| types::Vector6d Ki_vec_eigen(Ki_vec.data()); | ||
| types::Vector6d Kd_vec_eigen(Kd_vec.data()); |
There was a problem hiding this comment.
No reason to go through std::vector here is it?
There was a problem hiding this comment.
Have not loooked at it probably you are right
| /** Enforce positive hemisphere to prevent sign flips in the published | ||
| * reference quaternion that would cause the downstream controller to | ||
| * see large spurious orientation errors. | ||
| */ |
There was a problem hiding this comment.
It makes more sense for the controllers that compare quaternions to be responsible for the sign handling instead of assuming an input convention. But this is still nice for plotting 👍
There was a problem hiding this comment.
I like plots converging :(
There was a problem hiding this comment.
Why are there 3 param files?
There was a problem hiding this comment.
because i need to test that everything works, will change the workflows to use the sim file in the sim tests when my claude usage is back (i dont do devops dont blame me)
| /** | ||
| * @brief Compute the 6D quaternion error state ε̃ = [Δp; ε_q]. | ||
| * | ||
| * The scalar part q̃_w is not returned. The sign of the quaternion error is | ||
| * flipped when q̃_w < 0 to enforce the shortest-path convention. | ||
| * | ||
| * @param eta Actual vehicle pose [x, y, z, qw, qx, qy, qz] | ||
| * @param eta_d Desired vehicle pose [x, y, z, qw, qx, qy, qz] | ||
| * @return Eta struct whose [qx, qy, qz] fields carry ε_q (qw is discarded) | ||
| */ | ||
| types::Eta error_eta(const types::Eta& eta, const types::Eta& eta_d); |
| types::Eta error_eta(const types::Eta& eta, const types::Eta& eta_d) { | ||
| types::Eta eta_error; | ||
|
|
||
| eta_error.pos = eta.pos - eta_d.pos; | ||
| eta_error.ori = eta_d.ori.conjugate() * eta.ori; | ||
|
|
||
| eta_error.ori = eta_error.ori.normalized(); | ||
|
|
||
| return eta_error; | ||
| types::Eta error = eta - eta_d; | ||
| // Enforce shortest path: q and -q represent the same rotation, but only | ||
| // qw >= 0 gives the correct sign for the vector part used as error signal. | ||
| if (error.qw < 0.0) { | ||
| error.qw = -error.qw; | ||
| error.qx = -error.qx; | ||
| error.qy = -error.qy; | ||
| error.qz = -error.qz; | ||
| } | ||
| return error; | ||
| } |
There was a problem hiding this comment.
If we want this to return the 6d error vector we should use the error_quaternion from vortex_utils math.hpp.
There was a problem hiding this comment.
yes, i think i added that after doing this fix during easter
| reference_msg.header.frame_id = "odom" | ||
| # reference_msg.header.frame_id = "odom" | ||
| reference_msg.header.frame_id = "base_link" |
There was a problem hiding this comment.
bro one line changes you could do yourself T-T
There was a problem hiding this comment.
Out of the scope of this review
There was a problem hiding this comment.
Should avoid the RPY representation of pose/current_state so the reference mode does not inherit gimbal lock problems etc..
| eta_error.ori = eta_error.ori.normalized(); | ||
|
|
||
| return eta_error; | ||
| types::Eta error = eta - eta_d; |
There was a problem hiding this comment.
I am also not a fan of the - operator for quaternions types
There was a problem hiding this comment.
By the way wouldn't it be more accurate to use the full quaternion identity for error using the tan^-1 function (in utils) so that errors dont trickle down
There was a problem hiding this comment.
Depends on use case IMO. For the reference filter and controllers the errors should ideally never be large enough that it is a problem. This also avoids the singularity of the tan error
There was a problem hiding this comment.
So for the reference filter it is fine, but if you want to use the tan version for the controllers you are free to do so
…ushed vortex utils since im not a tyrant

implemented quat adaptive backstepping dp
modified quat pid dp
modified joystick interface
modified reference filter quat