I'm running Gazebo 1.9.2 with the following URDF file:
<?xml version="1.0"?> <!-- test.urdf --> <robot name="robot"> <link name="base_link"> <visual> <geometry> <box size="0.01 0.01 0.01"/> </geometry> </visual> <collision> <geometry> <box size="0.01 0.01 0.01"/> </geometry> </collision> <inertial> <mass value="0.001"/> <inertia ixx="0.000000017" ixy="0" ixz="0" iyy="0.000000017" iyz="0" izz="0.000000017"/> </inertial> </link> <gazebo reference="base_link"> <material>Gazebo/White</material> </gazebo> <link name="imu"> <visual> <geometry> <box size="0.05 0.05 0.05"/> </geometry> </visual> <collision> <geometry> <box size="0.05 0.05 0.05"/> </geometry> </collision> <inertial> <mass value="0.001"/> <inertia ixx="0.000000017" ixy="0" ixz="0" iyy="0.000000017" iyz="0" izz="0.000000017"/> </inertial> </link> <gazebo reference="imu"> <material>Gazebo/White</material> </gazebo> <joint name="base_link_to_imu" type="fixed"> <parent link="base_link"/> <child link="imu"/> <origin xyz="0 0 1"/> </joint> <gazebo> <plugin name="imu" filename="libgazebo_ros_imu.so"> <bodyName>imu</bodyName> <topicName>imu/data</topicName> <serviceName>imu/calibrate</serviceName> </plugin> </gazebo> </robot>
When I run Gazebo, the messages published to imu/data have "base_link" in their header.frame_id fields, when the field should contain "imu". I replaced the plugin's <gazebo> line with <gazebo reference="imu">, but that caused a syntax error:
Error [parser.cc:697] XML Element[plugin], child of element[link] not defined in SDF. Ignoring.[link] Error [parser.cc:688] Error reading element <link> Error [parser.cc:688] Error reading element <model> Error [parser.cc:348] Unable to read element <sdf> Error [parser.cc:299] parse as old deprecated model file failed. Error [World.cc:1469] Unable to read sdf string
I added a ROS_INFO_STREAM() call to gazebo_ros_imu.cpp:
if (!this->sdf->HasElement("bodyName")) { ROS_FATAL("imu plugin missing <bodyname>, cannot proceed"); return; } else this->link_name_ = this->sdf->Get<std::string>("bodyName"); ROS_INFO_STREAM("this->link_name_ = " << this->link_name_); // This prints "base_link".
This code confirmed that the plugin is getting "base_link" as the value of the bodyName parameter. Am I specifying the IMU plugin incorrectly in the URDF file?