Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Needed: Enabling Realistic Movement for Truck Model in Complex Terrain with ODE Physics #3375

Open
marcusvinicius178 opened this issue Mar 3, 2024 · 2 comments

Comments

@marcusvinicius178
Copy link

Hello Gazebo Team,

I'm currently working on integrating ROS2 with Gazebo to simulate a truck model navigating through a complex terrain environment (specifically, the Sonoma Raceway model). While I've managed to achieve partial success, the truck's movement remains unrealistic compared to expectations, moving either too slowly or becoming completely stuck. I've conducted extensive troubleshooting, including adjusting ODE physics parameters and experimenting with various model configurations, yet the issue persists. My partial solution is described here: Truck-Sonoma interaction Gazebo issue

Environment Details:

ROS2 Version: Iron
Gazebo Version: 11.10.2
Operating System: Ubuntu 22.04

Issue Description:

Automatically inserting the truck model into the environment via a ROS2 launch file leads to significantly restricted movement. This contrasts with manual insertion, where the truck moves more freely, as can be seen in this video: Raceway World: Truck Stucking

Despite modifying the SDF files to adjust friction properties and experimenting with different ODE physics parameters, the truck's movement is either too slow or it becomes stuck when the environment is set up automatically.

Attempts to Resolve:

  • Custom Ground Plane: Introduced with specific friction properties (mu and m2).
  • ODE Parameters Adjustment: Fine-tuned to find a balance that enables movement.
  • Following Navigation Tutorials: Implemented guidance from the Navigation2 with GPS tutorial, which successfully enabled movement for smaller models like the Turtlebot but not for the truck in the complex terrain.

Current ODE Configuration:

I've found a partial solution that allows for slow movement using direct cmd_vel commands but faces limitations with continuous movement, especially when using a trajectory planner. Here's the current ODE configuration in my world file:

<?xml version="1.0" ?>
<sdf version="1.6">
  <world name="default">
    <scene>
      <ambient>0.95 0.95 0.95 1</ambient>
      <background>0.3 0.3 0.3 1</background>
      <shadows>true</shadows>
    </scene>
    <include>
      <uri>model://sun</uri>
    </include>
    <model name="custom_ground_plane">
      <static>true</static>
      <link name="ground_plane_link">
        <collision name="ground_plane_collision">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>1000 1000</size>
            </plane>
          </geometry>
          <surface>
            <friction>
              <ode>
                <mu>1.0</mu>
                <mu2>0.5</mu2>
              </ode>
            </friction>
          </surface>
        </collision>
        <visual name="ground_plane_visual">
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>1000 1000</size>
            </plane>
          </geometry>
        </visual>
      </link>
      <pose>0 0 0 0 0 0</pose>
    </model>
    <include>
      <uri>model://sonoma_raceway</uri>
      <pose>-287.5 143.5 -7 0 0 0</pose>
    </include>
    <include>
      <uri>model://arocs_truck</uri>
      <pose>-1.8 2.02 0.38 0 0 2.482566</pose>
    </include>
    <spherical_coordinates>
      <surface_model>EARTH_WGS84</surface_model>
      <latitude_deg>38.161479</latitude_deg>
      <longitude_deg>-122.454630</longitude_deg>
      <elevation>488.0</elevation>
      <heading_deg>180</heading_deg>
    </spherical_coordinates>
    <physics type="ode">
      <real_time_update_rate>1000.0</real_time_update_rate>
      <max_step_size>0.013</max_step_size> <!-- Smaller for more accuracy -->
      <real_time_factor>1</real_time_factor>
      <ode>
        <solver>
          <type>quick</type>
          <iters>100</iters> <!-- Reduced from 150 to potentially soften the simulation, lower to reduce computational load -->
          <precon_iters>0</precon_iters>
          <sor>1.4</sor> <!-- Lower to potentially reduce rigidity -->
          <use_dynamic_moi_rescaling>1</use_dynamic_moi_rescaling>
        </solver>
        <constraints>
          <cfm>0.001</cfm> <!-- Lower for a tighter simulation, reducing "sponginess" -->
          <erp>0.15</erp> <!-- Increase to ensure error correction is more effective -->
          <contact_max_correcting_vel>500.000000</contact_max_correcting_vel> <!-- Lower to reduce the aggressiveness of contact corrections -->
          <contact_surface_layer>0.01</contact_surface_layer> <!-- Lower to minimize penetration without increasing rigidity -->
        </constraints>
      </ode>
    </physics>
  </world>
</sdf>

Request for Guidance:

I'm seeking insights into optimizing the ODE physics parameters or any other configurations to enable more realistic and consistent movement for the truck model in complex terrains. My best approaches using cmd_vel and path planner are displayed on videos below, however they are insufficient for a regular move.

Enable move for truck using cmd_vel

Truck stuck using trajectory planner

Any advice on handling such scenarios, especially considering the computational demands of detailed environments, would be greatly appreciated.

Thank you in advance for your time and assistance. Your support is invaluable in overcoming this hurdle and advancing our project.

@marcusvinicius178
Copy link
Author

marcusvinicius178 commented Mar 5, 2024

The solution was switch the default complex physics:

    <physics type="ode">
      <real_time_update_rate>1000.0</real_time_update_rate>
      <max_step_size>0.013</max_step_size> <!-- Smaller for more accuracy -->
      <real_time_factor>1</real_time_factor>
      <ode>
        <solver>
          <type>quick</type>
          <iters>100</iters> <!-- Reduced from 150 to potentially soften the simulation, lower to reduce computational load -->
          <precon_iters>0</precon_iters>
          <sor>1.4</sor> <!-- Lower to potentially reduce rigidity -->
          <use_dynamic_moi_rescaling>1</use_dynamic_moi_rescaling>
        </solver>
        <constraints>
          <cfm>0.001</cfm> <!-- Lower for a tighter simulation, reducing "sponginess" -->
          <erp>0.15</erp> <!-- Increase to ensure error correction is more effective -->
          <contact_max_correcting_vel>500.000000</contact_max_correcting_vel> <!-- Lower to reduce the aggressiveness of contact corrections -->
          <contact_surface_layer>0.01</contact_surface_layer> <!-- Lower to minimize penetration without increasing rigidity -->
        </constraints>
      </ode>
    </physics>

for this basic one, based on Prius Repository

    <physics name='default_physics' default='0' type='ode'>
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>1000</real_time_update_rate>
    </physics>

However I am still facing an issue, which is the joints of my truck does not let it static, even if I publish a cmd_vel = 0 to emulate a handbrake. It starts falling down on reverse as the video below shows:

Truck Sliding on Reverse

I am trying to implement a fake anchor, kind of handbrake, to attach the truck to the ground, but not sure if it is going to work.

Otherwise I will need to switch the simple ackermman gazeboplugin for a more complex dynamic truck model, which assigns torque, force, power, etc to the truck's whell joints such as Prius Hybrid Plugins

@marcusvinicius178
Copy link
Author

Hi, I have realized that the gazebo Ackermann plugin just simulates kinematics, which is why my truck is not able to move on inclined terrains with high friction. If someone has developed an Ackermann Dynamic model plugin for Gazebo simulations, which handles with Effort, Torque, Force, Power, please let me know. I guess something similar to Prius control from ROS1 could work: https://github.com/osrf/car_demo/blob/master/car_demo/plugins/PriusHybridPlugin.cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant