Skip to content

Commit 4d8f406

Browse files
Deprecate thread_priority again (#2644)
1 parent df846fe commit 4d8f406

File tree

3 files changed

+130
-12
lines changed

3 files changed

+130
-12
lines changed

hardware_interface/include/hardware_interface/hardware_info.hpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ struct HardwareAsyncParams
260260
};
261261

262262
/// This structure stores information about hardware defined in a robot's URDF.
263+
#ifdef _MSC_VER
264+
#pragma warning(push)
265+
#pragma warning(disable : 4996)
266+
#else
267+
#pragma GCC diagnostic push
268+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
269+
#endif
263270
struct HardwareInfo
264271
{
265272
/// Name of the hardware.
@@ -272,10 +279,8 @@ struct HardwareInfo
272279
unsigned int rw_rate;
273280
/// Component is async
274281
bool is_async;
275-
// TODO(anyone): deprecate after branching for kilted
276-
/// [[deprecated("Use async_params instead.")]]
277282
/// Async thread priority
278-
int thread_priority;
283+
[[deprecated("Use async_params instead.")]] int thread_priority;
279284
/// Async Parameters
280285
HardwareAsyncParams async_params;
281286
/// Name of the pluginlib plugin of the hardware that will be loaded.
@@ -322,6 +327,11 @@ struct HardwareInfo
322327
*/
323328
std::unordered_map<std::string, joint_limits::SoftJointLimits> soft_limits;
324329
};
330+
#ifdef _MSC_VER
331+
#pragma warning(pop)
332+
#else
333+
#pragma GCC diagnostic pop
334+
#endif
325335

326336
} // namespace hardware_interface
327337
#endif // HARDWARE_INTERFACE__HARDWARE_INFO_HPP_

