Robotics StackExchange | Archived questions

Questions about cartographer with urdf : param robot_description not found by searchParam()

Recently I'm trying to make a mobile robot with cartographer, & rplidar_a3. I finished to use my rplidar with cartographer with the commands(by googling).

roslaunch rplidarros viewrplidara3.launch roslaunch cartographerros rplidar_2d.launch

And fortunately, it worked well. so I thought that the next step should be murging rplidar_2d.launch with my urdf. And I've tried it but I couldn't visualize my urdf on rviz with an error msg like this

param robot_description not found by searchParam()

And also, I cannot found robotstatepublisher() on my rqt tf tree.

My modified rplidar_2d.launch and rplidar.lua files are like this.

<?xml version="1.0"?>

  <param name="robot_description"
    textfile="$(find cartographer_ros)/urdf/qs_bot.xacro"/>

  <node name="robot_state_publisher" pkg="robot_state_publisher"
    type="robot_state_publisher" />

  <node pkg="cartographer_ros" type="cartographer_node" name="cartographer_node"
    args="-configuration_directory $(find cartographer_ros)/configuration_files
    -configuration_basename rplidar.lua"
    output="screen">
    <remap from="echoes" to="scan" />
  </node>

  <node pkg="cartographer_ros" type="cartographer_occupancy_grid_node"
     name="cartographer_occupancy_grid_node"
     args="-resolution 0.05" />

  <!-- AMCL -->
  <!-- <node pkg="amcl" type="amcl" name="amcl" args="scan:=scan">
    <remap from="static_map" to="/static_map"/>
    <param name="initial_pose_x" value="$(arg x_pos)" />
    <param name="initial_pose_y" value="$(arg y_pos)" />
    <param name="global_frame_id" value="map" />
    <param name="odom_frame_id" value="$(arg robot_name)/odom" />
    <param name="base_frame_id" value="$(arg robot_name)/base_link" />
  </node> -->

  <node name="rviz" pkg="rviz" type="rviz" required="true"
    args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />

lua file

include "mapbuilder.lua" include "trajectorybuilder.lua"

options = {
    map_builder = MAP_BUILDER,
    trajectory_builder = TRAJECTORY_BUILDER,
    map_frame = "map",
    tracking_frame = "base_link",
    published_frame = "base_link",
    odom_frame = "odom",
    provide_odom_frame = true,
    publish_frame_projected_to_2d = false,
    use_pose_extrapolator = true,
    use_odometry = false,
    use_nav_sat = false,
    use_landmarks = false,
    num_laser_scans = 1,
    num_multi_echo_laser_scans = 0,
    num_subdivisions_per_laser_scan = 10,
    num_point_clouds = 0,
    lookup_transform_timeout_sec = 0.2,
    submap_publish_period_sec = 0.3,
    pose_publish_period_sec = 5e-3,
    trajectory_publish_period_sec = 30e-3,
    rangefinder_sampling_ratio = 1.,
    odometry_sampling_ratio = 1,
    fixed_frame_pose_sampling_ratio = 1,
    imu_sampling_ratio = 1,
    landmarks_sampling_ratio = 1,
}

MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
POSE_GRAPH.optimization_problem.huber_scale = 1e2

return options

And my urdf(.xacro) files are like this.

