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 14, 2023
1 parent 26c537b commit 5a35f28
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 62 deletions.
2 changes: 1 addition & 1 deletion system/redundant_autoware_state_checker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ ament_auto_add_executable(redundant_autoware_state_checker
ament_auto_package(INSTALL_TO_SHARE
launch
config
)
)
2 changes: 1 addition & 1 deletion system/redundant_autoware_state_checker/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# redundant_autoware_state_checker
# redundant_autoware_state_checker
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
ros__parameters:
states_equality_timeout: 1.0
update_rate_hz: 10.0
pose_distance_threshold: 1.0
pose_distance_threshold: 1.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<node pkg="redundant_autoware_state_checker" exec="redundant_autoware_state_checker" name="redundant_autoware_state_checker"/>
<param from="$(var config_file)"/>
</node>
</launch>
</launch>
2 changes: 1 addition & 1 deletion system/redundant_autoware_state_checker/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
namespace redundant_autoware_state_checker
{

RedundantAutowareStateChecker::RedundantAutowareStateChecker() : Node("RedundantAutowareStateChecker")
RedundantAutowareStateChecker::RedundantAutowareStateChecker()
: Node("RedundantAutowareStateChecker")
{
using std::placeholders::_1;

// Params
states_equality_timeout =
this->declare_parameter("states_equality_timeout", 1.0); // 1.0s
update_rate_hz = this->declare_parameter<double>("update_rate_hz", 10.0); // 10hz
pose_distance_threshold = this->declare_parameter<double>("pose_distance_threshold", 1.0); // 1.0m
states_equality_timeout = this->declare_parameter("states_equality_timeout", 1.0); // 1.0s
update_rate_hz = this->declare_parameter<double>("update_rate_hz", 10.0); // 10hz
pose_distance_threshold =
this->declare_parameter<double>("pose_distance_threshold", 1.0); // 1.0m

// Publishers
pub_diagnostic = create_publisher<diagnostic_msgs::msg::DiagnosticArray>(
Expand All @@ -35,24 +36,31 @@ RedundantAutowareStateChecker::RedundantAutowareStateChecker() : Node("Redundant
sub_overall_mrm_state = create_subscription<autoware_adapi_v1_msgs::msg::MrmState>(
"/supervisor/fail_safe/overall/mrm_state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_mrm_state, this, _1));
sub_main_pose_with_covariance = create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
"/main/localization/pose_with_covariance", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_main_pose_with_covariance, this, _1));
sub_main_pose_with_covariance =
create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
"/main/localization/pose_with_covariance", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_main_pose_with_covariance, this, _1));
sub_sub_pose_with_covariance = create_subscription<geometry_msgs::msg::PoseWithCovarianceStamped>(
"/sub/localization/pose_with_covariance", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_sub_pose_with_covariance, this, _1));
sub_main_operation_mode_state = create_subscription<autoware_adapi_v1_msgs::msg::OperationModeState>(
"/main/api/operation_mode/state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_main_operation_mode_state, this, _1));
sub_sub_operation_mode_state = create_subscription<autoware_adapi_v1_msgs::msg::OperationModeState>(
"/sub/api/operation_mode/state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_sub_operation_mode_state, this, _1));
sub_main_localization_initialization_state = create_subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>(
"/main/api/localization/initialization_state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_main_localization_initialization_state, this, _1));
sub_sub_localization_initialization_state = create_subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>(
"/sub/api/localization/initialization_state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_sub_localization_initialization_state, this, _1));
sub_main_operation_mode_state =
create_subscription<autoware_adapi_v1_msgs::msg::OperationModeState>(
"/main/api/operation_mode/state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_main_operation_mode_state, this, _1));
sub_sub_operation_mode_state =
create_subscription<autoware_adapi_v1_msgs::msg::OperationModeState>(
"/sub/api/operation_mode/state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_sub_operation_mode_state, this, _1));
sub_main_localization_initialization_state =
create_subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>(
"/main/api/localization/initialization_state", rclcpp::QoS(1),
std::bind(
&RedundantAutowareStateChecker::on_main_localization_initialization_state, this, _1));
sub_sub_localization_initialization_state =
create_subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>(
"/sub/api/localization/initialization_state", rclcpp::QoS(1),
std::bind(
&RedundantAutowareStateChecker::on_sub_localization_initialization_state, this, _1));
sub_main_route_state = create_subscription<autoware_adapi_v1_msgs::msg::RouteState>(
"/main/api/routing/state", rclcpp::QoS(1),
std::bind(&RedundantAutowareStateChecker::on_main_route_state, this, _1));
Expand All @@ -68,7 +76,8 @@ RedundantAutowareStateChecker::RedundantAutowareStateChecker() : Node("Redundant

// Timer
const auto period_ns = rclcpp::Rate(update_rate_hz).period();
timer_ = rclcpp::create_timer(this, get_clock(), period_ns, std::bind(&RedundantAutowareStateChecker::onTimer, this));
timer_ = rclcpp::create_timer(
this, get_clock(), period_ns, std::bind(&RedundantAutowareStateChecker::onTimer, this));

// Variables
is_autonomous = true;
Expand All @@ -82,9 +91,9 @@ RedundantAutowareStateChecker::RedundantAutowareStateChecker() : Node("Redundant
void RedundantAutowareStateChecker::on_mrm_state(
const autoware_adapi_v1_msgs::msg::MrmState::ConstSharedPtr msg)
{
is_autonomous = (
msg->state == autoware_adapi_v1_msgs::msg::MrmState::NORMAL &&
msg->behavior == autoware_adapi_v1_msgs::msg::MrmState::NONE);
is_autonomous =
(msg->state == autoware_adapi_v1_msgs::msg::MrmState::NORMAL &&
msg->behavior == autoware_adapi_v1_msgs::msg::MrmState::NONE);
}

void RedundantAutowareStateChecker::on_main_pose_with_covariance(
Expand Down Expand Up @@ -197,9 +206,12 @@ void RedundantAutowareStateChecker::onTimer()
if (is_equal_localization_initialization_state()) {
last_time_localization_initialization_state_is_equal = now;
} else {
if ((now - last_time_localization_initialization_state_is_equal).seconds() > states_equality_timeout) {
if (
(now - last_time_localization_initialization_state_is_equal).seconds() >
states_equality_timeout) {
diag_status_msg.level = diagnostic_msgs::msg::DiagnosticStatus::ERROR;
diag_status_msg.message += "Main and Sub ECUs' localization initialization states are different.";
diag_status_msg.message +=
"Main and Sub ECUs' localization initialization states are different.";
}
}

Expand Down Expand Up @@ -252,7 +264,10 @@ bool RedundantAutowareStateChecker::is_equal_operation_mode_stete()

// Currently, following menbers are used to check the equality

Check warning on line 265 in system/redundant_autoware_state_checker/src/redundant_autoware_state_checker.cpp

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (menbers)

Check warning on line 265 in system/redundant_autoware_state_checker/src/redundant_autoware_state_checker.cpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (menbers)
if (main_operation_mode_state->mode != sub_operation_mode_state->mode) return false;
if (main_operation_mode_state->is_autoware_control_enabled != sub_operation_mode_state->is_autoware_control_enabled) return false;
if (
main_operation_mode_state->is_autoware_control_enabled !=
sub_operation_mode_state->is_autoware_control_enabled)
return false;

return true;
}
Expand All @@ -264,7 +279,9 @@ bool RedundantAutowareStateChecker::is_equal_localization_initialization_state()
if (!has_subscribed_sub_localization_initialization_state) return true;

// Currently, following menbers are used to check the equality

Check warning on line 281 in system/redundant_autoware_state_checker/src/redundant_autoware_state_checker.cpp

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (menbers)

Check warning on line 281 in system/redundant_autoware_state_checker/src/redundant_autoware_state_checker.cpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (menbers)
if (main_localization_initialization_state->state != main_localization_initialization_state->state) return false;
if (
main_localization_initialization_state->state != main_localization_initialization_state->state)
return false;

return true;
}
Expand Down Expand Up @@ -293,8 +310,7 @@ bool RedundantAutowareStateChecker::is_equal_route()
return true;
}

} // namespace redundant_autoware_state_checker

} // namespace redundant_autoware_state_checker

int main(int argc, char ** argv)
{
Expand All @@ -306,4 +322,4 @@ int main(int argc, char ** argv)
executor.remove_node(node);
rclcpp::shutdown();
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef REDUNDANT_AUTOWARE_STATE_CHECKER_
#define REDUNDANT_AUTOWARE_STATE_CHECKER_
#ifndef REDUNDANT_AUTOWARE_STATE_CHECKER_HPP_
#define REDUNDANT_AUTOWARE_STATE_CHECKER_HPP_

#include <diagnostic_msgs/msg/diagnostic_array.hpp>
#include "rclcpp/rclcpp.hpp"

#include <autoware_adapi_v1_msgs/msg/localization_initialization_state.hpp>
#include <autoware_adapi_v1_msgs/msg/mrm_state.hpp>
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>
#include <autoware_adapi_v1_msgs/msg/operation_mode_state.hpp>
#include <autoware_adapi_v1_msgs/msg/localization_initialization_state.hpp>
#include <autoware_adapi_v1_msgs/msg/route_state.hpp>
#include <autoware_adapi_v1_msgs/msg/route.hpp>

#include "rclcpp/rclcpp.hpp"
#include <autoware_adapi_v1_msgs/msg/route_state.hpp>
#include <diagnostic_msgs/msg/diagnostic_array.hpp>
#include <geometry_msgs/msg/pose_with_covariance_stamped.hpp>

namespace redundant_autoware_state_checker
{
Expand All @@ -36,29 +36,41 @@ class RedundantAutowareStateChecker : public rclcpp::Node
private:
// Publishers
rclcpp::Publisher<diagnostic_msgs::msg::DiagnosticArray>::SharedPtr pub_diagnostic;

// Subscribers
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::MrmState>::SharedPtr sub_overall_mrm_state;
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr sub_main_pose_with_covariance;
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr sub_sub_pose_with_covariance;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::OperationModeState>::SharedPtr sub_main_operation_mode_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::OperationModeState>::SharedPtr sub_sub_operation_mode_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>::SharedPtr sub_main_localization_initialization_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>::SharedPtr sub_sub_localization_initialization_state;
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr
sub_main_pose_with_covariance;
rclcpp::Subscription<geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr
sub_sub_pose_with_covariance;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::OperationModeState>::SharedPtr
sub_main_operation_mode_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::OperationModeState>::SharedPtr
sub_sub_operation_mode_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>::SharedPtr
sub_main_localization_initialization_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::LocalizationInitializationState>::SharedPtr
sub_sub_localization_initialization_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::RouteState>::SharedPtr sub_main_route_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::RouteState>::SharedPtr sub_sub_route_state;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::Route>::SharedPtr sub_main_route;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::Route>::SharedPtr sub_sub_route;

// Callbacks
void onTimer();
void on_main_pose_with_covariance(const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg);
void on_sub_pose_with_covariance(const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg);
void on_main_pose_with_covariance(
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg);
void on_sub_pose_with_covariance(
const geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr msg);
void on_mrm_state(const autoware_adapi_v1_msgs::msg::MrmState::ConstSharedPtr msg);
void on_main_operation_mode_state(const autoware_adapi_v1_msgs::msg::OperationModeState::ConstSharedPtr msg);
void on_sub_operation_mode_state(const autoware_adapi_v1_msgs::msg::OperationModeState::ConstSharedPtr msg);
void on_main_localization_initialization_state(const autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr msg);
void on_sub_localization_initialization_state(const autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr msg);
void on_main_operation_mode_state(
const autoware_adapi_v1_msgs::msg::OperationModeState::ConstSharedPtr msg);
void on_sub_operation_mode_state(
const autoware_adapi_v1_msgs::msg::OperationModeState::ConstSharedPtr msg);
void on_main_localization_initialization_state(
const autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr msg);
void on_sub_localization_initialization_state(
const autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr msg);
void on_main_route_state(const autoware_adapi_v1_msgs::msg::RouteState::ConstSharedPtr msg);
void on_sub_route_state(const autoware_adapi_v1_msgs::msg::RouteState::ConstSharedPtr msg);
void on_main_route(const autoware_adapi_v1_msgs::msg::Route::ConstSharedPtr msg);
Expand All @@ -83,8 +95,10 @@ class RedundantAutowareStateChecker : public rclcpp::Node
geometry_msgs::msg::PoseWithCovarianceStamped::ConstSharedPtr sub_pose_with_covariance;
autoware_adapi_v1_msgs::msg::OperationModeState::ConstSharedPtr main_operation_mode_state;
autoware_adapi_v1_msgs::msg::OperationModeState::ConstSharedPtr sub_operation_mode_state;
autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr main_localization_initialization_state;
autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr sub_localization_initialization_state;
autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr
main_localization_initialization_state;
autoware_adapi_v1_msgs::msg::LocalizationInitializationState::ConstSharedPtr
sub_localization_initialization_state;
autoware_adapi_v1_msgs::msg::RouteState::ConstSharedPtr main_route_state;
autoware_adapi_v1_msgs::msg::RouteState::ConstSharedPtr sub_route_state;
autoware_adapi_v1_msgs::msg::Route::ConstSharedPtr main_route;
Expand All @@ -109,6 +123,6 @@ class RedundantAutowareStateChecker : public rclcpp::Node
bool is_equal_route();
};

} // namespace redundant_autoware_state_checker
} // namespace redundant_autoware_state_checker

#endif // REDUNDANT_AUTOWARE_STATE_CHECKER_
#endif // REDUNDANT_AUTOWARE_STATE_CHECKER_HPP_

0 comments on commit 5a35f28

Please sign in to comment.