1313#include "py/objstr.h"
1414#include "py/runtime.h"
1515
16+ //| """Robot Operating System (ROS2) connectivity through micro-ROS
17+ //|
18+ //| The `rclcpy` module contains basic classes and connectivity options for
19+ //| communicating with a ROS network running on a linux machine, using the
20+ //| eProsima's `micro-ROS client API <https://micro.ros.org/>`_.
21+ //|
22+ //| The underlying micro-ROS system uses a resource-constrained middleware layer
23+ //| (XRCE-DDS) that must be connected to an agent running within ROS2 on a host
24+ //| Linux computer. The API exposed by Circuitpython aims to be close to the
25+ //| standard Python API for ROS2, `rclpy`, with minor additions to support
26+ //| connecting to this agent.
27+ //|
28+ //| Wifi must be connected before calling any `rclcpy` functions. As with
29+ //| `rclpy`, the `rclcpy.init()` function must be run before creating any ROS
30+ //| objects. Child objects, such as publishers, must be created by their parent
31+ //| objects. For example::
32+ //|
33+ //| import os, wifi, time
34+ //| import rclcpy
35+ //| wifi.radio.connect(ssid=os.getenv('CIRCUITPY_WIFI_SSID'),
36+ //| password=os.getenv('CIRCUITPY_WIFI_PASSWORD'))
37+ //| rclcpy.init("192.168.10.111","8888")
38+ //| mynode = rclcpy.Node("foo")
39+ //| mypub = mynode.create_publisher("bar")
40+ //| mypub.publish_int32(42)
41+ //| """
42+
43+
44+ //| def init(
45+ //| agent_ip: str,
46+ //| agent_port: str,
47+ //| *,
48+ //| domain_id: int = 0,
49+ //| ) -> None:
50+ //| """Initialize micro-ROS and connect to a micro-ROS agent.
51+ //|
52+ //| This function starts ROS communications and connects to the micro-ROS agent
53+ //| on a linux computer. It must be called before creating ROS objects.
54+ //|
55+ //| :param str agent_ip: The IP address of the micro-ROS agent
56+ //| :param str agent_port: The port number of the micro-ROS agent as a string
57+ //| :param int domain_id: The ROS 2 domain ID for network isolation and organization.
58+ //| Devices with the same domain ID can communicate with each other.
59+ //| """
60+ //| ...
61+ //|
1662static mp_obj_t rclcpy_init (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
1763 enum { ARG_agent_ip , ARG_agent_port , ARG_domain_id };
1864 static const mp_arg_t allowed_args [] = {
@@ -31,6 +77,26 @@ static mp_obj_t rclcpy_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k
3177}
3278static MP_DEFINE_CONST_FUN_OBJ_KW (rclcpy_init_obj , 2 , rclcpy_init ) ;
3379
80+
81+ //| def create_node(
82+ //| node_name: str,
83+ //| *,
84+ //| namespace: str | None = None
85+ //| ) -> Node:
86+ //| """Create a Node.
87+ //|
88+ //| Creates an instance of a ROS2 Node. Nodes can be used to create other ROS
89+ //| entities like publishers or subscribers. Nodes must have a unique name, and
90+ //| may also be constructed from their class.
91+ //|
92+ //| :param str node_name: The name of the node. Must be a valid ROS 2 node name.
93+ //| :param str namespace: The namespace for the node. If None, the node will be
94+ //| created in the root namespace.
95+ //| :return: A new Node object
96+ //| :rtype: Node
97+ //| """
98+ //| ...
99+ //|
34100static mp_obj_t rclcpy_create_node (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
35101 enum { ARG_node_name , ARG_namespace };
36102 static const mp_arg_t allowed_args [] = {
0 commit comments