MATLAB Answers

Running Virtual Ubuntu Terminal commands via Matlab system() command : navigate to path and run command

12 views (last 30 days)
Ritish Shailly
Ritish Shailly on 13 Jul 2020
Commented: Ritish Shailly on 17 Jul 2020
Hi! I am running ubuntu on a virtual machine and I want to send some terminal commands via matlab.
First, I want to set a path i.e. 'cd ~/interbotix_ws/src/interbotix_ros_arms/interbotix_gazebo/launch'
and then I want to run a command 'roslaunch gazebo.launch robot_name:=wx200'.
I am using system(cd ~/interbotix_ws/src/interbotix_ros_arms/interbotix_gazebo/launch') and then entering system('roslaunch gazebo.launch robot_name:=wx200'). However, it throws error. It doesn't seems that it navigates to the path where I want it to go.
Please help so that I can navigate to the path and run the other command successfully.

  0 Comments

Sign in to comment.

Answers (1)

Cam Salzberger
Cam Salzberger on 13 Jul 2020
Hey Ritish,
You should be able to simply use "&&" to run two commands sequentially on Linux. Make sure you use the syntax appropriate to the terminal you use.
Also, you may be able to provide the full path to the launch file, so you don't need to "cd" to it first. I'm not as sure about that though.
-Cam

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!