Rostopic reporting incorrect subscriber type

asked 2018-04-29 20:40:45 -0500

Cerin gravatar image

What would cause rostopic to report an incorrect subscriber message type?

I have an Arduino running rosserial, defining a couple of subscribers like:

void on_motor_rotate(const std_msgs::Int16& msg) {
    nh.loginfo("Rotating...");
}
ros::Subscriber<std_msgs::Int16> on_motor_rotate_sub("motor/rotate", &on_motor_rotate);

void on_debug_level(const std_msgs::Int16& msg) {
    debug_level = msg.data;
}
ros::Subscriber<std_msgs::Int16> on_debug_level_sub("debug_level", &on_debug_level);

void setup() {
    nh.getHardware()->setBaud(115200);
    nh.initNode();
    nh.subscribe(on_motor_rotate_sub);
    nh.subscribe(on_debug_level_sub);
}

and I'm running the ROS node to communicate with my Arduino with the launch file:

<launch>
    <group ns="torso_arduino">
        <node pkg="rosserial_arduino" type="serial_node.py" name="serial_node" output="screen">
            <param name="~port" command="/dev/ttyACM0" />
            <param name="~baud" value="115200" />
        </node>
    </group>
</launch>

However, when I inspect the message types, I get the incorrect values for the first but not the second.

$ rostopic list /torso_arduino/motor/rotate --verbose

Published topics:

Subscribed topics:
 * /torso_arduino/motor/rotate [std_msgs/Empty] 1 subscriber

$ rostopic list /torso_arduino/debug_level --verbose

Published topics:

Subscribed topics:
 * /torso_arduino/debug_level [std_msgs/Int16] 1 subscriber

Notice how they both expect the Int16 type, but the first rostopic call incorrectly claims it expects the Empty type. Why is this?

edit retag flag offensive close merge delete