0
$\begingroup$

I am trying to simulate a tennis ball in gazebo. The issue is that the ball is having inconsistent bouncing effects. Means the ball is bouncing different number of times when released from the same height for multiple times.

  • 1st Drop: 4 bounce
  • 2nd Drop: 2 bounce
  • 3rd drop: ball stuck in ground without any bounce.

I need to have consistent bouncing effect because I need to predict the ball trajectory when applied force in x direction while the ball is in air.

I have gone through the following post but changing iteration dose not seems to help.

URDF

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro"  name="ball_1"> 
    <!-- Variables -->
    <xacro:property name="ball_radius" value="0.05"/>
    <xacro:property name="ball_mass" value="0.001"/>

    
    <!-- MATERIALS -->    
    <material name="orange">
      <color rgba="${255.0/255.0} ${108.0/255.0} ${10.0/255.0} 1.0"/>
    </material>
    
    <!-- BASE LINK -->    
    <link name="base_link"/>        
    
    <joint name="joint_1" type="fixed">
        <parent link="base_link"/>
        <child link="link_1"/>
        <origin xyz="0 0 0" rpy="0 0 0"/>        
    </joint>    

    <!-- Ball -->
    <link name="link_1">
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0"/>
            <geometry>
                <sphere radius="${ball_radius}"/>    
            </geometry>            
            <material name="orange"/>
        </visual>
        
        <collision>
            <geometry>
                <sphere radius="${ball_radius}"/>    
            </geometry>                                    
        </collision>
        
        
        <inertial>
            <origin xyz="0 0 0" rpy="0 0 0"/>            
            <mass value="${ball_mass}" />
        <inertia ixx="${(2/5) * ball_mass * (ball_radius*ball_radius)}" ixy="0.0" ixz="0.0"
                    iyy="${(2/5) * ball_mass * (ball_radius*ball_radius)}" iyz="0.0"
                izz="${(2/5) * ball_mass * (ball_radius*ball_radius)}" />
        </inertial>    
            
    </link>   
    
    <gazebo reference="link_1">
        <material>Gazebo/Orange</material>
        
        <maxVel value="20.0"/>       

        <kp value="100000000.0" />
        <kd value="1.0" />
            
    </gazebo>
    
</robot>

Launch File

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument
from launch_ros.actions import Node

from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource

import xacro


def generate_launch_description():
    
    
    # Process the URDF file
    pkg_path = os.path.join(get_package_share_directory('ball_spawner'))
    xacro_file = os.path.join(pkg_path,'description','copy_ball.urdf.xacro')
    robot_description_config = xacro.process_file(xacro_file)
    
    # ROBOT STATE PUBLISHER    
    # Create a robot_state_publisher node
    params = {'robot_description': robot_description_config.toxml()}
    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[params]
    )


    # RVIZ
    rviz = Node(
            package='rviz2',
            executable='rviz2',
            output='screen'
        )
    
    # Include the Gazebo launch file, provided by the gazebo_ros package
    gazebo = IncludeLaunchDescription(
                PythonLaunchDescriptionSource([os.path.join(
                    get_package_share_directory('gazebo_ros'), 'launch', 'gazebo.launch.py')]),
                    launch_arguments={'world': "./src/ball_spawner/worlds/world_1.world"}.items()
             )

    # Run the spawner node from the gazebo_ros package. The entity name doesn't really matter if you only have a single robot.
    spawn_entity = Node(package='gazebo_ros', executable='spawn_entity.py',
                        arguments=['-topic', 'robot_description',
                                   '-entity', 'ball_bot'],
                        output='screen')
    

    # Launch!
    return LaunchDescription([
        node_robot_state_publisher,
        rviz,
        gazebo,
        spawn_entity,
    ])
$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.