rosros

Simple unified interface to ROS1 / ROS2 Python API

Index
Installation
Example usage
ROS core functionality
ROS API helpers
Converting an existing package

API documentation
View the Project on GitHub suurjaak/rosros

Simple unified interface to ROS1 / ROS2 Python API

Auto-detects ROS version from run-time environment, and provides equivalent functionality in either ROS version.

Main use-cases:

Requires the corresponding ROS Python libraries: rospy family for ROS1, rclpy for ROS2.

Example usage

A simple node that publishes a message on receiving a service request:

import rosros

def on_trigger(req):
    pub.publish(True)
    return {"success": True, "message": "Triggered!"}

rosros.init_node("mynode")
params = rosros.init_params(service="/trigger", topic="/triggerings")
srv = rosros.create_service(params["service"], "std_srvs/Trigger", on_trigger)
pub = rosros.create_publisher(params["topic"], "std_msgs/Bool", latch=True, queue_size=2)
rosros.spin()

Attribution

rosros is written in Python.

This package includes partially copied and modified code from rclpy core library, released under the Apache-2.0 license. See 3rd-party licences.txt for full details.

License

(The 3-Clause BSD License)

Copyright (C) 2022 by Erki Suurjaak. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.