Package edu.tufts.hrilab.ros2
Class Ros2Factory
java.lang.Object
edu.tufts.hrilab.ros2.Ros2Factory
Factory class to allow users to generate ROS 2 objects without needing to know a specific
underlying implementation. The main purpose of this class is so we can implement different
ROS2 Java implementations without changing classes that use ROS2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Ros2NodeReturns an instance of a Ros2 Node with the default implementationstatic Ros2NodegetDefaultNode(int domainId) static <T extends id.jrosmessages.Message>
Ros2Publisher<T>getDefaultPublisher(Class<T> messageType, String topicName) Returns an instance of a Ros2 publisher with the default implementationstatic <T extends id.jrosmessages.Message>
Ros2Publisher<T>getDefaultPublisher(Class<T> messageType, String topicName, T msg) Returns an instance of a Ros2 Node with the default implementation, with a pre-initialized message.static <T extends id.jrosmessages.Message>
Ros2Subscriber<T>getDefaultSubscriber(Class<T> messageType, String topic, SubscriberCallback<T> callback)
-
Constructor Details
-
Ros2Factory
public Ros2Factory()
-
-
Method Details
-
getDefaultNode
Returns an instance of a Ros2 Node with the default implementation- Returns:
- Generic Ros2 Node
-
getDefaultNode
- Parameters:
domainId- Domain ID to create the node in- Returns:
- Generic Ros2 Node
- See Also:
-
getDefaultPublisher
public static <T extends id.jrosmessages.Message> Ros2Publisher<T> getDefaultPublisher(Class<T> messageType, String topicName) Returns an instance of a Ros2 publisher with the default implementation- Type Parameters:
T- Message type- Parameters:
messageType- Type of the message this publisher will publish, e.g. StringMessagetopicName- Topic on which to publish- Returns:
- Generic ROS2 Publisher
-
getDefaultPublisher
public static <T extends id.jrosmessages.Message> Ros2Publisher<T> getDefaultPublisher(Class<T> messageType, String topicName, T msg) Returns an instance of a Ros2 Node with the default implementation, with a pre-initialized message.- Type Parameters:
T- Message type- Parameters:
messageType- Type of the message this publisher will publish, e.g. StringMessagetopicName- Topic on which to publishmsg- Initialized message to publish- Returns:
- Generic ROS2 Publisher
-
getDefaultSubscriber
public static <T extends id.jrosmessages.Message> Ros2Subscriber<T> getDefaultSubscriber(Class<T> messageType, String topic, SubscriberCallback<T> callback) - Type Parameters:
T- Message type- Parameters:
messageType- Type of the message this publisher will publish, e.g. StringMessagetopic- Topic on which to publishcallback- Function to execute on received message- Returns:
- Generic ROS2 Subscriber
-