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
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.
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()
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.
(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:
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.