No version for distro humble showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro jazzy showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro kilted showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro rolling showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro ardent showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro bouncy showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro crystal showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro eloquent showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro dashing showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro galactic showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro foxy showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro iron showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro lunar showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro jade showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro indigo showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro hydro showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

No version for distro kinetic showing melodic. Known supported distros are highlighted in the buttons above.

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

Package Summary

Tags No category tags.
Version 2.5.1
License BSD
Build type CATKIN
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ctu-vras/ros-utils.git
VCS Type git
VCS Version master
Last Updated 2025-04-22
Dev Status DEVELOPED
CI status
Released RELEASED
Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

A Czech-army knife for ROS code written in Python.

Additional Links

Maintainers

  • Martin Pecka

Authors

  • Martin Pecka

cras_py_common

A Czech-army knife for ROS code written in Python.

The aim of this package is to provide some missing utility functions to rospy. Using libraries from this package, you should be able to write more efficient, safer and less error-prone code without much boilerplate. As this package is intended to handle a lot of the boring code for you “behind the scenes”, ubiquitous effort was put into unit-testing everything, so that you can rely on the provided code without the usual fear whether it works or not.

This readme shortly introduces the provided libraries. Detailed documentation can be found in the comments in code and in the API docs. Examples of usage can be found in the dependent packages from ros-utils, and in the unit tests.

Parts of this package were used by team CTU-CRAS-Norlab in DARPA Subterranean Challenge.

Support and Build Status

This package is supported on Melodic and Noetic until their End of Life (and maybe later). It is occasionally tested with non-default GCC versions like Melodic+GCC8 or Noetic+GCC11.

Development versions: CI Dev melodic Dev noetic ubuntu Dev noetic debian

Release jobs Melodic Melodic version: Bin melodic-amd64 Bin melodic-arm64 Bin melodic-armhf

Release jobs Noetic Noetic version: Bin ubuntu noetic-amd64 Bin ubuntu noetic-arm64 Bin ubuntu noetic-armhf Bin debian noetic-amd64 Bin debian noetic-arm64

List of Provided Modules

The most useful functions and classes from these modules are available directly from the cras package, i.e.

from cras import to_str
# instead of
from cras.string_utils import to_str

  • ctypes_utils: Utilities for working with the ctypes library.
  • geometry_utils: Finally THE module providing easy and foolproof conversion between quaternions and roll/pitch/yaw notation.
  • log_utils: Some convenience for rospy logging. Provides log*_once_identical() functions to log unique messages.
  • message_utils: Conversion of std_msgs/String to Python type etc. Generic access to message fields using a string “address”.
  • node_utils: Utilities for easier writing of nodes, adding e.g. easy-to-write reset() function that is automatically called when ROS time jumps back/forward.
  • param_utils: Utilities for type-safe, easy, unified and configurable access to ROS parameters. See below for examples and more details.
  • python_utils: General Python utilities.
  • static_transform_broadcaster: An drop-in replacement of tf2_ros.static_transform_broadcaster that can safely publish multiple transforms from a single node (upstreaming to tf2_ros in progress).
  • string_utils: Universal to_str() that converts almost anything to a sensible string.
  • test_utils: Utilities for writing unit tests, e.g. a tool that can “read” what was written by rospy.loginfo().
  • time_utils: Conversions between rospy.Rate and frequency. rospy.Rate equality comparison. Min/max time and duration constants. WallTime, WallRate, SteadyTime, SteadyRate, and a Timer that can use these custom rates.
  • topic_utils: Generic topic subscriber.

node_utils: Resettable nodes

Nodes can support resetting of their state. This is a concept very useful for simulation or postprocessing. Each node that supports resetting should be marked like this in its documentation:

Note This node is resettable and checks for time jumps.

This particularly means that the node subscribes to topics /reset and ~reset (any type). Whenever a message is received on either of these topics, the node’s reset() method is called.

Resetting is also done automatically any time the node figures out ROS time jumped back/forward too much. It is configured via these parameters:

  • /jump_back_tolerance (float, default 3.0 in wall time and 0.0 in sim time): Threshold for ROS time jump back detection.
  • ~jump_back_tolerance (float, default from /jump_back_tolerance): Threshold for ROS time jump back detection.
  • ~reset_on_time_jump_back (bool, default True): Whether to call reset() when ROS time jumps back.
  • /jump_forward_tolerance (float, default 10.0 in sim time and max duration in wall time): Threshold for ROS time jump forward detection.
  • ~jump_forward_tolerance (float, default from /jump_forward_tolerance): Threshold for ROS time jump forward detection.
  • ~reset_on_time_jump_forward (bool, default True in sim time and False in wall time): Whether to call reset() when ROS time jumps forward.

