Home | Tutorials | Wiki | Issues
Ask Your Question

Revision history [back]

not realistic simulation

Hi I'm trying to simulate a self balancing robot. My problem is that the robot doesn't fall when is a lot tilted. for example if the robot starts from the position in the picture, I expect that it will fall maybe with the wheels that slip a little bit, instead in my case the controller it's able to bring it to the vertical postion. it's like the wheels are stucked into the ground, I've tried to give the mass and inertia realistic as much as possible. The robot is it tall 20 cm with cheap motors at 6v. I've also tried to emulate them adding some velocity limit tothe joints and damping(but i'm not sure about these values) the motors can reach a max speed of 210 rpm with no load and a stall torque of 2kgcm. Do you have any advice why the robots doesn't fall? Thanks to everyone

image description

https://youtu.be/HOQlRCeUS4I <robot name="self_balancing_ai">

  <material name="Blue">
    <color rgba="${255/255} ${108/255} ${10/255} 0.9"/>
  </material>

  <material name="White">
    <color rgba="${255/255} ${255/255} ${255/255} ${0.9}"/>
  </material>

  <material name="Black">
    <color rgba="${0/255} ${0/255} ${0/255} ${0.9}"/>
  </material>


  <link name="base_segway">
    <visual>
      <geometry>
        <box size="0.15 0.05 0.2"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="White"/>
    </visual>
    <collision>
      <geometry>
        <box size="0.15 0.05 0.2"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
    </collision>
    <inertial>
      <mass value="0.3"/>
      <inertia ixx="0.003125" ixy="0.0" ixz="0.0" iyy="0.002125" iyz="0.0" izz="0.00125"/>
    </inertial>
  </link>


  <link name="battery">
    <visual>
      <geometry>
        <box size="0.07 0.04 0.02"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <material name="Green"/>
    </visual>
    <collision>
      <geometry>
        <box size="0.07 0.04 0.02"/>
      </geometry>
      <origin rpy="0 0 0" xyz="0 0 0"/>
    </collision>
    <inertial>
      <mass value="0.1"/>
      <inertia ixx="0.003125" ixy="0.0" ixz="0.0" iyy="0.002125" iyz="0.0" izz="0.00125"/>
    </inertial>
  </link>

  <joint name="base_segway_battery" type="fixed">
    <parent link="base_segway"/>
    <child link="battery"/>
    <origin rpy="0 0 0" xyz="0 0 0.11"/>
  </joint>


  <link name="motor_l">
    <visual>
      <geometry>
        <cylinder radius="0.0125" length="0.07"/>
      </geometry>
      <origin rpy="0 1.5708 0" xyz="0 0 0"/>
      <material name="Black"/>
    </visual>
    <collision>
      <geometry>
        <cylinder radius="0.0125" length="0.07"/>
      </geometry>
      <origin rpy="0 1.5708 0" xyz="0 0 0"/>
    </collision>
    <inertial>
      <mass value="0.1"/>
      <inertia ixx="0.000" ixy="0.0" ixz="0.0" iyy="0.000" iyz="0.0" izz="0.00001848"/>
    </inertial>
  </link>

  <joint name="base_segway_motorl" type="fixed">
    <parent link="base_segway"/>
    <child link="motor_l"/>
    <origin rpy="0 0 0" xyz="0.035 0 -0.1"/>
  </joint>


  <link name="motor_r">
    <visual>
      <geometry>
        <cylinder radius="0.0125" length="0.07"/>
      </geometry>
      <origin rpy="0 1.5708 0" xyz="0 0 0"/>
      <material name="Black"/>
    </visual>
    <collision>
      <geometry>
        <cylinder radius="0.0125" length="0.07"/>
      </geometry>
      <origin rpy="0 1.5708 0" xyz="0 0 0"/>
    </collision>
    <inertial>
      <mass value="0.1"/>
      <inertia ixx="0.000" ixy="0.0" ixz="0.0" iyy="0.000" iyz="0.0" izz="0.00001848"/>
    </inertial>
  </link>

  <joint name="base_segway_motorr" type="fixed">
    <parent link="base_segway"/>
    <child link="motor_r"/>
    <origin rpy="0 0 0" xyz="-0.035 0 -0.1"/>
  </joint>


  <link name="wheel_l">
    <visual>
      <geometry>
        <cylinder radius="0.0325" length="0.025"/>
      </geometry>
      <origin rpy="0 1.5708 0" xyz="0 0 0"/>
      <material name="Black"/>
    </visual>
    <collision>
      <geometry>
        <cylinder radius="0.0325" length="0.025"/>
      </geometry>
      <origin rpy="0 1.5708 0" xyz="0 0 0"/>
    </collision>
    <inertial>
      <mass value="0.035"/>
      <inertia ixx="0.000" ixy="0.0" ixz="0.0" iyy="0.000" iyz="0.0" izz="0.00001848"/>
    </inertial>
  </link>

  <joint name="base_segway_wheell" type="continuous">
    <parent link="base_segway"/>
    <child link="wheel_l"/>
    <origin rpy="0 0 0" xyz="0.1 0 -0.1"/>
    <dynamics damping="5.61e-3" friction="3.33e-2"/>
    <limit effort="0.3" velocity="20.0" lower="-22" upper="22" />
  </joint>

  <link name="wheel_r">
    <visual>
      <geometry>
        <cylinder radius="0.0325" length="0.025"/>
      </geometry>
      <origin rpy="0 -1.5708 0" xyz="0 0 0"/>
      <material name="Black"/>
    </visual>
    <collision>
      <geometry>
        <cylinder radius="0.0325" length="0.025"/>
      </geometry>
      <origin rpy="0 -1.5708 0" xyz="0 0 0"/>
    </collision>
    <inertial>
      <mass value="0.035"/>
      <inertia ixx="0.000" ixy="0.0" ixz="0.0" iyy="0.000" iyz="0.0" izz="0.00001848"/>
    </inertial>
  </link>

  <joint name="base_segway_wheelr" type="continuous">
    <parent link="base_segway"/>
    <child link="wheel_r"/>
    <origin rpy="0 0 0" xyz="-0.1 0 -0.1"/>
    <dynamics damping="5.61e-3" friction="3.33e-2"/>
    <limit effort="0.3" velocity="20.0" lower="-22" upper="22" />
  </joint>


<!-- TRANSMISSION -->

  <transmission name="base_segway_wheell_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="base_segway_wheell">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="base_segway_wheell_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

  <transmission name="base_segway_wheelr_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="base_segway_wheelr">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="base_segway_segway_wheelr_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

<gazebo reference="base_segway">
  <material>Gazebo/White</material>
  <mu1>1e100</mu1>
  <mu2>1e100</mu2>
  <kp>1e-15</kp>
  <kd>1e13</kd>
    <maxVel>0.0</maxVel>
    <selfCollide>true</selfCollide>
    <static>true</static>
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<gazebo reference="battery">
  <material>Gazebo/Green</material>
  <mu1>1e100</mu1>
  <mu2>1e100</mu2>
  <kp>1e-15</kp>
  <kd>1e13</kd>
    <maxVel>0.0</maxVel>
    <selfCollide>true</selfCollide>
    <static>true</static>
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<gazebo reference="motor_r">
  <material>Gazebo/White</material>
  <mu1>1e100</mu1>
  <mu2>1e100</mu2>
  <kp>1e-15</kp>
  <kd>1e13</kd>
    <maxVel>0.0</maxVel>
    <selfCollide>true</selfCollide>
    <static>true</static>
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<gazebo reference="motor_l">
  <material>Gazebo/White</material>
  <mu1>1e100</mu1>
  <mu2>1e100</mu2>
  <kp>1e-15</kp>
  <kd>1e13</kd>
    <maxVel>0.0</maxVel>
    <selfCollide>true</selfCollide>
    <static>true</static>
    <turnGravityOff>false</turnGravityOff>
</gazebo>

  <joint name="hokuyo_joint" type="fixed">
    <axis xyz="0 1 0" />
    <origin xyz="0.0475 0 0.055" rpy="0 0 0"/>
    <parent link="base_segway"/>
    <child link="hokuyo_link"/>
  </joint>

  <!-- Hokuyo Laser -->
  <link name="hokuyo_link">
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
    <box size="0.005 0.005 0.005"/>
      </geometry>
    </collision>
  <!--
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <box size="0.005 0.005 0.005"/>
      </geometry>
    </visual>

    <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>
  -->
  </link>

<gazebo reference="wheel_l">
  <material>Gazebo/Black</material>
  <kp>1e15</kp>
  <kd>1e13</kd>
  <mu1>0.8</mu1>
  <mu2>0.8</mu2>
  <maxVel>0</maxVel>
  <minDepth>0.000</minDepth>
    <selfCollide>true</selfCollide>
    <static>false</static>
    <turnGravityOff>false</turnGravityOff>
</gazebo>

<gazebo reference="wheel_r">
  <material>Gazebo/Black</material>
  <kp>1e15</kp>
  <kd>1e13</kd>
  <mu1>0.8</mu1>
  <mu2>0.8</mu2>
  <maxVel>0</maxVel>
  <minDepth>0.000</minDepth>
    <selfCollide>true</selfCollide>
    <static>false</static>
    <turnGravityOff>false</turnGravityOff>
</gazebo>


   <!-- hokuyo -->
  <gazebo reference="hokuyo_link">
    <sensor type="gpu_ray" name="head_hokuyo_sensor">
      <pose>0 0 0 0 0 0</pose>
      <visualize>false</visualize>
      <update_rate>40</update_rate>
      <ray>
        <scan>
          <horizontal>
            <samples>720</samples>
            <resolution>1</resolution>
            <min_angle>-0.1</min_angle>
            <max_angle>0.1</max_angle>
          </horizontal>
        </scan>
        <range>
          <min>0.01</min>
          <max>30.0</max>
          <resolution>0.01</resolution>
        </range>
        <noise>
          <type>gaussian</type>
          <!-- Noise parameters based on published spec for Hokuyo laser
               achieving "+-30mm" accuracy at range < 10m.  A mean of 0.0m and
               stddev of 0.01m will put 99.7% of samples within 0.03m of the true
               reading. -->
          <mean>0.0</mean>
          <stddev>0.01</stddev>
        </noise>
      </ray>
      <plugin name="gazebo_ros_head_hokuyo_controller" filename="libgazebo_ros_gpu_laser.so">
        <topicName>/self_balancing_ai/laser/scan</topicName>
        <frameName>hokuyo_link</frameName>
      </plugin>
    </sensor>
  </gazebo>
  <gazebo>
      <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
      <robotNamespace>/self_balancing_ai</robotNamespace>
    </plugin>


        <plugin name="imu_plugin" filename="libgazebo_ros_imu.so">
            <alwaysOn>true</alwaysOn>
            <bodyName>base_segway</bodyName>
            <topicName>imu</topicName>
            <serviceName>imu_service</serviceName>
            <gaussianNoise>0.0</gaussianNoise>
            <rpyOffsets>0 0 0</rpyOffsets>
            <accelDrift>0.05 0.05 0.05</accelDrift>
            <accelGaussianNoise>0.035 0.035 0.03</accelGaussianNoise>
            <rateDrift>0.0 0.0 0.0</rateDrift>
            <rateGaussianNoise>0.00 0.00 0.00</rateGaussianNoise>
            <headingDrift>0.0</headingDrift>
            <headingGaussianNoise>0.00</headingGaussianNoise>
            <updateRate>00</updateRate>
        </plugin>

  </gazebo>




</robot>