Ros_rust to publish data to another computer

I want to use rosrust for publishing data to another computer (where ros will be running). How can I do so by using this crate (GitHub - adnanademovic/rosrust: Pure Rust implementation of a ROS client library)
I am using current code to publish data into the same system.

fn main() {
    // Initialize node

    // Create publisher
    let chatter_pub = rosrust::publish("chatter", 100).unwrap();

    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 mut msg = rosrust_msg::std_msgs::String::default(); = format!("hello world {}", count);

        // Send string message to topic via publisher

        // Sleep to maintain 10Hz rate

        count += 1;

I figure out that It is essential to run rosbridge on the computer where you want to send data to. After installing rosbridge using the following command sudo apt-get install ros-<rosdistro>-rosbridge-server and launching using the command roslaunch rosbridge_server rosbridge_websocket.launch it was working perfectly. I would like to suggest to take care of the port number as rosbridge usually use 9090 and any different port number in the code could lead to error.

I am closing this issue as it has been solved. If the problem persists, please comment and the issue will be reopened if appropriate.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.