Skip to content

Commit 2749c81

Browse files
Update Python receiver get data documentation (cyberbotics#5847)
* Update Python receiver get data functions * Update receiver.md
1 parent 64627b1 commit 2749c81

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

docs/reference/receiver.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ namespace webots {
337337
from controller import Receiver
338338

339339
class Receiver (Device):
340-
def getData(self):
340+
def getBytes(self):
341+
def getString(self):
342+
def getFloats(self):
343+
def getInts(self):
344+
def getBools(self):
341345
def getDataSize(self):
342346
# ...
343347
```
@@ -392,16 +396,7 @@ The `wb_receiver_get_data_size` function returns the number of data bytes presen
392396
The *data size* is always equal to the *size* argument of the corresponding `emitter_send_packet` function call.
393397
It is illegal to call the `wb_receiver_get_data_size` function when the queue is empty (i.e. when `wb_receiver_get_queue_length() == 0`).
394398

395-
> **Note** [Python]: The `getData` function returns a string.
396-
Similarly to the `sendPacket` function of the [Emitter](emitter.md) device, using the functions of the struct module is recommended for sending primitive data types.
397-
Here is an example for getting the data:
398-
399-
> ```python
400-
> import struct
401-
> #...
402-
> message=receiver.getData()
403-
> dataList=struct.unpack("chd",message)
404-
> ```
399+
> **Note** [Python]: In the Python API, instead of having a single function returning the data, multiple functions are defined that automatically convert the data to the expected return type (bytes, string, list of floats, list of integers, list of booleans).
405400
406401
<!-- -->
407402

0 commit comments

Comments
 (0)