tf_listener and lookup_transform in roslibrust #177
Replies: 2 comments 2 replies
-
Very cool!! This is an awesome example to have of some real world usage of roslibrust outside of the silo I've been using it for and shows some areas where we have substantial work to continue to improve the usability and API of the crate. If you have additional perspectives on usability I'd love to hear them. Below are some of my thoughts upon reviewing the code:
This is pain we should be able to remove: let full_node_name = &format!("/{ns}/tf2tf").replace("//", "/");
let _dynamic_subscriber = nh.subscribe::<TFMessage>("/tf", 100).await.unwrap();
let _static_subscriber = nh.subscribe::<TFMessage>("/tf_static", 100).await.unwrap(); The rust side of me flinches at these unwraps, but frankly that is probably a more sane thing to do than most C++ ROS nodes do when communication to the ROS master fails. It shouldn't be hard to build systems with robust reconnection logic, but ROS's general style for C++ and Python has people not think about this, and you can make a really good case for that. Dealing with complex networking scenarios where things are going in and out of communication makes code fundamentally harder to write, and probably shouldn't be what "example code shows". But I do want the API of the crate to lead to the Rust "pit of success", as it stands I think the vast majority of users will end up just calling .unwrap() on the fact that an subscribe() call can fail... I'm toying with a lot of ideas of how to make handling the possible errors that can happen with ROS communication internally to the crate, and making more of the external API infallible, but hard to do this in ways that I can be confident will work for everybody. I'd like to steer the API / Behavior of roslibrust towards:
This API is slightly worse in some objective ways, as not handling the errors at the callsite of the triggering event means you lose context about what was happening. An example of this would be having a node where in multiple places you are publishing to the same topic, but it is only a serious problem when failures occur at specific locations. However, I think this API would make users of the crate significantly more likely to implement good error handling in their nodes.... Sorry long rant.
|
Beta Was this translation helpful? Give feedback.
-
I also said it at the top of my previous message, but I'll say it again. Thank you! |
Beta Was this translation helpful? Give feedback.
-
It needs additional features, testing, and cleanup but I made a roslibrust version of rustros_tf/tf_rosrust: https://github.com/lucasw/rustros_tf/tree/roslibrust, additional description is here: smilerobotics/tf_rosrust#55
There's also a node (in addition to echo.rs) that uses it here: https://github.com/lucasw/tf_demo/blob/old_tf_to_new_tf/src/bin/tf2tf.rs - you can look up any tf then publish the relationship as a new transform with any parent child desired. The python and C++ versions have additional features to modify parts of the found transform, zero out rotations or translations on any axis- I'll add that in later.
Having the equivalent of dynamic reconfigure (actually dynamic-dynamic reconfigure) would be nice but I can live without it, I can have a workflow of using the python or C++ version initially for experimentation then swapping in the rust node when the parameters are set. A replacement wouldn't need to use ros parameters/topics/services just a lightweight way to tell the node to change parameter values with the possibility of a gui front end in another process.
It looks comparable in performance to the C++ version so far.
Any suggestions are very welcome.
Beta Was this translation helpful? Give feedback.
All reactions