Skip to content

Commit 221301d

Browse files
authored
Merge pull request #625 from pazeshun/compile-on-pure-focal
[hrpsys_ros_bridge_tutorials] Enable to compile on pure Ubuntu Focal
2 parents 79a5af8 + 2117707 commit 221301d

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

hrpsys_ros_bridge_tutorials/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,14 @@ else ()
543543
set(euscollada_PACKAGE_PATH ${euscollada_PREFIX}/share/euscollada)
544544
endif()
545545

546+
# enable to execute with correct python version
547+
# cf. https://github.com/tork-a/openrtm_aist_python-release/pull/5
548+
find_package(PythonInterp QUIET)
549+
if(NOT PYTHONINTERP_FOUND)
550+
find_package(Python REQUIRED)
551+
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
552+
endif()
553+
546554
macro (generate_hand_attached_hrp2_model _robot_name)
547555
set(_model_dir "${PROJECT_SOURCE_DIR}/models/")
548556
set(_in_urdf_file "${_model_dir}/${_robot_name}.urdf")
@@ -551,7 +559,7 @@ macro (generate_hand_attached_hrp2_model _robot_name)
551559
string(TOLOWER ${_robot_name} _srobot_name)
552560
message("generate hand_attached_hrp2_model for ${_robot_name}")
553561
add_custom_command(OUTPUT ${_out_urdf_file}
554-
COMMAND ${_script_file}
562+
COMMAND ${PYTHON_EXECUTABLE} ${_script_file}
555563
LARM_LINK6 RARM_LINK6 ${_in_urdf_file} ${_out_urdf_file}
556564
DEPENDS ${_in_urdf_file} ${_script_file} ${_srobot_name}_${PROJECT_NAME}_compile_urdf)
557565
endmacro()
@@ -577,7 +585,7 @@ macro (attach_sensor_and_endeffector_to_hrp2jsk_urdf
577585
set(_out_urdf_file "${_model_dir}/${_out_file}")
578586
set(_script_file ${euscollada_PACKAGE_PATH}/scripts/add_sensor_to_collada.py)
579587
add_custom_command(OUTPUT ${_out_urdf_file}
580-
COMMAND ${_script_file}
588+
COMMAND ${PYTHON_EXECUTABLE} ${_script_file}
581589
${_in_urdf_file} -O ${_out_urdf_file} -C ${_in_yaml_file}
582590
DEPENDS ${_in_urdf_file} ${_in_yaml_file} ${_script_file})
583591
list(APPEND compile_urdf_robots ${_out_urdf_file})

hrpsys_ros_bridge_tutorials/models/gen_hand_attached_staro_model.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ INPUT_FILE=$2
1010
EUSCOLLADA_PATH=$3
1111
BODY_FILE=${INPUT_FILE//.urdf/_body.urdf}
1212

13+
# enable to execute with correct python version
14+
# cf. https://github.com/tork-a/openrtm_aist_python-release/pull/5
15+
if command -v python3 &>/dev/null; then
16+
PYTHON_EXECUTABLE=$(command -v python3)
17+
elif command -v python &>/dev/null; then
18+
PYTHON_EXECUTABLE=$(command -v python)
19+
else
20+
echo "Cannot find python executable"
21+
exit 1
22+
fi
23+
1324
tmp1=`mktemp`
1425
tmp2=`mktemp`
15-
${EUSCOLLADA_PATH}/scripts/remove_sensor_from_urdf.py LARM_LINK7 $INPUT_FILE $tmp1
16-
${EUSCOLLADA_PATH}/scripts/remove_sensor_from_urdf.py RARM_LINK7 $tmp1 $BODY_FILE
26+
${PYTHON_EXECUTABLE} ${EUSCOLLADA_PATH}/scripts/remove_sensor_from_urdf.py LARM_LINK7 $INPUT_FILE $tmp1
27+
${PYTHON_EXECUTABLE} ${EUSCOLLADA_PATH}/scripts/remove_sensor_from_urdf.py RARM_LINK7 $tmp1 $BODY_FILE

hrpsys_ros_bridge_tutorials/models/gen_sensor_attached_staro_model.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,22 @@ input_urdf=$3
99
output_urdf=$4
1010
yaml_file=$5
1111

12+
# enable to execute with correct python version
13+
# cf. https://github.com/tork-a/openrtm_aist_python-release/pull/5
14+
if command -v python3 &>/dev/null; then
15+
PYTHON_EXECUTABLE=$(command -v python3)
16+
elif command -v python &>/dev/null; then
17+
PYTHON_EXECUTABLE=$(command -v python)
18+
else
19+
echo "Cannot find python executable"
20+
exit 1
21+
fi
22+
1223
# generating model with sensors
1324
function add_sensor_to_tmp_urdf()
1425
{
1526
tmp_model=`mktemp`
16-
${eusurdf_path}/scripts/add_sensor_to_urdf.py $@ $tmp_model
27+
${PYTHON_EXECUTABLE} ${eusurdf_path}/scripts/add_sensor_to_urdf.py $@ $tmp_model
1728
if [ $? == 0 ]; then
1829
echo $tmp_model
1930
else
@@ -24,7 +35,7 @@ function add_sensor_to_tmp_urdf()
2435
function add_eef_to_tmp_urdf()
2536
{
2637
tmp_model=`mktemp`
27-
${eusurdf_path}/scripts/add_eef_to_urdf.py $@ $tmp_model
38+
${PYTHON_EXECUTABLE} ${eusurdf_path}/scripts/add_eef_to_urdf.py $@ $tmp_model
2839
if [ $? == 0 ]; then
2940
echo $tmp_model
3041
else
@@ -59,7 +70,7 @@ function generate_staro_model()
5970
# # tmp_model11=$(add_sensor_to_tmp_urdf 0 0.2 -0.2 0 0 1.57 LARM_LINK6 LARM_cb_jig $tmp_model10)
6071
# # tmp_model12=$(add_sensor_to_tmp_urdf 0 -0.2 -0.2 0 0 1.57 RARM_LINK6 RARM_cb_jig $tmp_model11)
6172
# cp $tmp_model4 $2
62-
${eusurdf_path}/scripts/add_sensor_to_collada.py $1 -O $2 -C $3
73+
${PYTHON_EXECUTABLE} ${eusurdf_path}/scripts/add_sensor_to_collada.py $1 -O $2 -C $3
6374
}
6475

6576
generate_staro_model $input_urdf $output_urdf $yaml_file

0 commit comments

Comments
 (0)