Ask Your Question

launch a launch file using a joy button

asked 2021-11-28 12:50:59 -0600

Is it possible somehow to launch a launch file just by pressing a button on a joystick? until now what I saw, is that joystick is used to send velocity messages to the cmd_vel topic. but I haven't seen it used to launch something. if it is possible what is the best way to do that? THANKS in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-11-29 11:46:14 -0600

First you need to be able to listen to the joystick in a separate node to listen when the button is pressed, so assuming you already have that, then you can use the roslaunch api:

Below the example shown in tutorial:

import roslaunch

package = 'rqt_gui'
executable = 'rqt_gui'
node = roslaunch.core.Node(package, executable)

launch = roslaunch.scriptapi.ROSLaunch()

process = launch.launch(node)
print process.is_alive()

Of course you will replace rqt_gui with your package and executable applicable to your application.

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


Asked: 2021-11-28 09:10:05 -0600

Seen: 17 times

Last updated: Nov 29 '21