Skip to content

Commit 0672ab6

Browse files
committed
updated publish_rate assignment logic
1 parent 93dce70 commit 0672ab6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

hardware_interface/include/hardware_interface/hardware_component_interface.hpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,16 @@ class HardwareComponentInterface : public rclcpp_lifecycle::node_interfaces::Lif
187187
try
188188
{
189189
publish_rate = hardware_interface::stod(it->second);
190+
191+
if (publish_rate < 0.0)
192+
{
193+
RCLCPP_ERROR(
194+
get_logger(),
195+
"'status_publish_rate' cannot be negative (got %.lf). Please fix your hardware "
196+
"parameters.",
197+
publish_rate);
198+
return CallbackReturn::ERROR;
199+
}
190200
}
191201
catch (const std::invalid_argument &)
192202
{
@@ -196,13 +206,7 @@ class HardwareComponentInterface : public rclcpp_lifecycle::node_interfaces::Lif
196206
}
197207
}
198208

199-
if (publish_rate == 0.0)
200-
{
201-
RCLCPP_INFO(
202-
get_logger(),
203-
"`status_publish_rate` is set to 0.0, hardware status publisher will not be created.");
204-
}
205-
else
209+
if (publish_rate > 0.0)
206210
{
207211
control_msgs::msg::HardwareStatus status_msg_template;
208212
if (init_hardware_status_message(status_msg_template) != CallbackReturn::SUCCESS)

0 commit comments

Comments
 (0)