Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some problems I had testing connectivity with the ros1 framework #4

Closed
jackyliu16 opened this issue Jul 24, 2023 · 4 comments
Closed

Comments

@jackyliu16
Copy link

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
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
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.

  1. when using the roscore tools from ros1 framework, if a subscriber is register after publisher then it will not receiver any kind of message, until publisher has register. But in ros-core-rs, if a subscriber register before publisher, both node will be clogging (which haven't received and send any message)
  2. it seems this unable to using tools in ros1 framework to detect the master node , which other node could be detected as node but master as topic
$ rosnode list
/talker
  1. it seems is unable to using rosbag to register into master to record the message.
$ rosbag record -O bag chatter
[ INFO] [1690180687.903903404]: Subscribing to chatter
[ WARN] [1690180687.905659229]: couldn't register subscriber on topic [/chatter]
[ INFO] [1690180687.906254249]: Recording to 'bag.bag'.
  1. it seems it's unable to use rostopic to echo the message has been sent in topic
$ rostopic echo chatter
Traceback (most recent call last):
  File "/nix/store/9587crxh9llk7h13zzb4qf7p439w93v4-ros-noetic-rostopic-1.16.0-r1/bin/.rostopic-wrapped", line 36, in <module>
    rostopic.rostopicmain()
  File "/nix/store/ppg86vx0n6dacfv4spbmkmz97hf8ia9p-ros-env/lib/python3.10/site-packages/rostopic/__init__.py", line 2130, in rostopicmain
    _rostopic_cmd_echo(argv)
  File "/nix/store/ppg86vx0n6dacfv4spbmkmz97hf8ia9p-ros-env/lib/python3.10/site-packages/rostopic/__init__.py", line 1406, in _rostopic_cmd_echo
    _rostopic_echo(topic, callback_echo, bag_file=options.bag)
  File "/nix/store/ppg86vx0n6dacfv4spbmkmz97hf8ia9p-ros-env/lib/python3.10/site-packages/rostopic/__init__.py", line 1017, in _rostopic_echo
    _check_master()
  File "/nix/store/ppg86vx0n6dacfv4spbmkmz97hf8ia9p-ros-env/lib/python3.10/site-packages/rostopic/__init__.py", line 90, in _check_master
    rosgraph.Master('/rostopic').getPid()
  File "/nix/store/ppg86vx0n6dacfv4spbmkmz97hf8ia9p-ros-env/lib/python3.10/site-packages/rosgraph/masterapi.py", line 292, in getPid
    return self._succeed(self.handle.getPid(self.caller_id))
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/xmlrpc/client.py", line 1122, in __call__
    return self.__send(self.__name, args)
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/xmlrpc/client.py", line 1464, in __request
    response = self.__transport.request(
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/xmlrpc/client.py", line 1166, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/xmlrpc/client.py", line 1182, in single_request
    return self.parse_response(resp)
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/xmlrpc/client.py", line 1354, in parse_response
    return u.close()
  File "/nix/store/6qk2ybm2yx2dxmx9h4dikr1shjhhbpfr-python3-3.10.11/lib/python3.10/xmlrpc/client.py", line 668, in close
    raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault 404: 'Unknown method.'>

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.

@jackyliu16 jackyliu16 changed the title If ros-core-rs could be discovered by ros1 framework? Some problems I had testing connectivity with the ros1 framework Jul 24, 2023
@PatWie
Copy link
Owner

PatWie commented Jul 24, 2023

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,...)

@jackyliu16
Copy link
Author

Thank you for your reply, I will take a serious look.

@jobafr
Copy link
Contributor

jobafr commented Jul 22, 2024

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.

@PatWie
Copy link
Owner

PatWie commented Jan 11, 2025

As lack of activity and trusting @jobafr explanation, this issue seems to be resolved.

@PatWie PatWie closed this as completed Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants