0
$\begingroup$

I am currently trying to add sensor(lidar) into my robot. I made base for a sensor, link to which sensor is attached through gazebo reference.

The problem is that adding a tag for some reason creates another one tf tree, with 2 nodes, where my lidar is attached. Whereas there still exists another tf tree with my robot and sensor base.

If i remove (in fact removing this tag removes sensor, but still keeps the link to which this sensor is attached) the tree becomes well defined.

I want to know how to fix this and to get the single tf tree.

Here is the tree i want to have()

Here is the tree i have after adding sensor with gazebo reference

What i add is the following(taken from livox github):

<gazebo reference="${name}">
      <sensor type="ray" name="${name}">
          <pose>0 0 0 0 0 0</pose>
          <visualize>${visualize}</visualize>
          <update_rate>${update_rate}</update_rate>
          <!-- This ray plgin is only for visualization. -->
          <plugin name="gazebo_ros_laser_controller" filename="liblivox_laser_simulation.so">
        <ray>
          <scan>
          <horizontal>
          <samples>100</samples>
          <resolution>1</resolution>
          <min_angle>${-horizontal_fov/360*M_PI}</min_angle>
          <max_angle>${horizontal_fov/360*M_PI}</max_angle>
          </horizontal>
          <vertical>
          <samples>50</samples>
          <resolution>1</resolution>
          <min_angle>${-vertical_fov/360*M_PI}</min_angle>
          <max_angle>${vertical_fov/360*M_PI}</max_angle>
          </vertical>
          </scan>
          <range>
          <min>${laser_min_range}</min>
          <max>${laser_max_range}</max>
          <resolution>${resolution}</resolution>
          </range>
          <noise>
          <type>gaussian</type>
          <mean>${noise_mean}</mean>
          <stddev>${noise_stddev}</stddev>
          </noise>
        </ray>
            <visualize>${visualize}</visualize>
        <samples>${samples}</samples>
        <downsample>${downsample}</downsample>
        <csv_file_name>package://livox_laser_simulation/scan_mode/avia.csv</csv_file_name>
        <ros_topic>${ros_topic}</ros_topic>
          </plugin>
      </sensor>
    </gazebo>

Here is the part of the urdf which connects lidar to trunk link:

  <joint name="scan_joint" type="fixed">
    <parent link="trunk"/>
    <child link="livox_base"/>
    <origin rpy="0 0 0" xyz="0.2 0.0 0.1"/>
  </joint>
  <material name="blue_custom">
    <color rgba="0 0 0.8 1"/>
  </material>
  <!-- <xacro:Livox_AVIA name="livox"/>
  <xacro:include filename="/home/ramil/catkin_ws/src/livox_laser_simulation/urdf/standardrobots_oasis300.xacro"/>
  <xacro:link_oasis name="oasis"/> -->
  <gazebo reference="livox">
    <sensor name="livox" type="ray">
      <pose>0 0 0 0 0 0</pose>
      <visualize>True</visualize>
      <update_rate>10</update_rate>
      <!-- This ray plgin is only for visualization. -->
      <plugin filename="liblivox_laser_simulation.so" name="gazebo_ros_laser_controller">
        <ray>
          <scan>
            <horizontal>
              <samples>100</samples>
              <resolution>1</resolution>
              <min_angle>-0.614355377778</min_angle>
              <max_angle>0.614355377778</max_angle>
            </horizontal>
            <vertical>
              <samples>50</samples>
              <resolution>1</resolution>
              <min_angle>-0.673696522222</min_angle>
              <max_angle>0.673696522222</max_angle>
            </vertical>
          </scan>
          <range>
            <min>0.1</min>
            <max>200.0</max>
            <resolution>0.002</resolution>
          </range>
          <noise>
            <type>gaussian</type>
            <mean>0.0</mean>
            <stddev>0.01</stddev>
          </noise>
        </ray>
        <visualize>True</visualize>
        <samples>24000</samples>
        <downsample>1</downsample>
        <csv_file_name>package://livox_laser_simulation/scan_mode/avia.csv</csv_file_name>
        <ros_topic>scan</ros_topic>
      </plugin>
    </sensor>
  </gazebo>
  <link name="livox_base">
    <inertial>
      <mass value="0.1"/>
      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01"/>
    </inertial>
    <visual>
      <origin rpy="0 0 0" xyz="0.00 0 0.00"/>
      <geometry>
        <mesh filename="package://livox_laser_simulation/meshes/livox_mid40.dae">
          </mesh>
      </geometry>
      <material name="blue_custom"/>
    </visual>
    <collision>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <mesh filename="package://livox_laser_simulation/meshes/livox_mid40.dae">
          </mesh>
      </geometry>
    </collision>
  </link>
  <!-- <xacro:Livox_Mid_gazebo_sensor name="livox" visualize="True"/> -->
  <link name="livox">
    <inertial>
      <mass value="0.1"/>
      <inertia ixx="0.01" ixy="0" ixz="0" iyy="0.01" iyz="0" izz="0.01"/>
    </inertial>
  </link>
  <joint name="base_to_livox_joint" type="fixed">
    <parent link="livox_base"/>
    <child link="livox"/>
    <origin rpy="0 0 0" xyz="0.0 0.0 0.0"/>
  </joint>
