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

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

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

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 image fvd  ( 2018-07-10 00:55:42 -0600 )edit

5 Answers

Sort by ยป oldest newest most voted
9

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

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

2

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

inani47 gravatar image inani47  ( 2018-04-14 09:04:42 -0600 )edit
23

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

Jim Rothrock gravatar image

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 image hsu  ( 2012-08-06 08:53:04 -0600 )edit

Hey Jim, Many thaks for providing this solution. Can you tell me how i apply this to a UR10 robot? I described my problem here:

https://answers.ros.org/question/4114...

Infraviored gravatar image Infraviored  ( 2023-01-17 09:21:00 -0600 )edit
0

answered 2023-01-17 09:22:03 -0600

Infraviored gravatar image

I have the same problem: I am trying to change the default orientation of a UR10 robot in gazebo.

I described my problem in this post: https://answers.ros.org/question/4114...

Maybe someone here can help me, as this here is solved.

edit flag offensive delete link more
0

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

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 -0600

Alberto E. gravatar image

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

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 image gvdhoorn  ( 2018-04-12 09:15:57 -0600 )edit

Question Tools

4 followers

Stats

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

Seen: 21,035 times

Last updated: Apr 12 '18