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

Set the initialpose (ROS2)

asked 2021-05-18 08:05:11 -0600

RamiAW gravatar image

updated 2021-05-18 08:06:00 -0600

Hello I am still relatively new to ROS2 and am currently working on getting my digital Turtlebot3 to drive around in a Gazebo environment. I'm using ROS2 foxy on Ubuntu 20.04 and for navigation I use navigation2.

I then execute the following commands:

  • ros2 launch gazebo_ros gzserver.launch.py world:=/home/.../env.world
  • ros2 run gazebo_ros spawn_entity.py -file /home/.../environment.sdf -entity environment
  • ros2 launch turtlebot3_gazebo robot_state_publisher.launch.py
  • ros2 launch nav2_bringup bringup_launch.py use_sim_time:=True autostart:=True map:=/home/map.yaml

Now the following error occurs at the last command.

[amcl-2] [WARN] [1620937828.832260000] [amcl]: ACML cannot publish a pose or update the transform. Please set the initial pose...

How do I set the initial pose? I know that you can do it via Rviz, but in this case I want to solve it without RViz (with a command or programmatically via rclpy).

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2021-05-18 11:02:20 -0600

shonigmann gravatar image

updated 2021-05-18 11:03:13 -0600

Two options that I know of if you do not want to use RVIZ to set the initial pose:

1) the amcl_node supports a set_initial_pose argument, as well as initial_pose.x, .y, .z, and .yaw. You can modify your launch files accordingly so this is set to your known or best guess initial position.

2) (probably the easier method) is to publish a message to the /intialpose topic. That should look something like this from the commandline:

ros2 topic pub -1 /initialpose geometry_msgs/PoseWithCovarianceStamped '{ header: {stamp: {sec: 0, nanosec: 0}, frame_id: "map"}, pose: { pose: {position: {x: 0.1, y: 0.0, z: 0.0}, orientation: {w: 0.1}}, } }'
edit flag offensive delete link more
0

answered 2023-01-13 11:08:24 -0600

Cullen SUN gravatar image

updated 2023-01-13 11:09:11 -0600

I found a nice video talking about this topic. Especially for people who wants to set via config yaml file

You can set it like below

amcl:
  ros__parameters:
    # other_configs ....
    set_initial_pose: true
    initial_pose: 
      x: 0.0
      y: 0.0
      yaw: 0.0
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-05-18 08:05:11 -0600

Seen: 5,979 times

Last updated: Jan 13 '23