rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
|
ROS system and node functionality. More...
Functions | |
create_client (service, cls_or_typename, **qosargs) | |
Returns a ROS service client instance, for invoking a service. | |
create_publisher (topic, cls_or_typename, latch=False, queue_size=0, **qosargs) | |
Returns a ROS publisher instance. | |
create_rate (frequency) | |
Returns a ROS rate instance, for sleeping at a fixed rate. | |
create_service (service, cls_or_typename, callback, **qosargs) | |
Returns a ROS service server instance, for providing a service. | |
create_subscriber (topic, cls_or_typename, callback, callback_args=None, queue_size=0, raw=False, **qosargs) | |
Returns a ROS subscriber instance. | |
create_timer (period, callback, oneshot=False, immediate=False) | |
Returns a ROS timer instance. | |
delete_param (name) | |
Deletes parameter from the node. | |
destroy_entity (item) | |
Closes the given publisher, subscriber, service client, or service server instance. | |
get_logger () | |
Returns `logging.Logger` for logging to ROS log handler. | |
get_namespace () | |
Returns ROS node namespace. | |
get_node_name () | |
Returns ROS node full name with namespace. | |
get_nodes () | |
Returns all ROS nodes, as `[node full name, ]`. | |
get_param (name, default=None, autoset=True) | |
Returns parameter value from the node. | |
get_param_names () | |
Returns the names of all parameters on the node. | |
get_params (nested=True) | |
Returns the current ROS node parameters, by default as nested dictionary. | |
get_ros_version () | |
Returns ROS version information, as {"major": "1" / "2", ?"minor": distro like "noetic"}. | |
get_rostime () | |
Returns ROS time instance for current ROS clock time. | |
get_services (node=None, namespace=None, include_types=True) | |
Returns all available ROS services, as `[(service name, [type name, ]), ]`. | |
get_topics () | |
Returns all available ROS topics, as `[(topic name, [type name, ]), ]`. | |
has_param (name) | |
Returns whether the parameter exists on the node. | |
init_node (name, args=None, namespace=None, anonymous=False, log_level=None, enable_rosout=True, multithreaded=True, reentrant=False) | |
Initializes ROS and creates ROS node. | |
init_params (defaults=None, **defaultkws) | |
Sets all parameters on node from defaults dictionary. | |
ok () | |
Returns whether ROS has been initialized and is not shut down. | |
on_shutdown (callback, *args, **kwargs) | |
Registers function to be called on shutdown, after node has been torn down. | |
register_init (node=None) | |
Informs `rosros` of ROS having been initialized outside of `init_node()`. | |
remap_name (name, namespace=None) | |
Returns the absolute remapped topic/service name if mapping exists. | |
resolve_name (name, namespace=None) | |
Returns absolute remapped name, namespaced under current node if relative or private. | |
set_param (name, value, descriptor=None) | |
Sets a parameter on the node. | |
shutdown (reason=None) | |
Shuts down live ROS node, if any. | |
sleep (duration) | |
Sleeps for the specified duration in ROS time. | |
spin () | |
Spins ROS node forever. | |
spin_once (timeout=None) | |
Waits until timeout in ROS1; executes one ROS operation or waits until timeout in ROS2. | |
spin_until_future_complete (future, timeout=None) | |
Spins ROS until future complete or timeout reached or ROS shut down. | |
start_spin () | |
Sets ROS node spinning forever in a background thread. | |
wait_for_publisher (topic, timeout=None, cls_or_typename=None) | |
Blocks until topic has at least one publisher. | |
wait_for_service (service, timeout=None, cls_or_typename=None) | |
Blocks until service is available. | |
wait_for_subscriber (topic, timeout=None, cls_or_typename=None) | |
Blocks until topic has at least one subscriber. | |
Variables | |
AnyMsg = ros.AnyMsg | |
rospy.AnyMsg in ROS1, equivalent stand-in in ROS2 | |
Bag = ros.Bag | |
rosbag.Bag in ROS1 (with some additional functionality), equivalent class in ROS2 | |
ros = ros1 or ros2 | |
ros1 = None | |
ROS system and node functionality.
rosros.core.create_client | ( | service, | |
cls_or_typename, | |||
** | qosargs | ||
) |
Returns a ROS service client instance, for invoking a service.
service | name of service to invoke |
cls_or_typename | ROS service class object like `std_srvs.srv.SetBool` or service type name like `"std_srvs/SetBool" |
qosargs | additional key-value arguments for ROS2 `QoSProfile`, like `reliability` (ignored in ROS1) |
rosros.core.create_publisher | ( | topic, | |
cls_or_typename, | |||
latch = False , |
|||
queue_size = 0 , |
|||
** | qosargs | ||
) |
Returns a ROS publisher instance.
topic | name of topic to open |
cls_or_typename | ROS message class object like `std_msgs.msg.Bool` or message type name like "std_msgs/Bool" |
latch | provide last published message to new subscribers (sets `DurabilityPolicy.TRANSIENT_LOCAL` in ROS2) |
queue_size | queue size of outgoing messages (0 or None: infinite) (sets QoS `depth` in ROS2) |
qosargs | additional key-value arguments for ROS2 `QoSProfile`, like `reliability` (uses only `depth` and `durability`=TRANSIENT_LOCAL in ROS1) |
rosros.core.create_rate | ( | frequency | ) |
rosros.core.create_service | ( | service, | |
cls_or_typename, | |||
callback, | |||
** | qosargs | ||
) |
Returns a ROS service server instance, for providing a service.
service | name of service to provide |
cls_or_typename | ROS service class object like `std_srvs.srv.SetBool` or service type name like `"std_srvs/SetBool" |
callback | callback function, invoked with `(request, response)`, expected to return the populated response, or a list/tuple/dictionary for populating the response. If the function only takes one argument, it is invoked with `(request)`. |
qosargs | additional key-value arguments for ROS2 `QoSProfile`, like `reliability` (ignored in ROS1) |
rosros.core.create_subscriber | ( | topic, | |
cls_or_typename, | |||
callback, | |||
callback_args = None , |
|||
queue_size = 0 , |
|||
raw = False , |
|||
** | qosargs | ||
) |
Returns a ROS subscriber instance.
topic | name of topic to listen to |
cls_or_typename | ROS message class object like `std_msgs.msg.Bool` or message type name like "std_msgs/Bool" |
callback | callback function, invoked with received message, and with additional arguments if given |
callback_args | additional arguments to pass to the callback, if any, invoked as `callback(msg, callback_args)ยด |
queue_size | queue size of incoming messages (0 or None: infinite) |
raw | invoke callback with serialized message bytes, make subscription with AnyMsg in ROS1 |
qosargs | additional key-value arguments for ROS2 `QoSProfile`, like `reliability` (uses only `depth` in ROS1). `__autodetect` will look up current publishers on the topic and create a compatible QoS. |
rosros.core.create_timer | ( | period, | |
callback, | |||
oneshot = False , |
|||
immediate = False |
|||
) |
Returns a ROS timer instance.
period | desired period between callbacks, as seconds or ROS duration |
callback | callback function invoked on timer, with no arguments |
oneshot | whether to fire only once |
immediate | whether to fire once immediately instead of waiting one period |
rosros.core.delete_param | ( | name | ) |
rosros.core.destroy_entity | ( | item | ) |
rosros.core.get_logger | ( | ) |
Returns `logging.Logger` for logging to ROS log handler.
Logging methods on the logger (`debug()`, `info()`, etc) accept additional keyword arguments:
rosros.core.get_node_name | ( | ) |
rosros.core.get_nodes | ( | ) |
rosros.core.get_param | ( | name, | |
default = None , |
|||
autoset = True |
|||
) |
Returns parameter value from the node.
default | optional default to return if parameter unknown |
autoset | set default value to node as parameter value if unknown |
KeyError | if parameter not set and default not given |
rosros.core.get_param_names | ( | ) |
rosros.core.get_params | ( | nested = True | ) |
rosros.core.get_ros_version | ( | ) |
rosros.core.get_rostime | ( | ) |
rosros.core.get_services | ( | node = None , |
|
namespace = None , |
|||
include_types = True |
|||
) |
Returns all available ROS services, as `[(service name, [type name, ]), ]`.
node | full name of the node to return services for, if any |
namespace | full or partial namespace to scope services from |
include_types | if false, type names will be returned as an empty list |
rosros.core.get_topics | ( | ) |
rosros.core.has_param | ( | name | ) |
rosros.core.init_node | ( | name, | |
args = None , |
|||
namespace = None , |
|||
anonymous = False , |
|||
log_level = None , |
|||
enable_rosout = True , |
|||
multithreaded = True , |
|||
reentrant = False |
|||
) |
Initializes ROS and creates ROS node.
name | node name, without namespace |
args | list of command-line arguments for the node |
namespace | node namespace override |
anonymous | whether to auto-generate a unique name for the node, using the given name as base |
log_level | level to set for ROS logging (name like "DEBUG" or one of `logging` constants like `logging.DEBUG`) |
enable_rosout | `False` to suppress auto-publication of rosout |
multithreaded | ROS2 only, ignored in ROS1: use `MultiThreadedExecutor` instead of `SingleThreadedExecutor` |
reentrant | ROS2 only, ignored in ROS1: use `ReentrantCallbackGroup` instead of `MutuallyExclusiveCallbackGroup` |
rosros.core.init_params | ( | defaults = None , |
|
** | defaultkws | ||
) |
Sets all parameters on node from defaults dictionary.
In ROS2, auto-declares unregistered parameters.
defaults | nested dictionary with suitable keys and values for ROS (keys must be valid namespace names, list values must not contain nested values) |
defaultkws | parameters as key=value |
rosros.core.ok | ( | ) |
rosros.core.on_shutdown | ( | callback, | |
* | args, | ||
** | kwargs | ||
) |
rosros.core.register_init | ( | node = None | ) |
rosros.core.remap_name | ( | name, | |
namespace = None |
|||
) |
Returns the absolute remapped topic/service name if mapping exists.
name | name to seek exact remapping for |
namespace | namespace to resolve relative and private names to, by default current node namespace |
rosros.core.resolve_name | ( | name, | |
namespace = None |
|||
) |
rosros.core.set_param | ( | name, | |
value, | |||
descriptor = None |
|||
) |
Sets a parameter on the node.
In ROS2, parameter will be auto-declared if unknown so far.
name | full name of the parameter in node namespace |
value | parameter value to set |
descriptor | optional `rcl_interfaces.msg.ParameterDescriptor` in ROS2 |
rosros.core.shutdown | ( | reason = None | ) |
rosros.core.sleep | ( | duration | ) |
rosros.core.spin_once | ( | timeout = None | ) |
rosros.core.spin_until_future_complete | ( | future, | |
timeout = None |
|||
) |
rosros.core.start_spin | ( | ) |
rosros.core.wait_for_publisher | ( | topic, | |
timeout = None , |
|||
cls_or_typename = None |
|||
) |
Blocks until topic has at least one publisher.
topic | name of topic to open |
timeout | time to wait at most, as seconds or ROS duration; None or <0 waits forever |
cls_or_typename | message type to expect if any, as ROS message class object like `std_msgs.msg.Bool` or message type name like "std_msgs/Bool" |
rosros.core.wait_for_service | ( | service, | |
timeout = None , |
|||
cls_or_typename = None |
|||
) |
Blocks until service is available.
service | name of service |
timeout | time to wait at most, as seconds or ROS duration; None or <0 waits forever |
cls_or_typename | service type to expect if any, as ROS service class object like `std_msgs.msg.Bool` or service type name like "std_srvs/SetBool" |
rosros.core.wait_for_subscriber | ( | topic, | |
timeout = None , |
|||
cls_or_typename = None |
|||
) |
Blocks until topic has at least one subscriber.
topic | name of topic to open |
timeout | time to wait at most, as seconds or ROS duration; None or <0 waits forever |
cls_or_typename | message type to expect if any, as ROS message class object like `std_msgs.msg.Bool` or message type name like "std_msgs/Bool" |
rosros.core.AnyMsg = ros.AnyMsg |
rosros.core.Bag = ros.Bag |