49 #ifndef __RTT_ROSCOMM_ROS_MSG_TRANSPORTER_HPP_ 50 #define __RTT_ROSCOMM_ROS_MSG_TRANSPORTER_HPP_ 52 #include <rtt/rtt-config.h> 61 #ifndef RTT_VERSION_GTE 62 #define RTT_VERSION_GTE(major,minor,patch) \ 63 ((RTT_VERSION_MAJOR > major) || (RTT_VERSION_MAJOR == major && \ 64 (RTT_VERSION_MINOR > minor) || (RTT_VERSION_MINOR == minor && \ 65 (RTT_VERSION_PATCH >= patch)))) 79 static const RosType &
toRos(
const OrocosType &t) {
return t; }
80 static const OrocosType &
fromRos(
const RosType &t) {
return t; }
116 ros_node_private(
"~")
119 std::stringstream namestr;
120 gethostname(hostname,
sizeof(hostname));
124 <<
'/' << port->
getName() <<
'/'<<
this <<
'/' << getpid();
126 namestr << hostname<<
'/' << port->
getName() <<
'/'<<
this <<
'/' << getpid();
128 policy.
name_id = namestr.str();
140 if(topicname.length() > 1 && topicname.at(0) ==
'~') {
146 act->addPublisher(
this );
152 act->removePublisher(
this );
169 return "RosPubChannelElement";
183 #if RTT_VERSION_GTE(2,8,99) 186 this->sample = sample;
192 this->sample = sample;
205 return act->trigger();
215 #if RTT_VERSION_GTE(2,8,99) 221 ros_pub.
publish(adapter::toRos(sample));
222 #if RTT_VERSION_GTE(2,8,99) 257 ros_node_private(
"~")
266 if(topicname.length() > 1 && topicname.at(0) ==
'~') {
287 return "RosSubChannelElement";
302 output->
write(adapter::fromRos(msg));
320 RTT::log(
RTT::Error) <<
"Cannot create ROS message transport because the node is not initialized or already shutting down. Did you import package rtt_rosnode before?" <<
RTT::endlog();
328 RTT::log(
RTT::Debug) <<
"Creating unbuffered publisher connection for port " << port->getName() <<
". This may not be real-time safe!" <<
RTT::endlog();
334 #if RTT_VERSION_GTE(2,8,99) 335 buf->connectTo(channel);
337 buf->setOutput(channel);
344 #if !RTT_VERSION_GTE(2,8,99) 347 channel->setOutput(buf);
boost::call_traits< T >::param_type param_t
boost::intrusive_ptr< ChannelElement< T > > shared_ptr
virtual std::string getElementName() const
void publish(const boost::shared_ptr< M > &message) const
virtual std::string getRemoteURI() const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual std::string getRemoteURI() const
const std::string & getName() const
static const OrocosType & fromRos(const RosType &t)
virtual bool isRemoteElement() const
RTT::base::ChannelElement< T >::value_t sample
RosPubChannelElement(RTT::base::PortInterface *port, const RTT::ConnPolicy &policy)
bool write(typename RTT::base::ChannelElement< T >::param_t sample)
DataFlowInterface * getInterface() const
RosPublishActivity::shared_ptr act
We must cache the RosPublishActivity object.
virtual RTT::base::ChannelElementBase::shared_ptr createStream(RTT::base::PortInterface *port, const RTT::ConnPolicy &policy, bool is_sender) const
std::string getTopic() const
static const RosType & toRos(const OrocosType &t)
virtual bool isRemoteElement() const
virtual FlowStatus read(reference_t sample, bool copy_old_data=true)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
RosSubChannelElement(RTT::base::PortInterface *port, const RTT::ConnPolicy &policy)
boost::intrusive_ptr< ChannelElementBase > shared_ptr
virtual bool data_sample(typename RTT::base::ChannelElement< T >::param_t sample)
RosMessageAdapter< T > adapter
ros::NodeHandle ros_node_private
virtual std::string getElementName() const
ros::NodeHandle ros_node_private
virtual bool inputReady()
void newData(const RosType &msg)
virtual WriteStatus write(param_t sample)
std::string getTopic() const
virtual bool inputReady()
RosMessageAdapter< T > adapter
static Logger::LogFunction endlog()
static const int UNBUFFERED
virtual const std::string & getName() const
TaskContext * getOwner() const
static shared_ptr Instance()