Skip to content

Commit

Permalink
Minor changes based on PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelirh committed Jun 18, 2024
1 parent f75c437 commit 08b9386
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion panther_hardware_interfaces/src/gpio_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void GPIODriver::ConfigureEdgeEventCallback(const std::function<void(const GPIOI
std::unique_ptr<gpiod::line_request> GPIODriver::CreateLineRequest(gpiod::chip & chip)
{
auto request_builder = chip.prepare_request();
request_builder.set_consumer("panther_gpiod");
request_builder.set_consumer("panther_hardware_interfaces");

for (GPIOInfo & gpio_info : gpio_info_storage_) {
ConfigureLineRequest(chip, request_builder, gpio_info);
Expand Down
2 changes: 1 addition & 1 deletion panther_lights/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ This node is responsible for displaying frames on the Husarion Panther robot's B

[//]: # (ROS_API_NODE_SERVICE_CLIENTS_START)

- `hardware/led_control_enable` [*std_srvs/SetBool*]: allows setting animation on Bumper Lights based on animation ID.
- `hardware/led_control_enable` [*std_srvs/SetBool*]: makes SBC controlling LEDs.

[//]: # (ROS_API_NODE_SERVICE_CLIENTS_END)

Expand Down
29 changes: 19 additions & 10 deletions panther_lights/src/driver_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,24 @@ void DriverNode::ToggleLEDControlCB(rclcpp::Client<SetBoolSrv>::SharedFutureWith
{
RCLCPP_DEBUG(this->get_logger(), "Received response after toggling LED control.");

auto result = future.get();
const auto result = future.get();

auto request = result.first;
auto response = result.second;
const auto request = result.first;
const auto response = result.second;

if (request->data == true && response->success) {
if (!response->success) {
RCLCPP_ERROR_THROTTLE(
this->get_logger(), *this->get_clock(), 5000, "Failed to toggle LED control.");
return;
}

if (request->data == true) {
led_control_granted_ = true;
ClearLEDs();
RCLCPP_INFO_THROTTLE(this->get_logger(), *this->get_clock(), 5000, "LED control granted.");
} else if (request->data == false && response->success) {
} else {
led_control_granted_ = false;
RCLCPP_INFO_THROTTLE(this->get_logger(), *this->get_clock(), 5000, "LED control revoked.");
} else {
RCLCPP_ERROR_THROTTLE(
this->get_logger(), *this->get_clock(), 5000, "Failed to toggle LED control.");
}
}

Expand Down Expand Up @@ -176,8 +179,14 @@ void DriverNode::FrameCB(
}

if (!message.empty()) {
RCLCPP_WARN_STREAM_THROTTLE(
this->get_logger(), *this->get_clock(), 5000, message << " on " << panel_name << "!");
// Since this is throttle warning, we need to add panel name condition to log from both panels
if (panel_name == "channel_1") {
RCLCPP_WARN_STREAM_THROTTLE(
this->get_logger(), *this->get_clock(), 5000, message << " on " << panel_name << "!");
} else if (panel_name == "channel_2") {
RCLCPP_WARN_STREAM_THROTTLE(
this->get_logger(), *this->get_clock(), 5000, message << " on " << panel_name << "!");
}

auto warn_msg = message + " on " + panel_name + "!";
diagnostic_updater_.broadcast(diagnostic_msgs::msg::DiagnosticStatus::WARN, warn_msg);
Expand Down

0 comments on commit 08b9386

Please sign in to comment.