@@ -43,6 +43,17 @@ void JointExponentialFilterArray::initialize(const double &cutoff_frequency,
43
43
initialized_ = true ;
44
44
}
45
45
46
+ JointPIDArray::JointPIDArray (const PIDParameters &pid_parameters)
47
+ : pid_parameters_(pid_parameters) // keep local copy of parameters since
48
+ // controller_toolbox::Pid::getGains is not const correct
49
+ // (i.e. can't be called in this->log_info)
50
+ {
51
+ std::for_each (pid_controllers_.begin (), pid_controllers_.end (), [&](auto &pid) {
52
+ pid.initPid (pid_parameters_.p , pid_parameters_.i , pid_parameters_.d , pid_parameters_.i_max ,
53
+ pid_parameters_.i_min , pid_parameters_.antiwindup );
54
+ });
55
+ }
56
+
46
57
void JointPIDArray::compute (const value_array_t &command_target, const value_array_t &state,
47
58
const std::chrono::nanoseconds &dt, value_array_t &command) {
48
59
std::for_each (command.begin (), command.end (), [&, i = 0 ](double &command_i) mutable {
@@ -59,11 +70,14 @@ void JointPIDArray::compute(const value_array_t &command_target, const double *s
59
70
});
60
71
}
61
72
62
- void JointPIDArray::initialize (const PIDParameters &pid_parameters, const double &dt) {
63
- std::for_each (pid_controllers_.begin (), pid_controllers_.end (), [&](auto &pid) {
64
- pid.initPid (pid_parameters.p * dt, pid_parameters.i * dt, pid_parameters.d * dt,
65
- pid_parameters.i_max * dt, pid_parameters.i_min * dt, pid_parameters.antiwindup );
66
- });
67
- initialized_ = true ;
68
- }
73
+ void JointPIDArray::log_info () const {
74
+ RCLCPP_INFO (rclcpp::get_logger (LOGGER_NAME), " *** Parameters:" );
75
+ RCLCPP_INFO (rclcpp::get_logger (LOGGER_NAME), " * p: %.1f" , pid_parameters_.p );
76
+ RCLCPP_INFO (rclcpp::get_logger (LOGGER_NAME), " * i: %.1f" , pid_parameters_.i );
77
+ RCLCPP_INFO (rclcpp::get_logger (LOGGER_NAME), " * d: %.1f" , pid_parameters_.d );
78
+ RCLCPP_INFO (rclcpp::get_logger (LOGGER_NAME), " * i_max: %.1f" , pid_parameters_.i_max );
79
+ RCLCPP_INFO (rclcpp::get_logger (LOGGER_NAME), " * i_min: %.1f" , pid_parameters_.i_min );
80
+ RCLCPP_INFO (rclcpp::get_logger (LOGGER_NAME), " * antiwindup: %s" ,
81
+ pid_parameters_.antiwindup ? " true" : " false" );
82
+ };
69
83
} // end of namespace lbr_fri_ros2
0 commit comments