qboticslabs / mastering_ros

This repository contains exercise files of the book "Mastering ROS for Robotics Programming"
https://www.packtpub.com/hardware-and-creative/mastering-ros-robotics-programming
468 stars 282 forks source link

unknown macro name: xacro:base XacroException(u'unknown macro name: xacro:base',) #11

Closed abdul-mannan-khan closed 7 years ago

abdul-mannan-khan commented 7 years ago

I have been trying to run follow this book but I am facing some problems particularly in Chapter 2 and 3 and specifically in the file view_arm.launch. It is worth mentioning that this error is also reported in ROS website as well (link)

Whenever I run this file, I get the following error

unknown macro name: xacro:base
XacroException(u'unknown macro name: xacro:base',)
when processing file: /home/khan/catkin_ws/src/mastering_ros_robot_description_pkg/urdf/seven_dof_arm.xacro
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/kinetic/share/xacro/xacro.py /home/khan/catkin_ws/src/mastering_ros_robot_description_pkg/urdf/seven_dof_arm.xacro] returned with code [2]. 

Param xml is <param command="$(find xacro)/xacro.py $(find mastering_ros_robot_description_pkg)/urdf/seven_dof_arm.xacro" name="robot_description"/>
The traceback for the exception was written to the log file

I have been trying to resolve this problem in any way I can but it is not working.

I am also seeing this warning along with the above mentioned error,

xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
inconsistent namespace redefinitions for xmlns:xacro:
 old: http://www.ros.org/wiki/xacro
 new: http://ros.org/wiki/xacro (/home/khan/catkin_ws/src/mastering_ros_robot_description_pkg/urdf/sensors/xtion_pro_live.urdf.xacro)
deprecated: xacro tags should be prepended with 'xacro' xml namespace.

Please, help me out how can I resolve this. Thank you.

myyerrol commented 7 years ago

Hi, @u04617

Maybe I know your problem. According to your terminal's warning informations, I think you use the distribution of ROS is Jade or Kinetic, and the problem is just on the distribution of ROS. Firstly, I am using the Indigo, and I use the following command no any problem.

$> roslaunch mastering_ros_robot_description_pkg view_arm.launch

So according to your error information, I find the following lines in the seven_dof_arm.xacro: screenshot from 2016-09-08 20 46 18 As mentioned by error, I also don't find the definition of macro base just like the following format: <xacro:macro name="base", params="xxx, ..." > ...... </xacro:macro> For example, if you are coding by using C++, you need call a function, but the function is not defined and implemented yet, the compiler must report a error. So solution is commenting out these lines: screenshot from 2016-09-08 21 11 28 As for why indigo can run, I think the checked mechanism of indigo's xacro is less than Jade or Kinetic.

In addition to the error, there are warning informations on the terminal. If you visit Xacro wiki, you can find the xacro of Jade or Kinetic has more enhanced functionality and more limits than that of Indigo. So for the cause of warning, you can get by running xacro with option --check-order on the terminal just like

$> roscd mastering_ros_robot_description_pkg
$> rosrun xacro xacro.py --check-order urdf/seven_dof_arm.xacro

Last, according to the warning informations, I think the solution is here: Deprecated Syntax

abdul-mannan-khan commented 7 years ago

Thank you so much myyerrol. I followed the instructions and issue is resolved. Thank you so much.

Xianyong commented 7 years ago

I am using the kinetic, and met the same issue. Yes, your solution works by commenting out those three macros, i.e., base, arm, and gripper. My questions is why it functions well with the old ROS distributions, such as Indigo. Where were those three macros defined in Indigo? Thanks.

myyerrol commented 7 years ago

Hi, @Xianyong

Firstly, you can look the following piccture: screenshot from 2016-09-13 13 23 00 Just you can see, it is the tree relationship of seven_dof_arm, and base, arm, gripper modules don't appear in it. In fact, I think that three modules are redundant or useless at least now(Because I'm not very clear about the author's intentions).

Secondly, for why it do well in the indigo distribution, the following picture may help you: screenshot from 2016-09-13 14 59 14 This picture is captured in the seven_dof_arm.urdf. In indigo, for no defined macros, Xacro can copy those directly from the .xacro file. But for kinetic, Xacro report error. As for the reason, if you visit the Xacro, you can find the checked mechanism of indigo's xacro is less than kinetic.

abdouakhad commented 1 year ago

I had the same error. All I did is include the file that contains the macro first and then calling it. <xacro:include filename="robot_essentials.xacro"/> <xacro:robot_wheel prefix="front_left" />