Skip to content

Commit

Permalink
style(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Dec 19, 2024
1 parent 93561bc commit d2b9ffc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
12 changes: 7 additions & 5 deletions launch/tier4_control_launch/launch/control.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
from launch_ros.substitutions import FindPackageShare
import yaml


def get_control_cmd_topic(context):
is_redundant = LaunchConfiguration('launch_redundancy_system_components').perform(context)
system_run_mode = LaunchConfiguration('system_run_mode').perform(context)
is_redundant = LaunchConfiguration("launch_redundancy_system_components").perform(context)
system_run_mode = LaunchConfiguration("system_run_mode").perform(context)

if is_redundant.lower() == "true" and system_run_mode.lower() == "planning_simulation":
return "/main/control/command/control_cmd"
return "/control/command/control_cmd"

if is_redundant.lower() == 'true' and system_run_mode.lower() == 'planning_simulation':
return '/main/control/command/control_cmd'
return '/control/command/control_cmd'

def launch_setup(context, *args, **kwargs):
with open(LaunchConfiguration("vehicle_param_file").perform(context), "r") as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class DummyDiagPublisher : public rclcpp::Node
rclcpp::node_interfaces::OnSetParametersCallbackHandle::SharedPtr param_callback_handle_;

void loadRequiredDiags();
rcl_interfaces::msg::SetParametersResult onSetParams(const std::vector<rclcpp::Parameter> & parameters);
rcl_interfaces::msg::SetParametersResult onSetParams(
const std::vector<rclcpp::Parameter> & parameters);

std::optional<Status> convertStrToStatus(const std::string & status_str);
std::string convertStatusToStr(const Status & status);
Expand Down
33 changes: 19 additions & 14 deletions system/dummy_diag_publisher/src/dummy_diag_publisher_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#define FMT_HEADER_ONLY
#include <fmt/format.h>

#include <sstream>
#include <unordered_map>

Expand Down Expand Up @@ -141,8 +142,8 @@ rclcpp::NodeOptions override_options(rclcpp::NodeOptions options)
true);
}

rcl_interfaces::msg::SetParametersResult
DummyDiagPublisher::onSetParams(const std::vector<rclcpp::Parameter> & parameters)
rcl_interfaces::msg::SetParametersResult DummyDiagPublisher::onSetParams(
const std::vector<rclcpp::Parameter> & parameters)
{
rcl_interfaces::msg::SetParametersResult result;
result.successful = true;
Expand All @@ -157,34 +158,39 @@ rcl_interfaces::msg::SetParametersResult
auto new_status = convertStrToStatus(parameter.as_string());
if (new_status) {
diag.status = *new_status;
RCLCPP_INFO(this->get_logger(), "Updated %s status to: %s",
diag.name.c_str(), parameter.as_string().c_str());
RCLCPP_INFO(
this->get_logger(), "Updated %s status to: %s", diag.name.c_str(),
parameter.as_string().c_str());
} else {
result.successful = false;
result.reason = "Invalid status value for: " + parameter.as_string();
RCLCPP_WARN(this->get_logger(), "Invalid status value for %s: %s",
diag.name.c_str(), parameter.as_string().c_str());
RCLCPP_WARN(
this->get_logger(), "Invalid status value for %s: %s", diag.name.c_str(),
parameter.as_string().c_str());
}
} else if (param_name == diag.name + std::string(".is_active")) {
param_found = true;
try {
diag.is_active = parameter.as_bool();
RCLCPP_INFO(this->get_logger(), "Updated %s is_active to: %s",
diag.name.c_str(), diag.is_active ? "true" : "false");
RCLCPP_INFO(
this->get_logger(), "Updated %s is_active to: %s", diag.name.c_str(),
diag.is_active ? "true" : "false");
} catch (const rclcpp::ParameterTypeException & e) {
result.successful = false;
result.reason = "Invalid is_active value for: " + parameter.as_string();
RCLCPP_WARN(this->get_logger(), "Invalid is_active value for %s: %s",
diag.name.c_str(), parameter.as_string().c_str());
RCLCPP_WARN(
this->get_logger(), "Invalid is_active value for %s: %s", diag.name.c_str(),
parameter.as_string().c_str());
}
}
}

if (!param_found) {
result.successful = false;
result.reason = "Parameter not registered: " + parameter.get_name();
RCLCPP_WARN(this->get_logger(), "Attempted to set unregistered parameter: %s",
parameter.get_name().c_str());
RCLCPP_WARN(
this->get_logger(), "Attempted to set unregistered parameter: %s",
parameter.get_name().c_str());
}
}

Expand Down Expand Up @@ -214,8 +220,7 @@ DummyDiagPublisher::DummyDiagPublisher(const rclcpp::NodeOptions & options)

// Parameter Callback Handle
param_callback_handle_ = this->add_on_set_parameters_callback(
std::bind(&DummyDiagPublisher::onSetParams, this, std::placeholders::_1)
);
std::bind(&DummyDiagPublisher::onSetParams, this, std::placeholders::_1));
}

#include <rclcpp_components/register_node_macro.hpp>
Expand Down

0 comments on commit d2b9ffc

Please sign in to comment.