Skip to content

Modelling Shallow Water Correctly #1691

Closed

Description

@gpans

Hi,

I'm a master student trying to use MuJoCo to design an amphibious robot. To simulate the water, my current methodology is to adaptively change the viscosity, density, and wind speed of the simulation based on the position of the robot on a hfield amphibious terrain (see bottom right of video for values).

This somewhat works however is not ideal/accurate as fluid forces are being applied across the entire body whereas in real life in amphibious terrain only half the body would be in water.

Environment_demo.mp4

Is it possible to apply various wind forces on various points of the hfield to mimic top half being air and bottom half being water. Any other suggestions or approaches would be much appreciated.

def controller(model, data):

    global water_bounds
    global rho_a
    global beta_a
    global rho_w
    global beta_w
    global valley_height
    global fluid_vel
    global wind_vel
    global water_present

    if water_present:
        if valley_height <= water_bounds:
            model.opt.viscosity = beta_w #viscosity of water
            model.opt.density = rho_w #density of water
            model.opt.wind = fluid_vel #speed of water (given it changes viscosity of entire system, wind will increase the speed of the entire denser/more viscous water flow as if its water flowing)
        else:
            model.opt.viscosity = beta_a #viscosity of air
            model.opt.density = rho_a #density of air
            model.opt.wind = wind_vel #no wind
    else:
            model.opt.viscosity = beta_a #viscosity of air
            model.opt.density = rho_a #density of air
            model.opt.wind = wind_vel #no wind
<mujoco>

    <asset>   
      <mesh name = "chassis" file = "C:\Users\Chassis.stl"/>
      <mesh name = "wheel_1" file = "C:\Users\Wheel1_pl.stl"/>
      <mesh name = "wheel_2" file = "C:\Users\Wheel2_pl.stl"/>
      <mesh name = "wheel_3" file = "C:\Users\Wheel3_pl.stl"/>
      <mesh name = "wheel_4" file = "C:\Users\Wheel4_pl.stl"/>
  
      <texture name="grid" type="2d" builtin="checker" width="512" height="512" rgb2="0 0 0" rgb1="1 1 1"/>
      <material name="grid" texture="grid" texrepeat="2 2" texuniform="true" reflectance=".6"/>
    </asset>
    <default>
        <default class="chassis">
             <geom type="mesh" mesh="chassis" mass="2.279" rgba="01.0 0.549 0.0 1" fluidcoef=".5 .25 1.5 0 0" fluidshape="ellipsoid"/>
        </default>
        <default class="wheel">
            <geom fitscale="1.2" type="mesh" friction="2 0.005 0.0001" contype="1" conaffinity="0" mass="0.285" material="grid" fluidcoef=".5 .25 1.5 0 0" fluidshape="ellipsoid"/>
           
        </default>
    </default>
    <worldbody>
        <body name="chassis_body" pos="-4.5 0 1" euler="0 0 90">
            <joint type="free"/>
            <geom class="chassis"/>
            <site name="robot_marker" pos="0 0 0" size="0.025" type="sphere" rgba="1 1 1 0"/>  

            <body name="wheel1_body">
                <joint name="wheel1_joint" type="hinge" pos="0.25 0.04 0.02" axis="1 0 0" damping="0.05"/>
                <geom class="wheel" mesh="wheel_1"/>
            </body>

            <body name="wheel2_body">
                <joint name="wheel2_joint" type="hinge" pos="-0.05 0.04 0.02" axis="1 0 0" damping="0.05"/>
                <geom class="wheel" mesh="wheel_2"/>
            </body>
        
            <body name="wheel3_body">
                <joint name="wheel3_joint" type="hinge" pos="0.25 0.26 0.02" axis="1 0 0" damping="0.05"/>
                <geom class="wheel" mesh="wheel_3"/>
            </body>
        
            <body name="wheel4_body">
                <joint name="wheel4_joint" type="hinge" pos="-0.05 0.26 0.02"  axis="1 0 0" damping="0.05"/>
                <geom class="wheel" mesh="wheel_4"/>
            </body>
        </body>
    </worldbody>

    <actuator>
    <motor name="rl_wheel" joint="wheel3_joint" gear="1" ctrlrange="-1 1" forcerange="-1 1"/>
    <motor name="rr_wheel" joint="wheel4_joint" gear="1" ctrlrange="-1 1" forcerange="-1 1"/>
    <motor name="fl_wheel" joint="wheel1_joint" gear="1" ctrlrange="-1 1" forcerange="-1 1"/>
    <motor name="fr_wheel" joint="wheel2_joint" gear="1" ctrlrange="-1 1" forcerange="-1 1"/>
    </actuator>

    <sensor>
        <framepos name ="robot position" objtype="site" objname="robot_marker"/>
    </sensor>

</mujoco>

Activity

  1. converted this issue into a discussion #1984 on Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionRequest for help or information

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions