0
$\begingroup$

Rosanswers logo

UPDATE: Hi, I found out that the front of robot model in gazebo falls into ground if the mass of the inertial section of the base_link as well as the caster (front_roller) is to large. But why? Tried to change the makro default_interial to some specific makros for box, cylinder and sphere. But I receive the same result if I use mass >1 for base_link or if i add the caster link.

Please check screenshots to get an idea of my strange robot position in gazebo.

Any idea?

BR Marco

Hi, i tried to setup a custom robot by using the tutorials and explanations on urdf, xacro and gazebo.

After several hours of finetuning gazebo started and the robort was shown :)

But the robot seems to be in the air (a few cm)(not standing on the ground plane) and any command is without any reaction. Tried RQT Gui or teleop to send commands. nothing happens.

Not sure whats wrong. In rviz robot seems to be on the ground. (and parallel to the ground - in gazebo not) UPDATE: In Rviz see the odom frame isnt parallel to the ground. Seems exactly the opposite angel as the robot is shown in gazebo. I also tried to add some coordinates to the footprint. Also I changed the origins so that base_link has z=0. Also strange is the z position of my front-roller in relation to the right and left roller. Both have in xacro the same z value. But in Rviz they are not shown on the same position.

UPDATE: Added to pics from rviz and gazebo.

Gazebo

Rviz

