cras_cpp_common
A Czech-army knife for ROS code written in C++.
README
cras_cpp_common
A Czech-army knife for ROS 2 code written in C++.
The aim of this package is to provide some missing utility functions to rclcpp. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.
This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.
Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.
Support and Build Status
This package is always tested for architectures amd64 and arm64.
This package is supported on ROS 1 Melodic and Noetic (on branch master) even after their End of Life.
This package is supported on ROS 2 Jazzy and Klited (on branch ros2). Humble and Foxy are not and will not be supported.
List of provided libraries
The ROS 2 port is still in its early stage. You will find more modules in this package, but their build and tests are disabled in CMake. Only modules listed here are actually available.
c_api: Utilities for writing a C API for your packages.
expected: Provides forward compatibility forstd::expected.
log_utils: Unified access to theROS_*andNODELET_*logging macros. This is more an internal utility of this package.
rate_limiter: Library for intelligent rate-limiting of events (mainly messages). So far it implements the algorithm fromtopic_tools throttle(not very good), and token bucket algorithm (pretty good for most cases).set_utils: ProvidesisSetIntersectionEmpty()working on a pair ofstd::sets.small_map: ProvidesSmallMapandSmallSet, variants ofstd::mapimplemented usingstd::listwhich are append-only and lock-free for reading.string_utils: Provides many string manipulation helpers you’ve always dreamed of. Universalto_string()that converts almost anything to a sensible string.startsWith()/endsWith(),replace(),contains(),split()/join(),format()(likesprintf()but without hassle and onstd::string),stripLeading()/stripTrailing(),removePrefix()/removeSuffix(),parseFloat()/parseDouble()(convert string to double independent of locale!),parseInt32()and friends (parse many textual representations to an integer, or with specified radix).parseTime()andparseDuration()to parse textual date/time strings toros::Timeandros::Duration.toValidRosName()to convert any input string to a valid ROS graph resource name.suppress_warnings: Unified macros that suppress various compiler warnings for a piece of code.test_utils: Provide a hack that allows loading a locally-defined nodelet without the need to register it via package.xml.tf2_utils:getRoll(),getPitch(),getYaw(),getRPY()from atf2::Quaternionorgeometry_msgs::Quaternion!
thread_utils:getThreadName()andsetThreadName().Also provides
ReverseSemaphoresynchronization primitive that counts towards zero and notifies when empty.
time_utils:remainingTime()tells you how much of a timeout remains if you started waiting at some specified time. Conversions betweenrclcpp::Rate()and frequency. Multiplication and division operators for ROS duration types. Seamless conversions between various time representations usingconvertTime(). Similarly,convertDuration().type_utils: Provides compile-time and run-timegetTypeName()helper that converts a C++ type to a string containing its name.