Skip to content

Commit

Permalink
tts upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ggh committed Aug 27, 2023
1 parent e2a7f89 commit f782cc3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
14 changes: 13 additions & 1 deletion yacyac_core/src/yac_supply_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "behaviortree_cpp/action_node.h"
#include "std_msgs/msg/header.hpp"
#include "yacyac_interface/action/supply.hpp"
#include "yacyac_interface/srv/tts.hpp"

// Custom type
struct YacSupplyList {
Expand Down Expand Up @@ -52,8 +53,11 @@ class YacSupplyCilent : public BT::SyncActionNode {

virtual BT::NodeStatus tick() override
{

std::cout << "yac supply client tick" << std::endl;
node_ = rclcpp::Node::make_shared("yac_supply_client");
TTS_client_ = node_->create_client<yacyac_interface::srv::TTS>(TTS_service_name);

auto action_client = rclcpp_action::create_client<yacyac_interface::action::Supply>(node_, "yacyac/supply_action");
// if no server is present, fail after 5 seconds
std::cout << "yac supply server wait" << std::endl;
Expand All @@ -79,6 +83,9 @@ class YacSupplyCilent : public BT::SyncActionNode {
auto goal_msg = yacyac_interface::action::Supply::Goal();
// yacyac_interface::action::Supply goal_msg;
// msg->qr_infos
auto request = std::make_shared<yacyac_interface::srv::TTS::Request>();
request->tts_str_t = "약 제조중입니다";
auto result = TTS_client_->async_send_request(request);
for (int i = 0; i < 8; i++) {
goal_msg.yac_supply_list[i] = (goal.yac_supply_list[i]);
std::cout << goal_msg.yac_supply_list[i] << " ";
Expand Down Expand Up @@ -121,7 +128,9 @@ class YacSupplyCilent : public BT::SyncActionNode {
RCLCPP_INFO(node_->get_logger(), "Yac supply aborted");
return BT::NodeStatus::FAILURE;
}

request = std::make_shared<yacyac_interface::srv::TTS::Request>();
request->tts_str_t = "약 제조가 완료되었습니다.";
result = TTS_client_->async_send_request(request);
RCLCPP_INFO(node_->get_logger(), "Yac supply return received");
return BT::NodeStatus::SUCCESS;
}
Expand All @@ -131,4 +140,7 @@ class YacSupplyCilent : public BT::SyncActionNode {

// auto node_ = std::make_shared<rclcpp::Node>("nav2_client");
rclcpp::Node::SharedPtr node_;
rclcpp::Client<yacyac_interface::srv::TTS>::SharedPtr TTS_client_;

const std::string TTS_service_name = "/yacyac/io";
};
16 changes: 7 additions & 9 deletions yacyac_servo/yacyac_servo/action_servo_ctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ def __init__(self):

def execute_callback(self, goal_handle):
print('제조 정보를 입력 받았습니다...')
self.req_io.tts_str_t = '제조 정보를 입력 받았습니다'
# self.req_io.tts_str_t = '제조 정보를 입력 받았습니다'

future = self.cli_io.call_async(self.req_io)
rp.spin_until_future_complete(self, future)
# future = self.cli_io.call_async(self.req_io)
# rp.spin_until_future_complete(self, future)

supply_list = list(goal_handle.request.yac_supply_list)
print("약 제조 리스트")
Expand All @@ -105,14 +105,12 @@ def execute_callback(self, goal_handle):
result.sequence = int(yac_sum)
print('총 ', yac_sum, '개의 약을 제조했습니다.')

self.req_io.tts_str_t = '제조가 완료 되었습니다.'
# self.req_io.tts_str_t = '제조가 완료 되었습니다.'

future = self.cli_io.call_async(self.req_io)
rp.spin_until_future_complete(self, future)
# future = self.cli_io.call_async(self.req_io)
# rp.spin_until_future_complete(self, future)

# send goal 다시 받기 위해 초기화
self._action_server = ActionServer(self, SupplyAction, "/yacyac/supply_action", self.execute_callback)



return result

Expand Down

0 comments on commit f782cc3

Please sign in to comment.