Carma-platform v4.11.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
log.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021-2022 LEIDOS.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
6 * 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, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
14 * the License.
15 */
16
18
19namespace basic_autonomy
20{
21
22namespace
23{
24// Function-local static is initialized once and is thread-safe (C++11).
25rclcpp::Logger & module_logger()
26{
27 static rclcpp::Logger logger = rclcpp::get_logger("basic_autonomy");
28 return logger;
29}
30} // anonymous namespace
31
32rclcpp::Logger get_logger() { return module_logger(); }
33void set_logger(rclcpp::Logger logger) { module_logger() = logger; }
34
35namespace log
36{
40std::string basicPointToStream(lanelet::BasicPoint2d point)
41{
42 std::ostringstream out;
43 out << point.x() << ", " << point.y();
44 return out.str();
45}
50{
51 std::ostringstream out;
52 out << "Point: " << basicPointToStream(point.point) << " Speed: " << point.speed;
53 return out.str();
54}
55
59void printDoublesPerLineWithPrefix(const std::string& prefix, const std::vector<double>& values)
60{
61 for (const auto& value : values)
62 {
63 RCLCPP_DEBUG_STREAM(basic_autonomy::get_logger(), prefix << value);
64 }
65}
66
67} // namespace log
68} // namespace basic_autonomy
void printDoublesPerLineWithPrefix(const std::string &prefix, const std::vector< double > &values)
Print a RCLCPP_DEBUG_STREAM for each value in values where the printed value is << prefix << value.
Definition: log.cpp:59
std::string basicPointToStream(lanelet::BasicPoint2d point)
Helper function to convert a lanelet::BasicPoint2d to a string.
Definition: log.cpp:40
std::string pointSpeedPairToStream(waypoint_generation::PointSpeedPair point)
Helper function to convert a PointSpeedPair to a string.
Definition: log.cpp:49
void set_logger(rclcpp::Logger logger)
Replace the module-level logger used by all basic_autonomy functions.
Definition: log.cpp:33
rclcpp::Logger get_logger()
Return the module-level logger used by all basic_autonomy functions.
Definition: log.cpp:32