Skip to content

Commit ef5400a

Browse files
author
Adam Ligocki
committed
added rust node and the rust to cpp message
1 parent fdda14f commit ef5400a

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

ros/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
# ROS
12
**/build/
23
**/devel/
4+
5+
# CLion and Pycharm
36
**/.idea/
47
**/cmake*/
58
**/__pycache__/
69
**/.catkin_workspace
10+
11+
# Rust
12+
**/Cargo.lock
13+
**/target

ros/src/cpp_node/src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class Controller {
1717
private:
1818

1919
void subscriber_callback (const std_msgs::Header& msg) const {
20-
std::cout << "Received msg with seq: " << msg.seq << std::endl;
20+
21+
auto delay = ros::Time::now() - msg.stamp;
22+
std::cout << "Message delay: " << delay << " sec" << std::endl;
2123
}
2224

2325
void timer_callback (const ros::TimerEvent& event) const {

ros/src/rust_node/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "rust_node"
3+
version = "1.1.0"
4+
authors = ["Adam Ligocki <[email protected]>"]
5+
edition = "2018"
6+
license = "MIT"
7+
8+
[dependencies]
9+
rosrust = "0.9"
10+
rosrust_msg = "0.1"

ros/src/rust_node/src/main.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use rosrust;
2+
3+
fn main() {
4+
5+
rosrust::init("rust_node");
6+
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();
13+
14+
rosrust::spin();
15+
}

0 commit comments

Comments
 (0)