0
$\begingroup$

Rosanswers logo

Without bash and python script: master and rviz works successfully

When I run "roscore" in first terminal. Master runs successfully

process[master]: started with pid [4355] ROS_MASTER_URI=http://userid:11311/

New terminal I type in "roslaunch /home/userid/catkin_ws/src/robot/launch/robot.launch". This basically open RVIZ with the robot model in grid successfully

Above steps are implemented as follows in bash and python script and it does NOT work.

##bashscript.sh

   source ~/.bashrc
    
 python pythonscript.py

##pythonscript.py

def init():
    os.system("gnome-terminal -e 'bash -c \"pwd; roslaunch /home/userid/catkin_ws/src/robot/launch/robot.launch; exec bash\"'")

if (__name__ == '__main__'):
    init()

This fails. RVIZ opens with a white blob in center on grid NOT the robot model. and left hand panel it says robot model error. status error.

Why rviz wouldn't work with script?


Originally posted by vrosuser on ROS Answers with karma: 5 on 2017-06-28

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Why would you want to start rviz from inside a python file at all?

It's hard to tell if that fits your functionality, but maybe you can use a ros launchfile.

You could then launch your executable as well as the other launchfile like this:

<launch>
    <include file="$(find robot)/launch/demo.launch"/>
    <node name="mynode" pkg="mypkg" type="pythonscipt />
</launch>

To get this to work you need to define "pythonscript" as an executable in your CMakeList.txt of course.


Originally posted by Felix_N with karma: 115 on 2017-06-28

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by vrosuser on 2017-06-29:
My plan was to include all launch cmds in python script. so user will have to simply run one python script, instead of doing a roslaunch. I will try the solution you have proposed.

I would still like to understand the theory as to why the method I have implemented not work.?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.