grepros 1.2.2
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
rosapi Class Reference

Generic interface for accessing ROS1 / ROS2 API. More...

Public Member Functions

 canonical (cls, typename)
 Returns "pkg/Type" for "pkg/msg/Type", standardizes various ROS2 formats.
 
 create_publisher (cls, topic, typecls, latch=True, queue_size=10)
 Returns ROS publisher instance.
 
 get_message_class (cls, typename)
 Returns ROS message class.
 
 get_message_fields (cls, val)
 Returns OrderedDict({field name: field type name}) if ROS1 message, else {}.
 
 get_message_types (cls)
 Returns a list of available message types, as ["pksg/Msg", ].
 
 init (cls, launch=False)
 Initializes ROS, creating and spinning node if specified.
 
 is_ros_message (cls, val)
 Returns whether value is a ROS message or special like time/duration.
 
 is_ros_time (cls, val)
 Returns whether value is a ROS time/duration.
 
 make_full_typename (cls, typename)
 Returns "pkg/msg/Type" for "pkg/Type".
 
 message_to_yaml (cls, msg)
 Returns ROS message as YAML string.
 
 scalar (cls, typename, bound=False)
 Returns scalar type from ROS message data type, like "uint8" from "uint8[100]".
 
 shutdown (cls)
 

Public Attributes

 ROS_TIME_CLASSES
 

Static Public Attributes

dict DDS_TYPES
 ROS2 Data Distribution Service types to ROS built-ins.
 
 NODE = None
 rclpy.Node instance
 
list ROS_BUILTIN_TYPES = ROS_NUMERIC_TYPES + ROS_STRING_TYPES
 All built-in basic types in ROS.
 
 ROS_INTEGER_RANGES
 Value ranges for ROS integer types, as {typename: (min, max)}.
 
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
 ROS time/duration types mapped to type names.
 

Detailed Description

Generic interface for accessing ROS1 / ROS2 API.

Definition at line 134 of file generate_msgs.py.

Member Function Documentation

◆ canonical()

canonical (   cls,
  typename 
)

Returns "pkg/Type" for "pkg/msg/Type", standardizes various ROS2 formats.

Converts DDS types like "octet" to "byte", and "sequence<uint8, 100>" to "uint8[100]".

Definition at line 217 of file generate_msgs.py.

◆ create_publisher()

create_publisher (   cls,
  topic,
  typecls,
  latch = True,
  queue_size = 10 
)

Returns ROS publisher instance.

Definition at line 247 of file generate_msgs.py.

◆ get_message_class()

get_message_class (   cls,
  typename 
)

Returns ROS message class.

Definition at line 257 of file generate_msgs.py.

◆ get_message_fields()

get_message_fields (   cls,
  val 
)

Returns OrderedDict({field name: field type name}) if ROS1 message, else {}.

Definition at line 264 of file generate_msgs.py.

◆ get_message_types()

get_message_types (   cls)

Returns a list of available message types, as ["pksg/Msg", ].

Definition at line 188 of file generate_msgs.py.

◆ init()

init (   cls,
  launch = False 
)

Initializes ROS, creating and spinning node if specified.

Definition at line 196 of file generate_msgs.py.

◆ is_ros_message()

is_ros_message (   cls,
  val 
)

Returns whether value is a ROS message or special like time/duration.

Definition at line 276 of file generate_msgs.py.

◆ is_ros_time()

is_ros_time (   cls,
  val 
)

Returns whether value is a ROS time/duration.

Definition at line 283 of file generate_msgs.py.

◆ make_full_typename()

make_full_typename (   cls,
  typename 
)

Returns "pkg/msg/Type" for "pkg/Type".

Definition at line 288 of file generate_msgs.py.

◆ message_to_yaml()

message_to_yaml (   cls,
  msg 
)

Returns ROS message as YAML string.

Definition at line 295 of file generate_msgs.py.

◆ scalar()

scalar (   cls,
  typename,
  bound = False 
)

Returns scalar type from ROS message data type, like "uint8" from "uint8[100]".

Returns type unchanged if already a scalar.

Parameters
boundif True, does not strip string boundaries like "string<=10"

Definition at line 309 of file generate_msgs.py.

◆ shutdown()

shutdown (   cls)

Definition at line 316 of file generate_msgs.py.

Member Data Documentation

◆ DDS_TYPES

dict DDS_TYPES
static
Initial value:
= {"boolean": "bool",
"float": "float32",
"double": "float64",
"octet": "byte",
"short": "int16",
"unsigned short": "uint16",
"long": "int32",
"unsigned long": "uint32",
"long long": "int64",
"unsigned long long": "uint64"}

ROS2 Data Distribution Service types to ROS built-ins.

Definition at line 176 of file generate_msgs.py.

◆ NODE

NODE = None
static

rclpy.Node instance

Definition at line 138 of file generate_msgs.py.

◆ ROS_BUILTIN_TYPES

list ROS_BUILTIN_TYPES = ROS_NUMERIC_TYPES + ROS_STRING_TYPES
static

All built-in basic types in ROS.

Definition at line 148 of file generate_msgs.py.

◆ ROS_INTEGER_RANGES

ROS_INTEGER_RANGES
static
Initial value:
= dict({
"byte": (-2** 7, 2** 7 - 1),
"int8": (-2** 7, 2** 7 - 1),
"int16": (-2**15, 2**15 - 1),
"int32": (-2**31, 2**31 - 1),
"int64": (-2**63, 2**63 - 1),
"char": (0, 2** 8 - 1),
"uint8": (0, 2** 8 - 1),
"uint16": (0, 2**16 - 1),
"uint32": (0, 2**31 - 1),
"uint64": (0, 2**64 - 1),
}, **{
"byte": (0, 2** 8 - 1),
"char": (-2** 7, 2** 7 - 1),
} if rclpy else {})

Value ranges for ROS integer types, as {typename: (min, max)}.

Definition at line 159 of file generate_msgs.py.

◆ ROS_NUMERIC_TYPES

list ROS_NUMERIC_TYPES
static
Initial value:
= ["byte", "char", "int8", "int16", "int32", "int64", "uint8",
"uint16", "uint32", "uint64", "float32", "float64", "bool"]

All built-in numeric types in ROS.

Definition at line 141 of file generate_msgs.py.

◆ ROS_STRING_TYPES

list ROS_STRING_TYPES = ["string", "wstring"]
static

All built-in string types in ROS.

Definition at line 145 of file generate_msgs.py.

◆ ROS_TIME_CLASSES [1/2]

dict ROS_TIME_CLASSES
static
Initial value:
= {rospy.Time: "time", rospy.Duration: "duration",
genpy.Time: "time", genpy.Duration: "duration"} if rospy else \
{rclpy.time.Time: "builtin_interfaces/Time",
builtin_interfaces.msg.Time: "builtin_interfaces/Time",
rclpy.duration.Duration: "builtin_interfaces/Duration",
builtin_interfaces.msg.Duration: "builtin_interfaces/Duration"}

ROS time/duration types mapped to type names.

Definition at line 151 of file generate_msgs.py.

◆ ROS_TIME_CLASSES [2/2]

ROS_TIME_CLASSES

Definition at line 285 of file generate_msgs.py.


The documentation for this class was generated from the following file: