Best practice for exposing an existing URDF model as a Gazebo 1.4 model
I can successfully load an existing URDF robot model into Gazebo 1.4. What I want to achieve now is a file/folder setup that plays as nicely as possible with Gazebo and my existing robot description ROS package. My current solution is to
- Leave existing robot description ROS package as-is, ie. Gazebo-agnostic (actual package).
- Create a model database in a simulation-specific folder added to the GAZEBO_MODEL_PATH.
The model database in 2. needs of course access to an up-to-date URDF model, and its mesh/image resources which do not live here, but in 1. I'm currently using cmake custom commands/targets to run xacro and expose resources through a symlink (code snippet at the end of the post). This works well.
My question is whether someone has come up with a simpler/more elegant solution to this problem.
Just for the record, I'm not adding the Gazebo model database directly in the existing robot description ROS package not only to prevent unwanted dependency couplings, but also because this ROS package does not fully comply with the Gazebo database folder structure, so Gazebo rightfully complains of unexpected contents when loading it.
TIA,
CMake code snippet:
rosbuild_find_ros_package(xacro)
rosbuild_find_ros_package(reem_description)
# Generate an up-to-date URDF robot description using xacro
set(INPUT_XACRO_FILE ${reem_description_PACKAGE_PATH}/robots/reem.urdf.xacro)
set(OUTPUT_URDF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/models/reem_description/model.urdf)
add_custom_command(OUTPUT ${OUTPUT_URDF_FILE}
COMMAND ${xacro_PACKAGE_PATH}/xacro.py ${INPUT_XACRO_FILE} -o ${OUTPUT_URDF_FILE})
add_custom_target(generate_urdf ALL DEPENDS ${OUTPUT_URDF_FILE})
# Create symlink to robot model resources (meshes, images)
set(INPUT_MESHES_DIR ${reem_description_PACKAGE_PATH}/meshes)
set(OUTPUT_MESHES_SYMLINK ${CMAKE_CURRENT_SOURCE_DIR}/models/reem_description/meshes)
add_custom_command(OUTPUT ${OUTPUT_MESHES_SYMLINK}
COMMAND ${CMAKE_COMMAND} -E create_symlink ${INPUT_MESHES_DIR} ${OUTPUT_MESHES_SYMLINK})
add_custom_target(generate_meshes_link ALL DEPENDS ${OUTPUT_MESHES_SYMLINK})