Ask Your Question

Set the initialpose (ROS2)

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

RamiAW gravatar image

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

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 world:=/home/.../
  • ros2 run gazebo_ros -file /home/.../environment.sdf -entity environment
  • ros2 launch turtlebot3_gazebo
  • ros2 launch nav2_bringup 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

1 Answer

Sort by ยป oldest newest most voted

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

shonigmann gravatar image

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

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

Your Answer

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

Add Answer

Question Tools



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

Seen: 889 times

Last updated: May 18 '21