#roslibrust #ros #publish #traits #native #ros2 #ros1

roslibrust_rosbridge

Common types and traits used throughout the roslibrust ecosystem

1 unstable release

new 0.12.0 Jan 7, 2025

#233 in Robotics

Download history 84/week @ 2025-01-02

84 downloads per month
Used in roslibrust

MIT license

130KB
2K SLoC

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(())
}

Dependencies

~8–16MB
~200K SLoC