Struct lcm::Lcm
[−]
[src]
pub struct Lcm { /* fields omitted */ }
An LCM instance that handles publishing and subscribing, as well as encoding and decoding messages.
Methods
impl Lcm
[src]
fn new() -> Result<Lcm>
Creates a new Lcm
instance.
use lcm::Lcm; let mut lcm = Lcm::new().unwrap();
fn get_fileno(&self) -> c_int
fn subscribe<M, F>(&mut self, channel: &str, callback: F) -> Rc<LcmSubscription> where
M: Message,
F: FnMut(M) + 'static,
M: Message,
F: FnMut(M) + 'static,
Subscribes a callback to a particular topic.
let mut lcm = Lcm::new().unwrap(); lcm.subscribe("GREETINGS", |name: String| println!("Hello, {}!", name) );
fn unsubscribe(&mut self, handler: Rc<LcmSubscription>) -> Result<()>
Unsubscribes a message handler.
let handler = lcm.subscribe("GREETINGS", handler_function); // ... lcm.unsubscribe(handler);
fn publish<M>(&mut self, channel: &str, message: &M) -> Result<()> where
M: Message,
M: Message,
Publishes a message on the specified channel.
let mut lcm = Lcm::new().unwrap(); lcm.publish("GREETINGS", &"Charles".to_string()).unwrap();
fn handle(&mut self) -> Result<()>
Waits for and dispatches the next incoming message.
let mut lcm = Lcm::new().unwrap(); lcm.subscribe("POSITION", handler_function); loop { lcm.handle().unwrap(); }
fn handle_timeout(&mut self, timeout: Duration) -> Result<()>
Waits for and dispatches the next incoming message, up to a time limit.
let mut lcm = Lcm::new().unwrap(); lcm.subscribe("POSITION", handler_function); let wait_dur = Duration::from_millis(100); loop { lcm.handle_timeout(Duration::from_millis(1000)).unwrap(); }
fn subscription_set_queue_capacity(
&self,
handler: Rc<LcmSubscription>,
num_messages: usize
)
&self,
handler: Rc<LcmSubscription>,
num_messages: usize
)
Adjusts the maximum number of received messages that can be queued up for a subscription.
The default is 30
.
let handler = lcm.subscribe("POSITION", handler_function); lcm.subscription_set_queue_capacity(handler, 30);