The node should either call self.check_time_jump() in each message callback, or call self.start_auto_check_time_jump() when the node is initialized (this runs a background thread doing the checks).

Please note that you may have to increase the jump forward tolerance if playing bag files with very high rates. In such case, it is safer to increase the threshold to 60 seconds or even more.

param_utils: Parameter Reading Helpers

param_utils provide a type-safe, unified and highly configurable interface for reading ROS parameters. Read a numpy matrix, vector of unsigned ints, rospy.Duration or geometry_msgs.msg.Vector3 directly without the need to write a single line of conversion code or value checking. Type of the value to read is automatically determined either from the provided default value, or from result_type parameter.

Example usage:

```python from cras import get_param, GetParamException from geometry_msgs.msg import Vector3

read array of 3 doubles from parameter server into a geometry_msgs.msg.Vector3, defaulting to the specified vector if not set.

gravity = get_param(“gravity”, Vector3(0, 0, -9.81), “m.s^-2”)

required parameters are specified by not having a default; if you still want conversion to some type, use result_type

try: gravity2 = get_param(“gravity”, “m.s^-2”, result_type=Vector3) except GetParamException as e: # the exception is raised if the required parameter is not set

File truncated at 100 lines see the full file

CHANGELOG

Changelog for package cras_py_common

2.5.1 (2025-02-18)

2.5.0 (2025-02-13)

  • plugin_utils: Fixed Python 2.7 compatibility.
  • Added plugin_utils.
  • string_utils: Added pretty_file_size()
  • message_utils: Added msg_to_raw and raw_to_msg
  • Fixed dependencies.
  • image_encodings: Added isDepth().
  • Added image_encodings.py and distortion_models.py .
  • Contributors: Martin Pecka

2.4.8 (2025-01-07)

2.4.7 (2024-12-12)

2.4.6 (2024-12-12)

  • string_utils: Added iconvConvert(), transliterateToAscii() and toValidRosName() functions.
  • Contributors: Martin Pecka

2.4.5 (2024-11-02)

2.4.4 (2024-09-14)

2.4.3 (2024-09-14)

2.4.2 (2024-09-05)

  • log_utils: Addded log_once_identical() functions.
  • log_utils: Fixed stack information for cras.log().
  • Contributors: Martin Pecka

2.4.1 (2024-09-04)

2.4.0 (2024-09-04)

  • string_utils: Fixed iconv functions when running with LC_ALL=C or other weird locale.
  • Added python_utils.
  • string_utils: Added methods for iconv-like conversions of strings and sanitization or ROS names.
  • Contributors: Martin Pecka

2.3.9 (2024-02-27)

  • Removed catkin_lint buildfarm hacks.
  • Contributors: Martin Pecka

2.3.8 (2024-01-12)

2.3.7 (2024-01-09)

2.3.6 (2024-01-09)

2.3.5 (2023-11-21)

2.3.4 (2023-10-25)

2.3.3 (2023-10-06)

2.3.2 (2023-10-06)

  • param_utils: Removed deprecated numpy aliases.
  • Contributors: Martin Pecka

2.3.1 (2023-07-13)

2.3.0 (2023-07-12)

  • Increased minimum CMake version to 3.10.2.
  • Contributors: Martin Pecka

2.2.3 (2023-06-16)

2.2.2 (2023-05-15)

  • ctypes_utils: Added ScalarAllocator.
  • Contributors: Martin Pecka

2.2.1 (2023-05-15)

  • message_utils: Added dict_to_dynamic_config_msg().
  • ctypes_utils: Added c_array() method.
  • message_utils: Added get_srv_types() and get_cfg_module().
  • Contributors: Martin Pecka

2.2.0 (2023-04-09)

2.1.2 (2023-02-10)

2.1.1 (2023-02-08)

2.1.0 (2023-02-08)

  • ctypes_utils: Added specialized allocators for ROS messages and for

File truncated at 100 lines see the full file

Wiki Tutorials

This package does not provide any links to tutorials in it's rosindex metadata. You can check on the ROS Wiki Tutorials page for the package.

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged cras_py_common at Robotics Stack Exchange

OSZAR »