-
Notifications
You must be signed in to change notification settings - Fork 602
feat: rust performance and api improvements #2080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aclauer
wants to merge
19
commits into
main
Choose a base branch
from
andrew/feat/native-rust-perf-improvements
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
422ea67
Good software, test based development
aclauer aee9f74
Pub and recv in separate tasks
aclauer 0db9ee5
Module macros
aclauer d2a4cd5
Faster route matching
aclauer 7da10eb
Clippy appeasement and add to precommit
aclauer e213766
Rename to handler
aclauer 26904cd
Merge remote-tracking branch 'origin/main' into andrew/feat/native-ru…
aclauer 8e4c5fd
Rename crates
aclauer 77c3b18
Doc
aclauer f0747c2
Propagate errors and typo
aclauer 354fa4e
Update native/rust/README.md
aclauer 1573e77
Address comments
aclauer 94490b6
Remove error sleep
aclauer c322cf4
Merge branch 'main' into andrew/feat/native-rust-perf-improvements
aclauer b83b451
Merge branch 'main' into andrew/feat/native-rust-perf-improvements
aclauer 8876e49
Merge branch 'main' into andrew/feat/native-rust-perf-improvements
aclauer 3978095
Merge branch 'main' into andrew/feat/native-rust-perf-improvements
aclauer 1b0e2b1
Merge branch 'main' into andrew/feat/native-rust-perf-improvements
aclauer 291dbfa
Teardown even with error
aclauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,55 @@ | ||
| // NativeModule ping example. | ||
| // | ||
| // Sends a Twist message at 5 Hz and logs each echo received on `confirm`. | ||
|
|
||
| use dimos_native_module::{LcmTransport, NativeModule}; | ||
| use dimos_module::{run, Input, LcmTransport, Module, Output}; | ||
| use lcm_msgs::geometry_msgs::{Twist, Vector3}; | ||
| use tokio::time::{interval, Duration}; | ||
|
|
||
| #[tokio::main] | ||
| async fn main() { | ||
| let transport = LcmTransport::new() | ||
| .await | ||
| .expect("Failed to create transport"); | ||
| let (mut module, _config) = NativeModule::from_stdin::<()>(transport) | ||
| .await | ||
| .expect("Failed to read config from stdin"); | ||
|
|
||
| let mut confirm = module.input("confirm", Twist::decode); | ||
| let data = module.output("data", Twist::encode); | ||
| let _handle = module.spawn(); | ||
| #[derive(Module)] | ||
| #[module(setup = start_publisher)] | ||
| struct Ping { | ||
| #[input(decode = Twist::decode)] | ||
| confirm: Input<Twist>, | ||
|
|
||
| let mut ticker = interval(Duration::from_millis(200)); | ||
| let mut seq = 0u64; | ||
| #[output(encode = Twist::encode)] | ||
| data: Output<Twist>, | ||
| } | ||
|
|
||
| loop { | ||
| tokio::select! { | ||
| _ = ticker.tick() => { | ||
| impl Ping { | ||
| async fn start_publisher(&mut self) { | ||
| let data = self.data.clone(); | ||
| tokio::spawn(async move { | ||
| let mut ticker = interval(Duration::from_millis(200)); | ||
| let mut seq = 0u64; | ||
| loop { | ||
| ticker.tick().await; | ||
| let msg = Twist { | ||
| linear: Vector3 { x: seq as f64, y: 0.0, z: 0.0 }, | ||
| angular: Vector3 { x: 0.0, y: 0.0, z: 0.0 }, | ||
| linear: Vector3 { | ||
| x: seq as f64, | ||
| y: 0.0, | ||
| z: 0.0, | ||
| }, | ||
| angular: Vector3 { | ||
| x: 0.0, | ||
| y: 0.0, | ||
| z: 0.0, | ||
| }, | ||
| }; | ||
| data.publish(&msg).await.ok(); | ||
| seq += 1; | ||
| } | ||
| Some(echo) = confirm.recv() => { | ||
| eprintln!("ping: echo received (seq={}, sample_config={})", echo.linear.x as u64, echo.angular.z as i64); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| async fn handle_confirm(&mut self, echo: Twist) { | ||
| println!( | ||
| "ping: echo received (seq={}, sample_config={})", | ||
| echo.linear.x as u64, echo.angular.z as i64, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| #[tokio::main] | ||
| async fn main() { | ||
| let transport = LcmTransport::new() | ||
| .await | ||
| .expect("Failed to create transport"); | ||
| run::<Ping, _>(transport).await.expect("ping run failed"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| target/ | ||
| /target/ | ||
| **/*.rs.bk |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dreamsorcerer example of why I care about single path for CI and local dev envs for linting/code modification, think we should do what we discussed with modifying vs validating pre-commit hooks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds good.