Hi,
To use XACRO in ROS2 you need to process the XACRO and convert it to xml:
import xacro
xacro_file = os.path.join(get_package_share_directory('box_car_description'), 'robot/', 'box_bot.xacro')
assert os.path.exists(xacro_file), "The box_bot.xacro doesnt exist in "+str(xacro_file)
robot_description_config = xacro.process_file(xacro_file)
robot_desc = robot_description_config.toxml()
I'll leave a git as an example for this of how to spawn a simple box robot that uses xacro, have a look at the spawning scripts:
GIT with EXAMPLE
SPAWN 1
SPAWN 2
ROSject Plug and play example
YOUTUBE VIDEO
Hope this helps
You should get something like this in the example: