[Discourse.ros.org] [Next Generation ROS] Callback Args in ROS2

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] Callback Args in ROS2

Gary Edwards via ros-users


Hey All,

I was curious as to whether or not ["callback_args"](https://github.com/ros/ros_comm/blob/melodic-devel/clients/rospy/src/rospy/topics.py#L537-L539) were going to make their way into ROS 2? If not, out of curiosity, what is the justification and are there any alternative solutions?

Thanks in advance.





---
[Visit Topic](https://discourse.ros.org/t/callback-args-in-ros2/4727/1) 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
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] Callback Args in ROS2

Gary Edwards via ros-users


There's no reason it could not be in `rclpy`. In C++, you'd probably just use a lambda or `std::bind` to accomplish this, but for convenience it could also be in `rclcpp` as well.

I would file a feature request issue on `rclpy` and/or `rclcpp` and consider doing a pr after getting feedback on the approach.





---
[Visit Topic](https://discourse.ros.org/t/callback-args-in-ros2/4727/2) 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
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] Callback Args in ROS2

Gary Edwards via ros-users


Thanks for the feedback and sorry for the delayed response. I haven't filed a feature request yet but I did find a temporary fix. I was able to get similar functionality utilizing [partial functions in python](https://docs.python.org/3/library/functools.html#functools.partial).

For example:
```
from functools import partial
create_subscription(msg_type, ros_topic, partial(callback_function(), passed_variable))
```





---
[Visit Topic](https://discourse.ros.org/t/callback-args-in-ros2/4727/3) 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
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] Callback Args in ROS2

Gary Edwards via ros-users


Yeah, that's a proper solution, similar to using a `lambda` or `std::bind` in C++. We'd only provide a similar interface in `rclpy` as a convenience, but it's not necessary at all.





---
[Visit Topic](https://discourse.ros.org/t/callback-args-in-ros2/4727/4) 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
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>
Reply | Threaded
Open this post in threaded view
|

[Discourse.ros.org] [Next Generation ROS] Callback Args in ROS2

Gary Edwards via ros-users


I'd vote for implementing it, at least in rclpy. I like to think of Python as a more beginner friendly interface many times.

@Seiwert thanks for your response anyways!





---
[Visit Topic](https://discourse.ros.org/t/callback-args-in-ros2/4727/5) 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
[hidden email]
http://lists.ros.org/mailman/listinfo/ros-users
Unsubscribe: <http://lists.ros.org/mailman//options/ros-users>