RAFALAMAO / hector-quadrotor-noetic

Hector Quadrotor ported to ROS Noetic with Gazebo 11
61 stars 36 forks source link

Undefined Tag in kinect_camera.urdf.xacro #12

Closed zzzzzyh111 closed 11 months ago

zzzzzyh111 commented 1 year ago

Recently, I have been doing research with the spawn_quadrotor_with_kinect.launch file, which has something to do with the kinect_camera.urdf.xacro file. However, when I tried to start the launch in Gazebo, some errors occurred:

RLException: while processing /home/zyh/catkin_ws/src/Hector/hector_quadrotor_noetic/hector_quadrotor/hector_quadrotor_gazebo/launch/spawn_quadrotor_with_kinect.launch: while processing /home/zyh/catkin_ws/src/Hector/hector_quadrotor_noetic/hector_quadrotor/hector_quadrotor_gazebo/launch/spawn_quadrotor.launch: Invalid tag: Cannot load command parameter [robot_description]: command [['/opt/ros/noetic/lib/xacro/xacro', '/home/zyh/catkin_ws/src/Hector/hector_quadrotor_noetic/hector_quadrotor/hector_quadrotor_description/urdf/quadrotor_with_kinect.gazebo.xacro', 'base_link_frame:=/base_link', 'world_frame:=world']] returned with code [2]. Param xml is <param name="robot_description" command="$(find xacro)/xacro '$(arg model)' base_link_frame:=$(arg base_link_frame) world_frame:=$(arg world_frame)"/ The traceback for the exception was written to the log file

And I found that this error is caused by the in kinect_camera.urdf.xacro file, line 17.

Personally, I supposed that this is because inertial_sphere tag is not pre-defined in the kinect_camera.urdf.xacro, which leads to the error. Therefore, I tried to define a inertial_sphere.urdf.xacro file first and include it later in the kinect_camera.urdf.xacro file to solve this problem. Here is the content:

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
  <xacro:macro name="inertial_sphere" params="mass diameter">
    <inertial>
      <mass value="${mass}"/>
      <inertia ixx="${(2/5)*mass*pow((diameter/2),2)}" ixy="${(2/5)*mass*pow((diameter/2),2)}" ixz = "${(2/5)*mass*pow((diameter/2),2)}" iyy="${(2/5)*mass*pow((diameter/2),2)}" iyz = "${(2/5)*mass*pow((diameter/2),2)}" izz="${(2/5)*mass*pow((diameter/2),2)}"/>
      <origin xyz="0 0 0" rpy="0 0 0" />
    </inertial>
    <visual>
      <geometry>
        <sphere radius="${diameter/2}"/>
      </geometry>
    </visual>
  </xacro:macro>
</robot>

I am writing to discuss with you whether this is a mistake caused by undefinition or my own problem. I hope to hear from you soon!

Best Regards :)

RAFALAMAO commented 1 year ago

I didn't use kinect, so, I didn't knows about that error xc, thank you very much for solving bro!

Do you think is good to add this fix to repo?

Sorry my bad english xD

zzzzzyh111 commented 1 year ago

Yes, although it may not be the best solution, it at least can solve the roslaunch issue. Thanks for your reply bro, and I hope this fix can make sense to other users.

All the best to your future endeavors!