ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

mux nodelets(topic tools)-how to use them ?

asked 2018-11-13 05:37:33 -0500

jithinreju@gmail.com gravatar image

updated 2018-11-16 09:16:42 -0500

gvdhoorn gravatar image

i am trying to use the mux_nodelets using the below launch file

   1   <node pkg="nodelet" type="nodelet" name="pcl_manager" args="manager" output="screen" />
   2   <!-- MUX the data onto one topic -->
   3   <node pkg="nodelet" type="nodelet" name="data_mux" args="load pcl/NodeletMUX pcl_manager" output="screen">
   4     <rosparam>
   5       input_topics: [/camera/points, /camera/state]
   6     </rosparam>
   7   </node>

my idea was to mutiplex topics:camera/state and camera/points and read the data_mux output (topic)

but it gives an error as below

Client [/image_converter1] wants topic /data_mux/output to have datatype/md5sum [std_msgs/String/992ce8a1687cec8c8bd883ec73ca41d1], but our version has [sensor_msgs/PointCloud2/1158d486dd51d683ce2f1be655c3c181]. Dropping connection
  1. i understand the message type for the mux_nodelet output is PointCloud2 format. how do i change this to a required messsage type ?

  2. If i have 2 topics which are having custom message type as input to mux_nodelet. How do i define the the mux_out topic, should i define a message type which is a mix of both the inputs topics ?

PS:the idea of using a nodelet was to save communication time

I am really new to nodelets .Please help .


edit : 16 nov

update : I complied the below code snipped below in one of my header files used in a node

typedef nodelet::NodeletMUX<camera_test::combine, message_filters::Subscriber<camera_test::combine> > NodeletMUX;
PLUGINLIB_DECLARE_CLASS (pcl, NodeletMUX, NodeletMUX, nodelet::Nodelet);

combine is message type defined in the package camera_test (combine message time is a custom message with Header)

but when i run the launch file below and run one addition node which publishes topics /camera/state and /camera/points .

<launch>  
  <node pkg="nodelet" type="nodelet" name="pcl_manager" args="manager" output="screen" />
  <!-- MUX the data onto one topic -->
  <node pkg="nodelet" type="nodelet" name="data_mux" args="load pcl/NodeletMUX pcl_manager" output="screen">
    <rosparam>
      input_topics: [/camera/state, /camera/points]
    </rosparam>
  </node>

</launch>

I get the below warning

[WARN] [1542361466.932969]: Could not process inbound connection: topic types do not match: [sensor_msgs/PointCloud2] vs. [camera_test/combine]{'topic': '/camera/state', 'tcp_nodelay': '0', 'md5sum': '1158d486dd51d683ce2f1be655c3c181', 'type': 'sensor_msgs/PointCloud2', 'callerid': '/pcl_manager'}

it looks like even after calling the PLUGLIB _DECLARE class with new message type,it still expects the message type PointCloud2 ? and if i do a rostopic echo data_mux out ,i get no messages I don`t understand what i am doing wrong .could someone please Help ?


edit 3 : Below is my header file where i have declared the PLUGINLIB_DECLARE class

can you please suggest what i should change here ?

#include <pluginlib/class_list_macros.h>
#include <nodelet/nodelet.h>
#include <nodelet_topic_tools/nodelet_mux.h>
#include <message_filters/subscriber.h>
#include "camera_test/combine.h"
#include <nodelet_topic_tools/nodelet_demux.h>
#include <sensor_msgs/PointCloud2.h>

typedef nodelet::NodeletMUX<camera_test::combine, message_filters::Subscriber<camera_test::combine> > NodeletMUX;
PLUGINLIB_DECLARE_CLASS (pcl, NodeletMUX, NodeletMUX, nodelet::Nodelet);
//typedef nodelet::NodeletDEMUX<sensor_msgs::PointCloud2> NodeletDEMUX;

btw I have not added an plugin.xml file for this nodelet ? could that be the problem ?

edit retag flag offensive close merge delete

Comments

the mux out still shows PointCloud2 rostopic info /data_mux/output Type: sensor_msgs/PointCloud2 Publishers: * /pcl_manager Subscribers: * /image_converter1

jithinreju@gmail.com gravatar image jithinreju@gmail.com  ( 2018-11-16 03:59:13 -0500 )edit

Could I please ask you to format your question properly next time? When copy-pasting code or console output (ie: errors/warnings), always select the text you just pasted and click the Preformatted Text button (the one with 101010 on it).

gvdhoorn gravatar image gvdhoorn  ( 2018-11-16 09:18:09 -0500 )edit

yes,yes . i am sorry for that

jithinreju@gmail.com gravatar image jithinreju@gmail.com  ( 2018-11-16 09:41:48 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-11-13 07:37:51 -0500

gvdhoorn gravatar image

updated 2018-11-16 04:05:17 -0500

From the nodelet_topic_tools/mux documentation:

To compile the NodeletMUX nodelet in your library, add something like:

typedef nodelet::NodeletMUX<sensor_msgs::PointCloud2, message_filters::Subscriber<sensor_msgs::PointCloud2> > NodeletMUX;
PLUGINLIB_DECLARE_CLASS (pcl, NodeletMUX, NodeletMUX, nodelet::Nodelet);

So in order to use different message types, you'll have to specialise the template for those message types and essentially create a new variant of mux.


Edit:

i had 2 querys ,as per the documentation mux nodelets takes upto 8 topics as input and publishes a combined topic(single) . so does this means the the other nodes publishing these 8 topic should be "nodelets" and not "nodes" ?

if you want to take advantage of zero-copy message exchange, then yes, all topics should be published by nodelets. And they should even be loaded in the same nodelet_manager.

Where should I exactly compile the snipped from above ?

In a ROS package. Doesn't really matter which one. As long as the build script is properly configured to allow the compiler access to the required headers.


Edit 2: I've not done this myself, but you're probably shadowing the NodeletMUX in pcl with your own declaration. It could be that by then using load pcl/NodeletMUX in your launch file, the nodelet_manager is still loading the pcl/NodeletMUX version, which only accepts PointCloud2 messages.

You might want to use a different name for your nodelet.

edit flag offensive delete link more

Comments

i changed the message type and i am able to compile , Do i need to start a nodelet manger seperately?

jithinreju@gmail.com gravatar image jithinreju@gmail.com  ( 2018-11-15 09:47:06 -0500 )edit

You either need to start a nodelet manager yourself, or reuse the one that you are loading your other nodelets in.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-15 09:48:44 -0500 )edit

1)i had 2 querys ,as per the documentation mux nodelets takes upto 8 topics as input and publishes a combined topic(single) . so does this means the the other nodes publishing these 8 topic should be "nodelets" and not "nodes" ? 2)Where should I exactly compile the snipped from above ?

jithinreju@gmail.com gravatar image jithinreju@gmail.com  ( 2018-11-15 10:11:36 -0500 )edit

edit 2 :I changed the name of the nodelet in the launchfile, still i get the same problem ... ..

jithinreju@gmail.com gravatar image jithinreju@gmail.com  ( 2018-11-16 08:00:40 -0500 )edit

You need to change the name of your nodelet in the header where you PLUGINLIB_DECLARE it. Changing the name attribute of the node that loads the nodelet is not going to affect anything.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-16 08:05:37 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-11-13 05:37:33 -0500

Seen: 597 times

Last updated: Nov 16 '18