ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

recall multiple ROS nodes in one main cpp ROS node

asked 2016-09-24 06:25:57 -0500

Omarzamany gravatar image

updated 2016-09-24 06:26:10 -0500

Hello, I'm using ROS indigo to fly my Erle Copter, I want to ask you about ROS nodes,

I have several ROS nodes: one of these nodes will take reading from one of the sensor and do some calculations, and based on the sensor readings the Copter (UAV) will know its direction.

My question is, if I want to run the ROS node that is responsible of sensor readings after reaching one of the waypoints, how can I call that ROS node so it works only once the UAV reaches the waypoint and move? and then move to the second waypoint and run the same node again

so recalling ROS node at specific time, can it be achieved and how?

I hope that you can understand my question since I didn't find what I want in the tutorial, all what I found is how to publish and subscribe in another one, but its not explained how to run a ROS nodes inside another ROS node (main one)

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2016-09-27 06:58:15 -0500

pablocesar gravatar image

updated 2016-09-27 07:22:45 -0500

If I understood your question, it seems to me that you are looking to this problem from the wrong perspective, you can solve it even with the use of simple topics and services without having to use Actionlib (which is a bit more powerful and complicated).

Have you asked yourself how does a mobile robot navigates or plans a path? (if not, please search for it). It is not difficult, just create a structured architecture where your nodes communicate with each-other (publish/subscribe pattern), where there must be a node that plans your path and a node that takes care of the odometry (position), so, the node that senses the location (odometry) must be publishing the position all the time. In the path planner node, use an if statement inside the listener subscribed to the topic that is publishing the odometry (odom_pose) to make sure that you will generate the new goal only when odom_pose is close enough to the previous goal_pose.

A better question could be more helpful.

edit flag offensive delete link more

answered 2016-09-24 15:10:46 -0500

NEngelhard gravatar image

updated 2016-09-24 15:11:31 -0500

I am not really sure what you want, but I think you should have a look at actions. Actionlib This allows a node to request another node to solve a task or run an algorithm. In your case one node could tell another one which waypoint was reached and that the node should now start to compute and publish the estimated pose.

edit flag offensive delete link more

answered 2016-09-26 02:57:54 -0500

gavran gravatar image

updated 2016-09-26 02:59:18 -0500

What @NEngelhard said is true, but if I understand your question correctly, you might also go this way:

  • make UAV reach a waypoint. Once it reached it, post info about it on a topic
  • in the other node (the one responsible for sensor readings), subscribe to that topic and register a callback function. As soon as the first node published to that topic, that callback function would be executed.
edit flag offensive delete link more

answered 2016-10-04 03:45:59 -0500

zhibo gravatar image

It is possible but messy using terminal command:

rosrun navigation waypoints
sleep 45
rosnode kill waypoints
rosrun navigation waypoints
sleep 45
rosnode kill waypoints

if you put those line of code in a terminal file, you can run it and it will perform your node every 45 seconds.

  • mkdir ~/bin
  • put your line of code inside a simple file, let's say waypoint
  • chmod +x waypoint
  • export PATH=$PATH:~/bin in your ~/.bashrc
  • then in another terminal just type waypoint
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-09-24 06:25:57 -0500

Seen: 450 times

Last updated: Oct 04 '16