Apollo 10.0
自动驾驶开放平台
paramserver.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/cyber.h"
20
24
25int main(int argc, char** argv) {
27 std::shared_ptr<apollo::cyber::Node> node =
28 apollo::cyber::CreateNode("parameter");
29 auto param_server = std::make_shared<ParameterServer>(node);
30 auto param_client = std::make_shared<ParameterClient>(node, "parameter");
31 param_server->SetParameter(Parameter("int", 1));
32 Parameter parameter;
33 param_server->GetParameter("int", &parameter);
34 AINFO << "int: " << parameter.AsInt64();
35 param_client->SetParameter(Parameter("string", "test"));
36 param_client->GetParameter("string", &parameter);
37 AINFO << "string: " << parameter.AsString();
38 param_client->GetParameter("int", &parameter);
39 AINFO << "int: " << parameter.AsInt64();
40 return 0;
41}
Parameter Client is used to set/get/list parameter(s) by sending a request to ParameterServer
Parameter Service is a very important function of auto-driving.
A Parameter holds an apollo::cyber::proto::Param, It's more human-readable, you can use basic-value t...
Definition parameter.h:42
int64_t AsInt64() const
Get Paramter as an int64_t value
Definition parameter.h:352
const std::string AsString() const
Get Paramter as a string value
Definition parameter.h:356
#define AINFO
Definition log.h:42
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
int main(int argc, char **argv)