xacro definition of robot:

   <robot name="hallrover_v1" xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:property name="hallrover_body_width" value="0.20"/>
  <xacro:property name="hallrover_body_length" value="1.50"/>
  <xacro:property name="hallrover_body_heigth" value="0.10"/>
  <xacro:property name="hallrover_frame_heigth" value="0.05"/>
  <xacro:property name="hallrover_frame_width" value="1.34"/>
  <!-- - roller_length*2 + roller_body_space*2 + hallrover_body_width + hallrover_frame_thick*2 -->
  <xacro:property name="hallrover_frame_length" value="1.50"/>
  <xacro:property name="hallrover_frame_thick" value="0.05"/>
  <!-- hallrover_frame_height -->
  <xacro:property name="roller_length" value="0.50"/>
  <xacro:property name="roller_diam" value="0.25"/>
  <xacro:property name="roller_body_space" value="0.02"/>
  
    <xacro:macro name="default_inertial" params="mass">
    <inertial>
      <mass value="${mass}"/>
      <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
  </xacro:macro>
  <!-- Import all Gazebo-customization elements, including Gazebo colors -->
  <xacro:include filename="$(find hallrover_v1)/urdf/hallrover_v1.gazebo"/>
  
  <!--https://www.generationrobots.com/blog/en/2015/02/robotic-simulation-scenarios-with-gazebo-and-ros/ -->
  <link name="base_footprint">
   <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <box size="0.001 0.001 0.001" />
      </geometry>
    </visual>
  </link>
  <joint name="base_joint" type="fixed">
    <parent link="base_footprint"/>
    <child link="base_link"/>
     <origin xyz="0 0 0" rpy="0 0 0" />
  </joint>
  <gazebo>
    <material>Gazebo/White</material>
  </gazebo>
  
  <link name="base_link">
    <visual>
      <geometry>
        <box size="${hallrover_body_width} ${hallrover_body_length} ${hallrover_body_heigth}"/>
      </geometry>
      <origin xyz="0 0 0"/>
      <material name="white">
        <color rgba="1 1 1 1"/>
      </material>
    </visual>
    <collision>
      <geometry>
        <box size="${hallrover_frame_width} ${hallrover_body_length} ${roller_diam + hallrover_body_heigth}"/>
       <!-- z not exactly correct - doesnt matter -->
            </geometry>
    </collision>
    <xacro:default_inertial mass="10"/>
  </link>
  
  <link name="body_frame_rear">
    <visual>
      <geometry>
        <box size="${hallrover_frame_width} ${hallrover_frame_thick} ${hallrover_frame_heigth}"/>
      </geometry>
      <origin xyz="0 -${hallrover_body_length / 2} ${hallrover_body_heigth /2}"/>
      <material name="white">
        <color rgba="1 1 1 1"/>
      </material>
    </visual>
    <xacro:default_inertial mass="1"/>
  </link>
  <joint name="frame_to_body_rear" type="fixed">
    <parent link="base_link"/>
    <child link="body_frame_rear"/>
  </joint>
  
  <link name="body_frame_front">
    <visual>
      <geometry>
        <box size="${hallrover_frame_width} ${hallrover_frame_thick} ${hallrover_frame_heigth}"/>
      </geometry>
      <origin xyz="0 ${hallrover_body_length / 2} ${ hallrover_body_heigth/2}"/>
      <material name="white">
        <color rgba="1 1 1 1"/>
      </material>
    </visual>
    <xacro:default_inertial mass="1"/>
  </link>
  <joint name="frame_to_body_front" type="fixed">
    <parent link="base_link"/>
    <child link="body_frame_front"/>
  </joint>
  
  <link name="body_frame_right">
    <visual>
      <geometry>
        <box size="${hallrover_frame_thick} ${hallrover_frame_length} ${hallrover_frame_heigth}"/>
      </geometry>
      <origin xyz="${hallrover_frame_width / 2 - hallrover_frame_thick / 2} 0 ${hallrover_body_heigth/2}"/>
      <material name="white">
        <color rgba="1 1 1 1"/>
      </material>
    </visual>
    <xacro:default_inertial mass="1.5"/>
  </link>
  <joint name="frame_to_body_right" type="fixed">
    <parent link="base_link"/>
    <child link="body_frame_right"/>
  </joint>
  
  <link name="body_frame_left">
    <visual>
      <geometry>
        <box size="${hallrover_frame_thick} ${hallrover_frame_length} ${hallrover_frame_heigth}"/>
      </geometry>
      <origin xyz="-${hallrover_frame_width / 2  - hallrover_frame_thick / 2 } 0 ${hallrover_body_heigth/2}"/>
      <material name="white">
        <color rgba="1 1 1 1"/>
      </material>
    </visual>
    <xacro:default_inertial mass="1.5"/>
  </link>
  <joint name="frame_to_body_left" type="fixed">
    <parent link="base_link"/>
    <child link="body_frame_left"/>
  </joint>
 

  <link name="front_roller">
    <visual>
      <geometry>
        <sphere radius="${roller_diam /2 }"/>
      </geometry>
     
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
    <xacro:default_inertial mass="2"/>
  </link>
  <joint name="front_roller_to_body" type="fixed">
    <parent link="base_link"/>
    <child link="front_roller"/>
       <origin xyz="0 ${hallrover_body_length /2 - roller_diam /2} -${roller_diam}"/>
  </joint>
  <gazebo reference="front_roller">
    <material>Gazebo/Black</material>
  </gazebo>

    
  <!-- https://www.generationrobots.com/blog/en/2015/02/robotic-simulation-scenarios-with-gazebo-and-ros/ -->
  <link name="roller_left">
    <visual>
      <geometry>
        <cylinder length="${roller_length}" radius="${roller_diam /2}"/>
      </geometry>
      <origin rpy="0 ${pi/2} 0" xyz="0 0 0"/>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
    <collision>
      <geometry>
        <cylinder length="${roller_length}" radius="${roller_diam /2}"/>
        <origin rpy="0 ${pi/2} 0" xyz="0 0 0"/>
      </geometry>
    </collision>
    <xacro:default_inertial mass="5"/>
  </link>
  <gazebo reference="roller_left">
    <mu1 value="1.0"/>
    <mu2 value="1.0"/>
    <kp value="10000000.0"/>
    <kd value="1.0"/>
    <fdir1 value="1 0 0"/>
    <material>Gazebo/Black</material>
  </gazebo>
  <joint name="body_to_roller_left" type="continuous">
    <parent link="base_link"/>
    <child link="roller_left"/>
    <axis rpy="0 0 0" xyz=" 0 1 0"/>
    <origin rpy="0 0 0" xyz="-${roller_body_space + roller_length /2 + hallrover_body_width /2} -${hallrover_body_length / 2 - roller_diam /2}  -${roller_diam / 2 }"/>
    <limit effort="100" velocity="100"/>
    <joint_properties damping="0.0" friction="0.0"/>
  </joint>
  <transmission name="left_roller_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="body_to_roller_left">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="left_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>10</mechanicalReduction>
    </actuator>
  </transmission>
  
  <link name="roller_right">
    <visual>
      <geometry>
        <cylinder length="${roller_length}" radius="${roller_diam /2}"/>
      </geometry>
      <origin rpy="0 ${pi/2} 0" xyz="0 0 0"/>
      <material name="black">
        <color rgba="0 0 0 1"/>
      </material>
    </visual>
    <collision>
      <geometry>
        <cylinder length="${roller_length}" radius="${roller_diam /2}"/>
        <origin rpy="0 ${pi/2} 0" xyz="0 0 0"/>
      </geometry>
    </collision>
    <xacro:default_inertial mass="5"/>
  </link>
  <gazebo reference="roller_right">
    <mu1 value="1.0"/>
    <mu2 value="1.0"/>
    <kp value="10000000.0"/>
    <kd value="1.0"/>
    <fdir1 value="1 0 0"/>
    <material>Gazebo/Black</material>
  </gazebo>
  <joint name="body_to_roller_right" type="continuous">
    <parent link="base_link"/>
    <child link="roller_right"/>
    <axis rpy="0 0 0" xyz="0 1 0"/>>
    <origin rpy="0 0 0" xyz="${roller_body_space + roller_length /2 + hallrover_body_width /2} -${hallrover_body_length / 2 - roller_diam /2}  -${roller_diam / 2 }"/>
    <limit effort="100" velocity="100"/><joint_properties damping="0.0" friction="0.0"/>
  </joint>
  <transmission name="right_roller_trans">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="body_to_roller_right">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="right_motor">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>10</mechanicalReduction>
    </actuator>
  </transmission>