$\endgroup$
2
  • $\begingroup$ First image is a tree which i want to have(single tree), second image is a tree which i have after i add sensor with gazebo reference $\endgroup$
    – Ramil
    Feb 28 at 15:04
  • $\begingroup$ i want to know how to fix this double tf tree into a single one, updated the question $\endgroup$
    – Ramil
    Mar 1 at 6:34

2 Answers 2

1
$\begingroup$

This does not appear to be breaking your tree, but creating an additional detached tree.

The tree will only connect if they share a common ancestor. As pointed out by @Chuck you appear to have two links that have base in the name. But since they are not exactly the same the links don't connect to each other.

Looking at your second tree, the first guess is that a1_gazebo::base should match the existing base link. Whatever you're launching or running should have a parameter to set the base link.

$\endgroup$
0
$\begingroup$

You haven't posted the sensor config that generates the incorrect tf tree, but your bad tf graphic shows livox as a child of a1_gazebo::base and not just base.

What happens if you change the config from a1_gazebo::base to base?

:EDIT:

Okay, so you posted a partial URDF file, but I didn't see a joint in there, so I was confused as to how your sensor was linked to anything, so I went to the GitHub account you mentioned and found this livox_mid70.xacro file that has the following joint defined at the bottom:

<joint name="${name}_to_${name}_base_joint" type="fixed">
  <parent link="${name}_base"/>
  <child link="${name}"/>
  <origin rpy="0 0 0" xyz="0.0 0.0 0.0"/>
</joint>

The weird thing here is that this parent link is defined as ${name}_base, but the base frame you're getting in your tf tree is a1_gazebo::base.

I would suspect your joint's parent link is incorrectly named, but your URDF snippet doesn't give any joint details, so I can't really comment/troubleshoot beyond this.

$\endgroup$
8
  • $\begingroup$ by sensor config do you mean the urdf file? $\endgroup$
    – Ramil
    Mar 1 at 6:34
  • 1
    $\begingroup$ @Ramil You said The problem is that adding a tag for some reason creates another one tf tree - where are you adding the tag? You haven't shown us what text you're modifying to trigger the tf tree to split. $\endgroup$
    – Chuck
    Mar 1 at 15:02
  • $\begingroup$ i have added the urdf part which breaks the tf tree $\endgroup$
    – Ramil
    Mar 2 at 6:16
  • $\begingroup$ @Ramil - I edited my answer here. $\endgroup$
    – Chuck
    Mar 2 at 14:21
  • $\begingroup$ i have added more info about URDF into my question $\endgroup$
    – Ramil
    Mar 3 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.