<?xml version="1.0" ?>

  <!-- colors -->
  <material name="black">
    <color rgba="0 0 0 1"/>
  </material>
  <material name="white">
    <color rgba="1 1 1 1"/>
  </material>
  <material name="green">
    <color rgba="0 1 0 1"/>
  </material>

  <xacro:macro name="Transmission_block" params="joint_name">
    <transmission name="${joint_name}_trans">
    <type>transmission_interface/SimpleTransmission</type>
      <joint name="${joint_name}">
         <hardwareInterface>PositionJointInterface</hardwareInterface>
      </joint>
    <actuator name="${joint_name}_motor">
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
    </transmission>
  </xacro:macro>

  <!-- xacro parameters -->
  <xacro:property name="joint_wheel_match" value="-0.053 0.02 -0.052" />
  <xacro:property name="center_to_left_dis" value="0.2175" />
  <xacro:property name="center_to_right_dis" value="-${center_to_left_dis}" />
  <xacro:property name="center_to_front_dis" value="0.176" />
  <xacro:property name="center_to_back_dis" value="-0.169" />
  <xacro:property name="wheel_mass" value="0.8" />
  <xacro:property name="wheel_height" value="-0.085" />
  <!-- <xacro:property name="wheel_width" value="0.03552" /> -->
  <xacro:property name="wheel_width" value="0.046" />
  <xacro:property name="wheel_radius" value="0.0762" />
  <xacro:property name="PI" value="3.1415926535" />
  <xacro:macro name="cylinder_inertia" params ="m r h">
    <inertial>
      <mass value="${m}"/>
        <inertia ixx="${m*(3*r*r+h*h)/12}"  ixy="0.0" ixz="0.0"
            iyy="${m*(3*r*r+h*h)/12}"  iyz= "0.0"
            izz="${m*r*r/2}"/>
        </inertial>
  </xacro:macro>
  <xacro:macro name="default_inertial" params="mass">
    <inertial>
      <mass value="${mass}" />
        <!-- <inertia ixx="0.033034844532" ixy="-0.000000003511" ixz="0.00039886535"
                 iyy="0.038536631314" iyz="0.000028117499" izz="0.049732878241"/> -->
        <inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
    </inertial>
  </xacro:macro>

  <xacro:macro name="omni_steering" params="">
    <gazebo>
      <plugin name="object_controller" filename="libqs_bot_planar_move.so">
        <commandTopic>cmd_vel</commandTopic>
        <odometryTopic>odom</odometryTopic>
        <odometryFrame>odom</odometryFrame>
        <odometryRate>50.0</odometryRate>
        <robotBaseFrame>base_link</robotBaseFrame>
        <publishTf>true</publishTf>
      </plugin>
      <!-- <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so"/> -->
    </gazebo>
  </xacro:macro>

  <!-- base link -->
  <link name="base_link">
    <visual>
      <origin rpy="0 0 0" xyz="-0.2476 -0.2193 -0.12"/>
      <geometry>
        <mesh filename="package://qs_bot/meshes/base_frame.STL" scale="0.001 0.001 0.001"/>
        <!-- <box size="0.48 0.48 0.225"/> -->
      </geometry>
    </visual>
    <collision>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <!-- <mesh filename="package://qs_bot/meshes/base_frame.STL" scale="0.001 0.001 0.001"/> -->
        <box size="0.48 0.48 0.225"/>
      </geometry>
    </collision>
    <xacro:default_inertial mass="13.617"/>
  </link>

  <gazebo reference="base_link">
    <material>Gazebo/Red</material>
  </gazebo>

  <xacro:macro name="wheel" params= "prefix suffix X Y Z">
    <link name= "${prefix}_${suffix}_wheel">
      <visual>
        <origin rpy= "${PI/2} 0 0" xyz= "${joint_wheel_match}"/>
        <geometry>
          <mesh filename="package://qs_bot/meshes/mecanum_wheel.STL" scale="0.001 0.001 0.001"/>
        </geometry>
        <material name= "black"/>
      </visual>
      <collision>
        <origin rpy= "${PI/2} 0 0" xyz= "${joint_wheel_match}"/>
        <geometry>
          <mesh filename="package://qs_bot/meshes/mecanum_wheel.STL" scale="0.001 0.001 0.001"/>
        </geometry>
      </collision>
      <xacro:cylinder_inertia m="${wheel_mass}" r="${wheel_radius}" h="${wheel_width}"/>
    </link>

    <gazebo reference ="${prefix}_${suffix}_wheel">
      <mu1>1.0</mu1>
      <mu2>1.0</mu2>
      <kp>10000000.0</kp>
      <kd>1.0</kd>
      <material>Gazebo/DarkGrey</material>
    </gazebo>

    <joint name="${prefix}_${suffix}_wheel_joint" type="continuous">
      <parent link= "base_link"/>
      <child link= "${prefix}_${suffix}_wheel"/>
      <origin xyz= "${X} ${Y} ${Z}" rpy="0 0 0"/>
      <axis xyz="0 1 0"/>
    </joint>

    <transmission name="${prefix}_${suffix}_wheel_trans">
      <type>transmission_interface/SimpleTransmission</type>
      <actuator name="${prefix}_${suffix}_wheel_motor">
      <hardwareInterface>EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
      </actuator>
      <joint name="${prefix}_${suffix}_wheel_joint">
      <hardwareInterface>VelocityJointInterface</hardwareInterface>
      </joint>
    </transmission>
  </xacro:macro>

  <xacro:wheel prefix="right" suffix="front" X="${center_to_front_dis}" Y="${center_to_right_dis}" Z="${wheel_height}"/>
  <xacro:wheel prefix="right" suffix="back" X="${center_to_back_dis}" Y="${center_to_right_dis}" Z="${wheel_height}"/>
  <xacro:wheel prefix="left" suffix="front" X="${center_to_front_dis}" Y="${center_to_left_dis}" Z="${wheel_height}"/>
  <xacro:wheel prefix="left" suffix="back" X="${center_to_back_dis}" Y="${center_to_left_dis}" Z="${wheel_height}"/>
  <xacro:omni_steering/>

  <!-- sensors -->
  <link name="laser_frame">
    <visual>
      <!-- <origin rpy="0 0 -${PI/2}" xyz="-0.0375 0.0375 -0.01"/> -->
      <!-- <origin rpy="0 0 0" xyz="-0.0375 0.0375 -0.01"/> -->
      <geometry>
        <!--mesh filename="package://qs_bot/meshes/LiDAR.STL" scale="0.001 0.001 0.001"/-->
        <cylinder radius="0.05" length="0.04"/>
      </geometry>
      <material name="black"/>
    </visual>
    <collision>
      <geometry>
        <cylinder radius="0.05" length="0.04"/>
      </geometry>
    </collision>
    <!-- <xacro:inertial_cylinder mass="0.1" length="0.04" radius="0.05">
        <origin xyz="0 0 0" rpy="0 0 0"/>
    </xacro:inertial_cylinder> -->
  </link>

  <joint name="laser_joint" type="fixed">
    <axis xyz="0 1 0"/>
    <parent link="base_link"/>
    <child link="laser_frame"/>
    <origin rpy="0 0 0" xyz="0 0 0.135"/>
  </joint>

  <sensor name="rplidar" update_rate="20">
    <parent link="laser_frame"/>
    <origin xyz="0 0 0" rpy="0 0 0"/>
    <ray>
      <scan>
        <horizontal samples="360" resolution="2" min_angle="-3.14" max_angle="3.14"/>
      </scan>
    </ray>
  </sensor>

  <gazebo reference="laser_frame">
    <material>Gazebo/Blue</material>
     <turnGravityOff>false</turnGravityOff>
    <sensor name="laser" type="ray">
      <pose>0 0 0 0 0 0</pose>
      <visualize>true</visualize>
      <update_rate>40</update_rate>
      <ray>
        <scan>
          <horizontal>
            <samples>360</samples>
            <resolution>2</resolution>
            <min_angle>-3.14</min_angle>
            <max_angle>3.14</max_angle>
          </horizontal>
        </scan>
        <range>
          <min>0.3</min>
          <max>12</max>
          <!-- <resolution>0.001</resolution> -->
        </range>
      </ray>
      <!-- <plugin name="laser_controller" filename="libgazebo_ros_ray_sensor.so"> -->
      <plugin name="gazebo_ros_head_rplidar_controller" filename="libgazebo_ros_laser.so">
        <ros>
          <argument>~/out:=scan</argument>
        </ros>
        <output_type>sensor_msgs/LaserScan</output_type>
        <!-- <topicName>/scan</topicName> -->
        <frameName>laser_frame</frameName>
      </plugin>
    </sensor>
  </gazebo>

  <link name="imu">
    <visual>
      <origin rpy="0 0 -${PI/2}" xyz="0 0 0"/>
      <geometry>
        <box size="0.05 0.05 0.01"/>
      </geometry>
      <material name="green"/>
    </visual>
  </link>
  <joint name="imu_joint" type="fixed">
    <axis xyz="0 1 0"/>
    <parent link="base_link"/>
    <child link="imu"/>
    <origin rpy="0 0 0" xyz="0 0 0.007"/>
  </joint>

  <!-- gazebo -->
  <!-- <gazebo>
    <plugin name="gazebo_ros_control" filename= "libgazebo_ros_control.so">
    <robotNamespace>/</robotNamespace>
    </plugin>
  </gazebo> -->


</robot>

I know that it is quite long, but Can anybody help me why I can't see my robot on rviz?

And additional question is, I cannot think about how to merge cartographer with my urdf and my real mobile robot. The signal that I'm trying to input is my rplidar and imu signal(encoder odometry optional).

Asked by daidalos99 on 2022-11-16 06:52:20 UTC

Comments

Answers