[ros-users] [Discourse.ros.org] [Next Generation ROS] Optional Fields in Message

Asmodehn ros.discourse at gmail.com
Wed Dec 21 02:20:52 UTC 2016




And I would personally add a even more obvious usecase : **remote function call in python**.
A function can have optional arguments, and since python works with references and implicit typing, a safe simple default for any type is `None`

if I have a function : 
```python
def do_that(fibnum, timeout = None): 
  return fibonnacci_compute(fib_num, timeout)
```
and I want to expose it to other nodes via a service : 
```
float timeout
---
int fib_result
```

- sending timeout == 0 (how the ROS1 msg type `__init__` function initialize it) means return right away.
- sending timeout == None (how the python api is built) means no timeout, ie. run for ever.

Nullable default arguments are core part of the language so it is not unusual to see such APIs in python.

So I think having some standard way to represent a nullable/optional field in a message would be very useful.






---
[Visit Topic](https://discourse.ros.org/t/optional-fields-in-message/991/10) or reply to this email to respond.




More information about the ros-users mailing list