uuv_simulator icon indicating copy to clipboard operation
uuv_simulator copied to clipboard

How to enable angular motion of the uuv models in Gazebo?

Open Gowresh7 opened this issue 3 years ago • 5 comments

I am simulating the LAUV model in gazebo with teleop through joystick. What I noticed was that the model never undergoes angular motion, i.e., It only either translates to the left or right instead of changing its heading towards the direction (Screenshot attached) Screenshot from 2020-10-02 19-16-28

How to enable the model with angular motions?

Gowresh7 avatar Oct 05 '20 12:10 Gowresh7

Hi,

Could you kindly share you urdf?

brschettini avatar Oct 11 '20 13:10 brschettini

The following are my description files of LAUV model:-

  1. base.xacro:- `

<xacro:include filename="$(find uuv_descriptions)/urdf/common.urdf.xacro"/>

<xacro:include filename="$(find uuv_sensor_ros_plugins)/urdf/sensor_snippets.xacro"/>

<xacro:include filename="$(find uuv_gazebo_ros_plugins)/urdf/snippets.xacro"/>

<xacro:include filename="$(find lauv_description)/urdf/snippets.xacro"/>

<xacro:property name="mass" value="19.6"/>

<xacro:property name="cog" value="0 0 0"/>

<xacro:property name="rho" value="1028"/>

<xacro:property name="visual_mesh_file" value="file://$(find lauv_description)/meshes/body.dae"/>

<xacro:property name="collision_mesh_file" value="file://$(find lauv_description)/meshes/body.stl"/>

<xacro:macro name="lauv_base" params="namespace *gazebo inertial_reference_frame">

  <!-- Rigid body description of the base link -->
  <link name="${namespace}/base_link">
    <!--
      Be careful to setup the coefficients for the inertial tensor,
      otherwise your model will become unstable on Gazebo
    -->
    <inertial>
      <mass value="${mass}" />
      <origin xyz="${cog}" rpy="0 0 0"/>
      <inertia ixx="${0.5 * mass * lauv_radius * lauv_radius}" ixy="0" ixz="0"
               iyy="${0.083333333 * mass * 3 * lauv_radius * lauv_radius + 0.083333333 * mass * lauv_length * lauv_length}" iyz="0"
               izz="${0.083333333 * mass * 3 * lauv_radius * lauv_radius + 0.083333333 * mass * lauv_length * lauv_length}" />
    </inertial>

    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <mesh filename="${visual_mesh_file}" scale="1 1 1" />
      </geometry>
    </visual>

    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>s
      <geometry>
        <mesh filename="${collision_mesh_file}" scale="1 1 1" />
      </geometry>
    </collision>
  </link>

<gazebo reference="${namespace}/base_link">
  <selfCollide>false</selfCollide>
</gazebo>

<gazebo>
    <plugin name="talker" filename="libtalker.so">
        <name_link_to_change_mass>lauv/base_link</name_link_to_change_mass>
    </plugin>
</gazebo>


<!-- Set up hydrodynamic plugin given as input parameter -->
<xacro:insert_block name="gazebo"/>

<!-- Include the thruster modules -->
<xacro:include filename="$(find lauv_description)/urdf/actuators.xacro"/>

<!-- Include the sensor modules -->
<xacro:include filename="$(find lauv_description)/urdf/sensors.xacro"/>

</xacro:macro>

`

  1. actuators.xacro:-

