30 #ifndef __RTT_ROSCOMM_ROS_MSG_TRANSPORTER_HPP_ 31 #define __RTT_ROSCOMM_ROS_MSG_TRANSPORTER_HPP_ 33 #include <rtt/rtt-config.h> 42 #ifndef RTT_VERSION_GTE 43 #define RTT_VERSION_GTE(major,minor,patch) \ 44 ((RTT_VERSION_MAJOR > major) || (RTT_VERSION_MAJOR == major && \ 45 (RTT_VERSION_MINOR > minor) || (RTT_VERSION_MINOR == minor && \ 46 (RTT_VERSION_PATCH >= patch)))) 60 static const RosType &
toRos(
const OrocosType &t) {
return t; }
61 static const OrocosType &
fromRos(
const RosType &t) {
return t; }
100 std::stringstream namestr;
101 gethostname(hostname,
sizeof(hostname));
105 <<
'/' << port->
getName() <<
'/'<<
this <<
'/' << getpid();
107 namestr << hostname<<
'/' << port->
getName() <<
'/'<<
this <<
'/' << getpid();
109 policy.
name_id = namestr.str();
121 if(topicname.length() > 1 && topicname.at(0) ==
'~') {
127 act->addPublisher(
this );
133 act->removePublisher(
this );
150 return "RosPubChannelElement";
164 #if RTT_VERSION_GTE(2,8,99) 167 this->sample = sample;
173 this->sample = sample;
186 return act->trigger();
196 #if RTT_VERSION_GTE(2,8,99) 202 ros_pub.
publish(adapter::toRos(sample));
203 #if RTT_VERSION_GTE(2,8,99) 238 ros_node_private(
"~")
247 if(topicname.length() > 1 && topicname.at(0) ==
'~') {
268 return "RosSubChannelElement";
283 output->
write(adapter::fromRos(msg));
301 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();
309 RTT::log(
RTT::Debug) <<
"Creating unbuffered publisher connection for port " << port->getName() <<
". This may not be real-time safe!" <<
RTT::endlog();
315 #if RTT_VERSION_GTE(2,8,99) 316 buf->connectTo(channel);
318 buf->setOutput(channel);
325 #if !RTT_VERSION_GTE(2,8,99) 328 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()