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

Create launch file in python

asked 2021-07-23 07:33:42 -0500

SC0d3r gravatar image

updated 2021-07-23 07:35:26 -0500

Hi guys I want to translate my launch file from .launch to .py file I google but I just found how to create them in ROS 2, and I found couple of solutions which didnt worked for me, my launch file is this

<launch>
<include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="paused" default="false" />
    <arg name="use_sim_time" default="true" />
    <arg name="gui" default="false" />
    <arg name="headless" default="false" />
    <arg name="debug" default="false" />
</include>

<rosparam file="$(find self_balancing_robot)/config/gazebo_ros_control_params.yaml" command="load" />

<!-- Load the URDF into the ROS parameter server -->
<param name="robot_description" command="$(find xacro)/xacro '$(find self_balancing_robot)/urdf/sbrobot.xacro'" />

<!-- Spawn sbrobot into Gazebo -->
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen" args="-param robot_description -urdf -model sbrobot" />

</launch>

so how can I create the include world,rosparam,setting param robot_description and finally starting the node spawn urdf in python file

Edit: running the launch file with os.system or Popen is not useful for my project

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-23 08:31:25 -0500

Ranjit Kathiriya gravatar image

updated 2021-07-23 10:21:34 -0500

so how can I create the include world,rosparam,setting param robot_description and finally starting the node spawn urdf in python file

I am sorry I got your question.

import roslaunch

package = 'rqt_gui'
executable = 'rqt_gui'
node = roslaunch.core.Node(package, executable)

launch = roslaunch.scriptapi.ROSLaunch()
launch.start()

process = launch.launch(node)
print(process.is_alive())
process.stop()

Over here what you can do You create launch files for the following and then you can call your main launch file like this.

os.system or Popen is not useful for my project

As you mentioned this is not useful for you can I ask you what issue you are having with this?

And also you can also have a look at https://wiki.ros.org/rospy/Overview/I...

edit flag offensive delete link more

Comments

1

Ty for you answer but I found alot of material about how to create them in ros 2,but I am on ros 1.15 and I wanted to know how to create them in ros 1.15, that would be awesome if anyone pointed me to a tutorial or sth cause everything I find uses the launch_ros which is ROS 2 pkg

SC0d3r gravatar image SC0d3r  ( 2021-07-23 08:39:30 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-07-23 07:33:42 -0500

Seen: 521 times

Last updated: Jul 23 '21