Ask Your Question

How could I use "ROS" commands in a bash file ?

asked 2018-05-23 10:52:21 -0600

Fjara gravatar image

updated 2018-05-24 08:13:33 -0600

Hey ! First, i'm sorry for my english , i don't use translator and i'm not really good at.

Let me explain my problem : I want to use "PuTTY" via Windows' terminal (to connect to linux) with the arguments "-m" and a file .txt This file will be read by PuTTY and execute line by line the commands. But there's a problem , every linux' commands works, but "catkin_make" or "rosrun" it wrote :

bash: line 2: catkin_make: command not found

per exemple

However , i can use it manually via PuTTY

How can I use ROS commands in a bash file ?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-05-24 10:36:58 -0600

gvdhoorn gravatar image

This is an environment setup issue (ie: the environment is not correctly setup). Passing absolute paths to commands will work around some problems, but not all (ie: rospkg not being able to find ROS packages and others).

edit flag offensive delete link more


@gvdhoorn so what do you recommand me ? It's my mate who had installed all the things , and I need to wait him to make some test (he's absent atm) I don't know which commands we need ( catkin_make , rosrun , but don't know the others ) I'll be back with more informations Thanks for your answer

Fjara gravatar imageFjara ( 2018-05-25 02:33:54 -0600 )edit

You have a few options, but I don't know how Putty treats each of the lines in your -m file.txt: if they are all executed in individual SSH sessions, then you'll need to source the correct setup.basheach time before you run a new command.

If it's all a single session, source once.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-25 02:35:54 -0600 )edit

Well , isn't enough if we sourced it in the .bashrc ? I will try to get some infos about the -m so ! :)

Fjara gravatar imageFjara ( 2018-05-25 02:39:09 -0600 )edit

Well , isn't enough if we sourced it in the .bashrc ?

It can be, but regular SSH logins do not source $HOME/.bashrc. That is not a ROS problem btw, just how SSH/bash work.

If you solve/work-around that, your initial approach might work.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-25 02:57:31 -0600 )edit

Thanks for your answers ! I'll make some tests and i'll come back

Fjara gravatar imageFjara ( 2018-05-25 03:07:32 -0600 )edit

hey , so with the source : /opt/ros/kinetic/bin/catkin_make

    Traceback (most recent call last):
  File "/opt/ros/kinetic/bin/catkin_make", line 12, in <module>
    from catkin.init_workspace import init_workspace
ImportError: No module named catkin.init_workspace
Fjara gravatar imageFjara ( 2018-05-25 09:46:41 -0600 )edit

I used :

cd catkin_ws
/opt/ros/kinetic/bin/catkin_make 2>> erreurs.log
Fjara gravatar imageFjara ( 2018-05-25 09:49:02 -0600 )edit

I'm not sure I understand what you're trying to do exactly.

In a nutshell, I believe you need to:

  1. source /opt/ros/kinetic/setup.bash
  2. run your commands

you cannot sourcecatkin_make.

gvdhoorn gravatar imagegvdhoorn ( 2018-05-25 09:58:29 -0600 )edit

answered 2018-05-23 11:38:55 -0600

updated 2018-05-23 11:43:59 -0600

if you are facing such issue. try to give the complete path of the command. catkin_make and rosrun.

catkin_make command is useful only in the catkin_workspace. Navigate to the workspace and then run the command by complete path /opt/ros/indigo/bin/catkin_make for catkin_make. /opt/ros/indigo/bin/rosrun <package _name> <executable> for rosrun.

Note: Change the indigo with the installed distro.

edit flag offensive delete link more


Thanks for the quick answer, i'll try it as fast as i can !

Fjara gravatar imageFjara ( 2018-05-24 02:24:54 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-05-23 10:52:21 -0600

Seen: 515 times

Last updated: May 24 '18