Ask Your Question
0

A launcher for program.c++ that launches roscore [closed]

asked 2014-08-12 04:55:07 -0600

alex.filgueira gravatar image

Hi, I have a question. I´m use ROS Hydro in Ubuntu 12.04. I have a program in C++ that launch ros --> roscore and others nodes, as are: hokuyo_node or hector_slam.

I want launch this program.c++ with double-click.

If I launch this program in a ubuntu-terminal, the program run is OK, but I can´t do a launcher for this program. I try:

1) gnome-desktop-item-edit {ubication} --create-new ---> In order, I write the program.c++ path and select terminal aplication. The window terminal open with this launcher said:

sh: 1: rosnode: not found

2) gnome-desktop-item-edit {ubication} --create-new ---> In order, I write the program.c++ path and select aplication. The launcher not do nothing.

3) I do a script for launch the program.c++ :

#!/bin/sh
cd
cd /home/lab18/terese3_adq/data/principal

./mainexecut > mainbash.log &

disown -h %1 
bg 1

mainexecut = program.c++ and "/home/lab18/terese3_adq/data/principal" is the path to is this program. The result is similar, if I launch this script in a terminal, the program run is Ok, but if I do a launcher or launch with double-click on the script, the result is:

sh: 1: rosnode: not found

4) I do other script for launch the program.c++ :

#!/bin/sh
gnome-terminal -e "bash -c \"cd; cd /home/lab18/terese3_adq/data/principal/; ./mainexecut; exec bash\""

This script has the same result.

I haven't idea from where is the error, or the possible solution.

I thank for some idea.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by alex.filgueira
close date 2014-08-25 05:21:55.804881

3 Answers

Sort by » oldest newest most voted
0

answered 2014-08-14 21:26:22 -0600

Murilo F. M. gravatar image

As stated before, the issue is with the environment variables not being set properly. Your errors show that the 'sh' shell is being used, but you're likely setting up ROS using 'bash' shell.

If you follow this link, you can create a 'mainexecut.desktop' and modify the 'Exec=...' with 'Exec=bash -i -c /path/to/mainexecut'. This is how IDEs are suggested to be configured, as documented here. This solution works for me.

If you're not using Unity, there must be something along those lines for Gnome (or KDE).

Mind you, the user's workspace and '/opt/ros/hydro/setup.bash' must be sourced upon loading your .bashrc.

I hope it helps!

edit flag offensive delete link more
0

answered 2014-08-25 05:21:16 -0600

alex.filgueira gravatar image

Ok, thanks for help me.

Now, this launched go very well. I use the 3) option with the export routes. I got this routes with:

echo $ROS_ROOT
echo $PYTHONPATH
echo $PATH
echo $ROS_MASTER_URI

Also I changed .sh to .bash

And I do a launched follow this link. But I changed the terminal line.

[Desktop Entry]
Version=1.0
Name=tararitarara
Comment=This is my comment
Exec=bash -i -c /path/to/script.bash
Icon=/path/to/icon
Terminal=false
Type=Application
Categories=Utility;Application;
edit flag offensive delete link more
0

answered 2014-08-12 05:12:16 -0600

Wolf gravatar image

My guess is that some environment variables are not set. For your 3) try you could try to copy+paste the ROS specific source / export commands from your ~/.bashrc after #!/bin/sh.

Another point is that all this might work better if you use bash shell; use #!/bin/bash and/or google how to set the default shell for your OS when double clicking.....

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-08-12 04:55:07 -0600

Seen: 1,089 times

Last updated: Aug 25 '14