|
1 | 1 | #include "crisp_controllers/utils/fiters.hpp" |
| 2 | +#include "crisp_controllers/utils/ros2_version.hpp" |
2 | 3 | #include "crisp_controllers/utils/torque_rate_saturation.hpp" |
3 | 4 |
|
4 | 5 | #include <Eigen/src/Core/Matrix.h> |
|
13 | 14 | #include "pinocchio/algorithm/model.hpp" |
14 | 15 | #include <cstddef> |
15 | 16 | #include <fmt/format.h> |
| 17 | +#if HAS_ROS2_CONTROL_INTROSPECTION |
| 18 | +#include <hardware_interface/introspection.hpp> |
| 19 | +#endif |
16 | 20 | #include <pinocchio/algorithm/aba.hpp> |
17 | 21 | #include <pinocchio/algorithm/compute-all-terms.hpp> |
18 | 22 | #include <pinocchio/algorithm/frames.hxx> |
@@ -405,6 +409,28 @@ CallbackReturn CartesianController::on_configure( |
405 | 409 | // Initialize nullspace projection matrix |
406 | 410 | nullspace_projection = Eigen::MatrixXd::Identity(model_.nv, model_.nv); |
407 | 411 |
|
| 412 | +#if HAS_ROS2_CONTROL_INTROSPECTION |
| 413 | + this->enable_introspection(true); |
| 414 | + for (int i = 0; i < tau_task.size(); ++i) { |
| 415 | + REGISTER_ROS2_CONTROL_INTROSPECTION("tau_task_" + std::to_string(i), |
| 416 | + &tau_task[i]); |
| 417 | + REGISTER_ROS2_CONTROL_INTROSPECTION("tau_desired_" + std::to_string(i), |
| 418 | + &tau_d[i]); |
| 419 | + } |
| 420 | + for (int i = 0; i < error.size(); ++i) { |
| 421 | + REGISTER_ROS2_CONTROL_INTROSPECTION("error_" + std::to_string(i), |
| 422 | + &error[i]); |
| 423 | + REGISTER_ROS2_CONTROL_INTROSPECTION("target_position_" + std::to_string(i), |
| 424 | + &target_position_[i]); |
| 425 | + } |
| 426 | + for (int i = 0; i < target_orientation_.coeffs().size(); ++i) { |
| 427 | + REGISTER_ROS2_CONTROL_INTROSPECTION( |
| 428 | + "target_orientation_" + std::to_string(i), |
| 429 | + &target_orientation_.coeffs()[i]); |
| 430 | + } |
| 431 | +#endif |
| 432 | + |
| 433 | + |
408 | 434 | RCLCPP_INFO(get_node()->get_logger(), "State interfaces and control vectors initialized."); |
409 | 435 |
|
410 | 436 | return CallbackReturn::SUCCESS; |
|
0 commit comments