[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ros-users
Subject:    [ros-users] GenericPublisher using ShapeShifter and SerializedMessage
From:       felix.messmer () ipa ! fraunhofer ! de (Felix Messmer)
Date:       2011-12-12 12:43:37
Message-ID: 1323693817.699.0.camel () sony-vaio-fxm
[Download RAW message or body]

Hi there,

I want to write a generic publisher that is able to publish ros-topics
where each instance of this class publishes topics of different message
types (e.g. pub_1 publishes std_msg::Int32, pub_2 publishes
sensor_msgs::PointCloud2,...).

I work with serialized messages, i.e.:

ros::serialization::IStream i_stream((u_int8_t*) testArray.data(),
m_genericRosTopic.SerializedMessageSize);

contains my serialized message which I want to publish. I also know the
message type and the topic_name, that I want to publish on.

How can I do this in a generic way? I saw that the ros::Publisher class
has a publish() function that is able to publish a
ros::SerializedMessage.

Thus, I made a SerializedMessage from the IStream:

boost::shared_array<uint8_t> buf(i_stream.getData());
ros::SerializedMessage msg(buf, i_stream.getLength());

My generic publisher class has a ros::Publisher as a member. For
advertising, I found:

m_genericRosTopic_publisher = m_shapeShifter.advertise(n,
m_genericRosTopic.TopicName, 10);

After that I would like to publish the topic somehow:

m_genericRosTopic_publisher.publish(msg);

Publishing like this doesn't work. I guess there is still something
missing. But it seems that everything I need is already there (somewhere
in roscpp), but I am not able to put the puzzle together.

Can someone help me out here, by clarifying the correct usage of
topic_tools::ShapeShifter, ros::SerializedMessage and ros::Publisher?

Thanks for your help!


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic