Open nicholaspalomo opened 3 years ago
@nicholaspalomo Hello, did you solve this problem? Now I myself need to implement this service. And I would like to know your feedback. At the moment, I need to contact this service, but I don’t even see it when gazebo.launch.py
is running when executing the ros2 service list
command
Hi, I was trying to get this working as well, but also could not see the /get_entity_state
service when running ros2 service list
while using Gazebo 11 / ROS Galactic.
A workaround I used was to embed the gazebo_ros_p3d
plugin in the model's SDF/URDF file. By looking at the source code in this repo (here) and ctrl-F-ing for the required XML tags, here is an example of the arguments that can be used.
<plugin name="p3d_base_footprint" filename="libgazebo_ros_p3d.so">
<ros>
<namespace>$(arg prefix)</namespace>
<remapping>odom:=$(arg prefix)_odom</remapping>
</ros>
<always_on>true</always_on>
<update_rate>100</update_rate>
<body_name>$(arg prefix)_base_footprint</body_name>
<frame_name>world</frame_name>
<gaussian_noise>0.00</gaussian_noise>
<xyz_offset>0 0 0</xyz_offset>
<rpy_offset>0 0 0</rpy_offset>
</plugin>
I was working on a multi-robot example and thus needed to start each plugin in its own namespace. The message topics can also be remapped. The plugin publishes nav_msgs/Odometry messages on the selected topic.
However, this does not publish any TF messages, so I guess you have to write a TF publisher node that subscribes to the topic that was specified earlier.
My actual application was to get the ground truth positions of diff drive robots in my Gazebo environment, so a more direct solution was using an option in the diff drive controller source. Setting the odometry_source
flag lets you change from a simulated encoder and the ground truth value.
If you set <odometry_source>1</odometry_source>
, it selects a ground truth value. Setting odometry_source
to 0
(by default) simulates an encoder. The great thing is that the diff drive plugin also publishes TF transforms for both the robot base as well as its wheels, which is more direct.
An example of what I did:
<!-- ++++++++++++++++++++++++++++++ Diff Drive Plugin ++++++++++++++++++++++++++++ -->
<plugin name="$(arg prefix)_diff_drive" filename="libgazebo_ros_diff_drive.so">
<ros>
<remapping>/tf:=tf</remapping>
<namespace>$(arg prefix)</namespace>
</ros>
<always_on>true</always_on>
<update_rate>100</update_rate>
<left_joint>$(arg prefix)_left_wheel_joint</left_joint>
<right_joint>$(arg prefix)_right_wheel_joint</right_joint>
<wheel_separation>${chassis_y+wheelwidth+2*wheelgap}</wheel_separation>
<wheel_diameter>${wheeldiam}</wheel_diameter>
<max_wheel_torque>20</max_wheel_torque>
<max_wheel_acceleration>1.0</max_wheel_acceleration>
<odometry_frame>$(arg prefix)odom</odometry_frame>
<robot_base_frame>$(arg prefix)_base_footprint</robot_base_frame>
<!-- 0 is encoder, 1 is world (ground truth) -->
<odometry_source>1</odometry_source>
<publish_odom>true</publish_odom>
<publish_odom_tf>true</publish_odom_tf>
<publish_wheel_tf>true</publish_wheel_tf>
</plugin>
<!-- +++++++++++++++++++++++++++++ Joint State Plugin ++++++++++++++++++++++++++++ -->
<plugin name="$(arg prefix)_joint_states" filename="libgazebo_ros_joint_state_publisher.so">
<ros>
<namespace>$(arg prefix)</namespace>
</ros>
<joint_name>$(arg prefix)_right_wheel_joint</joint_name>
<joint_name>$(arg prefix)_left_wheel_joint</joint_name>
<update_rate>100</update_rate>
</plugin>
I hope this helps!
Hi, I was also trying to read the robot pose from gazebo and could not find the /get_entity_state service. I found a workaround, which is to add the lib_gazebo_ros_state.so
plugin in the world file being launched. (In my case, it was /usr/share/gazebo-11/worlds/empty.world). This link helped me: https://answers.ros.org/question/360161/ros2-dashing-service-get_entity_state-is-missing/.
Description
ROS2 hangs upon calling
/get_entity_state
message to query pose information about model spawned in Gazebo.To Reproduce
Steps to reproduce the behavior:
source /opt/ros/foxy/setup.bash
ros2 launch gazebo_ros gazebo.launch.py
gzclient
)import rclpy from rclpy.node import Node from rclpy.client import Client
from gazebo_msgs.srv import SpawnEntity, GetEntityState from geometry_msgs.msg import Pose
MODEL_DATABASE_TEMPLATE = """\