225{
226 if (max_angular_z_speed_ == 0 || max_linear_x_speed_ == 0)
227 return;
228
229 if (cmd_vel.angular.z == 0)
230 {
231 cmd_vel.linear.x = max_linear_x_speed_;
232 }
233 else
234 {
235 double kurvature = cmd_vel.linear.x / cmd_vel.angular.z;
236
237 double linearAuthority = fabs(cmd_vel.linear.x / max_linear_x_speed_);
238 double angularAuthority = fabs(cmd_vel.angular.z / max_angular_z_speed_);
239 if (linearAuthority < angularAuthority)
240 {
241
242 cmd_vel.linear.x = max_linear_x_speed_;
243 cmd_vel.angular.z = kurvature / max_linear_x_speed_;
244 ROS_WARN_STREAM("k=" << kurvature << "lets go to maximum linear capacity: " << cmd_vel);
245 }
246 else
247 {
248
249 cmd_vel.angular.x = max_angular_z_speed_;
250 cmd_vel.linear.x = kurvature * max_angular_z_speed_;
251 ROS_WARN_STREAM("lets go to maximum angular capacity: " << cmd_vel);
252 }
253 }
254}