Skip to content

Commit 7331b3a

Browse files
committed
Add more conditions to protect the infinity builds
1 parent 428c819 commit 7331b3a

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

controller_manager/include/controller_manager/controller_spec.hpp

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ struct ControllerPeerInfo
152152
continue; // skip this predecessor, as it is already in a group as individual
153153
}
154154

155+
if (
156+
std::find(
157+
current_combination.begin(), current_combination.end(), predecessors[i]->name) !=
158+
current_combination.end())
159+
{
160+
continue; // skip this predecessor, as it is already in the current combination
161+
}
162+
155163
current_combination.push_back(predecessors[i]->name);
156164
generate_combinations(i + 1);
157165
current_combination.pop_back();
@@ -160,7 +168,8 @@ struct ControllerPeerInfo
160168

161169
RCLCPP_INFO(
162170
rclcpp::get_logger("controller_manager"),
163-
"Generating combinations of predecessors for controller: %s", name.c_str());
171+
"Generating combinations of predecessors for controller: %s (%s)",
172+
predecessor->name.c_str(), name.c_str());
164173
generate_combinations(0);
165174
// Add the combinations to the mutually exclusive predecessor groups
166175
for (const auto & combination : combinations)
@@ -275,6 +284,13 @@ struct ControllerPeerInfo
275284
continue; // skip this successor, as it is already in a group as individual
276285
}
277286

287+
if (
288+
std::find(
289+
current_combination.begin(), current_combination.end(), successors[i]->name) !=
290+
current_combination.end())
291+
{
292+
continue; // skip this successor, as it is already in the current combination
293+
}
278294
current_combination.push_back(successors[i]->name);
279295
generate_combinations(i + 1);
280296
current_combination.pop_back();
@@ -299,6 +315,10 @@ struct ControllerPeerInfo
299315
mutually_exclusive_successor_groups.push_back(group);
300316
}
301317
}
318+
RCLCPP_INFO_STREAM(
319+
rclcpp::get_logger("controller_manager"),
320+
"Mutually exclusive successor groups for controller: "
321+
<< name << " are: " << mutually_exclusive_successor_groups.size());
302322
}
303323
}
304324

@@ -554,8 +574,25 @@ class ControllerChainDependencyGraph
554574
{
555575
controller_graph_[successor.name] = successor;
556576
}
557-
controller_graph_[predecessor.name].successors.push_back(&controller_graph_[successor.name]);
558-
controller_graph_[successor.name].predecessors.push_back(&controller_graph_[predecessor.name]);
577+
if (
578+
std::find_if(
579+
controller_graph_[predecessor.name].successors.begin(),
580+
controller_graph_[predecessor.name].successors.end(),
581+
[&successor](const ControllerPeerInfo * s) { return s->name == successor.name; }) ==
582+
controller_graph_[predecessor.name].successors.end())
583+
{
584+
controller_graph_[predecessor.name].successors.push_back(&controller_graph_[successor.name]);
585+
}
586+
if (
587+
std::find_if(
588+
controller_graph_[successor.name].predecessors.begin(),
589+
controller_graph_[successor.name].predecessors.end(),
590+
[&predecessor](const ControllerPeerInfo * p) { return p->name == predecessor.name; }) ==
591+
controller_graph_[successor.name].predecessors.end())
592+
{
593+
controller_graph_[successor.name].predecessors.push_back(
594+
&controller_graph_[predecessor.name]);
595+
}
559596
}
560597

561598
std::vector<std::string> get_dependencies_to_activate(const std::string & controller_name)

0 commit comments

Comments
 (0)