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

I am new to ROS and am wondering about the difference between launch script and launch node?

asked 2021-06-01 03:32:28 -0500

hoangdung2000 gravatar image

updated 2021-06-01 18:37:37 -0500

jayess gravatar image

example launch script:

python ~/helloworld/turtlebot/goforward_and_avoid_obstacle.py

example launch node:

roslaunch simple_navigation_goals movebase_seq.launch
edit retag flag offensive close merge delete

Comments

Launch files allow you to run multiple scripts and define input variables, and set default values. Personally, I would find it hard to remember which combination of nodes and parameters I need to run without having it consolidated into a launch file.

Also, workspaces may contain C++ and python code, but you can run either with roslaunch.

fruitbot gravatar image fruitbot  ( 2021-06-01 13:19:49 -0500 )edit

you mean i can put file.py in a package and run it with roslaunch just like for launch file

hoangdung2000 gravatar image hoangdung2000  ( 2021-06-05 01:55:38 -0500 )edit
1

Yes. Here is an example of a launch file calling other launch files as well as two scripts:

<launch>

  <include file="$(find turtlebot_bringup)/launch/3dsensor.launch" >
  </include>

  <include file="$(find usb_cam)/launch/usb_cam-test.launch" >
  </include>

  <include file="$(find my_fruit_finder)/launch/my_fruit_finder.launch" >
  </include>

  <include file="$(find my_moveit_config2)/launch/my_planning_execution.launch">
  </include>

  <node pkg="robotiq_2f_gripper_control" type="Robotiq2FGripperRtuNode.py" name="robotiq2FGripper"  args="/tmp/ttyUR">
  </node> 

 <node pkg="my_robot" type="execution_commander.py" name="move_group_python_interface"  output="screen">
  </node>

</launch>
fruitbot gravatar image fruitbot  ( 2021-06-07 11:15:40 -0500 )edit

Thank you very much, by the way I want to make a simulation example that controls turtlebot to move along a diamond in Rviz. What steps should I take?

hoangdung2000 gravatar image hoangdung2000  ( 2021-06-08 02:46:47 -0500 )edit
1

I think you should open a new question for this. I am not a moderator, but you would likely find more feedback and make it easier for others to find your answer in the future :)

That said, I would probably start off with exploring a ROS package for the turtlebot and look into Gazebo

fruitbot gravatar image fruitbot  ( 2021-06-08 10:09:32 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-06-01 08:08:34 -0500

abhishek47 gravatar image

Quoting directly from Changes between ROS 1 and ROS 2 (emphasis mine):

In ROS 1 roslaunch files are defined in XML with very limited capabilities. In ROS 2 launch file are written in Python which enables to use more complex logic like conditionals etc.

edit flag offensive delete link more

Comments

2

Elaborating further:

You create a node with some processes you wish to be carried-out such as interfacing with a serial port or adjusting motor speeds or running an A* pathfinding algorithm.

You then reference that created node in a launch file. The idea is that you can use a launch file, be it the XML files used in ROS1 or the Python files in ROS2, wherein you reference any number of nodes while setting run-time parameters.

With ROS it is common practice to provide start-time or run-time access to node-specific program variables in the form of Parameters (e.g. PID algorithm constants, rotary encoder min/max values, serial port paths). You can then set node-specific Parameter values within a launch file. You might create a node for which you would like two concurrently-running instances, and for each instance you might want to change something. This is easily done using launch ...(more)

Spectre gravatar image Spectre  ( 2021-06-01 16:49:20 -0500 )edit

@abhishek47kashyap What you mean above is how to run a program of two types ROS ???

hoangdung2000 gravatar image hoangdung2000  ( 2021-06-05 01:40:13 -0500 )edit

@Spectre I want to make a simulation example that controls turtlebot to move along a diamond in Rviz. What steps should I take?

hoangdung2000 gravatar image hoangdung2000  ( 2021-06-05 01:52:01 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-06-01 03:32:28 -0500

Seen: 514 times

Last updated: Jun 05 '21