Open jackyliu16 opened 1 year ago
Thanks for the detailed write-up! I never intended this as a drop in replacement (more to bridge custom tools to the ROS world eg. for visualization).
both node will be clogging I was under the impression that the subscriber will talk to the publisher directly. Need to have a look
I might help to have RUST_LOG=DEBUG in the core for standard ros tooling compatibility (rostopic echo chatter,...)
Thank you for your reply, I will take a serious look.
Hi @jackyliu16,
I know it's been a year, but if this is still of interest to you, could you check again with the current version? I had similar issues with rosbag, and it turned out the bug was fixed in one of ros-core-rs's dependencies a while ago. The current git main version of ros-core-rs does pull in that fix now.
I was trying to simple use ros-core-rs as a kind of standalone software, unlike sync application you provide, I using the publisher subscriber example of rosrust.
Environment: Ubuntu 22.04
nix-ros-overlay noetic
``` { pkgs ? import ../. {} }: with pkgs; with rosPackages.noetic; with pythonPackages; mkShell { buildInputs = [ glibcLocales (buildEnv { paths = [ catkin ros-core roslaunch ros-comm roslaunch rospy rosbag rostopic rospy-tutorials # cmake-modules rosbash ros-tutorials # turtlebot3-description # turtlebot3-teleop # turtlebot3-gazebo gazebo-plugins xacro ]; }) ]; ROS_HOSTNAME = "localhost"; ROS_MASTER_URI = "http://localhost:11311"; TURTLEBOT3_MODEL = "burger"; } ```=====
publisher.rs
```rust const TOPIC_NAME: &str = "/chatter"; fn main() { env_logger::init(); // Initialize node rosrust::init("talker"); // Create publisher let chatter_pub = rosrust::publish(TOPIC_NAME, 2).unwrap(); chatter_pub.wait_for_subscribers(None).unwrap(); let log_names = rosrust::param("~log_names").unwrap().get().unwrap_or(false); let mut count = 0; // Create object that maintains 10Hz between sleep requests let rate = rosrust::rate(10.0); // Breaks when a shutdown signal is sent while rosrust::is_ok() { // Create string message let msg = rosrust_msg::std_msgs::String { data: format!("hello world from rosrust {}", count), }; // Log event rosrust::ros_info!("Publishing: {}", msg.data); // Send string message to topic via publisher chatter_pub.send(msg).unwrap(); if log_names { rosrust::ros_info!("Subscriber names: {:?}", chatter_pub.subscriber_names()); } // Sleep to maintain 10Hz rate rate.sleep(); count += 1; } } ```subscriber.rs
```rust const TOPIC_NAME: &str = "/chatter"; fn main() { env_logger::init(); // Initialize node rosrust::init("listener"); // Create subscriber // The subscriber is stopped when the returned object is destroyed let subscriber_info = rosrust::subscribe(TOPIC_NAME, 2, |v: rosrust_msg::std_msgs::String| { // Callback for handling received messages rosrust::ros_info!("Received: {}", v.data); }) .unwrap(); let log_names = rosrust::param("~log_names").unwrap().get().unwrap_or(false); if log_names { let rate = rosrust::rate(1.0); while rosrust::is_ok() { rosrust::ros_info!("Publisher uris: {:?}", subscriber_info.publisher_uris()); rate.sleep(); } } else { // Block the thread until a shutdown signal is received rosrust::spin(); } } ```When I'm trying to use this kind of packages, connect with local rospy package talker_listern from beginner_learnning, using cargo run as a kind of master. I found rosrust example is capable to connection to master and send message to rospy packages though topic.
These are a few questions I had during my brief test, and I would appreciate it if anyone could answer them or helpping in it.