Skip to content

Commit

Permalink
fix: use adapi mrm state
Browse files Browse the repository at this point in the history
Signed-off-by: TetsuKawa <kawaguchitnon@icloud.com>
  • Loading branch information
TetsuKawa committed Aug 16, 2024
1 parent 07144ae commit fb42a33
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion system/leader_election_converter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ In addition, it receives a udp packet`MrmState` and publish `/system/mrm_request

| Interface Type | Interface Name | Data Type | Description |
| -------------- | ------------------------------ | ----------------------------------- | ------------------------ |
| subscriber | `/system/fail_safe/mrm_state` | `tier4_system_msgs/msg/MrmState` | MRM status of each ECU. |
| subscriber | `/system/fail_safe/mrm_state` | `autoware_adapi_v1_msgs/msg/MrmState` | MRM status of each ECU. |
| udp sender | none | `struct MrmState` | Same as above. |
| publisher | `/system/election/mrm_request` | `tier4_system_msgs/msg/MrmBehavior` | Request of MRM behavior. |
| udp receiver | none | `struct MrmRequest` | Same as above. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <autoware_adapi_v1_msgs/msg/mrm_state.hpp>
#include <tier4_system_msgs/msg/election_communication.hpp>
#include <tier4_system_msgs/msg/election_status.hpp>
#include <tier4_system_msgs/msg/mrm_state.hpp>

#include <atomic>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void MrmConverter::setSubscriber()
rclcpp::SubscriptionOptions options;
options.callback_group = callback_group_;

sub_mrm_state_ = node_->create_subscription<tier4_system_msgs::msg::MrmState>(
sub_mrm_state_ = node_->create_subscription<autoware_adapi_v1_msgs::msg::MrmState>(
"~/input/mrm_state", qos, std::bind(&MrmConverter::convertToUdp, this, std::placeholders::_1),
options);
}
Expand All @@ -77,11 +77,11 @@ void MrmConverter::setPublisher()
}

void MrmConverter::convertToUdp(
const tier4_system_msgs::msg::MrmState::ConstSharedPtr mrm_state_msg)
const autoware_adapi_v1_msgs::msg::MrmState::ConstSharedPtr mrm_state_msg)
{
MrmState mrm_state;
mrm_state.state = mrm_state_msg->state;
mrm_state.behavior = mrm_state_msg->behavior.type;
mrm_state.behavior = mrm_state_msg->behavior;

udp_mrm_state_sender_->send(mrm_state);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <rclcpp/rclcpp.hpp>

#include <tier4_system_msgs/msg/mrm_behavior.hpp>
#include <tier4_system_msgs/msg/mrm_state.hpp>
#include <autoware_adapi_v1_msgs/msg/mrm_state.hpp>

#include <atomic>
#include <memory>
Expand All @@ -33,8 +33,8 @@ namespace leader_election_converter

typedef struct MrmState
{
tier4_system_msgs::msg::MrmState::_state_type state;
tier4_system_msgs::msg::MrmBehavior::_type_type behavior;
autoware_adapi_v1_msgs::msg::MrmState::_state_type state;
autoware_adapi_v1_msgs::msg::MrmState::_behavior_type behavior;
} MrmState;

typedef struct MrmRequest
Expand All @@ -55,14 +55,14 @@ class MrmConverter

private:
void startUdpReceiver(const std::string & src_ip, const std::string & src_port);
void convertToUdp(const tier4_system_msgs::msg::MrmState::ConstSharedPtr mrm_state_msg);
void convertToUdp(const autoware_adapi_v1_msgs::msg::MrmState::ConstSharedPtr mrm_state_msg);
void convertToTopic(const MrmRequest & mrm_request);

rclcpp::Node * node_;
std::unique_ptr<UdpSender<MrmState>> udp_mrm_state_sender_;
std::unique_ptr<UdpReceiver<MrmRequest>> udp_mrm_request_receiver_;
rclcpp::CallbackGroup::SharedPtr callback_group_;
rclcpp::Subscription<tier4_system_msgs::msg::MrmState>::SharedPtr sub_mrm_state_;
rclcpp::Subscription<autoware_adapi_v1_msgs::msg::MrmState>::SharedPtr sub_mrm_state_;
rclcpp::Publisher<tier4_system_msgs::msg::MrmBehavior>::SharedPtr pub_mrm_request_;

std::thread udp_receiver_thread_;
Expand Down

0 comments on commit fb42a33

Please sign in to comment.