Crate roslibrust_rosbridge

Crate roslibrust_rosbridge 

Source
Expand description

A implementation of roslibrust’s generic traits for rosbridge_suite communication.

rosbridge_server provides a useful websocket interface to ROS.

This server operates over a single port making it easier to use in constrained networking environments and support TLS.

Additionally, rosbridge_server exists for both ROS1 and ROS2 with an unchanged API meaning code targeting rosbridge can be used with both ROS1 and ROS2.

This backend is fundamentally less efficient than native ROS1 communication, but its added flexibility can be very useful.

Basic Example:

// Normally accessed as roslibrust::{Result, TopicProvider, Publish}
use roslibrust_common::{Result, TopicProvider, Publish};
// Normally you'd use generated types from roslibrust::codegen
use roslibrust_test::ros1::*;
use roslibrust_rosbridge::ClientHandle;

async fn my_behavior(ros: impl TopicProvider) -> Result<()> {
    let publisher = ros.advertise::<std_msgs::String>("my_topic").await?;
    publisher.publish(&std_msgs::String { data: "Hello, world!".to_string() }).await?;
    Ok(())
}

#[tokio::main]
async fn main() -> Result<()> {
    // Create a rosbridge handle we can use
    let ros = ClientHandle::new("ws://localhost:9090").await?;
    // Use it like ros:
    my_behavior(ros).await?;
    Ok(())
}

Structs§

ClientHandle
The ClientHandle is the fundamental object through which users of this library are expected to interact with it.
ClientHandleOptions
Builder options for creating a client
Publisher
A handle given to the caller when they advertise a topic
ServiceClient
Rosbridge doesn’t have the same concept of service client that ros1 native has This type is used to replicate the api of ros1::ServiceClient, but really it just a thin wrapper around call_service() and has no performance benefits
ServiceHandle
The handle returned to the caller of advertise_service this struct represents the lifetime of the service, and dropping this struct automatically unadvertises and removes the service. No interaction with this struct is expected beyond managing its lifetime.
Subscriber
Represents a single instance of listening to a topic, and provides the ability to extract messages