Gazebo | Ignition | Community
Ask Your Question

/gazebo/get_model_state in ROS2 not present

asked 2022-07-13 08:20:53 -0500

Zeckurbo gravatar image

updated 2022-07-18 06:29:35 -0500


I want to extract with a python script the position of a robot (that I know the model name of) from gazebo.

In many forum posts and tutorials for ROS1, the /gazebo/get_model_state service (API docu) is used for that, but as mentioned here it is deprecated.

What I have done so far is following this tutorial and now want to use it to get the position of a turtlebot3 inside its demo world.

If I put ros2 service call /get_entity_state gazebo_msgs/GetEntityState '{name: turtlebot3, reference_frame: world}' the output is just:

waiting for service to become available...

Does that mean, /get_entity_state is not running automatically when gazebo is started?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-07-18 06:37:44 -0500

Zeckurbo gravatar image

updated 2022-07-18 06:39:21 -0500

As I found out here, if you want to use get_model_state, you can simply add

<plugin name="gazebo_ros_state" filename="">


to the world file of your ros2 package. To test it, you can run

ros2 service call /gazebo/get_entity_state gazebo_msgs/GetEntityState '{name: my_robot_name, reference_frame: world}'

when gazebo is running in the background, and the service appears on ros2 service list

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2022-07-13 08:20:53 -0500

Seen: 1,123 times

Last updated: Jul 18 '22