1

I am trying to create two .desktop entries to launch shell scripts.

the shell scripts fullLaunch.sh and tracepen.sh should be executed. Both run when launched from the terminal.

They launch multiple other files, including ros launchfiles and other shell scripts.

tracepen.desktop looks like this:

[Desktop Entry]
Type=Application
Exec=bash /home/qiaoyue/happyspace/src/fmp_robot_shellscripts/robot/tracepen.sh
Icon=/home/qiaoyue/happyspace/src/fmp_robot_shellscripts/icons/tracepen.png
Name=Trace Pen
Terminal=true

tracepen.sh:

#!/bin/bash

Check if SteamVR is running

if pgrep -x "vrmonitor" > /dev/null then echo "SteamVR is running" else echo "SteamVR is not running, starting it now..." xdg-open steam://rungameid/250820 & disown echo "Waiting for SteamVR to start..."

# Wait for SteamVR to start
while ! pgrep -x "vrmonitor" > /dev/null
do
    sleep 1
done

fi

echo "Starting up tracepen"

rosrun fmp_tracepen_node tracepen_node.py

bahavior: steam is started, but in the end i am not left with an open terminal running the tracepen_node.py. Starting it directly with ./tracepen.sh does.


fullLaunch.desktop (basically the same):

[Desktop Entry]
Type=Application
Exec=/home/qiaoyue/happyspace/src/fmp_robot_shellscripts/robot/fullLaunch.sh
Icon=/home/qiaoyue/happyspace/src/fmp_robot_shellscripts/icons/launch.png
Name=Robot
Terminal=true

fulLaunch.sh:

#!/bin/bash

wait_for_topic() { TOPIC=$1 while true; do if rostopic list | grep -q "$TOPIC"; then break else sleep 0.5 fi done }

Check if roscore is already running, if yes then kill it

if (rosnode list &> /dev/null); then killall -9 roscore killall -9 rosmaster fi

Start roscore in a new tab

nohup roscore &> /dev/null &

Wait for roscore to start

while ! (rosnode list &> /dev/null); do sleep 0.5 done

gnome-terminal -- bash -c "roslaunch fmp_launch trajServer.launch"

Wait for move_group to start

wait_for_topic "/sequence_move_group"

gnome-terminal --tab -- bash -c "rosrun fmp_move_traj trajectory_server.py" gnome-terminal --tab -- bash -c "rosrun fmp_move_traj pose_server.py" gnome-terminal --tab -- bash -c "rviz -d $(rospack find fmp_move_traj)/rvizLaunch/realRobot.rviz" gnome-terminal --tab -- bash -c "rosrun fmp_move_traj buttons.py" gnome-terminal --tab -- bash -c "rosrun fmp_move_traj poseModifier.py"

the .desktop launches two terminals, one with an error that immediately terminates.

1 Answers1

1

If you're expecting a terminal to pop open, you'll need to launch it yourself and then run the command in that terminal. Try replacing:

rosrun fmp_tracepen_node tracepen_node.py

with something like

gnome-terminal -x rosrun fmp_tracepen_node tracepen_node.py
ckhan
  • 151
  • But isn't this what my fulllaunch.sh script is doing anyway? All commands are run in gnome terminal tabs. – Florian Schneider May 27 '23 at 15:56
  • I see now that your second script does use a terminal for some of the commands. Lets separate your two problems. Does my suggestion above address your expectation that a terminal needs to be opened for your tracepen_node.py script? – ckhan May 28 '23 at 01:52
  • 1
    More generally: I think your problems are about the unexpected absence of controlling terminals for processes you are starting from these scripts. Notes in https://askubuntu.com/questions/436891/create-a-desktop-file-that-opens-and-execute-a-command-in-a-terminal might help. – ckhan May 28 '23 at 01:54
  • I was able to get the tracepen.sh working( using Exec=gnome-terminal -e "bash -c '/home/qiaoyue/happyspace/src/fmp_robot_shellscripts/robot/tracepen.sh'"), but the fullLaunch.sh still makes problems. – Florian Schneider May 30 '23 at 08:23