</robot>

Gazebo include

<robot>

<!-- https://www.generationrobots.com/blog/en/2015/02/robotic-simulation-scenarios-with-gazebo-and-ros/ -->
  <gazebo>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
      <robotNamespace>/hallrover</robotNamespace>
    </plugin>
  </gazebo>



<!-- http://gazebosim.org/tutorials?tut=ros_gzplugins#DifferentialDrive --> 
<gazebo>
  <plugin name="differential_drive_controller" filename="libgazebo_ros_diff_drive.so">
    <alwaysOn>true</alwaysOn>
      <legacyMode>false</legacyMode>
    <updateRate>100.0</updateRate>
    <leftJoint>body_to_roller_left</leftJoint>
    <rightJoint>body_to_roller_right</rightJoint>
    <wheelSeparation>${roller_length+hallrover_body_width}</wheelSeparation>
    <wheelDiameter>${roller_diam}</wheelDiameter>
    <torque>20</torque>
    <commandTopic>cmd_vel</commandTopic>
    <odometryTopic>odom</odometryTopic>
    <odometryFrame>odom</odometryFrame>
    <robotBaseFrame>footprint</robotBaseFrame>
  </plugin>
</gazebo>   
    

</robot>

launch file

<launch>
  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam command="load" file="$(find hallrover_v1)/config/hallrover_control_v1.yaml"/>
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find hallrover_v1)/worlds/hallrover.world"/>
    <arg default="false" name="paused"/>
    <arg default="true" name="use_sim_time"/>
    <arg default="true" name="gui"/>
    <arg default="false" name="headless"/>
    <arg default="false" name="debug"/>
  </include>
  <!-- load the controllers -->
  <node args="joint_state_controller
      rightRoller_effort_controller
      leftRoller_effort_controller" name="controller_spawner" ns="/hallrover" output="screen" pkg="controller_manager" respawn="false" type="spawner"/>
  <param command="$(find xacro)/xacro.py '$(find hallrover_v1)/urdf/hallrover_v1.xacro'" name="robot_description"/>
  <!-- Spawn a robot into Gazebo -->
  <node args="-param robot_description -urdf -model hallrover_v1" name="spawn_urdf" pkg="gazebo_ros" type="spawn_model"/>
  <!-- http://gazebosim.org/tutorials/?tut=ros_control -->  
  <!-- convert joint states to TF transforms for rviz, etc -->
  <node name="robot_state_publisher" output="screen" pkg="robot_state_publisher" respawn="false" type="robot_state_publisher">
    <remap from="/joint_states" to="/hallrover/joint_states"/>
  </node>
</launch>

Originally posted by Boregard on ROS Answers with karma: 46 on 2018-02-17

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hey guys, I'm happy.Issue solved.

  1. collision definition of my caster was missing. Therefore the caster was not recognized by gazebo and the front of the bot (base_link) was on ground.
  2. Rear of the bot was in air because the rpy attribute was not set for the rollers in the collision segment

Br Marco


Originally posted by Boregard with karma: 46 on 2018-02-20

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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