RobotWebTools / rclnodejs

Node.js version of ROS 2.0 client
https://docs.ros.org/en/humble/Concepts/Basic/About-Client-Libraries.html?highlight=rclnodejs#community-maintained
Apache License 2.0
311 stars 70 forks source link

Publisher topic name field not accurately giving the topic name. #949

Closed PranavDhulipala closed 5 months ago

PranavDhulipala commented 6 months ago

When you create a publisher using let publisher = node.createPublisher('std_msgs/msg/String', 'test/this/chatter'); and then do console.log(publisher.topic); it prints only chatter and not test/this/chatter but it seems to publish on test/this/chatter though

Steps To Reproduce

import * as rclnodejs from 'rclnodejs';

// Create a node that publishes a msg to the topic 'foo' every 1 second.
// View the topic from the ros2 commandline as shown below:
//     ros2 topic echo foo std_msgs/msg/String
async function example() {

  await rclnodejs.init();
  let node = rclnodejs.createNode('MyNode');

  // Create main working components here, e.g., publisher, subscriber, service, client, action
  // For example, a publisher sending a msg every 1 sec
  let publisher = node.createPublisher('std_msgs/msg/String', 'test/this/chatter');
  console.log(publisher.topic);
  let cnt = 0;
  let msg = rclnodejs.createMessageObject('std_msgs/msg/String');
  node.createTimer(1000, () => {
    msg.data = `msg: ${cnt += 1}`
    publisher.publish(msg);
  });

  node.spin();

}

(async function main(): Promise<void> {
  example();
})().catch((): void => {
  process.exitCode = 1
})

it prints only chatter and not test/this/chatter

minggangw commented 5 months ago

@PranavDhulipala Thanks for submitting the issue, I'm going to take a look later.

minggangw commented 5 months ago

@PranavDhulipala Please check with latest https://www.npmjs.com/package/rclnodejs/v/0.24.0, now the behavior aligns with rclpy.

PranavDhulipala commented 5 months ago

@minggangw thanks for the fix, this works. However the behavior is similar for createService . I can open another bug if you want me to

minggangw commented 5 months ago

Thanks for your feedback, I'm going to open an issue to track the client/service problem. @PranavDhulipala

minggangw commented 5 months ago

@minggangw thanks for the fix, this works. However the behavior is similar for createService . I can open another bug if you want me to

952 created

minggangw commented 5 months ago

@PranavDhulipala please try with https://www.npmjs.com/package/rclnodejs/v/0.25.0 and feel free to open issue if you find, you are welcome to contribute!

PranavDhulipala commented 5 months ago

Confirmed, it works thanks :)