Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
utils.hpp
Go to the documentation of this file.
1/**
2 * \verbatim
3 * ___ ___
4 * \ \ / /
5 * \ \/ / Copyright (c) Fixposition AG
6 * / /\ \ License: see the LICENSE file
7 * /__/ \__\
8 * \endverbatim
9 *
10 * @file
11 * @brief Fixposition SDK: ROS1 utilities
12 *
13 * @page FPSDK_ROS1_UTILS ROS1 utilities
14 *
15 * **API**: fpsdk_ros1/utils.hpp and fpsdk::ros1::utils
16 *
17 */
18#ifndef __FPSDK_ROS1_UTILS_HPP__
19#define __FPSDK_ROS1_UTILS_HPP__
20
21/* LIBC/STL */
22#include <cstring>
23#include <string>
24#include <vector>
25
26/* EXTERNAL */
27#include <fpsdk_ros1/ext/ros_console.hpp>
28#include <fpsdk_ros1/ext/ros_time.hpp>
29
30/* Fixposition SDK */
31#include <fpsdk_common/time.hpp>
32
33/* PACKAGE */
34
35namespace fpsdk {
36namespace ros1 {
37/**
38 * @brief ROS1 utilities
39 */
40namespace utils {
41/* ****************************************************************************************************************** */
42
43/**
44 * @brief Redirect fp:common::logging to ROS console
45 *
46 * This configures the fpsdk::common::logging facility to output via the ROS console. This does *not* configure the ROS
47 * console (logger level, logger name, etc.).
48 *
49 * The mapping of fpsdk::common::logging::LoggingLevel to ros::console::levels is as follows:
50 *
51 * - TRACE and DEBUG --> DEBUG
52 * - INFO and NOTICE --> INFO
53 * - WARNING --> WARN
54 * - ERROR --> ERROR
55 * - FATAL --> FATAL
56 *
57 * @param[in] logger_name The name of the logger. The default value should give the caller package's
58 * ROSCONSOLE_DEFAULT_NAME, for example, "ros1_fpsdk_demo". That is, typically this argument
59 * should be left empty (the default value).
60 */
61void RedirectLoggingToRosConsole(const char* logger_name = ROSCONSOLE_DEFAULT_NAME /* = caller's package name */);
62
63/**
64 * @brief Loads a parameter from the ROS parameter server (int)
65 *
66 * @param[in] name The parameter name
67 * @param[out] value The value
68 *
69 * @returns true if parameter found and loaded, false otherwise
70 */
71bool LoadRosParam(const std::string& name, int& value);
72
73/**
74 * @brief Loads a parameter from the ROS parameter server (string)
75 *
76 * @param[in] name The parameter name
77 * @param[out] value The value
78 *
79 * @returns true if parameter found and loaded, false otherwise
80 */
81bool LoadRosParam(const std::string& name, std::string& value);
82
83/**
84 * @brief Loads a parameter from the ROS parameter server (bool)
85 *
86 * @param[in] name The parameter name
87 * @param[out] value The value
88 *
89 * @returns true if parameter found and loaded, false otherwise
90 */
91bool LoadRosParam(const std::string& name, bool& value);
92
93/**
94 * @brief Loads a parameter from the ROS parameter server (float)
95 *
96 * @param[in] name The parameter name
97 * @param[out] value The value
98 *
99 * @returns true if parameter found and loaded, false otherwise
100 */
101bool LoadRosParam(const std::string& name, float& value);
102
103/**
104 * @brief Loads a parameter from the ROS parameter server (double)
105 *
106 * @param[in] name The parameter name
107 * @param[out] value The value
108 *
109 * @returns true if parameter found and loaded, false otherwise
110 */
111bool LoadRosParam(const std::string& name, double& value);
112
113/**
114 * @brief Loads a parameter from the ROS parameter server (list of strings)
115 *
116 * @param[in] name The parameter name
117 * @param[out] value The value
118 *
119 * @returns true if parameter found and loaded, false otherwise
120 */
121bool LoadRosParam(const std::string& name, std::vector<std::string>& value);
122
123/**
124 * @brief Convert to ROS time (atomic -> POSIX)
125 *
126 * @param[in] time The Time object (atomic)
127 *
128 * @returns the ROS time object (POSIX)
129 */
130ros::Time ConvTime(const fpsdk::common::time::Time& time);
131
132/**
133 * @brief Convert from ROS time (POSIX -> atomic)
134 *
135 * @param[in] time The ROS time object (POSIX)
136 *
137 * @returns the Time object (atomic)
138 */
139fpsdk::common::time::Time ConvTime(const ros::Time& time);
140
141/* ****************************************************************************************************************** */
142} // namespace utils
143} // namespace ros1
144} // namespace fpsdk
145#endif // __FPSDK_ROS1_UTILS_HPP__
bool LoadRosParam(const std::string &name, int &value)
Loads a parameter from the ROS parameter server (int)
void RedirectLoggingToRosConsole(const char *logger_name=ROSCONSOLE_DEFAULT_NAME)
Redirect fp:common::logging to ROS console.
ros::Time ConvTime(const fpsdk::common::time::Time &time)
Convert to ROS time (atomic -> POSIX)
Fixposition SDK.
Fixposition SDK: Time utilities.