Ask Your Question
7

How do I set the inital pose of a robot in gazebo?

asked 2012-08-06 05:18:45 -0500

EmbeddedSystem gravatar image

Let's say I've created my own world file that has: <include file="$(find pr2_gazebo)/launch/pr2.launch"/>

This normally spawns the robot at x=0, y=0.

How could I spawn it somewhere else, say x=1, y=1?

I know I could spawn the robot and then move it by calling the service: set_model_state, but I've found doing this with the pr2 doesn't work very well with other objects in the world.

pr2_no_controllers has an arg called 'optenv ROBOT_INITIAL_POSE.' How do I get at this from my world file?

edit retag flag offensive close merge delete

Comments

If you came to this thread trying to set an initial joint configuration of the robot, check this thread too: https://answers.ros.org/question/2481...

fvd gravatar imagefvd ( 2018-07-10 00:55:42 -0500 )edit

4 Answers

Sort by ยป oldest newest most voted
7

answered 2012-08-06 08:59:30 -0500

hsu gravatar image

you can set the environment variable in commandline, e.g.:

ROBOT_INITIAL_POSE="-y 2" roslaunch pr2_gazebo pr2_empty_world.launch^C
edit flag offensive delete link more

Comments

1

is there a way to add this to my launch file for turtlebot?

inani47 gravatar imageinani47 ( 2018-04-14 09:04:42 -0500 )edit
13

answered 2012-08-06 05:35:21 -0500

You can create your own launch file to spawn the robot. For example:

<!-- spawn_robot.launch -->
<launch>
  <!-- Robot pose -->
  <arg name="x" default="0"/>
  <arg name="y" default="0"/>
  <arg name="z" default="0"/>
  <arg name="roll" default="0"/>
  <arg name="pitch" default="0"/>
  <arg name="yaw" default="0"/>

  <param name="robot_description"
         command="$(find xacro)/xacro.py $(find myrobot_description)/urdf/myrobot.urdf.xacro"/>
  <node name="spawn_robot" pkg="gazebo" type="spawn_model"
        args="-urdf -param robot_description -model myrobot
              -x $(arg x) -y $(arg y) -z $(arg z)
              -R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"/>
</launch>

Then you change <include file="$(find pr2_gazebo)/launch/pr2.launch"/> to:

<include file="$(find myrobot_description)/launch/spawn_robot.launch">
  <arg name="x" value="1.0"/>
  <arg name="y" value="1.0"/>
</include>
edit flag offensive delete link more

Comments

Thanks Jim, I like this approach, will consider adding these arguments/defaults to the pr2_no_controllers.launch.

hsu gravatar imagehsu ( 2012-08-06 08:53:04 -0500 )edit
0

answered 2018-04-09 13:55:58 -0500

pendragon gravatar image

You can also simply add this to your .bashrc file export ROBOT_INITIAL_POSE="-x 1.0 -y 2.3 -z 0.0 -R 1.43 -P 0.3444 -Y 1.0865"

Remember to source the .bashrc after.

edit flag offensive delete link more
-1

answered 2018-04-12 08:54:20 -0500

Alberto E. gravatar image

updated 2018-04-12 08:55:29 -0500

You can also simply substitute the call to the ROBOT_INITIAL_POSE environment variable ('optenv ROBOT_INITIAL_POSE') by the values you want your robot to spawn (-x 1 -y 1). I've created a very short video showing an example of it: https://www.youtube.com/watch?v=9ggSf...

edit flag offensive delete link more

Comments

1

I would actually disrecommend that. The ROBOT_INITIAL_POSE variable allows you to customise this without editing any files, which is always preferable over customising something which is not necessarily under your control. This configuration interface exists for a reason.

gvdhoorn gravatar imagegvdhoorn ( 2018-04-12 09:15:57 -0500 )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

4 followers

Stats

Asked: 2012-08-06 05:18:45 -0500

Seen: 10,990 times

Last updated: Apr 12 '18