Skip to content

Commit f619c04

Browse files
author
Adam Ligocki
committed
fixed rust code
1 parent c606ab2 commit f619c04

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

ros/src/rust_node/src/lib.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
use rosrust;
2-
use rosrust::Message;
2+
use std::sync::Arc;
33

4-
pub struct Controller<T>{
5-
subscriber: subscriber<T>,
6-
publisher: publisher<T>,
4+
pub struct Controller{
5+
subscriber: Arc<rosrust::Subscriber>,
76
}
87

98

10-
impl<T> Controller<T> where T: Message {
9+
impl Controller {
1110

12-
pub fn new() -> Controller<T> {
11+
pub fn new() -> Controller {
1312

14-
let publisher = rosrust::publish("rust_to_cpp", 0).unwrap();
15-
let subscriber = rosrust::subscribe("python_to_rust", 1, move |v: rosrust_msg::std_msgs::Header| {
16-
rosrust::ros_info!("Received: {}", v.seq);
13+
let publisher = Arc::new(rosrust::publish("rust_to_cpp", 0).unwrap());
14+
let subscriber = Arc::new(rosrust::subscribe("python_to_rust", 1, move |v: rosrust_msg::std_msgs::Header| {
1715
publisher.send(v).unwrap();
18-
});
16+
}).unwrap());
1917

2018
Controller {
2119
subscriber,
22-
publisher
2320
}
2421
}
2522
}

ros/src/rust_node/src/main.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,7 @@ fn main() {
55

66
rosrust::init("rust_node");
77

8-
let publisher = rosrust::publish("rust_to_cpp", 0).unwrap();
9-
let subscriber_info = rosrust::subscribe("python_to_rust", 1, move |v: rosrust_msg::std_msgs::Header| {
10-
rosrust::ros_info!("Received: {}", v.seq);
11-
publisher.send(v).unwrap();
12-
})
13-
.unwrap();
14-
158
let controller = rust_node::Controller::new();
169

17-
let a = publisher;
18-
1910
rosrust::spin();
2011
}

0 commit comments

Comments
 (0)