`

<xacro:thruster_macro robot_namespace="${namespace}" thruster_id="0">
    <origin xyz="-0.53994 0 0" rpy="0 0 ${pi}" />
</xacro:thruster_macro>

<!-- Instantiate fins, if necessary -->
<xacro:fin_macro namespace="${namespace}" fin_id="0" mesh_filename="${red_fin_mesh_file}">
  <origin xyz="-0.4 0 0.04" rpy="0 0 0" />
</xacro:fin_macro>
<xacro:fin_macro namespace="${namespace}" fin_id="1" mesh_filename="${black_fin_mesh_file}">
  <origin xyz="-0.4 -0.04 0" rpy="${0.5 * pi} 0 0" />
</xacro:fin_macro>
<xacro:fin_macro namespace="${namespace}" fin_id="2" mesh_filename="${black_fin_mesh_file}">
  <origin xyz="-0.4 0 -0.04" rpy="${pi} 0 0" />
</xacro:fin_macro>
<xacro:fin_macro namespace="${namespace}" fin_id="3" mesh_filename="${black_fin_mesh_file}">
  <origin xyz="-0.4 0.04 0" rpy="${-0.5 * pi} 0 0" />
</xacro:fin_macro>
<xacro:fin_macro namespace="${namespace}" fin_id="4" mesh_filename="${black_fin_mesh_file}">
  <origin xyz="0.4 -0.04 0" rpy="${0.5 * pi} 0 0" />
</xacro:fin_macro>
<xacro:fin_macro namespace="${namespace}" fin_id="5" mesh_filename="${black_fin_mesh_file}">
  <origin xyz="0.4 0.04 0" rpy="${-0.5 * pi} 0 0" />
</xacro:fin_macro>

`

  1. gazebo.xacro:- `

    <xacro:property name="lauv_cob" value="0 0 0.01"/>

    <xacro:property name="lauv_volume" value="0.019085175"/>

    <xacro:property name="lauv_length" value="1.08"/> <xacro:property name="lauv_width" value="0.15"/> <xacro:property name="lauv_radius" value="${0.5 * lauv_width}"/> <xacro:property name="lauv_height" value="0.15"/>

    <xacro:macro name="lauv_hydro_model" params="namespace">

    0
     <!-- Link's volume -->
     <volume>${lauv_volume}</volume>
    
     <!-- Link's bounding box, it is used to recalculate the immersed
     volume when close to the surface.
     This is a workaround the invalid bounding box given by Gazebo-->
     <box>
       <width>${lauv_width}</width>
       <length>${lauv_length}</length>
       <height>${lauv_height}</height>
     </box>
    
     <!-- Center of buoyancy -->
     <center_of_buoyancy>${lauv_cob}</center_of_buoyancy>
    
     <!-- 1) Fossen's equation of motion -->
     <hydrodynamic_model>
       <type>fossen</type>
       <added_mass>
         1     0     0     0     0     0
         0     16    0     0     0     0
         0     0     16    0     0     0
         0     0     0     0.005 0     0
         0     0     0     0     1.3   0
         0     0     0     0     0     1.3
       </added_mass>
       <!--
         The linear damping coefficients can be provided as a diagonal (6 elements)
         or a full matrix (36 coefficients), like the added-mass coefficients above
       -->
       <linear_damping>
         -2.4  0     0     0     0     0
         0     -23   0     0     0     11.5
         0     0     -23   0     -11.5 0
         0     0     0     -0.3  0     0
         0     0     3.1   0     -9.7  0
         0     -3.1  0     0     0     -9.7
       </linear_damping>
       <!--
         The linear damping coefficients proportional to the forward speed
         can be provided as a diagonal (6 elements) or a full matrix (36 coefficients),
         like the added-mass coefficients above.
         This matrix is mostly useful for slender bodies (e.g. AUVs with torpedo shape)
       -->
       <linear_damping_forward_speed>
         0 0 0 0 0 0
       </linear_damping_forward_speed>
       <!--
         The quadratic damping coefficients can be provided as a diagonal (6 elements)
         or a full matrix (36 coefficients), like the added-mass coefficients above
       -->
       <quadratic_damping>
         -2.4   0      0      0       0      0
         0      -80    0      0       0      0.3
         0      0      -80    0       -0.3   0
         0      0      0      -0.0006 0      0
         0      0      1.5    0       -9.1   0
         0      -1.5   0      0       0      -9.1
       </quadratic_damping>
     </hydrodynamic_model>
    

4. sensors.xacro:-

<xacro:property name="camera_size" value="0.1"/> <xacro:property name="camera_origin_x" value="0.6"/> <xacro:property name="camera_origin_y" value="0"/> <xacro:property name="camera_origin_z" value="0"/>

<xacro:default_gps namespace="${namespace}" parent_link="${namespace}/base_link" />

<xacro:default_pose_3d_macro namespace="${namespace}" parent_link="${namespace}/base_link" inertial_reference_frame="${inertial_reference_frame}" />

<xacro:default_imu namespace="${namespace}" parent_link="${namespace}/base_link"> </xacro:default_imu>

<inertial>
  <mass value="1e-5" />
  <origin xyz="0 0 0" rpy="0 0 0"/>
  <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
</inertial>
30.0 1.3962634 800 800 R8G8B8 0.02 300 gaussian 0.0 0.007 true 0.0 /mybot/camera1 image_raw camera_info camera_link 0.07 0.0 0.0 0.0 0.0 0.0

<xacro:chemical_concentration_sensor_macro namespace="${namespace}" suffix="" reference_frame="world" parent_link="${namespace}/base_link" input_topic="/plume/particles" output_topic="particle_concentration" update_rate="2" gamma="0.001" water_salinity_value="35.0" plume_salinity_value="1.0" salinity_output_topic="salinity" salinity_unit="ppt" gain="5.0" noise_sigma="0.01" noise_amplitude="1" radius="50.0"> </xacro:chemical_concentration_sensor_macro>

`

  1. snippets.xacro:- `

<xacro:property name="prop_mesh_file" value="file://$(find lauv_description)/meshes/propeller.dae"/>

<xacro:macro name="thruster_macro" params="robot_namespace thruster_id *origin">

<!--
Dummy link as place holder for the thruster frame,
since thrusters can often be inside the collision geometry
of the vehicle and may cause internal collisions if set otherwise
-->
<link name="${robot_namespace}/thruster_${thruster_id}">

  <visual>
    <geometry>
      <mesh filename="${prop_mesh_file}" scale="1 1 1" />
    </geometry>
  </visual>

  <inertial>
    <mass value="0.001" />
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <inertia ixx="0.000000017" ixy="0.0" ixz="0.0"
           iyy="0.000000017" iyz="0.0"
           izz="0.000000017" />
  </inertial>
</link>

<!-- Joint between thruster link and vehicle base link -->
<joint name="${robot_namespace}/thruster_${thruster_id}_joint" type="continuous">
  <xacro:insert_block name="origin" />
  <axis xyz="1 0 0" />
  <parent link="${robot_namespace}/base_link" />
  <child link="${robot_namespace}/thruster_${thruster_id}" />
</joint>

<gazebo>
  <!-- Thruster ROS plugin -->
  <plugin name="${robot_namespace}_${thruster_id}_thruster_model" filename="libuuv_thruster_ros_plugin.so">
    <!-- Name of the thruster link -->
    <linkName>${robot_namespace}/thruster_${thruster_id}</linkName>

    <!-- Name of the joint between thruster and vehicle base link -->
    <jointName>${robot_namespace}/thruster_${thruster_id}_joint</jointName>

    <!-- Make the thruster aware of its id -->
    <thrusterID>${thruster_id}</thrusterID>

    <!-- Gain of the input command signal -->
    <gain>1</gain>

    <!-- Maximum allowed input value for the input signal for thruster unit -->
    <clampMax>-3000</clampMax>

    <!-- Minimum allowed value for the input signal for thruster unit -->
    <clampMin>3000</clampMin>

    <!-- Minimum and maximum thrust force output allowed -->
    <thrustMin>-50</thrustMin>
    <thrustMax>50</thrustMax>

    <!--
    Value from 0 to 1 to set the efficiency of the output thrust force
    Default value is 1.0
    -->
    <thrust_efficiency>1</thrust_efficiency>

    <!--
    Value from 0 to 1 to set the efficiency of the propeller as a factor
    to be multiplied to the current value of the state variable at each
    iteration.
    Default value is 1.0
    -->
    <propeller_efficiency>1</propeller_efficiency>

    <dynamics>
      <type>FirstOrder</type>
      <timeConstant>0.05</timeConstant>
    </dynamics>

    <conversion>
      <type>Basic</type>
      <rotorConstant>0.0002</rotorConstant>
    </conversion>        

  </plugin>
</gazebo>

<gazebo reference="${robot_namespace}/thruster_${thruster_id}">
  <selfCollide>false</selfCollide>
</gazebo>

</xacro:macro>

<xacro:property name="black_fin_mesh_file" value="file://$(find lauv_description)/meshes/black_fin.dae"/> <xacro:property name="red_fin_mesh_file" value="file://$(find lauv_description)/meshes/red_fin.dae"/>

<xacro:property name="fin_area" value="0.0064"/> <xacro:property name="fin_rho" value="1028"/> <xacro:property name="fin_lift_coefficient" value="3.0"/> <xacro:property name="fin_drag_coefficient" value="1.98"/>

<xacro:macro name="fin_macro" params="namespace fin_id *origin mesh_filename"> <xacro:fin_quadratic_macro namespace="${namespace}" parent_link="${namespace}/base_link" fin_id="${fin_id}" min_joint_limit="${-90.0 * d2r}" max_joint_limit="${90.0 * d2r}" mesh_filename="${mesh_filename}" fin_dynamics_time_constant="0.2" lift_constant="${0.5 * fin_rho * fin_area * fin_lift_coefficient}" drag_constant="${0.5 * fin_rho * fin_area * fin_drag_coefficient}" current_velocity_topic="current_velocity"> <xacro:insert_block name="origin"/> </xacro:fin_quadratic_macro> </xacro:macro>

<!-- <xacro:macro name="fin_macro" params="namespace fin_id *origin mesh_filename">
  <xacro:fin_two_lines_macro
    namespace="${namespace}"
    parent_link="${namespace}/base_link"
    fin_id="${fin_id}"
    min_joint_limit="${-80*d2r}"
    max_joint_limit="${80*d2r}"
    mesh_filename="${mesh_filename}"
    fin_dynamics_time_constant="0.1"
    fin_cross_section_area="${fin_area}"        
    current_velocity_topic="current_velocity"
    fluid_density="1028.0"
    a0="0.0"
    alpha_stall="0.436332313" 
    cla="2.435070629"
    cla_stall="0"
    cda="0"
    cda_stall="0">
    <xacro:insert_block name="origin"/>
  </xacro:fin_two_lines_macro>
</xacro:macro> -->

<!-- cla_stall="-1.929963096"
    cda="1.101841914" -->

`

Gowresh7 avatar Oct 12 '20 04:10 Gowresh7

Hi @brschettini, I hope this is what you had asked for.

Gowresh7 avatar Oct 13 '20 09:10 Gowresh7

@brschettini Is there a way to bring in the angular motion functionality?

Gowresh7 avatar Oct 15 '20 12:10 Gowresh7

@Gowresh7 Hi, did you solve this problem?

nitianlei984 avatar May 07 '21 13:05 nitianlei984