Apollo 10.0
自动驾驶开放平台
listener.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. 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 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#include "cyber/examples/proto/examples.pb.h"
18
19#include "cyber/cyber.h"
20
22 const std::shared_ptr<apollo::cyber::examples::proto::Chatter>& msg) {
23 AINFO << "Received message seq-> " << msg->seq();
24 AINFO << "msgcontent->" << msg->content();
25}
26
27int main(int argc, char* argv[]) {
28 // init cyber framework
29 apollo::cyber::Init(argv[0]);
30 // create listener node
31 auto listener_node = apollo::cyber::CreateNode("listener");
32 // create listener
33 auto listener =
34 listener_node->CreateReader<apollo::cyber::examples::proto::Chatter>(
35 "channel/chatter", MessageCallback);
37 return 0;
38}
int main(int argc, char *argv[])
Definition listener.cc:27
void MessageCallback(const std::shared_ptr< apollo::cyber::examples::proto::Chatter > &msg)
Definition listener.cc:21
#define AINFO
Definition log.h:42
void WaitForShutdown()
Definition state.h:50
bool Init(const char *binary_name, const std::string &dag_info)
Definition init.cc:98
std::unique_ptr< Node > CreateNode(const std::string &node_name, const std::string &name_space)
Definition cyber.cc:33