Package lcm.lcm
Class LCM
java.lang.Object
lcm.lcm.LCM
Lightweight Communications and Marshalling Java implementation
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Call this function to release all resources used by the LCM instance.static String
int
Return the number of subscriptions.static LCM
Retrieve a default instance of LCM using either the environment variable LCM_DEFAULT_URL or the default.static void
Minimalist test code.void
Publish raw data on a channel, bypassing the LCM type specification.void
Publish a string on a channel.void
publish
(String channel, LCMEncodable e) Publish an LCM-defined type on a channel.void
receiveMessage
(String channel, byte[] data, int offset, int length) Not for use by end users.void
subscribe
(String regex, LCMSubscriber sub) Subscribe to all channels whose name matches the regular expression.void
A convenience function that subscribes to all LCM channels.void
unsubscribe
(String regex, LCMSubscriber sub) Remove this particular regex/subscriber pair (UNTESTED AND API MAY CHANGE).
-
Constructor Details
-
LCM
Create a new LCM object, connecting to one or more URLs. If no URL is specified, the environment variable LCM_DEFAULT_URL is used. If that environment variable is not defined, then the default URL is used.- Throws:
IOException
-
-
Method Details
-
getDefaultURL
- Returns:
- The value of the LCM_DEFAULT_URL environment variable if set or "udpm://239.255.76.67:7667".
-
getSingleton
Retrieve a default instance of LCM using either the environment variable LCM_DEFAULT_URL or the default. If an exception occurs, System.exit(-1) is called. -
getNumSubscriptions
public int getNumSubscriptions()Return the number of subscriptions. -
publish
Publish a string on a channel. This method does not use the LCM type definitions and thus is not type safe. This method is primarily provided for testing purposes and may be removed in the future.- Throws:
IOException
-
publish
Publish an LCM-defined type on a channel. If more than one URL was specified, the message will be sent on each. -
publish
Publish raw data on a channel, bypassing the LCM type specification. If more than one URL was specified when the LCM object was created, the message will be sent on each.- Throws:
IOException
-
subscribe
Subscribe to all channels whose name matches the regular expression. Note that to subscribe to all channels, you must specify ".*", not "*". -
unsubscribe
Remove this particular regex/subscriber pair (UNTESTED AND API MAY CHANGE). If regex is null, all subscriptions for 'sub' are cancelled. If subscriber is null, any previous subscriptions matching the regular expression will be cancelled. If both 'sub' and 'regex' are null, all subscriptions will be cancelled. -
receiveMessage
Not for use by end users. Provider back ends call this method when they receive a message. The subscribers that match the channel name are synchronously notified. -
subscribeAll
A convenience function that subscribes to all LCM channels. -
close
public void close()Call this function to release all resources used by the LCM instance. After calling this function, the LCM instance should consume no resources, and cannot be used to receive or transmit messages. -
main
Minimalist test code.
-