Skip to content

Commit

Permalink
feat: replace node
Browse files Browse the repository at this point in the history
Signed-off-by: TetsuKawa <[email protected]>
  • Loading branch information
TetsuKawa committed Dec 1, 2024
1 parent 5ecb9aa commit b9fe262
Show file tree
Hide file tree
Showing 18 changed files with 57 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@
<include file="$(find-pkg-share control_cmd_switcher)/launch/control_cmd_switcher.launch.xml"/>
</group>

<!-- Leader Election Converter-->
<!-- Redundancy Switcher Interface-->
<group>
<include file="$(find-pkg-share leader_election_converter)/launch/leader_election_converter.launch.xml">
<arg name="param_file" value="$(find-pkg-share autoware_launch)/config/system/leader_election_converter/leader_election_converter.param.yaml"/>
<include file="$(find-pkg-share redundancy_switcher_interface)/launch/redundancy_switcher_interface.launch.xml">
<arg name="param_file" value="$(find-pkg-share autoware_launch)/config/system/redundancy_switcher_interface/redundancy_switcher_interface.param.yaml"/>
<arg name="input_mrm_state" value="/system/fail_safe/mrm_state"/>
</include>
</group>
Expand Down
4 changes: 1 addition & 3 deletions launch/tier4_system_launch/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

<exec_depend>component_state_monitor</exec_depend>
<exec_depend>control_cmd_switcher</exec_depend>
<exec_depend>control_cmd_switcher</exec_depend>
<exec_depend>emergency_handler</exec_depend>
<exec_depend>leader_election_converter</exec_depend>
<exec_depend>leader_election_converter</exec_depend>
<exec_depend>redundancy_switcher_interface</exec_depend>
<exec_depend>system_error_monitor</exec_depend>
<exec_depend>system_monitor</exec_depend>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.14)
project(leader_election_converter)
project(redundancy_switcher_interface)

find_package(autoware_cmake REQUIRED)
autoware_package()
Expand All @@ -15,14 +15,14 @@ target_include_directories(common_converter PRIVATE
)

ament_auto_add_library(${PROJECT_NAME} SHARED
src/node/leader_election_converter.cpp
src/node/redundancy_switcher_interface.cpp
)
target_include_directories(${PROJECT_NAME} PRIVATE src/common/converter)

target_link_libraries(${PROJECT_NAME} common_converter)

rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "leader_election_converter::LeaderElectionConverter"
PLUGIN "redundancy_switcher_interface::RedundancySwitcherInterface"
EXECUTABLE ${PROJECT_NAME}_node
EXECUTOR MultiThreadedExecutor
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# leader_election_converter
# redundancy_switcher_interface

## Overview

The leader election converter node is responsible for relaying UDP packets and ROS2 topics between the leader_election invoked by systemd and Autoware executed on ROS2.
The redundancy switcher interface node is responsible for relaying UDP packets and ROS2 topics between the redundancy_switcher invoked by systemd and Autoware executed on ROS2.

## availability converter

