|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | 3.0.4 |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |
Dependant Packages
Launch files
Messages
Services
Plugins
Recent questions tagged jsk_ros1_ros2_compat at Robotics Stack Exchange
|
jsk_ros1_ros2_compat package from jsk_common repoaudio_video_recorder jsk_common dynamic_tf_publisher jsk_data jsk_ros1_ros2_compat image_view2 jsk_rosbag_tools jsk_tools jsk_topic_tools |
ROS Distro
|
Package Summary
| Version | 3.0.4 |
| License | BSD |
| Build type | CATKIN |
| Use | RECOMMENDED |
Repository Summary
| Checkout URI | https://github.com/jsk-ros-pkg/jsk_common.git |
| VCS Type | git |
| VCS Version | master |
| Last Updated | 2026-11-04 |
| Dev Status | UNMAINTAINED |
| Released | RELEASED |
| Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Package Description
Maintainers
- Kei Okada
Authors
jsk_ros1_ros2_compat
Shared ROS1 (roscpp/rospy) / ROS2 (rclcpp/rclpy) compatibility helpers, so that a package can keep one source tree that builds and runs on both, with the ROS1 code left as close to the original as possible.
Porting style
- One
package.xml/CMakeLists.txtbranched on$ROS_VERSION.-
package.xml:condition="$ROS_VERSION == 1"/"== 2"on the dependencies and on<build_type>in<export>. -
CMakeLists.txt: keep the ROS1 lines byte-identical (no re-indentation), e.g. prepend the ROS2 build and wrap the original inelse()/endif():
-
if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 3.8)
project(foo)
find_package(ament_cmake REQUIRED)
find_package(jsk_ros1_ros2_compat REQUIRED)
jsk_ros1_ros2_compat_install_python(PROGRAMS scripts/foo_node.py)
ament_package()
else() # if("$ENV{ROS_VERSION}" EQUAL 2)
cmake_minimum_required(VERSION 2.8.3)
project(foo)
... # the ROS1 original, unchanged
endif() # if("$ENV{ROS_VERSION}" EQUAL 2)
- Python nodes call
ros_compat.xxx(node, ...)instead ofrospy.xxx(...), wherenodeisNoneon ROS1 and therclpy.node.Nodeon ROS2.
Python: jsk_ros1_ros2_compat.rospy_rclpy_compat
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
if __name__ == '__main__':
node = ros_compat.init_node('foo') # None on ROS1
Foo(node)
ros_compat.spin(node)
| ROS1 | ROS2 | |
|---|---|---|
get_param(node, '~name', default), has_param
|
rospy.get_param |
declares a (dynamically typed) parameter |
init_node(name, anonymous=False, multi_threaded=False) |
rospy.init_node, returns None
|
rclpy.init() + a new node, returned (multi_threaded: see below) |
spin(node), spin_once(node, timeout_sec), shutdown(node) (after an own while not is_shutdown(node) loop) |
rospy.spin, rospy.sleep, - |
spin_and_shutdown, rclpy.spin_once, cleanup |
loginfo/logwarn/logerr/logdebug/logfatal(node, msg) |
rospy.log* |
node.get_logger().* (msg must be a str; node=None uses a logger named after the script) |
loginfo/logwarn/logerr_throttle(node, period, msg), loginfo/logwarn/logerr_once(node, msg)
|
like rospy.log*_throttle/_once
|
like throttle_duration_sec=/once=True (per call site, done in compat) |
create_publisher(node, topic, type, queue_size=1, latch=False) |
rospy.Publisher |
node.create_publisher (latch: transient-local QoS) |
create_subscription(node, topic, type, cb, queue_size=None, latch=False) |
rospy.Subscriber (None: unbounded) |
node.create_subscription (None: depth 1; latch: transient-local QoS; ~foo -> ~/foo) |
wait_for_service(node, name, type, timeout) (returns bool), set_param(node, name, value)
|
rospy.wait_for_service, rospy.set_param
|
a client’s wait_for_service, node.set_parameters
|
create_service, create_trigger_service, call_service, create_request/response, get_response_class (FooResponse(*values) on both) |
rospy.Service/ServiceProxy |
node.create_service/create_client |
create_timer(node, period, cb) |
rospy.Timer |
node.create_timer (cb(None)) |
create_simple_action_client(node, name, type) |
actionlib.SimpleActionClient |
same subset over rclpy.action.ActionClient
|
create_simple_action_server(node, name, type, execute_cb) |
actionlib.SimpleActionServer |
same subset over rclpy.action.ActionServer
|
callback_group= of create_subscription/service/trigger_service/timer/simple_action_client/simple_action_server
|
ignored (rospy runs each callback in its own thread) | the rclpy callback group, e.g. ReentrantCallbackGroup() with a MultiThreadedExecutor
|
init_node(name, multi_threaded=True), for callbacks waiting for other callbacks (e.g. a service callback waiting for a topic) |
ignored (as above) |
create_* default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor
|
create_reconfigure_server(node, Config, cb, defaults) |
dynamic_reconfigure.server.Server |
parameters declared from defaults + on-set callback |
now_sec, stamp_now, stamp_to_sec, duration_from_sec, sleep, Rate
|
rospy.Time/Duration/... |
node.get_clock(), … |
get_name, is_shutdown, on_shutdown, signal_shutdown
|
rospy.* |
node name / rclpy context |
create_tf_buffer_and_listener, create_tf_broadcaster
|
tf2_ros |
tf2_ros with node
|
spin_and_shutdown(node, executor=None) |
- | spin until SIGINT/SIGTERM/signal_shutdown, then clean up |
Action types: pass FooAction/FooGoal on ROS1 and Foo/Foo.Goal on
ROS2; timeouts are in seconds on both. actionlib/dynamic_reconfigure
are imported lazily, so depend on them in your own package.
Packages outside jsk_common
jsk_ros1_ros2_compat is only released with jsk_common >= 3.0, which is not available for every ROS1 distro. Depend on it for ROS2 only and fall back to rospy when it can not be imported, listing just the functions you use:
<exec_depend condition="$ROS_VERSION == 2">jsk_ros1_ros2_compat</exec_depend>
try:
from jsk_ros1_ros2_compat import rospy_rclpy_compat as ros_compat
from jsk_ros1_ros2_compat.rospy_rclpy_compat import ROS_VERSION
except ImportError:
# jsk_common < 3.0 has no jsk_ros1_ros2_compat, so this is ROS1 only:
# forward ros_compat.xxx(node, ...) to rospy.xxx(...)
import rospy
ROS_VERSION = 1
class ros_compat(object):
get_param = staticmethod(lambda node, *args, **kwargs: rospy.get_param(*args, **kwargs))
loginfo = staticmethod(lambda node, *args, **kwargs: rospy.loginfo(*args, **kwargs))
Or, to keep the original rospy code untouched for its ROS1 users, add a
jsk_ros1_ros2_compat version next to it and choose by whether
jsk_ros1_ros2_compat can be imported (not by ROS_VERSION):
```python try:
File truncated at 100 lines see the full file
Changelog for package jsk_ros1_ros2_compat
3.0.4 (2026-11-04)
3.0.3 (2026-11-03)
-
Merge pull request #1835 from k-okada/ros-version-fallback-ament Fix ROS2 buildfarm binary jobs: ROS_VERSION without ros_environment, boost for jsk_topic_tools
-
Merge pull request #1834 from pazeshun/array-to-heatmap [jsk_ros1_ros2_compat, jsk_topic_tools, jsk_rosbag_tools] Add array heatmap tools with ROS 1 and ROS 2 support
-
Guess ROS_VERSION from AMENT_PREFIX_PATH when unset, depend on ros_environment The ROS2 binary jobs of the buildfarm failed at find_package(catkin): they install only the build dependencies, none of which pulls in ros_environment, so $ENV{ROS_VERSION} is empty and the fallback at the top of CMakeLists.txt chose ROS1.
- package.xml: add a ROS2 buildtool_depend on ros_environment, which sets ROS_VERSION.
- CMakeLists.txt: when ROS_VERSION is still unset, guess it from AMENT_PREFIX_PATH (bloom's ROS2 debian/rules passes it to cmake, setup.sh and colcon set the environment variable, catkin never does) instead of always assuming ROS1, and warn about it. jsk_tools had no fallback at all and gets the same block. Applies to jsk_ros1_ros2_compat, jsk_tools, jsk_topic_tools, jsk_common, jsk_data, jsk_rosbag_tools, dynamic_tf_publisher, audio_video_recorder and image_view2. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Merge pull request #1 from k-okada/array-to-heatmap-old-distros Support indigo/kinetic in array heatmap tools (OpenCV 2.4, numpy < 1.9, rosbag < 1.13)
-
[jsk_ros1_ros2_compat] rosbag: raw messages with connection headers on rosbag < 1.13 rosbag of indigo/kinetic has neither read_messages(..., return_connection_header=) nor write(..., connection_header=), which failed test_add_heatmap on the kinetic CI. There, read_raw_messages() takes the header of each topic's connection from the bag, and write_raw() registers a new topic's connection with the given header before writing, as write(..., connection_header=) does on newer rosbag. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
Add array heatmap tools with ROS 1 and ROS 2 support
- Render numeric MultiArray and scalar Image topics as heatmap images with optional cell values and configurable color scales
- Add heatmap topics to bags while preserving original messages, recording timestamps, and connection or QoS metadata
- Extend the compatibility layer with raw bag I/O and shared message type helpers
- Add installation rules, documentation, and tests for both ROS versions
-
Merge pull request #1833 from k-okada/release-3.0.2 3.0.2
-
Contributors: Kei Okada, Shun Hasegawa
3.0.2 (2026-11-02)
-
Merge pull request #1831 from k-okada/ros2-compat-fixes [jsk_ros1_ros2_compat] fix queue_size/shutdown/throttle; add init_node/spin, latch, actionlib, reconfigure, uv venv helpers
-
[jsk_ros1_ros2_compat] spin() with an own executor, not rclpy's global one rclpy.spin(node) spins rclpy's global executor, so a callback could not call a library which spins its own node with rclpy.spin_until_future_complete(), such as sound_play's SoundClient(node, blocking=True).say() ('Executor is already spinning'). Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] return from wait_for_result() on shutdown On ROS2, the result of a goal never comes after SIGINT/SIGTERM, so a callback blocked in send_goal_and_wait()/wait_for_result() without a timeout kept its executor thread, and so the process, alive. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
-
[jsk_ros1_ros2_compat] add init_node(..., multi_threaded=True) For nodes whose callbacks wait for other callbacks (e.g. a service callback waiting for a topic or an action result), which works on rospy, as it runs each callback in its own thread, but deadlocks with rclpy's single-threaded executor and default (mutually exclusive) callback group. With multi_threaded=True, create_*() of the node default to a ReentrantCallbackGroup and spin() uses a MultiThreadedExecutor, so the node code needs no rclpy specific executor/callback group; ignored on ROS1. Co-Authored-By: Claude Opus 5.5 <<noreply@anthropic.com>>
File truncated at 100 lines see the full file
Package Dependencies
System Dependencies
| Name |
|---|
| curl |