Go to the documentation of this file.
22 #ifndef INPUT_ROS_NODE_H
23 #define INPUT_ROS_NODE_H
25 #include <boost/python.hpp>
26 #include <boost/shared_ptr.hpp>
27 #include <boost/function.hpp>
40 template<
class MSG_TYPE>
52 {
return "RosSubscriber"; }
59 using boost::placeholders::_1;
63 rosProxy->
subscribe(this->
id(), callback);
66 "\". NRPCoreSim is not connected to ROS and this node can't subscribe to topics. Add \"ROSNode\" parameter to your experiment configuration");
78 std::lock_guard<std::mutex> lock(_msgMutex);
81 if(_msgTemp.size() < _msgTemp.capacity())
82 _msgTemp.push_back(std::move(msg));
84 NRPLogger::debug(
"'"+this->
id()+
"' node capacity is full. Dropping message...");
89 std::lock_guard<std::mutex> lock(_msgMutex);
97 for(
auto & msg : _msgTemp) {
98 _msgStore.push_back(std::move(msg));
113 std::mutex _msgMutex;
115 std::vector<boost::shared_ptr<MSG_TYPE const>> _msgTemp;
117 std::vector<boost::shared_ptr<MSG_TYPE const>> _msgStore;
123 template<
class MSG_TYPE>
141 #endif //INPUT_ROS_NODE_H
static void warn(const FormatString &fmt, const Args &...args)
NRP logging function with message formatting for warning level.
Definition: nrp_logger.h:149
Definition: nrp_ros_proxy.h:30
const std::string & id() const
Returns the node 'id'.
Definition: computational_node.h:57
static NRPROSProxy & getInstance()
Get singleton instance of NRPROSProxy.
Definition: nrp_ros_proxy.cpp:26
void subscribe(const std::string &address, const boost::function< void(const boost::shared_ptr< MSG_TYPE const > &)> &callback, size_t queueSize=10)
Subscribe to ROS topic 'address' with callback function 'callback'.
Definition: nrp_ros_proxy.h:55
static void debug(const FormatString &fmt, const Args &...args)
NRP logging function with message formatting for debug level.
Definition: nrp_logger.h:127