Skip to content

Commit 3b14b28

Browse files
committed
docs updated
1 parent 76e6b1f commit 3b14b28

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
# uPy-rosserial
2-
`rosserial` a method used by ROS in order to establish communication via serial , mostly this is used with microcontrollers, which in this case are the ones responsible in some ROS applications for actuators and sensors usage.
2+
`rosserial` is a method used by ROS in order to establish communication via serial, basically a middleware, mostly used with microcontrollers, which in this case are the ones responsible in some ROS applications for actuators and sensors usage.
33

4-
Since there is no rosserial package for uPy as there is for Arduino, this repo has been created where every needed script to establish rosserial with uPy will be found.
4+
This library targets the communication between ROS and uPy with rosserial as middleware.
55

66
## Features
77
- [x] Advertising Topics
88
- [x] Publishing
99
- [x] Subscribing
1010
- [ ] Services
1111

12-
**To Do: Subscribing testing and implementation.**
12+
**To Do: Implement services usage.**
1313

1414
## Installation
1515
Before using this library you must have ROS installed, as well as rosserial which would be with the following command:
16-
`sudo apt install ros-<version>-rosserial`
1716

17+
`sudo apt install ros-<version>-rosserial`
1818

1919
In theory every board with the kind of generic `UART` class for ESP32 is capable of using this library, but it must be known exactly which `UART ID` is being used, this means for example, for ESP32 defined pins correspond to TX0 and RX0 for UART0, and so on. In the examples below, UART2 is used.
2020

21-
In order to use ros node communication, have in mind a python class for each message must be available. this means a dependency of this library is [uPy Genpy](https://github.com/FunPythonEC/uPy-genpy) and [uPy rosserial_msgs](https://github.com/FunPythonEC/uPy-rosserial_msgs), `ugenpy` used to create Python classes for messages from `*.msg` files while `rosserial_msgs` has the `TopicInfo` class for topic negotiation. Follow the installation from `ugenpy` before proceeding.
2221

23-
Once `ugenpy` and `rosserial_msgs` are inside, the package `uros` from this repository must be copied to the flash memory. I strongly recommend using [rshell](https://github.com/dhylands/rshell).
22+
### Copying source files
23+
In order to use ros node communication, have in mind a python class for each message must be available. this means a dependency of this library is [uPy Genpy](https://github.com/FunPythonEC/uPy-genpy) and [uPy rosserial_msgs](https://github.com/FunPythonEC/uPy-rosserial_msgs), `ugenpy` used to create Python classes for messages from `*.msg` files while `rosserial_msgs` has the `TopicInfo` class for topic negotiation. The folders from `src` from this current repo and the other two must be copied
24+
25+
I strongly recommend using [rshell](https://github.com/dhylands/rshell).
2426

27+
### Using upip
2528
Now available with upip, could be installed with:
2629
``` python
2730
import upip
2831
upip.install('micropython-rosserial')
2932
```
33+
If `micropython-rosserial` is installed, because of requirementes, `ugenpy` and `TopicInfo` will too.
3034
>Note: must be connected to WiFi to use upip like this.
3135
3236
**Have in mind before publishing or subscribing to a topic, the message class must be generated with `ugenpy`**
@@ -94,4 +98,26 @@ node = uros.NodeHandle(2, 115200)
9498
node.subscribe('chatter', String, cb)
9599
while True:
96100
node.publish('greet', packet)
97-
```
101+
```
102+
103+
## Classes
104+
### `uros.NodeHandle`
105+
#### Constructor
106+
##### `uros.NodeHandle(serial_id, baudrate)`
107+
Initiates the class which handles the node, advertised topics, publishes and subscribe.
108+
* `serial_id`: corresponds to the UART ID, in case of ESP32, it has 3 UARTS, in the examples UART2 is used.
109+
* `baudrate`: is the baudrate in which the board will communicate.
110+
111+
#### Methods
112+
##### `uros.NodeHandle.publish(topic_name, msg, buffer_size=1024)`
113+
Publishes data to a defined topic, with a defined message class.
114+
* `topic_name`: the topic where the message will be put or published.
115+
* `msg`: the msg class initiated with its slots values defined.
116+
* `buffer_size`: the amount of bytes that will be published as a maximum from this particular topic, 1024 is by default.
117+
118+
##### `uros.NodeHandle.subscribe(topic_name, msgobj, cb, buffer_size=1024)`
119+
Subscribe to a defined topic.
120+
* `topic_name`: same as publish.
121+
* `msgobj`: is the object class, but not instantiated, just the class passed.
122+
* `cb`: must be defined, it is a callback function, with a single argument that corresponds to the inconming message class.
123+
* `buffer_size`: same as publish.

0 commit comments

Comments
 (0)