Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ members = [
"node-hub/dora-rav1e",
"node-hub/dora-dav1d",
"node-hub/dora-rustypot",
"node-hub/dora-tcp",
"libraries/extensions/ros2-bridge",
"libraries/extensions/ros2-bridge/msg-gen",
"libraries/extensions/ros2-bridge/python",
Expand Down
13 changes: 13 additions & 0 deletions node-hub/dora-tcp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "dora-tcp"
version.workspace = true
edition.workspace = true
documentation.workspace = true
description.workspace = true
license.workspace = true
repository.workspace = true

[dependencies]
dora-node-api = { workspace = true }
tokio = { version = "1.45.0", features = ["full"] }
eyre = "0.6.8"
34 changes: 34 additions & 0 deletions node-hub/dora-tcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# dora-tcp

Basic TCP Implementation for streaming data to a TCP Destination.


## Getting Started
Copy the node to your dora project and build it


Example:
- Streaming drive commands to a Unity simulation hosting a TCP server.

Example dataflow.yml
```shell
nodes:
- id: drive_director
build: cargo build -p drive_director
path: target/debug/drive_director
inputs:
tick: dora/timer/millis/100
outputs:
- command
- id: dora-tcp
build: cargo build -p dora-tcp
path: target/debug/dora-tcp
inputs:
command: drive_director/command
```

## Input definition

- command: String

Note: I used a colon to separate the commands ie drive:10 but you can modify as needed.
37 changes: 37 additions & 0 deletions node-hub/dora-tcp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Basic TCP implementation for streaming events to a TCP Destination
*/
use dora_node_api::{DoraNode, Event};
use eyre::Result;
use tokio::io::AsyncWriteExt;
use tokio::net::TcpStream;

pub async fn lib_main() -> Result<()> {
// NOTE: Hard-coded address
let mut stream =
TcpStream::connect(std::env::var("ADDR").unwrap_or("127.0.0.1:8052".to_string())).await?;

let (_, mut events) = DoraNode::init_from_env()?;

while let Some(event) = events.recv() {
match event {
Event::Input {
id,
metadata: _,
data,
} => match id.as_str() {
"text" => {
// Extract the command
let command: &str = (&data).try_into()?;

// Send the command to the Unity over tcp
stream.write_all(command.as_bytes()).await?;
}
_ => {}
},
_ => {}
}
}

Ok(())
}
5 changes: 5 additions & 0 deletions node-hub/dora-tcp/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[tokio::main]

async fn main() -> Result<(), eyre::Error> {
dora_tcp::lib_main().await
}
Loading