Skip to content

Commit d93864f

Browse files
committed
use std::find
1 parent 908ee5c commit d93864f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

joint_trajectory_controller/src/joint_trajectory_controller.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,16 +556,10 @@ rclcpp_action::GoalResponse JointTrajectoryController::goal_callback(
556556
}
557557

558558
for (auto i = 0ul; i < goal->trajectory.joint_names.size(); ++i) {
559-
bool found_matching = false;
560559
std::string incoming_joint_name = goal->trajectory.joint_names[i];
561-
for (auto j = 0ul; j < joint_names_.size(); ++j) {
562-
if (incoming_joint_name == joint_names_[j]) {
563-
found_matching = true;
564-
break;
565-
}
566-
}
567560

568-
if (found_matching == false) {
561+
auto it = std::find(joint_names_.begin(), joint_names_.end(), incoming_joint_name);
562+
if (it == joint_names_.end()) {
569563
RCLCPP_ERROR(
570564
lifecycle_node_->get_logger(),
571565
"Incoming joint %s doesn't match the controller's joints.",

0 commit comments

Comments
 (0)