use rosrust::RawMessageDescription;
mod msg {
rosrust::rosmsg_include!(std_msgs / String);
}
fn main() {
env_logger::init();
rosrust::init("talker");
let chatter_pub = rosrust::publish_with_description(
"chatter",
2,
RawMessageDescription {
msg_definition: "string data\n".into(),
md5sum: "992ce8a1687cec8c8bd883ec73ca41d1".into(),
msg_type: "std_msgs/String".into(),
},
)
.unwrap();
chatter_pub.wait_for_subscribers(None).unwrap();
let log_names = rosrust::param("~log_names").unwrap().get().unwrap_or(false);
let mut count = 0;
let rate = rosrust::rate(10.0);
while rosrust::is_ok() {
let msg = rosrust::RawMessage(vec![
27,
0,
0,
0,
104,
101,
108,
108,
111,
32,
119,
111,
114,
108,
100,
32,
102,
114,
111,
109,
32,
114,
111,
115,
114,
117,
115,
116,
32,
48 + (count / 10) % 10,
48 + count % 10,
]);
rosrust::ros_info!("Publishing: {:?}", msg.0);
chatter_pub.send(msg).unwrap();
if log_names {
rosrust::ros_info!("Subscriber names: {:?}", chatter_pub.subscriber_names());
}
rate.sleep();
count += 1;
}
}