Skip to content

Commit

Permalink
do not run xacro when catkin_make.
Browse files Browse the repository at this point in the history
  • Loading branch information
hrpuser committed Oct 23, 2014
1 parent 4658cd9 commit 49f152c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
7 changes: 3 additions & 4 deletions hrpsys_ros_bridge_tutorials/catkin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,13 @@ generate_default_launch_eusinterface_files("$(find openhrp3)/share/OpenHRP-3.1/s
macro (generate_hand_attached_hrp2_model _robot_name)
set(_model_dir "${PROJECT_SOURCE_DIR}/models/")
set(_in_urdf_file "${_model_dir}/${_robot_name}.urdf")
set(_out_urdf_file "${_model_dir}/${_robot_name}_WH.urdf")
set(_out_urdf_file "${_model_dir}/${_robot_name}_body.urdf")
string(TOLOWER ${_robot_name} _srobot_name)
set(_launch_file "${PROJECT_SOURCE_DIR}/launch/${_srobot_name}_ros_bridge.launch")
set(_script_file "${PROJECT_SOURCE_DIR}/models/gen_hand_attached_hrp2_model.sh")
message("generate hand_attached_hrp2_model for ${_robot_name}")
add_custom_command(OUTPUT ${_out_urdf_file}
COMMAND ${_script_file} ${_robot_name} ${_in_urdf_file} ${_out_urdf_file} ${_launch_file} ${PROJECT_SOURCE_DIR}/..
DEPENDS ${_in_urdf_file} ${_launch_file} "${_model_dir}/HRP3HAND_L.urdf" "${_model_dir}/HRP3HAND_R.urdf")
COMMAND ${_script_file} ${_robot_name} ${_in_urdf_file} ${PROJECT_SOURCE_DIR}/..
DEPENDS ${_in_urdf_file})
add_custom_target(${_robot_name}_model_generate DEPENDS ${_out_urdf_file})
list(APPEND compile_urdf_robots ${_robot_name}_model_generate)
endmacro()
Expand Down
2 changes: 1 addition & 1 deletion hrpsys_ros_bridge_tutorials/models/HRP2JSKNT.urdf.xacro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="HRP2JSKNT" >
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP2JSKNT_tmp.urdf" />
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP2JSKNT_body.urdf" />
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP3HAND_L.urdf" />
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP3HAND_R.urdf" />
</robot>
2 changes: 1 addition & 1 deletion hrpsys_ros_bridge_tutorials/models/HRP2JSKNTS.urdf.xacro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<robot xmlns:xacro="http://www.ros.org/wiki/xacro" name="HRP2JSKNTS" >
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP2JSKNTS_tmp.urdf" />
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP2JSKNTS_body.urdf" />
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP3HAND_L.urdf" />
<xacro:include filename="$(find hrpsys_ros_bridge_tutorials)/models/HRP3HAND_R.urdf" />
</robot>
30 changes: 9 additions & 21 deletions hrpsys_ros_bridge_tutorials/models/gen_hand_attached_hrp2_model.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,22 @@ trap error ERR

ROBOT_MODEL=$1
INPUT_FILE=$2
OUTPUT_FILE=$3
LAUNCH_FILE=$4
ADDITIONAL_ROS_PACKAGE_PATH=$5
TMP_FILE=`echo ${INPUT_FILE} | sed "s/.urdf/_tmp.urdf/g"`
ADDITIONAL_ROS_PACKAGE_PATH=$3
BODY_FILE=`echo ${INPUT_FILE} | sed "s/.urdf/_body.urdf/g"`
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$ADDITIONAL_ROS_PACKAGE_PATH


# make tmp file
cp ${INPUT_FILE} ${TMP_FILE}
cp ${INPUT_FILE} ${BODY_FILE}

# remove LARM_LINK6
L_START=`grep -n "<link name=\"LARM_LINK6\"" -m 1 ${TMP_FILE} -m 1 | cut -f1 -d:`
L_END=$(sed -n "${L_START},\$p" ${TMP_FILE} | grep -n "<\/gazebo>" -m 1 | cut -f1 -d:) ##
L_START=`grep -n "<link name=\"LARM_LINK6\"" -m 1 ${BODY_FILE} -m 1 | cut -f1 -d:`
L_END=$(sed -n "${L_START},\$p" ${BODY_FILE} | grep -n "<\/gazebo>" -m 1 | cut -f1 -d:) ##
L_END=`expr ${L_START} + ${L_END} - 1`
sed -i -e "${L_START},${L_END}d" ${TMP_FILE}
sed -i -e "${L_START},${L_END}d" ${BODY_FILE}

# remove RARM_LINK6
L_START=`grep -n "<link name=\"RARM_LINK6\"" ${TMP_FILE} -m 1 | cut -f1 -d:`
L_END=$(sed -n "${L_START},\$p" ${TMP_FILE} | grep -n "<\/gazebo>" -m 1 | cut -f1 -d:) ##
L_START=`grep -n "<link name=\"RARM_LINK6\"" ${BODY_FILE} -m 1 | cut -f1 -d:`
L_END=$(sed -n "${L_START},\$p" ${BODY_FILE} | grep -n "<\/gazebo>" -m 1 | cut -f1 -d:) ##
L_END=`expr ${L_START} + ${L_END} - 1`
sed -i -e "${L_START},${L_END}d" ${TMP_FILE}

# generate URDF with xacro
rosrun xacro xacro.py `echo ${INPUT_FILE} | sed "s/.urdf/.urdf.xacro/g"` > ${OUTPUT_FILE}

# remove tmp file
rm -rf ${TMP_FILE}

# overwrite launch file to use new model
OUTPUT_FILE_BASENAME=`basename ${OUTPUT_FILE}`
sed -i -e "s@arg\ name=\"COLLADA_FILE\"\ \(.*\)${ROBOT_MODEL}.dae\"@arg\ name=\"COLLADA_FILE\"\ \\1${OUTPUT_FILE_BASENAME}\"@g" ${LAUNCH_FILE}
sed -i -e "${L_START},${L_END}d" ${BODY_FILE}

0 comments on commit 49f152c

Please sign in to comment.