Skip to content

Commit 6cbb5f0

Browse files
authored
[Transmission] Fix the differential transmission configure checks (#2682)
1 parent 2e20aac commit 6cbb5f0

File tree

1 file changed

+113
-17
lines changed

1 file changed

+113
-17
lines changed

transmission_interface/include/transmission_interface/differential_transmission.hpp

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,48 @@ void DifferentialTransmission::configure(
242242
joint_absolute_position_ =
243243
get_ordered_handles(joint_handles, joint_names, HW_IF_ABSOLUTE_POSITION);
244244

245-
if (
246-
joint_position_.size() != 2 && joint_velocity_.size() != 2 && joint_effort_.size() != 2 &&
247-
joint_torque_.size() != 2 && joint_force_.size() != 2 && joint_absolute_position_.size() != 2)
245+
if (!joint_position_.empty() && joint_position_.size() != 2)
246+
{
247+
throw Exception(
248+
fmt::format(
249+
FMT_COMPILE("Not enough valid or required joint position handles were present. \n{}"),
250+
get_handles_info()));
251+
}
252+
if (!joint_velocity_.empty() && joint_velocity_.size() != 2)
253+
{
254+
throw Exception(
255+
fmt::format(
256+
FMT_COMPILE("Not enough valid or required joint velocity handles were present. \n{}"),
257+
get_handles_info()));
258+
}
259+
if (!joint_effort_.empty() && joint_effort_.size() != 2)
260+
{
261+
throw Exception(
262+
fmt::format(
263+
FMT_COMPILE("Not enough valid or required joint effort handles were present. \n{}"),
264+
get_handles_info()));
265+
}
266+
if (!joint_torque_.empty() && joint_torque_.size() != 2)
248267
{
249-
throw Exception("Not enough valid or required joint handles were presented.");
268+
throw Exception(
269+
fmt::format(
270+
FMT_COMPILE("Not enough valid or required joint torque handles were present. \n{}"),
271+
get_handles_info()));
272+
}
273+
if (!joint_force_.empty() && joint_force_.size() != 2)
274+
{
275+
throw Exception(
276+
fmt::format(
277+
FMT_COMPILE("Not enough valid or required joint force handles were present. \n{}"),
278+
get_handles_info()));
279+
}
280+
if (!joint_absolute_position_.empty() && joint_absolute_position_.size() != 2)
281+
{
282+
throw Exception(
283+
fmt::format(
284+
FMT_COMPILE(
285+
"Not enough valid or required joint absolute position handles were present. \n{}"),
286+
get_handles_info()));
250287
}
251288

252289
actuator_position_ =
@@ -262,27 +299,86 @@ void DifferentialTransmission::configure(
262299
actuator_absolute_position_ =
263300
get_ordered_handles(actuator_handles, actuator_names, HW_IF_ABSOLUTE_POSITION);
264301

265-
if (
266-
actuator_position_.size() != 2 && actuator_velocity_.size() != 2 &&
267-
actuator_effort_.size() != 2 && actuator_torque_.size() != 2 && actuator_force_.size() != 2 &&
268-
actuator_absolute_position_.size() != 2)
302+
if (!actuator_position_.empty() && actuator_position_.size() != 2)
269303
{
270304
throw Exception(
271305
fmt::format(
272-
FMT_COMPILE("Not enough valid or required actuator handles were presented. \n{}"),
306+
FMT_COMPILE("Not enough valid or required actuator position handles were present. \n{}"),
307+
get_handles_info()));
308+
}
309+
if (!actuator_velocity_.empty() && actuator_velocity_.size() != 2)
310+
{
311+
throw Exception(
312+
fmt::format(
313+
FMT_COMPILE("Not enough valid or required actuator velocity handles were present. \n{}"),
314+
get_handles_info()));
315+
}
316+
if (!actuator_effort_.empty() && actuator_effort_.size() != 2)
317+
{
318+
throw Exception(
319+
fmt::format(
320+
FMT_COMPILE("Not enough valid or required actuator effort handles were present. \n{}"),
321+
get_handles_info()));
322+
}
323+
if (!actuator_torque_.empty() && actuator_torque_.size() != 2)
324+
{
325+
throw Exception(
326+
fmt::format(
327+
FMT_COMPILE("Not enough valid or required actuator torque handles were present. \n{}"),
328+
get_handles_info()));
329+
}
330+
if (!actuator_force_.empty() && actuator_force_.size() != 2)
331+
{
332+
throw Exception(
333+
fmt::format(
334+
FMT_COMPILE("Not enough valid or required actuator force handles were present. \n{}"),
335+
get_handles_info()));
336+
}
337+
if (!actuator_absolute_position_.empty() && actuator_absolute_position_.size() != 2)
338+
{
339+
throw Exception(
340+
fmt::format(
341+
FMT_COMPILE(
342+
"Not enough valid or required actuator absolute position handles were "
343+
"present. \n{}"),
273344
get_handles_info()));
274345
}
275346

276-
if (
277-
joint_position_.size() != actuator_position_.size() &&
278-
joint_velocity_.size() != actuator_velocity_.size() &&
279-
joint_effort_.size() != actuator_effort_.size() &&
280-
joint_torque_.size() != actuator_torque_.size() &&
281-
joint_force_.size() != actuator_force_.size() &&
282-
joint_absolute_position_.size() != actuator_absolute_position_.size())
347+
if (joint_position_.size() != actuator_position_.size())
348+
{
349+
throw Exception(
350+
fmt::format(
351+
FMT_COMPILE("Pair-wise mismatch on position interfaces. \n{}"), get_handles_info()));
352+
}
353+
if (joint_velocity_.size() != actuator_velocity_.size())
354+
{
355+
throw Exception(
356+
fmt::format(
357+
FMT_COMPILE("Pair-wise mismatch on velocity interfaces. \n{}"), get_handles_info()));
358+
}
359+
if (joint_effort_.size() != actuator_effort_.size())
360+
{
361+
throw Exception(
362+
fmt::format(
363+
FMT_COMPILE("Pair-wise mismatch on effort interfaces. \n{}"), get_handles_info()));
364+
}
365+
if (joint_torque_.size() != actuator_torque_.size())
283366
{
284367
throw Exception(
285-
fmt::format(FMT_COMPILE("Pair-wise mismatch on interfaces. \n{}"), get_handles_info()));
368+
fmt::format(
369+
FMT_COMPILE("Pair-wise mismatch on torque interfaces. \n{}"), get_handles_info()));
370+
}
371+
if (joint_force_.size() != actuator_force_.size())
372+
{
373+
throw Exception(
374+
fmt::format(FMT_COMPILE("Pair-wise mismatch on force interfaces. \n{}"), get_handles_info()));
375+
}
376+
if (joint_absolute_position_.size() != actuator_absolute_position_.size())
377+
{
378+
throw Exception(
379+
fmt::format(
380+
FMT_COMPILE("Pair-wise mismatch on absolute position interfaces. \n{}"),
381+
get_handles_info()));
286382
}
287383
}
288384

0 commit comments

Comments
 (0)