I am using the usv urdf file I created to open the gazevo world in the example link above. It seems to be able to load the model into the gazebo world, but there is a problem that the model continues to sink to the bottom. i want to know the solution for this
my urdf code is here: `
<?xml version="1.0"?>
<robot name="1kw" xmlns:xacro="http://ros.org/wiki/xacro" >
<xacro:include filename="$(find wamv_gazebo)/urdf/1kw2.gazebo.xacro"/>
<xacro:include filename="$(find wamv_gazebo)/urdf/dynamics/wamv_gazebo_dynamics_plugin.xacro" />
<!-- Define robot constants -->
<xacro:property name="base_W" value="1.5"/>
<xacro:property name="base_D" value="0.09"/>
<xacro:property name="base_H" value="0.03"/>
<xacro:property name="base_M" value="0.08"/>
<xacro:macro name="base_inertia" params="m w d h">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0" />
<mass value="${m}"/>
<inertia ixx="${(m/12) * (d*d)}" ixy = "0" ixz = "0" iyy="${(m/12) * (w*w + d*d)}" iyz = "0" izz="${(m/12) * (w*w)}"/>
</inertial>
</xacro:macro>
<!-- Robot Footprint -->
<link name="base_footprint"/>
<joint name="base_joint" type="fixed">
<parent link="base_footprint"/>
<child link="base_link"/>
<origin xyz="0.0 0.0 0.3" rpy="1.570796 0 0"/>
</joint>
<!-- USV Base -->
<link name="base_link">
<visual>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_body2.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.24 0 0.3"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_body2.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.24 0 0.3"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
<!-- IMU -->
<joint name="imu_joint" type="fixed">
<parent link="base_link"/>
<child link="imu_link"/>
<origin xyz="0.0 0 0.0" rpy="0 0 0"/>
</joint>
<link name="imu_link"/>
<joint name="lid_joint" type="fixed">
<parent link="base_link"/>
<child link="lid_link"/>
<origin xyz="0.0 0.0 0" rpy="0 0 0"/>
</joint>
<!-- USV lid -->
<link name="lid_link">
<visual>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_Lid.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.24 0 0.3"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_Lid.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.24 0 0.3"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="10" ixy="0.0" ixz="0.0" iyy="10" iyz="0.0" izz="10"/>
</inertial>
</link>
<joint name="lidar_joint" type="fixed">
<parent link="lid_link"/>
<child link="lidar_link"/>
<origin xyz="0 0.235 0" rpy="0 0 0"/>
</joint>
<!-- USV lidar -->
<link name="lidar_link">
<visual>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_Lidar.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.24 -0.235 0.3"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_Lidar.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.24 -0.235 0.3"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
<joint name="left_propeller_joint" type="continuous">
<parent link="base_link"/>
<child link="left_propeller_link"/>
<origin xyz="0.6 -0.375 0.298" rpy="0 0 0"/>
<axis rpy="0 0 0" xyz="1 0 0"/>
<limit effort="100" velocity="100" />
<dynamics friction="0.05" damping="0.05" />
</joint>
<!-- USV left propeller -->
<link name="left_propeller_link">
<visual>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_left_propeller.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.84 0.375 0.002"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_left_propeller.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.84 0.375 0.002"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
<joint name="right_propeller_joint" type="continuous">
<parent link="base_link"/>
<child link="right_propeller_link"/>
<origin xyz="0.6 -0.375 -0.298" rpy="0 0 0"/>
<axis rpy="0 0 0" xyz="1 0 0"/>
<limit effort="100" velocity="100" />
<dynamics friction="0.05" damping="0.05" />
</joint>
<!-- USV right propeller -->
<link name="right_propeller_link">
<visual>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_right_propeller.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.84 0.375 0.598"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_right_propeller.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.84 0.375 0.598"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
<joint name="front_antenna_joint" type="fixed">
<parent link="base_link"/>
<child link="front_antenna_link"/>
<origin xyz="-0.7898 0.05 0" rpy="0 0 0"/>
</joint>
<!-- USV front antenna -->
<link name="front_antenna_link">
<visual>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_antenna_front.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="0.5498 -0.05 0.3"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_antenna_front.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="0.5498 -0.05 0.3"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
<joint name="back_antenna_joint" type="fixed">
<parent link="base_link"/>
<child link="back_antenna_link"/>
<origin xyz="0.7328 0.05 0" rpy="0 0 0"/>
</joint>
<!-- USV back antenna -->
<link name="back_antenna_link">
<visual>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_antenna_back.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.9728 -0.05 0.3"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<mesh filename="package://oneusv_urdf/mesh/1kw_ship_antenna_back.stl" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-0.9728 -0.05 0.3"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
<joint name="left_cam_joint" type="fixed">
<parent link="base_link"/>
<child link="left_cam_link"/>
<origin xyz="-0.812 -0.008 0.05" rpy="0 1.570796 0"/>
</joint>
<!-- USV left cam -->
<link name="left_cam_link">
<visual>
<geometry>
<cylinder length="0.02" radius="0.01"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.02" radius="0.01"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
<joint name="right_cam_joint" type="fixed">
<parent link="base_link"/>
<child link="right_cam_link"/>
<origin xyz="-0.812 -0.008 -0.05" rpy="0 1.570796 0"/>
</joint>
<!-- USV right cam -->
<link name="right_cam_link">
<visual>
<geometry>
<cylinder length="0.02" radius="0.01"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
<material name="yellow">
<color rgba="1 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="0.02" radius="0.01"/>
</geometry>
<origin rpy="0 0 0" xyz="0 0 0"/>
</collision>
<inertial>
<mass value="1"/>
<inertia ixx="1" ixy="0.0" ixz="0.0" iyy="1" iyz="0.0" izz="1"/>
</inertial>
</link>
</robot>
`
and my gazebo xacro code is here `
<?xml version="1.0"?>
<robot name="1kw" xmlns:xacro="http://ros.org/wiki/xacro" >
<xacro:arg name="laser_visual" default="false"/>
<xacro:arg name="imu_visual" default="false"/>
<gazebo reference="base_link">
<material>Gazebo/Gray</material>
</gazebo>
<gazebo reference="lid_link">
<material>Gazebo/White</material>
</gazebo>
<gazebo reference="front_antenna_link">
<material>Gazebo/White</material>
</gazebo>
<gazebo reference="back_antenna_link">
<material>Gazebo/White</material>
</gazebo>
<gazebo reference="left_cam_link">
<material>Gazebo/FlatBlack</material>
<sensor type="camera" name="left_sensor">
<update_rate>30.0</update_rate>
<visualize>false</visualize>
<camera name="left_camera">
<horizontal_fov>1.3962634</horizontal_fov>
<image>
<width>1280</width>
<height>720</height>
<format>R8G8B8</format>
</image>
<clip>
<near>0.05</near>
<far>300</far>
</clip>
<noise>
<type>gaussian</type>
<!-- Noise is sampled independently per pixel on each frame.
That pixel's noise value is added to each of its color
channels, which at that point lie in the range [0,1]. -->
<mean>0.0</mean>
<stddev>0.007</stddev>
</noise>
</camera>
<plugin name="camera_plugin_left" filename="libgazebo_ros_camera.so">
<alwaysOn>true</alwaysOn>
<updateRate>0.0</updateRate>
<cameraName>left_camera</cameraName>
<imageTopicName>image_raw_left</imageTopicName>
<cameraInfoTopicName>camera_info</cameraInfoTopicName>
<frameName>left_cam_link</frameName>
<hackBaseline>0.07</hackBaseline>
<distortionK1>0.0</distortionK1>
<distortionK2>0.0</distortionK2>
<distortionK3>0.0</distortionK3>
<distortionT1>0.0</distortionT1>
<distortionT2>0.0</distortionT2>
</plugin>
</sensor>
</gazebo>
<gazebo reference="right_cam_link">
<material>Gazebo/FlatBlack</material>
<sensor type="camera" name="right_sensor">
<update_rate>30.0</update_rate>
<visualize>false</visualize>
<camera name="right_camera">
<horizontal_fov>1.3962634</horizontal_fov>
<image>
<width>1280</width>
<height>720</height>
<format>R8G8B8</format>
</image>
<clip>
<near>0.05</near>
<far>300</far>
</clip>
<noise>
<type>gaussian</type>
<!-- Noise is sampled independently per pixel on each frame.
That pixel's noise value is added to each of its color
channels, which at that point lie in the range [0,1]. -->
<mean>0.0</mean>
<stddev>0.007</stddev>
</noise>
</camera>
<plugin name="camera_plugin_right" filename="libgazebo_ros_camera.so">
<alwaysOn>true</alwaysOn>
<updateRate>0.0</updateRate>
<cameraName>right_camera</cameraName>
<imageTopicName>image_raw_right</imageTopicName>
<cameraInfoTopicName>camera_info</cameraInfoTopicName>
<frameName>right_cam_link</frameName>
<hackBaseline>0.07</hackBaseline>
<distortionK1>0.0</distortionK1>
<distortionK2>0.0</distortionK2>
<distortionK3>0.0</distortionK3>
<distortionT1>0.0</distortionT1>
<distortionT2>0.0</distortionT2>
</plugin>
</sensor>
</gazebo>
<gazebo reference="imu_link">
<sensor type="imu" name="imu">
<always_on>true</always_on>
<visualize>$(arg imu_visual)</visualize>
</sensor>
</gazebo>
<gazebo>
<plugin name="imu_plugin" filename="libgazebo_ros_imu.so">
<alwaysOn>true</alwaysOn>
<bodyName>imu_link</bodyName>
<frameName>imu_link</frameName>
<topicName>imu</topicName>
<serviceName>imu_service</serviceName>
<gaussianNoise>0.0</gaussianNoise>
<updateRate>0</updateRate>
<imu>
<noise>
<type>gaussian</type>
<rate>
<mean>0.0</mean>
<stddev>2e-4</stddev>
<bias_mean>0.0000075</bias_mean>
<bias_stddev>0.0000008</bias_stddev>
</rate>
<accel>
<mean>0.0</mean>
<stddev>1.7e-2</stddev>
<bias_mean>0.1</bias_mean>
<bias_stddev>0.001</bias_stddev>
</accel>
</noise>
</imu>
</plugin>
</gazebo>
<gazebo reference="lidar_link">
<material>Gazebo/Blue</material>
</gazebo>
<gazebo reference="left_propeller_link">
<material>Gazebo/Gray</material>
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>500000.0</kp>
<kd>10.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
<fdir1>1 0 0</fdir1>
</gazebo>
<gazebo reference="right_propeller_link">
<material>Gazebo/Gray</material>
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>500000.0</kp>
<kd>10.0</kd>
<minDepth>0.001</minDepth>
<maxVel>0.1</maxVel>
<fdir1>1 0 0</fdir1>
</gazebo>
<gazebo>
<plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
<commandTopic>cmd_vel</commandTopic>
<odometryTopic>odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<odometrySource>world</odometrySource>
<publishOdomTF>true</publishOdomTF>
<robotBaseFrame>base_footprint</robotBaseFrame>
<publishWheelTF>false</publishWheelTF>
<publishTf>true</publishTf>
<publishWheelJointState>true</publishWheelJointState>
<legacyMode>false</legacyMode>
<updateRate>30</updateRate>
<leftJoint>left_propeller_joint</leftJoint>
<rightJoint>right_propeller_joint</rightJoint>
<wheelSeparation>0.596</wheelSeparation>
<wheelDiameter>0.098</wheelDiameter>
<wheelAcceleration>1</wheelAcceleration>
<wheelTorque>10</wheelTorque>
<rosDebugLevel>na</rosDebugLevel>
</plugin>
</gazebo>
</robot>
`
I was having issues with this. I had to include a model of a ground plane in gazebo. The ground plane model will be static and act as a floor so your robots will continuously fall on this flat ground instead of through it.