[Solved] Create a script to activate the joystick

Hi all,

I try to make a simple script for steering the Rover with a joystick without using a terminal.

I create a joystick.sh file :

#!/bin/bash
roslaunch leo_joy_example joy.launch

If i launch the script with a terminal, it work. But if i " double-click" on the sript :
/home/ubuntu/joystick.sh: ligne 5: roslaunch : commande introuvable

If i add this env variable :

PATH=$PATH:/opt/ros/noetic/bin:/opt/gcc-arm-none-eabi-9-2020-q2-update/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
export PATH

When i “double-click” on the sript:

Traceback (most recent call last):
  File "/opt/ros/noetic/bin/roslaunch", line 34, in <module>
    import roslaunch
ModuleNotFoundError: No module named 'roslaunch'

Do you have any ideas?

It works :slight_smile:
For the joystick.sh :

#!/bin/bash
source /opt/ros/noetic/setup.bash
source /home/ubuntu/ros_ws/devel/setup.bash

export ROS_MASTER_URI=http://master.localnet:11311
export ROS_IP=XX.XX.XX.XX

roslaunch leo_joy_example joy.launch

To create a desktop launcher :
In ~/local/share/applications/, i created a file leo_joystick.desktop with:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Name=Joystick LEO
Comment=Activate the joystick
Exec=sh -c /home/ubuntu/ros_ws/src/leo_joy_example/joystick.sh
Terminal=true 
X-MultipleArgs=
Type=Application
Icon=/home/ubuntu/ros_ws/src/leo_joy_example/LEO_joystick.jpeg
Categories= internet
MimeType=text/xhtml_xml
StartupWMClass=
StartupNotify=

Maybe it will be help for someone else