Skip to content

Commit 76e14b7

Browse files
committed
Add link_name: '*' option.
Signed-off-by: Ivan Santiago Paunovic <[email protected]>
1 parent de56797 commit 76e14b7

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

src/systems/user_commands/UserCommands.cc

+32-21
Original file line numberDiff line numberDiff line change
@@ -1468,29 +1468,40 @@ bool WheelSlipCommand::Execute()
14681468
return false;
14691469
}
14701470
Model model{modelEntity};
1471-
Entity linkEntity = model.LinkByName(
1472-
*this->iface->ecm, wheelSlipMsg->link_name());
1473-
if (kNullEntity == linkEntity)
1474-
{
1475-
ignerr << "Failed to find link with name [" << wheelSlipMsg->link_name()
1476-
<< "] for model [" << wheelSlipMsg->model_name() << "]."
1477-
<< std::endl;
1478-
return false;
1479-
}
1471+
auto linkName = wheelSlipMsg->link_name();
14801472

1481-
auto wheelSlipCmdComp =
1473+
auto doForEachLink = [this, wheelSlipMsg](Entity linkEntity) {
1474+
auto wheelSlipCmdComp =
14821475
this->iface->ecm->Component<components::WheelSlipCmd>(linkEntity);
1483-
if (!wheelSlipCmdComp)
1484-
{
1485-
this->iface->ecm->CreateComponent(
1486-
linkEntity, components::WheelSlipCmd(*wheelSlipMsg));
1487-
}
1488-
else
1489-
{
1490-
auto state = wheelSlipCmdComp->SetData(*wheelSlipMsg, this->wheelSlipEql) ?
1491-
ComponentState::OneTimeChange : ComponentState::NoChange;
1492-
this->iface->ecm->SetChanged(
1493-
linkEntity, components::WheelSlipCmd::typeId, state);
1476+
if (!wheelSlipCmdComp)
1477+
{
1478+
this->iface->ecm->CreateComponent(
1479+
linkEntity, components::WheelSlipCmd(*wheelSlipMsg));
1480+
}
1481+
else
1482+
{
1483+
auto state = wheelSlipCmdComp->SetData(*wheelSlipMsg, this->wheelSlipEql) ?
1484+
ComponentState::OneTimeChange : ComponentState::NoChange;
1485+
this->iface->ecm->SetChanged(
1486+
linkEntity, components::WheelSlipCmd::typeId, state);
1487+
}
1488+
};
1489+
1490+
if (linkName != "*") {
1491+
Entity linkEntity = model.LinkByName(
1492+
*this->iface->ecm, wheelSlipMsg->link_name());
1493+
if (kNullEntity == linkEntity)
1494+
{
1495+
ignerr << "Failed to find link with name [" << wheelSlipMsg->link_name()
1496+
<< "] for model [" << wheelSlipMsg->model_name() << "]."
1497+
<< std::endl;
1498+
return false;
1499+
}
1500+
doForEachLink(linkEntity);
1501+
} else {
1502+
for (const auto & linkEntity : model.Links(*this->iface->ecm)) {
1503+
doForEachLink(linkEntity);
1504+
}
14941505
}
14951506
return true;
14961507
}

0 commit comments

Comments
 (0)