NRP Core  1.4.1
InputMQTTNode< MSG_TYPE > Class Template Reference

Input node used to connect a ROS subscriber to the computational graph. More...

#include <input_node.h>

Inheritance diagram for InputMQTTNode< MSG_TYPE >:
InputNode< MSG_TYPE > ComputationalNode

Public Member Functions

 InputMQTTNode (const std::string &id, const std::string &address)
 Constructor. More...
 
std::string typeStr () const override
 Returns the node 'type' as a string. More...
 
- Public Member Functions inherited from InputNode< MSG_TYPE >
 InputNode (const std::string &id, InputNodePolicies::MsgPublishPolicy msgPublishPolicy=InputNodePolicies::MsgPublishPolicy::LAST, InputNodePolicies::MsgCachePolicy msgCachePolicy=InputNodePolicies::MsgCachePolicy::KEEP_CACHE, size_t queue_size=10)
 Constructor. More...
 
void registerOutput (const std::string &id)
 Registers an Output port with id 'id' with this node. More...
 
OutputPort< MSG_TYPE > * getSinglePort (const std::string &id)
 Returns a pointer to single output port if the port is registered, nullptr otherwise. More...
 
OutputPort< std::vector< const MSG_TYPE * > > * getListPort (const std::string &id)
 Returns a pointer to list output port if the port is registered, nullptr otherwise. More...
 
InputNodePolicies::MsgPublishPolicy msgPublishPolicy ()
 
InputNodePolicies::MsgCachePolicy msgCachePolicy ()
 
void setMsgPublishPolicy (InputNodePolicies::MsgPublishPolicy msgPublishPolicy)
 
void setMsgCachePolicy (InputNodePolicies::MsgCachePolicy msgCachePolicy)
 
- Public Member Functions inherited from ComputationalNode
 ComputationalNode ()=delete
 
virtual ~ComputationalNode ()=default
 
 ComputationalNode (std::string id, NodeType type)
 Constructor. More...
 
const std::string & id () const
 Returns the node 'id'. More...
 
NodeType type () const
 Returns the node 'type'. More...
 
void setVisited (bool visited)
 Sets a value for the node 'visited' property, used for graph traversing. More...
 
bool isVisited () const
 Returns true if the node has been marked as visited, false otherwise. More...
 
void setDoCompute (bool doCompute)
 Sets a value for the node 'doCompute' property, used in some graph execution modes. More...
 
virtual bool doCompute () const
 Tells if this node should be executed in this graph execution cycle, used in some graph execution modes. More...
 

Protected Member Functions

void configure () override
 Configures the node making it ready to execute 'compute'. More...
 
void topic_callback (const std::string &msg)
 callback function used in the MQTT subscriber More...
 
bool updatePortData (const std::string &id) override
 Updates pointers stored in _portMap for port 'id'. More...
 
virtual void setMsgFromString ()
 set the msg conversion function depending on template argument MSG_TYPE More...
 
- Protected Member Functions inherited from InputNode< MSG_TYPE >
void compute () override final
 Compute. Updates and sends stored msgs. More...
 
- Protected Member Functions inherited from ComputationalNode
virtual void graphCycleStartCB ()
 Function called by the Computational Graph at the beginning of a new execution cycle. More...
 
virtual void graphLoadedCB ()
 Function called by the Computational Graph to nodes that the graph has been completely loaded. More...
 

Protected Attributes

std::function< MSG_TYPE(const std::string &)> _msgFromString
 converts msgs in string format to MSG_TYPE More...
 
- Protected Attributes inherited from InputNode< MSG_TYPE >
InputNodePolicies::MsgPublishPolicy _msgPublishPolicy
 Send policy used by this node. More...
 
InputNodePolicies::MsgCachePolicy _msgCachePolicy
 Msg cache policy used by this node. More...
 
std::map< std::string, DataPortHandle< MSG_TYPE > > _portMap
 Map containing data to handle topics. Data is guaranteed to be unchanged between 'compute' calls
More...
 
size_t _queueSize
 Maximum number of msgs that the node can store per port. More...
 

Additional Inherited Members

- Public Types inherited from ComputationalNode
enum  NodeType { Input, Output, Functional }
 All the possible node types. More...
 
- Static Public Member Functions inherited from ComputationalNode
static std::pair< std::string, std::string > parseNodeAddress (const std::string &address, bool hasPort=true)
 Parses a computational node address returning the node id and the port (if any) contained in the address. More...
 
- Static Public Attributes inherited from ComputationalNode
const static std::map< NodeType, std::string > nodeTypeStr
 

Detailed Description

template<class MSG_TYPE>
class InputMQTTNode< MSG_TYPE >

Input node used to connect a ROS subscriber to the computational graph.

The template parameter MSG_TYPE is the ROS msg type this node subscribes to

Constructor & Destructor Documentation

◆ InputMQTTNode()

template<class MSG_TYPE >
InputMQTTNode< MSG_TYPE >::InputMQTTNode ( const std::string &  id,
const std::string &  address 
)
inline

Constructor.

Member Function Documentation

◆ configure()

template<class MSG_TYPE >
void InputMQTTNode< MSG_TYPE >::configure ( )
inlineoverrideprotectedvirtual

Configures the node making it ready to execute 'compute'.

Implements ComputationalNode.

◆ setMsgFromString()

template<class MSG_TYPE >
virtual void InputMQTTNode< MSG_TYPE >::setMsgFromString ( )
inlineprotectedvirtual

set the msg conversion function depending on template argument MSG_TYPE

Reimplemented in DPInputMQTTNode< MSG_TYPE >.

◆ topic_callback()

template<class MSG_TYPE >
void InputMQTTNode< MSG_TYPE >::topic_callback ( const std::string &  msg)
inlineprotected

callback function used in the MQTT subscriber

◆ typeStr()

template<class MSG_TYPE >
std::string InputMQTTNode< MSG_TYPE >::typeStr ( ) const
inlineoverridevirtual

Returns the node 'type' as a string.

Reimplemented from ComputationalNode.

◆ updatePortData()

template<class MSG_TYPE >
bool InputMQTTNode< MSG_TYPE >::updatePortData ( const std::string &  id)
inlineoverrideprotectedvirtual

Updates pointers stored in _portMap for port 'id'.

Expected behavior: Implementations of this function must guarantee that data pointers stored in _portMap[id] are valid and will not change between calls to this function. Even after the function is called again, pointers in _portMap[id] should still be valid and remain unchanged if the function returns false, i.e., if port 'id' data wasn't changed.

Parameters
idkey in _portMap which data is asked to be updated
Returns
true if port 'id' has new data, false otherwise

Implements InputNode< MSG_TYPE >.

Member Data Documentation

◆ _msgFromString

template<class MSG_TYPE >
std::function<MSG_TYPE (const std::string&)> InputMQTTNode< MSG_TYPE >::_msgFromString
protected

converts msgs in string format to MSG_TYPE


The documentation for this class was generated from the following file: