grepros 1.2.2
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
api.py File Reference

Go to the source code of this file.

Classes

class  Bag
 Bag factory metaclass. More...
 
class  BaseBag
 ROS bag interface. More...
 
class  TypeMeta
 Container for caching and retrieving message type metadata. More...
 

Namespaces

namespace  grepros
 
namespace  grepros.api
 ROS interface, shared facade for ROS1 and ROS2.
 

Functions

 calculate_definition_hash (typename, msgdef, extradefs=())
 Returns MD5 hash for message type definition.
 
 canonical (typename, unbounded=False)
 Returns "pkg/Type" for "pkg/subdir/Type", standardizes various ROS2 formats.
 
 create_publisher (topic, cls_or_typename, queue_size)
 Returns a ROS publisher instance, with .get_num_connections() and .unregister().
 
 create_subscriber (topic, cls_or_typename, handler, queue_size)
 Returns a ROS subscriber instance.
 
 deserialize_message (msg, cls_or_typename)
 Returns ROS message or service request/response instantiated from serialized binary.
 
 dict_to_message (dct, msg)
 Returns given ROS message populated from Python dictionary.
 
 filter_fields (fieldmap, top=(), include=(), exclude=())
 Returns fieldmap filtered by include and exclude patterns.
 
 format_message_value (msg, name, value)
 Returns a message attribute value as string.
 
 get_alias_type (typename)
 Returns ROS built-in type for alias like "char", if any; reverse of get_alias_type().
 
 get_message_class (typename)
 Returns ROS message class, or None if unavailable.
 
 get_message_definition (msg_or_type)
 Returns ROS message type definition full text, including subtype definitions.
 
 get_message_fields (val)
 Returns OrderedDict({field name: field type name}) if ROS message, else {}.
 
 get_message_type (msg_or_cls)
 Returns ROS message type name, like "std_msgs/Header".
 
 get_message_type_hash (msg_or_type)
 Returns ROS message type MD5 hash, or "" if unknown type.
 
 get_message_value (msg, name, typename=None, default=Ellipsis)
 Returns object attribute value, with numeric arrays converted to lists.
 
 get_ros_time_category (msg_or_type)
 Returns "time" or "duration" for time/duration type or instance, else original argument.
 
 get_rostime (fallback=False)
 Returns current ROS time, as rospy.Time or rclpy.time.Time.
 
 get_topic_types ()
 Returns currently available ROS topics, as [(topicname, typename)].
 
 get_type_alias (typename)
 Returns alias like "char" for ROS built-in type, if any; reverse of get_type_alias().
 
 init_node (name=None)
 Initializes a ROS1 or ROS2 node if not already initialized.
 
 is_ros_message (val, ignore_time=False)
 Returns whether value is a ROS message or special like ROS time/duration class or instance.
 
 is_ros_time (val)
 Returns whether value is a ROS time/duration class or instance.
 
 iter_message_fields (msg, messages_only=False, flat=False, scalars=(), include=(), exclude=(), top=())
 Yields ((nested, path), value, typename) from ROS message.
 
 make_bag_time (stamp, bag)
 Returns value as ROS timestamp, conditionally as relative to bag start/end time.
 
 make_duration (secs=0, nsecs=0)
 Returns a ROS duration.
 
 make_full_typename (typename, category="msg")
 Returns "pkg/msg/Type" for "pkg/Type".
 
 make_live_time (stamp)
 Returns value as ROS timestamp, conditionally as relative to system time.
 
 make_message_hash (msg, include=(), exclude=())
 Returns hashcode for ROS message, as a hex digest.
 
 make_time (secs=0, nsecs=0)
 Returns a ROS time.
 
 message_to_dict (msg, replace=None)
 Returns ROS message as nested Python dictionary.
 
 parse_definition_fields (typename, typedef)
 Returns field names and type names from a message definition text.
 
 parse_definition_subtypes (typedef, nesting=False)
 Returns subtype names and type definitions from a full message definition.
 
 scalar (typename)
 Returns scalar type from ROS message data type, like "uint8" from uint8-array.
 
 serialize_message (msg)
 Returns ROS message as a serialized binary.
 
 set_message_value (obj, name, value)
 Sets message or object attribute value.
 
 shutdown_node ()
 Shuts down live ROS node.
 
 time_message (val, to_message=True, clock_type=None)
 Converts ROS2 time/duration between rclpy and builtin_interfaces objects.
 
 to_datetime (val)
 Returns value as datetime.datetime if value is ROS time/duration, else value.
 
 to_decimal (val)
 Returns value as decimal.Decimal if value is ROS time/duration, else value.
 
 to_duration (val)
 Returns value as ROS duration if convertible (int/float/time/datetime/decimal), else value.
 
 to_nsec (val)
 Returns value in nanoseconds if value is ROS time/duration, else value.
 
 to_sec (val)
 Returns value in seconds if value is ROS time/duration, else value.
 
 to_sec_nsec (val)
 Returns value as (seconds, nanoseconds) if value is ROS time/duration, else value.
 
 to_time (val)
 Returns value as ROS time if convertible (int/float/duration/datetime/decimal), else value.
 
 validate (live=False)
 Initializes ROS bindings, returns whether ROS environment set, prints or raises error if not.
 

Variables

tuple BAG_EXTENSIONS = ()
 Bagfile extensions to seek, including leading dot, populated after init.
 
str NODE_NAME = "grepros"
 Node base name for connecting to ROS (will be anonymized).
 
 realapi = None
 Module grepros.ros1 or grepros.ros2.
 
 ROS1 = None
 Flag denoting ROS1 environment, populated on validate()
 
 ROS2 = None
 Flag denoting ROS2 environment, populated on validate()
 
dict ROS_ALIAS_TYPES = {}
 Mapping between type aliases and real types, like {"byte": "int8"} in ROS1.
 
dict ROS_BUILTIN_CTORS
 Python constructors for ROS built-in types, as {ROS name: type class}.
 
list ROS_BUILTIN_TYPES = ROS_NUMERIC_TYPES + ROS_STRING_TYPES
 All built-in basic types in ROS.
 
list ROS_COMMON_TYPES = []
 All built-in basic types plus time types in ROS, populated after init.
 
 ROS_FAMILY = None
 ROS Python module family, "rospy" or "rclpy", populated on validate()
 
list ROS_NUMERIC_TYPES
 All built-in numeric types in ROS.
 
list ROS_STRING_TYPES = ["string", "wstring"]
 All built-in string types in ROS.
 
dict ROS_TIME_CLASSES = {}
 ROS1 time/duration types mapped to type names, populated after init.
 
list ROS_TIME_TYPES = []
 ROS time/duration types, populated after init.
 
 ROS_VERSION = None
 ROS version from environment, populated on validate() as integer.
 
tuple SKIP_EXTENSIONS = ()
 Bagfile extensions to skip, including leading dot, populated after init.