0
$\begingroup$

Rosanswers logo

I want to start or stop some ros nodes remotely. As I want to control a robot by my Android mobile phone through WIFI, and the robot maybe has no keyboard or displayer, so I cannot start the ros node by input "rosrun" or "roslaunch" in the terminal, and I want to use the smart phone to control some ros nodes, like start or stop them. For example, I want to let the robot to draw a map by GMapping node, so I press a button on my smart phone, and the Gmapping node run, then I press another button on my smart phone, the Gmapping node stops. And I have writed a node that could communicate with the smart phone.

I have been looking for the methods for a long time, and I cannot find a perfect method. I find this method link text that proposed by DimitriProsser is really good, however he only tell us the way to start.

So I want to know, are there other methods to achieve my goal? Thank you a lot!


Originally posted by tanghz on ROS Answers with karma: 130 on 2015-12-25

Post score: 2


Original comments

Comment by AutoCar on 2019-01-22:
How do you connect your smart phone to the robot?

Comment by billy on 2019-01-22:
I've done it using rosbridge and a webbrowser. I'm sure there are several ways.

But the mods are going to give you a hard time for asking a question using an answer on an unrelated topic. : (

Comment by jayess on 2019-01-23:
@AutoCar please don't use an answer to ask a question. This isn't a forum. You can ask a new question and reference this question instead.

$\endgroup$

3 Answers 3

0
$\begingroup$

Rosanswers logo

I think you can do it using launch files, I never used it in the end, but it works for starting and stopping nodes programmatically (as long as it is one you previously launched programmatically)

http://answers.ros.org/question/203154/is-it-possible-to-run-and-quit-launch-files-from-code-inside-a-node/


Originally posted by nickw with karma: 1504 on 2015-12-25

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by tanghz on 2015-12-25:
Thank you very much, I will try it. It would be better if there's a C++ tutorial. I think maybe I have to learn the Python programming language.

Comment by tanghz on 2015-12-27:
Thank you very much, now I solved it, I have answered my own question. Thank you very much.

$\endgroup$
0
$\begingroup$

Rosanswers logo

For example, there is a launch file named "rplidar.launch" and located in the "rplidar_ros" package, after I start the launch file, the ros node name is "rplidarNode", then I start and stop it in the ROS C++ code:

system("roslaunch rplidar_ros rplidar.launch");  //start

system("rosnode kill rplidarNode");              //stop

By the way, remember to new a thread, or the code would block and you cannot stop the node.


Originally posted by tanghz with karma: 130 on 2015-12-27

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by sonictl on 2016-12-07:
what do you mean"new a thread"? I mean, the code blocks and how to solve the block?

$\endgroup$
0
$\begingroup$

Rosanswers logo

From https://www.theconstructsim.com/launch-node-using-ros-program/

import roslaunch
node = roslaunch.core.Node("other_pkg", "pkg_executable")
launch = roslaunch.scriptapi.ROSLaunch()
launch.start()
script = launch.launch(node)

Couldn't find the cpp equivalent way though


Originally posted by Rufus with karma: 1083 on 2020-10-06

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.