Expand Down Expand Up @@ -42,9 +42,9 @@ The log converter receive udp packets into a structure called `ElectionCommuni
| udp receiver | none | `struct ElectionCommunication` | messages among election nodes. |
| udp receiver | none | `struct ElectionStatus` | Leader Election status. |
| publisher | `/system/election/communication` | `tier4_system_msgs/msg/ElectionCommunication` | messages among election nodes. |
| publisher | `/system/election/status` | `tier4_system_msgs/msg/MrmState` | Leader Election status. |
| publisher | `/system/election/status` | `autoware_adapi_v1_msgs/msg/MrmState` | Leader Election status. |
| publisher | `/system/fail_safe/over_all/mrm_state` | `autoware_adapi_v1_msgs/msg/mrm_state` | System-wide MRM status. |

## Parameters

{{ json_to_markdown("system/leader_election_converter/schema/leader_election_converter.schema.json") }}
{{ json_to_markdown("system/redundancy_switcher_interface/schema/redundancy_switcher_interface.schema.json") }}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<launch>
<arg name="param_file" default="$(find-pkg-share leader_election_converter)/config/leader_election_converter.param.yaml"/>
<arg name="param_file" default="$(find-pkg-share redundancy_switcher_interface)/config/redundancy_switcher_interface.param.yaml"/>
<arg name="input_control_mode" default="/vehicle/status/control_mode"/>
<arg name="input_operation_mode_availability" default="/system/operation_mode/availability"/>
<arg name="input_mrm_state" default="/system/fail_safe/mrm_state"/>
<arg name="output_mrm_request" default="/system/mrm_request"/>
<arg name="output_over_all_mrm_state" default="/system/fail_safe/over_all/mrm_state"/>
<arg name="output_election_communication" default="/system/election/communication"/>
<arg name="output_election_status" default="/system/election/status"/>
<node pkg="leader_election_converter" exec="leader_election_converter_node">
<node pkg="redundancy_switcher_interface" exec="redundancy_switcher_interface_node">
<param from="$(var param_file)"/>
<remap from="~/input/control_mode" to="$(var input_control_mode)"/>
<remap from="~/input/operation_mode_availability" to="$(var input_operation_mode_availability)"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>leader_election_converter</name>
<name>redundancy_switcher_interface</name>
<version>0.1.0</version>
<description>The leader election converter package</description>
<description>The redundancy switcher interface package</description>
<maintainer email="[email protected]">TetsuKawa</maintainer>
<license>Apache License 2.0</license>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Parameters for leader election converter",
"title": "Parameters for redundancy switcher interface",
"type": "object",
"definitions": {
"leader_election_converter": {
"redundancy_switcher_interface": {
"type": "object",
"properties": {
"availability_dest_ip": {
Expand Down Expand Up @@ -77,7 +77,7 @@
"type": "object",
"properties": {
"ros__parameters": {
"$ref": "#/definitions/leader_election_converter"
"$ref": "#/definitions/redundancy_switcher_interface"
}
},
"required": ["ros__parameters"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <memory>
#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

AvailabilityConverter::AvailabilityConverter(rclcpp::Node * node) : node_(node)
Expand Down Expand Up @@ -80,4 +80,4 @@ void AvailabilityConverter::convertToUdp(
}
}

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <memory>
#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

struct Availability
Expand Down Expand Up @@ -62,6 +62,6 @@ class AvailabilityConverter
sub_operation_mode_availability_;
};

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface

#endif // COMMON__CONVERTER__AVAILABILITY_CONVERTER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <memory>
#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

LogConverter::LogConverter(rclcpp::Node * node)
Expand Down Expand Up @@ -103,7 +103,8 @@ void LogConverter::convertElectionCommunicationToTopic(const ElectionCommunicati
msg.node_id = (node_msg.msg >> 8) & 0xFF;
msg.type = node_msg.msg & 0xFF;
msg.term = (node_msg.msg >> 16) & 0xFF;
msg.link = (node_msg.msg >> 24) & 0xFF;
msg.path = (node_msg.msg >> 24) & 0x0F;
msg.link = (node_msg.msg >> 28) & 0x0F;
msg.heartbeat = (node_msg.msg >> 56) & 0x0F;
msg.checksum = (node_msg.msg >> 60) & 0x0F;
pub_election_communication_->publish(msg);
Expand All @@ -112,13 +113,13 @@ void LogConverter::convertElectionCommunicationToTopic(const ElectionCommunicati
void LogConverter::convertElectionStatusToTopic(const ElectionStatus & status)
{
tier4_system_msgs::msg::ElectionStatus election_status;
autoware_adapi_v1_msgs::msg::MrmState mrm_status;
autoware_adapi_v1_msgs::msg::MrmState mrm_state;

election_status.stamp = node_->now();
election_status.leader_id = status.leader_id;
election_status.path_info = status.path_info;
election_status.mrm_state.state = status.state;
election_status.mrm_state.behavior.type = status.behavior;
election_status.mrm_state.state = status.mrm_state.state;
election_status.mrm_state.behavior = status.mrm_state.behavior;
election_status.election_start_count = status.election_start_count;
election_status.in_election = status.in_election;
election_status.has_received_availability = status.has_received_availability;
Expand All @@ -130,10 +131,10 @@ void LogConverter::convertElectionStatusToTopic(const ElectionStatus & status)
election_status.is_sub_vcu_connected = status.is_sub_vcu_connected;
pub_election_status_->publish(election_status);

mrm_status.stamp = node_->now();
mrm_status.state = status.state;
mrm_status.behavior = status.behavior;
pub_over_all_mrm_state_->publish(mrm_status);
mrm_state.stamp = node_->now();
mrm_state.state = status.mrm_state.state;
mrm_state.behavior = mrm_state.behavior;
pub_over_all_mrm_state_->publish(mrm_state);
}

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <string>
#include <thread>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

typedef struct ElectionCommunication
Expand All @@ -41,8 +41,7 @@ typedef struct ElectionStatus
{
tier4_system_msgs::msg::ElectionStatus::_leader_id_type leader_id;
tier4_system_msgs::msg::ElectionStatus::_path_info_type path_info;
tier4_system_msgs::msg::MrmState::_state_type state;
tier4_system_msgs::msg::MrmBehavior::_type_type behavior;
tier4_system_msgs::msg::ElectionStatus::_mrm_state_type mrm_state;
tier4_system_msgs::msg::ElectionStatus::_election_start_count_type election_start_count;
tier4_system_msgs::msg::ElectionStatus::_in_election_type in_election;
tier4_system_msgs::msg::ElectionStatus::_has_received_availability_type has_received_availability;
Expand Down Expand Up @@ -86,6 +85,6 @@ class LogConverter
std::atomic<bool> is_election_status_running_;
};

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface

#endif // COMMON__CONVERTER__LOG_CONVERTER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <memory>
#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

MrmConverter::MrmConverter(rclcpp::Node * node) : node_(node), is_udp_receiver_running_(true)
Expand Down Expand Up @@ -95,4 +95,4 @@ void MrmConverter::convertToTopic(const MrmRequest & mrm_request)
pub_mrm_request_->publish(mrm_request_msg);
}

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <string>
#include <thread>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

typedef struct MrmState
Expand Down Expand Up @@ -69,6 +69,6 @@ class MrmConverter
std::atomic<bool> is_udp_receiver_running_;
};

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface

#endif // COMMON__CONVERTER__MRM_CONVERTER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <stdexcept>
#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

template <typename T>
Expand Down Expand Up @@ -146,6 +146,6 @@ void UdpReceiver<T>::receive()
}
}

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface

#endif // COMMON__CONVERTER__UDP_RECEIVER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <stdexcept>
#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

template <typename T>
Expand Down Expand Up @@ -77,6 +77,6 @@ void UdpSender<T>::send(const T & data)
}
}

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface

#endif // COMMON__CONVERTER__UDP_SENDER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "leader_election_converter.hpp"
#include "redundancy_switcher_interface.hpp"

#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

LeaderElectionConverter::LeaderElectionConverter(const rclcpp::NodeOptions & node_options)
: Node("leader_election_converter", node_options),
RedundancySwitcherInterface::RedundancySwitcherInterface(const rclcpp::NodeOptions & node_options)
: Node("redundancy_switcher_interface", node_options),
availability_converter_(this),
mrm_converter_(this),
log_converter_(this)
Expand Down Expand Up @@ -56,7 +56,7 @@ LeaderElectionConverter::LeaderElectionConverter(const rclcpp::NodeOptions & nod
log_converter_.setUdpElectionStatusReceiver(election_status_src_ip_, election_status_src_port_);
}

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(leader_election_converter::LeaderElectionConverter)
RCLCPP_COMPONENTS_REGISTER_NODE(redundancy_switcher_interface::RedundancySwitcherInterface)
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NODE__LEADER_ELECTION_CONVERTER_HPP_
#define NODE__LEADER_ELECTION_CONVERTER_HPP_
#ifndef NODE__REDUNDANCY_SWITCHER_INTERFACE_HPP_
#define NODE__REDUNDANCY_SWITCHER_INTERFACE_HPP_

#include "availability_converter.hpp"
#include "log_converter.hpp"
Expand All @@ -24,13 +24,13 @@
#include <memory>
#include <string>

namespace leader_election_converter
namespace redundancy_switcher_interface
{

class LeaderElectionConverter : public rclcpp::Node
class RedundancySwitcherInterface : public rclcpp::Node
{
public:
explicit LeaderElectionConverter(const rclcpp::NodeOptions & node_options);
explicit RedundancySwitcherInterface(const rclcpp::NodeOptions & node_options);

private:
std::string availability_dest_ip_;
Expand All @@ -49,6 +49,6 @@ class LeaderElectionConverter : public rclcpp::Node
LogConverter log_converter_;
};

} // namespace leader_election_converter
} // namespace redundancy_switcher_interface

#endif // NODE__LEADER_ELECTION_CONVERTER_HPP_
#endif // NODE__REDUNDANCY_SWITCHER_INTERFACE_HPP_

0 comments on commit b9fe262

Please sign in to comment.