[ros-users] [Discourse.ros.org] [Next Generation ROS] Option…

Forside
Vedhæftede filer:
Indlæg som e-mail
+ (text/plain)
Slet denne besked
Besvar denne besked
Skribent: Asmodehn via ros-users
Dato:  
Til: ros-users
Emne: [ros-users] [Discourse.ros.org] [Next Generation ROS] Optional Fields in Message



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.


If you do not want to receive messages from ros-users please use the unsubscribe link below. If you use the one above, you will stop all of ros-users from receiving updates.
______________________________________________________________________________
ros-users mailing list

http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>