Ask Your Question
0

Is there a way to specify the initial position of the Robotic from .world file?

asked 2020-01-05 02:39:22 -0600

HaoranBai17 gravatar image

updated 2020-01-05 05:51:46 -0600

gvdhoorn gravatar image

Hi, I winder if I can specify the initial position of the robotic that I can later control using rosrun on some script file in the .world file? For example, when I include a <include> block of turtlebot in the .world file and run on this .world file, the turtlebot in the Gazebo map is not controllable, like this .world file below:

<?xml version="1.0"?>
<sdf version="1.5">
  <world name="basic_world">

    <include>
      <uri>model://ground_plane</uri>
    </include>

    <include>
      <uri>model://sun</uri>
      <pose>6 3 3.7 0 0.4 2.5</pose>
      <name>sun_0</name>
    </include>

    <include>
      <uri>model://turtlebot</uri>
      <pose>-1.1 2.6 -0.245 -0.78 0 0</pose>
      <name>turtlebot_1</name>
    </include>

  </world>
</sdf>

If I then run rosrun on some control script attempt to drive the turtlebot, nothing would happen, the turtlebot seems to be only a 'pure' model on the map, only I ran roslaunch on a turtlebot package and change the map reference to my own map I can control that turtlebot on the map with my Python script, like this:

roslaunch turtlebot_gazebo turtlebot_world.launch world_file:=my.world

And it seems that to change the initial position of this 'controllable' turtlebot would be something not very easy and smooth, I may have to dive deep into the code of the official turtlebot package and change the initial position, a seperate process of .world file. So my question being, is there a way I can specify the initial position(6 parameters, x, y, z, roll, pitch, yaw) of a controllable turtlebot in the Gazebo .world file? By saying controllable, I mean I can later run rosrun on a Python control script in another terminal to control that turtlebot to make it move and perform certain tasks in the Gazebo simulation.

edit retag flag offensive close merge delete

Comments

I'm doubting whether you wouldn't get better answers/more response on Gazebo Answers. The fact you're using a .world file for this essentially makes it a Gazebo-specific question.

gvdhoorn gravatar imagegvdhoorn ( 2020-01-05 06:02:53 -0600 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-01-16 11:05:37 -0600

Yes, it is possible to spawn the robot at a user-defined pose. See this launch file for an example:

https://github.com/dfki-ric/mir_robot...

Usage is like this:

sudo apt install ros-melodic-mir-gazebo
roslaunch mir_gazebo mir_empty_world.launch robot_x:=1.0 robot_y:=2.0 robot_yaw:=0.78
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2020-01-05 02:26:24 -0600

Seen: 20 times

Last updated: Jan 16