hardware_interface/src/component_parser.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,23 @@ HardwareInfo parse_resource_from_xml(
675675
hardware.type = get_attribute_value(ros2_control_it, kTypeAttribute, kROS2ControlTag);
676676
hardware.rw_rate = parse_rw_rate_attribute(ros2_control_it);
677677
hardware.is_async = parse_is_async_attribute(ros2_control_it);
678-
hardware.thread_priority = hardware.is_async ? parse_thread_priority_attribute(ros2_control_it)
679-
: std::numeric_limits<int>::max();
680-
hardware.async_params.thread_priority = hardware.thread_priority;
678+
hardware.async_params.thread_priority = hardware.is_async
679+
? parse_thread_priority_attribute(ros2_control_it)
680+
: std::numeric_limits<int>::max();
681+
// TODO(anyone): remove this line once thread_priority is removed
682+
#ifdef _MSC_VER
683+
#pragma warning(push)
684+
#pragma warning(disable : 4996)
685+
#else
686+
#pragma GCC diagnostic push
687+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
688+
#endif
689+
hardware.thread_priority = hardware.async_params.thread_priority;
690+
#ifdef _MSC_VER
691+
#pragma warning(pop)
692+
#else
693+
#pragma GCC diagnostic pop
694+
#endif
681695

682696
// Parse everything under ros2_control tag
683697
hardware.hardware_plugin_name = "";
@@ -725,7 +739,20 @@ HardwareInfo parse_resource_from_xml(
725739
if (async_it->FindAttribute(kThreadPriorityAttribute))
726740
{
727741
hardware.async_params.thread_priority = parse_thread_priority_attribute(async_it);
742+
// TODO(anyone): remove this line once thread_priority is removed
743+
#ifdef _MSC_VER
744+
#pragma warning(push)
745+
#pragma warning(disable : 4996)
746+
#else
747+
#pragma GCC diagnostic push
748+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
749+
#endif
728750
hardware.thread_priority = hardware.async_params.thread_priority;
751+
#ifdef _MSC_VER
752+
#pragma warning(pop)
753+
#else
754+
#pragma GCC diagnostic pop
755+
#endif
729756
}
730757
if (async_it->FindAttribute(kPrintWarningsAttribute))
731758
{

hardware_interface/test/test_component_parser.cpp

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,21 @@ TEST_F(TestComponentParser, successfully_parse_valid_urdf_system_robot_with_gpio
880880
hardware_info.hardware_plugin_name, "ros2_control_demo_hardware/RRBotSystemWithGPIOHardware");
881881

882882
ASSERT_FALSE(hardware_info.is_async);
883-
ASSERT_EQ(hardware_info.thread_priority, std::numeric_limits<int>::max());
883+
// TODO(anyone): remove this line once thread_priority is removed
884+
#ifdef _MSC_VER
885+
#pragma warning(push)
886+
#pragma warning(disable : 4996)
887+
#else
888+
#pragma GCC diagnostic push
889+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
890+
#endif
891+
ASSERT_EQ(hardware_info.thread_priority, hardware_info.async_params.thread_priority);
892+
#ifdef _MSC_VER
893+
#pragma warning(pop)
894+
#else
895+
#pragma GCC diagnostic pop
896+
#endif
897+
ASSERT_EQ(hardware_info.async_params.thread_priority, std::numeric_limits<int>::max());
884898
ASSERT_THAT(hardware_info.joints, SizeIs(2));
885899

886900
EXPECT_EQ(hardware_info.joints[0].name, "joint1");
@@ -952,7 +966,21 @@ TEST_F(TestComponentParser, successfully_parse_valid_urdf_system_with_size_and_d
952966
ASSERT_THAT(hardware_info.joints, SizeIs(1));
953967

954968
ASSERT_FALSE(hardware_info.is_async);
955-
ASSERT_EQ(hardware_info.thread_priority, std::numeric_limits<int>::max());
969+
// TODO(anyone): remove this line once thread_priority is removed
970+
#ifdef _MSC_VER
971+
#pragma warning(push)
972+
#pragma warning(disable : 4996)
973+
#else
974+
#pragma GCC diagnostic push
975+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
976+
#endif
977+
ASSERT_EQ(hardware_info.thread_priority, hardware_info.async_params.thread_priority);
978+
#ifdef _MSC_VER
979+
#pragma warning(pop)
980+
#else
981+
#pragma GCC diagnostic pop
982+
#endif
983+
ASSERT_EQ(hardware_info.async_params.thread_priority, std::numeric_limits<int>::max());
956984
EXPECT_EQ(hardware_info.joints[0].name, "joint1");
957985
EXPECT_EQ(hardware_info.joints[0].type, "joint");
958986
EXPECT_THAT(hardware_info.joints[0].command_interfaces, SizeIs(1));
@@ -1002,7 +1030,21 @@ TEST_F(
10021030

10031031
ASSERT_THAT(hardware_info.joints, SizeIs(1));
10041032
ASSERT_FALSE(hardware_info.is_async);
1005-
ASSERT_EQ(hardware_info.thread_priority, std::numeric_limits<int>::max());
1033+
// TODO(anyone): remove this line once thread_priority is removed
1034+
#ifdef _MSC_VER
1035+
#pragma warning(push)
1036+
#pragma warning(disable : 4996)
1037+
#else
1038+
#pragma GCC diagnostic push
1039+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1040+
#endif
1041+
ASSERT_EQ(hardware_info.thread_priority, hardware_info.async_params.thread_priority);
1042+
#ifdef _MSC_VER
1043+
#pragma warning(pop)
1044+
#else
1045+
#pragma GCC diagnostic pop
1046+
#endif
1047+
ASSERT_EQ(hardware_info.async_params.thread_priority, std::numeric_limits<int>::max());
10061048
EXPECT_EQ(hardware_info.joints[0].name, "joint1");
10071049
EXPECT_EQ(hardware_info.joints[0].type, "joint");
10081050
EXPECT_THAT(hardware_info.joints[0].command_interfaces, SizeIs(2));
@@ -1430,7 +1472,20 @@ TEST_F(TestComponentParser, successfully_parse_valid_urdf_async_components)
14301472
ASSERT_THAT(hardware_info.group, IsEmpty());
14311473
ASSERT_THAT(hardware_info.joints, SizeIs(1));
14321474
ASSERT_TRUE(hardware_info.is_async);
1433-
ASSERT_EQ(hardware_info.thread_priority, 30);
1475+
// TODO(anyone): remove this line once thread_priority is removed
1476+
#ifdef _MSC_VER
1477+
#pragma warning(push)
1478+
#pragma warning(disable : 4996)
1479+
#else
1480+
#pragma GCC diagnostic push
1481+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1482+
#endif
1483+
ASSERT_EQ(hardware_info.thread_priority, hardware_info.async_params.thread_priority);
1484+
#ifdef _MSC_VER
1485+
#pragma warning(pop)
1486+
#else
1487+
#pragma GCC diagnostic pop
1488+
#endif
14341489
ASSERT_EQ(hardware_info.async_params.thread_priority, 30);
14351490
ASSERT_EQ(hardware_info.async_params.scheduling_policy, "detached");
14361491
ASSERT_FALSE(hardware_info.async_params.print_warnings);
@@ -1450,7 +1505,20 @@ TEST_F(TestComponentParser, successfully_parse_valid_urdf_async_components)
14501505
ASSERT_THAT(hardware_info.joints, IsEmpty());
14511506
ASSERT_THAT(hardware_info.sensors, SizeIs(1));
14521507
ASSERT_TRUE(hardware_info.is_async);
1453-
ASSERT_EQ(hardware_info.thread_priority, 50);
1508+
// TODO(anyone): remove this line once thread_priority is removed
1509+
#ifdef _MSC_VER
1510+
#pragma warning(push)
1511+
#pragma warning(disable : 4996)
1512+
#else
1513+
#pragma GCC diagnostic push
1514+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1515+
#endif
1516+
ASSERT_EQ(hardware_info.thread_priority, hardware_info.async_params.thread_priority);
1517+
#ifdef _MSC_VER
1518+
#pragma warning(pop)
1519+
#else
1520+
#pragma GCC diagnostic pop
1521+
#endif
14541522
ASSERT_EQ(hardware_info.async_params.thread_priority, 50);
14551523
ASSERT_EQ(hardware_info.async_params.scheduling_policy, "synchronized");
14561524
ASSERT_TRUE(hardware_info.async_params.print_warnings);
@@ -1478,7 +1546,20 @@ TEST_F(TestComponentParser, successfully_parse_valid_urdf_async_components)
14781546
EXPECT_EQ(hardware_info.gpios[0].name, "configuration");
14791547
EXPECT_EQ(hardware_info.gpios[0].type, "gpio");
14801548
ASSERT_TRUE(hardware_info.is_async);
1481-
ASSERT_EQ(hardware_info.thread_priority, 70);
1549+
// TODO(anyone): remove this line once thread_priority is removed
1550+
#ifdef _MSC_VER
1551+
#pragma warning(push)
1552+
#pragma warning(disable : 4996)
1553+
#else
1554+
#pragma GCC diagnostic push
1555+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1556+
#endif
1557+
ASSERT_EQ(hardware_info.thread_priority, hardware_info.async_params.thread_priority);
1558+
#ifdef _MSC_VER
1559+
#pragma warning(pop)
1560+
#else
1561+
#pragma GCC diagnostic pop
1562+
#endif
14821563
ASSERT_EQ(hardware_info.async_params.thread_priority, 70);
14831564
ASSERT_EQ(hardware_info.async_params.scheduling_policy, "synchronized");
14841565
ASSERT_EQ(1u, hardware_info.async_params.cpu_affinity_cores.size());

0 commit comments

Comments
 (0)