Gazebo | Ignition | Community
Ask Your Question

After a day of reading a book on ROS, I have a few questions.

asked 2020-04-13 22:15:40 -0600

hulkthewitchhunter gravatar image

updated 2020-04-13 22:33:40 -0600

Please bear with me since it will be a tad long. I have 3 questions and each question has sub-sections. I am following the ROS Robotics by example by Dr. Harman. I am asking these questions after a lot of googling but could not find or understand the answers provided. Kindly explain to me the following questions like I am 5.

1) To spawn turlebot in my custom map, I copied the lauch folder from /opt/ros/kinetic/share/turtlebot_gazebo to my package named trial. Then I set the TURTLEBOT_GAZEBO_WORLD_FILE=/home/kacd/catkin_ws/src/trial/worlds/ to load the turtlebot to my custom world.

Alternatively, I could also have done roslaunch turtlebot_gazebo turtlebot_world.launch world_file:=<full path to the world file> But then I would have had to run it from the turtlebot_gazebo package.

1a)What's the best way to do this to spawn turtlebot to a custom map from (?) your package? 

1b) We know that when turtlebot is spawned, a node cmd_vel is already associated with it that we publish the velocities to. Let's say that we spawn our model. How can you associate the same node (cmd_vel) to your model? Do we do it through launch files?

2) On reading further, I realized that we create launch files for Rviz and Gazebo separately

2a) How can we create launch files?

2b) What are the requirements for making a .launch file i.e. what all data, files should we have?

2c) Is the following statement correct: .launch files contain the nodes associated with a robot/model. If not then what does a launch file contain?
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2020-04-15 09:28:08 -0600

kumpakri gravatar image

updated 2020-04-15 09:42:50 -0600

1) First you run your world.

Then you spawn robot in your map by loading its description to a parameter server in your launch file

<param name="robot_description"
    command="$(find xacro)/xacro --inorder '$(find turtlebot_description)/urdf/turtlebot.xacro'" />

I do not know what is the file with turtlebot description called, but the location should be something similar for every robot. This is the standard.

Then you run the spawner node to spawn the robot in your world.

<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
    args="-urdf -model turtlebot -param robot_description"/>

I do not see into your turtlebot package, but the cmd_vel comes with the ros_control plugin. Somewhere in the gazebo.xacro file of your robot description a controller plugin should be loaded. You then have a choice between different controllers inside this plugin. One of which is the differencial controller (or something like that). This type of controller uses the cmd_vel topic to command velocity.

2) Most of the times I simply copy-paste what I need from already existing launch file into a new one. Launchfile contain all the nodes that you want to be running upon start of the simulation. Keep in mind that the order of the launching is not specified. The node located at the last line of the launch file can be run as first and so on. There is no way known to me how to force any order.

An important fact about roslaunch—one that can be easy to forget—is that all of the nodes in a launch file are started at roughly the same time. As a result, you cannot be sure about the order in which the nodes will initialize themselves. Well-written ROS nodes don’t care about the order in which they and their siblings start up. (Jason M. O’Kane, A Gentle Introduction to ROS.[1])

You can also include other launchfiles in the launchfile, define parameters and load parameters to ROS parameter server (as shown in the tags above).

You create Gazebo and Rviz launch files separately, because often you do not want to launch them at the same time.


edit flag offensive delete link more

Question Tools

1 follower


Asked: 2020-04-13 22:15:40 -0600

Seen: 1,627 times

Last updated: Apr 15 '20