Skip to content

Only the last message is published #199

@genkv

Description

@genkv
function declearSubAndPubs(rosNode) {
  const nh = rosnodejs.nh;
  const customMessage = rosnodejs.require('my_package').msg.TransportRequestType;
  let pub = nh.advertise('/queue', customMessage);

  let sub = rosNode.subscribe('/chatter', customMessage,
        (data) => { // define callback execution
          rosnodejs.log.info('I heard: [' + data.type + ']');

          // send to pub
          pub.publish(new customMessage({type: 1}));
          pub.publish(new customMessage({type: 2}));
          pub.publish(new customMessage({type: 3}));
          pub.publish(new customMessage({type: 4}));
        }
);

Hi, have a question about the publisher. In my prototype code, where whenever a message is heard, I consequently publish some messages of the same type to a channel.

However, when I rostopic echo queue, only the last message type: 4 is printed. Kindly asking why. Should I wait a minimal number of milliseconds between each publish or do something else? thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions