ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Call rosrun from Matlab or alternative

asked 2015-04-26 03:56:20 -0500

charles gravatar image

updated 2015-04-26 04:59:57 -0500

I already have a ros package with an executable inside it. From the terminal this is what I do to execute it:

$ source ~/catkin_ws/devel/setup.bash
$ rosrun my_package my_executable

This executable print some text on the shell:

Hello world

I want to call this commands in Matlab and import the printed text. I tried creating a shell script like this:

#!/bin/bash

source ~/catkin_ws/devel/setup.bash
rosrun my_package my_executable

and running it from Matlab in the following way:

[a,b] = system('~/./my_script')

but this is what I get:

[rosrun] Couldn't find executable named my_executable below /home/user/catkin_ws/src/my_package

The script works fine if called directly from the shell. How can I solve?

edit retag flag offensive close merge delete

Comments

Please include your script in your question.

ahendrix gravatar image ahendrix  ( 2015-04-26 04:40:46 -0500 )edit

I've included the script. Any suggestions?

charles gravatar image charles  ( 2015-04-27 03:24:38 -0500 )edit

I don't see anything obviously wrong with your script or the commands you're running. Are you certain your script works?

ahendrix gravatar image ahendrix  ( 2015-04-27 03:48:01 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-31 21:51:00 -0500

umerhuzaifa gravatar image

Hi,

It worked for me. I got the error too that you are mentioning but then I changed my MATLAB current directory to where the catkin_ws was, included it in the path (with the subfolders) and yes it started working.

I hope this helps someone who is still looking for an answer.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-26 03:56:20 -0500

Seen: 1,014 times

Last updated: Mar 31 '16