File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ from std_msgs.msg import Header
77if __name__ == '__main__' :
88
99 a = Header
10- rospy .init_node ('python_node' , anonymous = True )
10+ rospy .init_node ('python_node' , anonymous = False )
1111
1212 controller = cnt .Controller ()
1313
Original file line number Diff line number Diff line change 1+ use rosrust;
2+ use std:: sync:: Arc ;
3+
4+ pub struct Controller {
5+ subscriber : Arc < rosrust:: Subscriber > ,
6+ }
7+
8+
9+ impl Controller {
10+
11+ pub fn new ( ) -> Controller {
12+
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 | {
15+ publisher. send ( v) . unwrap ( ) ;
16+ } ) . unwrap ( ) ) ;
17+
18+ Controller {
19+ subscriber,
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change 11use rosrust;
2+ extern crate rust_node;
23
34fn main ( ) {
45
56 rosrust:: init ( "rust_node" ) ;
67
7- let publisher = rosrust:: publish ( "rust_to_cpp" , 0 ) . unwrap ( ) ;
8- let subscriber_info = rosrust:: subscribe ( "python_to_rust" , 1 , move |v : rosrust_msg:: std_msgs:: Header | {
9- rosrust:: ros_info!( "Received: {}" , v. seq) ;
10- publisher. send ( v) . unwrap ( ) ;
11- } )
12- . unwrap ( ) ;
8+ let controller = rust_node:: Controller :: new ( ) ;
139
1410 rosrust:: spin ( ) ;
1511}
You can’t perform that action at this time.
0 commit comments