Skip to content

Commit 73811dd

Browse files
committed
check if is transmission otherwise export normal way
1 parent 4cddbb1 commit 73811dd

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

mock_hardware/src/generic_system.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,20 @@ std::vector<hardware_interface::StateInterface> GenericSystem::export_state_inte
353353
joint_interfaces_.begin(), joint_interfaces_.end(),
354354
[&](const InterfaceData & interface) { return interface.name_ == joint.name; });
355355

356-
// joint is not used by transmissions so we use the storage matrix for each StateInterface
357-
if (joint_interface == joint_interfaces_.end())
356+
for (const auto & interface : joint.state_interfaces)
358357
{
359-
for (const auto & interface : joint.state_interfaces)
358+
// joint is used by transmissions, because we found it in joint_interfaces vector which is
359+
// used for storing the transmission and its of the supported types for transmission so we use
360+
// separate InterfaceData storage vector.
361+
if (
362+
joint_interface != joint_interfaces_.end() &&
363+
interface.name == hardware_interface::HW_IF_POSITION)
360364
{
365+
state_interfaces.emplace_back(hardware_interface::StateInterface(
366+
joint.name, hardware_interface::HW_IF_POSITION, &joint_interface->state_));
367+
}
368+
else
369+
{ // joint is not used by transmissions so we use the storage matrix for each StateInterface
361370
// Add interface: if not in the standard list then use "other" interface list
362371
if (!get_interface(
363372
joint.name, standard_interfaces_, interface.name, i, joint_states_, state_interfaces))
@@ -372,12 +381,6 @@ std::vector<hardware_interface::StateInterface> GenericSystem::export_state_inte
372381
}
373382
}
374383
}
375-
// joint is used by transmissions so we use the separate InterfaceData storage vector.
376-
else
377-
{
378-
state_interfaces.emplace_back(hardware_interface::StateInterface(
379-
joint.name, hardware_interface::HW_IF_POSITION, &joint_interface->state_));
380-
}
381384
++i;
382385
}
383386

@@ -413,11 +416,21 @@ std::vector<hardware_interface::CommandInterface> GenericSystem::export_command_
413416
joint_interfaces_.begin(), joint_interfaces_.end(),
414417
[&](const InterfaceData & interface) { return interface.name_ == joint.name; });
415418

416-
// joint is not used by transmissions so we use the storage matrix for each CommandInterface
417-
if (joint_interface == joint_interfaces_.end())
419+
for (const auto & interface : joint.command_interfaces)
418420
{
419-
for (const auto & interface : joint.command_interfaces)
421+
// joint is used by transmissions, because we found it in joint_interfaces vector which is
422+
// used for storing the transmission and its of the supported types for transmission so we use
423+
// separate InterfaceData storage vector.
424+
if (
425+
joint_interface != joint_interfaces_.end() &&
426+
interface.name == hardware_interface::HW_IF_POSITION)
420427
{
428+
command_interfaces.emplace_back(hardware_interface::CommandInterface(
429+
joint.name, hardware_interface::HW_IF_POSITION, &joint_interface->command_));
430+
}
431+
else
432+
{
433+
// joint is not used by transmissions so we use the storage matrix for each CommandInterface
421434
// Add interface: if not in the standard list than use "other" interface list
422435
if (!get_interface(
423436
joint.name, standard_interfaces_, interface.name, i, joint_commands_,
@@ -434,12 +447,6 @@ std::vector<hardware_interface::CommandInterface> GenericSystem::export_command_
434447
}
435448
}
436449
}
437-
// joint is used by transmissions so we use the separate InterfaceData storage vector.
438-
else
439-
{
440-
command_interfaces.emplace_back(hardware_interface::CommandInterface(
441-
joint.name, hardware_interface::HW_IF_POSITION, &joint_interface->command_));
442-
}
443450
++i;
444451
}
445452
// Set position control mode per default

0 commit comments

Comments
 (0)