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

Can I create twice nodes within in one Source code?

asked 2019-05-14 10:40:27 -0600

macleonsh gravatar image

updated 2019-05-14 12:01:47 -0600

Dear all, As a ROS newbie I am studying the service and write some testcode based on tutorials. it works well but one addition question raised. sorry if it is a silly question... For exp,if ROBOT had completed one task (nodeA) it needs notify other node(B) some parameters (position,tate etc..) as this is not a frequent messge would be better use service rather than topic. Then Node B need do something else based on these message.

My question is as each source code can only create one node(is that correct understanding??) so within the node A,can I create another service node (service client C) that to communicate with server node B? If it is not allowed,what is the suggest solution?

Thanks at much Mac

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-05-14 12:04:49 -0600

gvdhoorn gravatar image

My question is as each source code can only create one node(is that correct understanding??)

each program (or process) can only start a single node in ROS 1.

so within the node A,can I create another service node (service client C) that to communicate with server node B?

No, you cannot create a second node in the same process.

If it is not allowed,what is the suggest solution?

You can create any number of service clients and servers per node.

The only limitation is on the node, not the service client/server, publishers/subscribers or action clients/servers.

edit flag offensive delete link more

Comments

Thank for the quick answer. OK so I maybe confuse the node and a service? If Node A is a control node (charge of the Robot movement control,i.e. publisher to cmd_vel ), it can not create a server client node C ,is that right? But I can write code to create Node C (service client) and node B (service server), and in node A I can use (Don't know the proper name) the Node C to communicate with Node B? Please let me know if that is correct understanding..

macleonsh gravatar image macleonsh  ( 2019-05-14 19:48:06 -0600 )edit

BTW,for above node B(a server client) it usually be used and shutdown. If I still need that does that mean NodeB creator shall not exit but keep alive? That looks violate the concept of service?

macleonsh gravatar image macleonsh  ( 2019-05-14 20:15:08 -0600 )edit

I'm not sure I completely follow your follow-up question. It also seems very similar to your questions(s) in #q323056.

gvdhoorn gravatar image gvdhoorn  ( 2019-05-15 03:00:48 -0600 )edit

Thanks I finally manage it out..

macleonsh gravatar image macleonsh  ( 2019-05-15 08:34:09 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2019-05-14 10:40:27 -0600

Seen: 109 times

Last updated: May 14 '19