get ros2 version in C++
Are there any #define to know which version of ROS2 I'm using in C++ source?
Are there any #define to know which version of ROS2 I'm using in C++ source?
There are no defines in C/C++ out of the box.
That being said if your package depends on ros_environment
the following environment variables are set: ROS_VERSION
(which is either 1
or 2
), ROS_DISTRO
(e.g. dashing
or melodic
), etc.
You can use either to set compiler definitions in your package to be used in conditionals.
If you need more fine grain control you can also use the exact version number of each dependency (e.g. https://github.com/ros2/rmw_cyclonedd...).
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2019-11-01 16:46:52 -0600
Seen: 201 times
Last updated: Nov 02 '19
How to get and send serialized Request and Response in rclcpp ROS2
ROS2 Package using both C++ and Python
rosidl_generator_py UnsupportedTypeSupport: Could not import 'rosidl_typesupport_c' for package
ROS 2 Bouncy : Node, Log and Classes best practice
ROS on Windows: Subsystem for Linux, ROS 2 or ROS with Docker on Windows
How to read a bag file in ROS2?
ros2 launch_test gtest parameters argument
ROS2 Talker Listener not communicating
An error with building ros2 and a question about rviz
ros1_bridge fails to generate service when custom message from the same package is used