Crate robomotion

Crate robomotion 

Source
Expand description

Robomotion Rust SDK

This library provides the official Rust SDK for building Robomotion packages. It offers a runtime framework for creating plugin-based automation nodes that communicate with the Robomotion platform via gRPC.

§Example

use robomotion::prelude::*;

#[derive(Node, Default)]
#[node(id = "MyPackage.HelloWorld", name = "Hello World", icon = "mdiHand", color = "#3498db")]
struct HelloWorld {
    node: NodeBase,

    #[input(title = "Name", var_type = "string", scope = "Message", name = "name")]
    in_name: InVariable<String>,

    #[output(title = "Greeting", var_type = "string", scope = "Message", name = "greeting")]
    out_greeting: OutVariable<String>,
}

#[async_trait]
impl MessageHandler for HelloWorld {
    async fn on_create(&mut self) -> Result<()> {
        Ok(())
    }

    async fn on_message(&mut self, ctx: &mut Context) -> Result<()> {
        let name = self.in_name.get(ctx).await?;
        self.out_greeting.set(ctx, format!("Hello, {}!", name)).await?;
        Ok(())
    }

    async fn on_close(&mut self) -> Result<()> {
        Ok(())
    }
}

#[tokio::main]
async fn main() {
    register_nodes![HelloWorld];
    start().await;
}

Modules§

debug
Debug attach/detach functionality for development.
message
Message context for data flow between nodes.
prelude
proto
Generated protobuf code for gRPC communication.
runtime
Core runtime types and functionality for Robomotion nodes.
utils
Utility functions.

Macros§

register_nodes
Macro to register multiple nodes.

Derive Macros§

Node
Derive macro for Robomotion nodes.