Ask Your Question
0

How do I launch a robot like turtlebot in a custom made world

asked 2020-09-30 03:46:56 -0600

Qilos gravatar image

Hello, I created a world file in which i want to launch lets say the turtle bot.

In catkin_ws/src/turtlebot3_simulations/turtlebot3_gazebo/worlds i put my world file

and in catkin_ws/src/turtlebot3_simulations/turtlebot3_gazebo/launch i copied and edited a lauch file:

<launch> <arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/> <arg name="x_pos" default="-2.0"/> <arg name="y_pos" default="-0.5"/> <arg name="z_pos" default="0.0"/>

<include file="$(find gazebo_ros)/launch/simpleWorld.launch"> <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/simpleWorld.world"/> <arg name="paused" value="false"/> <arg name="use_sim_time" value="true"/> <arg name="gui" value="true"/> <arg name="headless" value="false"/> <arg name="debug" value="false"/> </include>

<node pkg="gazebo_ros" type="spawn_model" name="spawn_urdf" args="-urdf -model turtlebot3_$(arg model) -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description"/> </launch>

I edited so that in these two lines so that instead of emptyworld.world and emptyworld.launch there are my custom world: <include file="$(find gazebo_ros)/launch/simpleWorld.launch"> <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/simpleWorld.world"/>

and launching it i get following error:

RLException: while processing /opt/ros/noetic/share/gazebo_ros/launch/simpleWorld.launch: Invalid roslaunch XML syntax: [Errno 2] No such file or directory: '/opt/ros/noetic/share/gazebo_ros/launch/simpleWorld.launch' The traceback for the exception was written to the log file

So my question is what do i have to do to launch a turtlebot in a world that i created? It cant be so difficult

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-10-01 05:03:42 -0600

Weasfas gravatar image

updated 2020-10-01 05:07:40 -0600

Hi @Qilos,

To launch a custom world you do not need to change the gazebo_ros launcher, you just need to pass the world file location to the launcher. The error is telling you that the launch file you are passing does not exist. You will need to do something like:

<?xml version="1.0"?>
<launch>

  <!-- [...] Tutlebot things-->

  <!-- Coordinates to spawn model -->
  <arg name="x" default="0.0"/>
  <arg name="y" default="0.0"/>
  <arg name="z" default="0.02"/>
  <arg name="roll" default="0.0"/>
  <arg name="pitch" default="0.0"/>
  <arg name="yaw" default="0.0"/>
  <arg name="output" default="log"/>

  <arg name="world" default="$(find turtlebot3_gazebo)/worlds/simpleWorld.world"/>

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(arg world)"/>
  </include>

  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="$(arg output)"
    args="-urdf -model  turtlebot3_$(arg model) -param robot_description -x $(arg x) -y $(arg y) -z $(arg z) -R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"/>

</launch>

Please note that the launch file is not changed but the world_name param.

Hope this helps with your problem.

Regards.

edit flag offensive delete link more

Comments

Hi @Weasfas i tried what you told me but all what happens now is the turtlebot that launches in an empty world. The world i built doesnt load just the turtlebot. Am I doing something wrong?

Qilos gravatar image Qilos  ( 2020-10-05 03:35:37 -0600 )edit

Hi I also tried replacing a worldfile with my own. That didnt work either i got an error massage. Why is it impossible to load the turtlebot into my own world :/

Qilos gravatar image Qilos  ( 2020-10-05 03:50:36 -0600 )edit
1

@Qilos if you launch Gazebo with a "corrupted" world, ODE will throw an error and launch automatically the default empty world. You need to check yor custom world definition because it seems that your SDF world is the thing that is crashing the simulation. Can you post your world file?

Weasfas gravatar image Weasfas  ( 2020-10-05 04:06:08 -0600 )edit

Thank you for your help @Weasfas I couldnt upload here bc i dont have 5 points yet. I uploaded my world and my launch file here: https://gofile.io/d/HvMxYR I really appreciate your help

Qilos gravatar image Qilos  ( 2020-10-05 05:01:49 -0600 )edit

so i have been trying a bit and i get 2 errors: this one somewhere in the middle

[spawn_urdf-4] process has died [pid 18740, exit code 1, cmd /opt/ros/noetic/lib/gazebo_ros/spawn_model -urdf -model turtlebot3_burger -x 0.0 -y 0.0 -z 0.0 -param robot_description __name:=spawn_urdf __log:=/home/hermann/.ros/log/d00a6cea-06f3-11eb-adf6-2967bc61623c/spawn_urdf-4.log]. log file: /home/hermann/.ros/log/d00a6cea-06f3-11eb-adf6-2967bc61623c/spawn_urdf-4*.log

and the rest at the end.

But my world now loaded. I found out i get those errors when i add objects besides the cylinder or boxes like Person standing or a table. Do I have to add these models somehow to my packages or why do i get an error because of them?

Qilos gravatar image Qilos  ( 2020-10-05 05:19:56 -0600 )edit

I had tested your files on my environment and I found no errors, neither in the world or the turtlebot model. So I suspect that is something related with your enviroment. For instance if you are telling me that this error appear when you add a new model maybe you did not set up properly the models paths for Gazebo, you lack of those in your machine, or even one of those model are not well implemented.

Weasfas gravatar image Weasfas  ( 2020-10-05 09:13:48 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-09-30 03:46:56 -0600

Seen: 1,050 times

Last updated: Oct 01 '20