Skip to content

Commit 3255499

Browse files
committed
added warning for invalid sizes
1 parent d93864f commit 3255499

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

joint_trajectory_controller/src/joint_trajectory_controller.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,16 +626,22 @@ void JointTrajectoryController::sort_to_local_joint_order(
626626
{
627627
// rearrange all points in the trajectory message based on mapping
628628
std::vector<size_t> mapping_vector = mapping(trajectory_msg->joint_names, joint_names_);
629-
auto remap = [](const std::vector<double> & to_remap, const std::vector<size_t> & mapping)
629+
auto remap = [this](const std::vector<double> & to_remap, const std::vector<size_t> & mapping)
630630
-> std::vector<double>
631631
{
632+
if (to_remap.empty()) {
633+
return to_remap;
634+
}
632635
if (to_remap.size() != mapping.size()) {
636+
RCLCPP_WARN(
637+
lifecycle_node_->get_logger(),
638+
"Invalid input size (%d) for sorting", to_remap.size());
633639
return to_remap;
634640
}
635641
std::vector<double> output;
636642
output.resize(mapping.size(), 0.0);
637643
for (auto index = 0ul; index < mapping.size(); ++index) {
638-
unsigned int map_index = mapping[index];
644+
auto map_index = mapping[index];
639645
output[map_index] = to_remap[index];
640646
}
641647
return output;

0 commit comments

Comments
 (0)