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

How to name a rosserial_arduino node?

asked 2017-02-11 22:57:39 -0500

Cerin gravatar image

How do you give a name to a rosserial_arduino node? There are several good examples, but none of them specify a name, resulting in the published topics and listeners appearing in the root namespace.

Normally, a node's name is specified with ros::init(argc, argv, "some_name"); but it doesn't look like rosserial_arduino supports this.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2017-02-12 05:18:52 -0500

duck-development gravatar image

updated 2017-02-12 05:20:34 -0500

you can chage the node name with an ros Lauch file

here my code in my Launch file:

<node pkg="rosserial_python" type="serial_node.py" name="serial_stepper_node">
  <param name="port" value="/dev/ttyUSB0"/>
</node>
edit flag offensive delete link more

Comments

Apparently, I can also do the same thing with a <group ns="some_name"> tag.

Cerin gravatar image Cerin  ( 2017-02-12 14:12:47 -0500 )edit
0

answered 2021-10-31 23:58:05 -0500

Another way:

cd /opt/ros/noetic/lib/rosserial_python

sudo cp serial_node.py [new_node_name].py

sudo nano [new_node_name].py

scroll to line containing: rospy.init_node("serial_node") and replace "serial_node" with "[new_node_name]"

sudo chmod +x [new_node_name].py

rosrun rosserial_python [new_node_name].py /dev/ttyUSB0

edit flag offensive delete link more

Comments

1

I would strongly recommend against doing this.

Changing source code of a node just to change the node name is completely unnecessary and an anti-pattern.

gvdhoorn gravatar image gvdhoorn  ( 2021-11-01 02:56:27 -0500 )edit
0

answered 2017-02-12 07:53:07 -0500

gvdhoorn gravatar image

IIRC, rosserial will always publish using global names.

I've seen people push the rosserial node(s) into a namespace to change that.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-02-11 22:57:39 -0500

Seen: 1,450 times

Last updated: Oct 31 '21