CfgMgr::Get

Description

Reads configuration parameters by parameter name or namespace.

Prototype

uint32_t CfgMgr::Get(const std::string &kParam, T &value, const std::string &srv = "")

Function Security Level

ASIL-D

Parameters

Parameter

Input/Output

Description

kParam

Input

Key, which is a parameter name or namespace, for example, /ros/use_sim_time or /ros. Starting with a slash (/) is not mandatory.

srv

Input

Parameter group, which corresponds to a resource file. If it is not specified, parameters are obtained from the parameter groups on which you have the permission by default, which reduces the efficiency.

value

Output

Used to receive the value of a parameter. You can specify the parameter type. For details about the supported types, see "Usage".

Returns

The return value is of the uint32_t type, indicating whether parameters are successfully obtained. If the operation is successful, CFGMGR_SUCCESS is returned. If the operation fails, an error code is returned.

Usage

  • Non-template functions can overload for various types. The value type can be std::string, double, float, int, bool, std::vector<std::string>, std::vector<double>, std::vector<float>, std::vector<int>, std::vector<bool>, std::map<std::string, std::string>, std::map<std::string, double>, std::map<std::string, float>, std::map<std::string, int>, and std::map<std::string, bool>.
  • When a parameter is obtained based on the namespace, the value type must be map. If parameter types in this namespace are different, the value type must be std::map<std::string, std::string>, indicating a key-value pair.
  • The parameter group refers to group under yaml_path, which must correspond to the virtual resource file for permission management.

Precautions

  • The key must be less than 128 bytes, and a single value must be less than 256 bytes.
  • After obtaining parameters, you are advised to determine their validity based on the service logic.
  • For parameters of the map type, the original data of input parameters is not cleared during the Get operation. Instead, the data is modified or added.
  • If a parameter fails to be obtained or is invalid, determine whether to report the fault or perform other operations.
  • The interface may return a failure message for several reasons, including the absence of permissions and parameters, parameter loading failure, and data transmission failure (management plane).