main.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #include <aws/core/Aws.h>
17 #include <aws/core/config/AWSProfileConfigLoader.h>
18 #include <aws/core/utils/logging/AWSLogging.h>
19 #include <aws/core/utils/logging/LogMacros.h>
22 #include <lex_node/lex_node.h>
23 #include <ros/ros.h>
24 
25 #include <lex_common/error_codes.h>
26 #include <lex_common/lex_common.h>
27 
28 void shutdown(const Aws::SDKOptions &options) {
29  AWS_LOG_INFO(__func__, "Shutting down Lex Node...");
30  Aws::Utils::Logging::ShutdownAWSLogging();
31  Aws::ShutdownAPI(options);
32  ros::shutdown();
33 }
34 
42 int main(int argc, char *argv[]) {
43  ros::init(argc, argv, "lex_node");
44 
45  Aws::Utils::Logging::InitializeAWSLogging(
46  Aws::MakeShared<Aws::Utils::Logging::AWSROSLogger>("lex_node"));
47  Aws::SDKOptions options;
48  Aws::InitAPI(options);
49 
50  Aws::Lex::LexNode lex_node;
51  {
52  // Build a lex interactor and give it to the lex node to use it.
53  // Lex has an internal conversation session, therefore the lex interactor
54  // should only be available for use by one point of entry.
55  auto lex_interactor = std::make_shared<Aws::Lex::LexInteractor>();
56  auto params = std::make_shared<Aws::Client::Ros1NodeParameterReader>();
57  auto error_code = Aws::Lex::BuildLexInteractor(params, *lex_interactor);
58  if (error_code != Aws::Lex::ErrorCode::SUCCESS) {
59  shutdown(options);
60  return error_code;
61  }
62  lex_node.Init(std::move(lex_interactor));
63  }
64  AWS_LOG_INFO(__func__, "Starting Lex Node...");
65 
66  // blocking here, waiting until shutdown.
67  ros::spin();
68 
69  AWS_LOG_INFO(__func__, "Shutting down Lex Node...");
70  shutdown(options);
71 
72  return Aws::Lex::ErrorCode::SUCCESS;
73 }
74 
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ErrorCode BuildLexInteractor(std::shared_ptr< Client::ParameterReaderInterface > params, LexInteractor &lex_interactor)
void shutdown(const Aws::SDKOptions &options)
Definition: main.cpp:28
ErrorCode Init(std::shared_ptr< PostContentInterface > lex_interactor)
Definition: lex_node.cpp:53
ROSCPP_DECL void spin()
ROSCPP_DECL void shutdown()
int main(int argc, char *argv[])
Definition: main.cpp:42


lex_node
Author(s): AWS RoboMaker
autogenerated on Fri Mar 5 2021 03:13:38