Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[euscollada] Test predefined pose methods in generated pr2 model #175

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions euscollada/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pr2.dae
pr2.l
pr2.urdf
56 changes: 46 additions & 10 deletions euscollada/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@
cmake_minimum_required(VERSION 2.8.3)
project(euscollada)

# check rosversion if >=indigo
execute_process(
COMMAND python -c "import sys; sys.exit(ord('$ENV{ROS_DISTRO}'[0]) >= ord('indigo'[0]))"
RESULT_VARIABLE rosversion_ge_indigo)

IF(${rosversion_ge_indigo})
find_package(catkin REQUIRED COMPONENTS collada_urdf rospack collada_parser resource_retriever)
ELSE()
find_package(catkin REQUIRED COMPONENTS collada_urdf rospack collada_parser urdfdom resource_retriever)
ENDIF()
if("$ENV{ROS_DISTRO}" STRGREATER "hydro")
find_package(catkin REQUIRED COMPONENTS collada_urdf rospack collada_parser resource_retriever pr2_description)
else()
find_package(catkin REQUIRED COMPONENTS collada_urdf rospack collada_parser urdfdom resource_retriever pr2_description)
endif()

catkin_package()

Expand Down Expand Up @@ -55,3 +50,44 @@ install(DIRECTORY src scripts
file(GLOB _install_files RELATIVE ${PROJECT_SOURCE_DIR} *.yaml *.sh)
install(FILES ${_install_files}
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})


if(CATKIN_ENABLE_TESTING)
# --------------
# Generate pr2.l
# --------------
if(EXISTS ${pr2_description_PREFIX}/share/pr2_description/robots/pr2.urdf.xacro)
set(pr2_xacro ${pr2_description_PREFIX}/share/pr2_description/robots/pr2.urdf.xacro)
elseif(EXISTS ${pr2_mechanism_model_SOURCE_PREFIX}/robots/pr2.urdf)
set(pr2_xacro ${pr2_description_SOURCE_PREFIX}/robots/pr2.urdf.xacro)
else()
message(FATAL "Could not find pr2.urdf.xacro at either ${pr2_description_PREFIX}/share/pr2_description/robots/pr2.urdf.xacro or ${pr2_description_SOURCE_PREFIX}/robots/pr2.urdf.xacro.")
endif()
if (EXISTS ${pr2_xacro})
message(STATUS "Found pr2.urdf.xacro at ${pr2_xacro}")
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/pr2.urdf
COMMAND rosrun xacro xacro ${pr2_xacro} > pr2.urdf
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS ${pr2_xacro})
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/pr2.dae
COMMAND rosrun collada_urdf urdf_to_collada pr2.urdf pr2.dae
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS pr2.urdf)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/pr2.l
COMMAND ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION}/collada2eus pr2.dae pr2.yaml pr2.l
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS collada2eus pr2.dae pr2.yaml)
# get collada-dom version
find_package(PkgConfig)
pkg_check_modules(COLLADA collada-dom>=2.4.4 )
if (${COLLADA_FOUND})
add_custom_target(generate_pr2_eusmodel ALL DEPENDS ${PROJECT_SOURCE_DIR}/pr2.l)
else()
pkg_check_modules(COLLADA collada-dom)
message(WARNING "urdf_to_collada requries collada-dom >= 2.4.4, installed version is ${COLLADA_VERSION}")
endif()
endif()

find_package(rostest REQUIRED)
add_rostest(test/euscollada-test.launch DEPENDENCIES generate_pr2_eusmodel)
endif()
9 changes: 5 additions & 4 deletions euscollada/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
<build_depend>liburdfdom-dev</build_depend> <!-- for indigo -->
<build_depend>libqhull</build_depend>
<build_depend>cmake_modules</build_depend>
<build_depend>pr2_description</build_depend>
<build_depend>rosbuild</build_depend>
<build_depend>rosboost_cfg</build_depend>
<build_depend>tf</build_depend>
<build_depend>mk</build_depend>
<build_depend>collada_urdf</build_depend>
<build_depend>xacro</build_depend>

<run_depend>roscpp</run_depend>
<run_depend>rospack</run_depend>
Expand All @@ -48,10 +50,9 @@
<run_depend>tf</run_depend>
<run_depend>collada_urdf</run_depend>

<!-- <test_depend>collada_urdf</test_depend> -->
<!-- <test_depend>euslisp</test_depend> -->
<!-- <test_depend>roseus</test_depend> -->
<!-- <test_depend>jsk_tools</test_depend> -->
<test_depend>euslisp</test_depend>
<test_depend>roseus</test_depend>
<test_depend>rostest</test_depend>

<export>
<rosdoc config="rosdoc.yaml"/>
Expand Down
22 changes: 15 additions & 7 deletions euscollada/test/euscollada-pr2-test.l
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,25 @@
;; (send-all (send *pr2* :links) :draw-on :flush t))
;; )

(deftest pr2-weight-test
(if (not (boundp '*pr2*)) (pr2))
(let* ((strm (piped-fork "echo $(grep \"<mass\" `rospack find pr2_mechanism_model`/pr2.urdf | cut -d\\\" -f2)"))
(urdf-weight (reduce #'+ (read-from-string (format nil "(~A )" (read-line strm nil nil)))))
(euslisp-weight (* 1e-3 (send *pr2* :weight)))) ;; [g] -> [kg]
(close strm)
(assert (eps= urdf-weight euslisp-weight) (format nil "check weight urdf:~A euslisp:~A" urdf-weight euslisp-weight))))
; (deftest pr2-weight-test
; (if (not (boundp '*pr2*)) (pr2))
; (let* ((strm (piped-fork "echo $(grep \"<mass\" `rospack find pr2_mechanism_model`/pr2.urdf | cut -d\\\" -f2)"))
; (urdf-weight (reduce #'+ (read-from-string (format nil "(~A )" (read-line strm nil nil)))))
; (euslisp-weight (* 1e-3 (send *pr2* :weight)))) ;; [g] -> [kg]
; (close strm)
; (assert (eps= urdf-weight euslisp-weight) (format nil "check weight urdf:~A euslisp:~A" urdf-weight euslisp-weight))))

(load "irteus/irtmodel.l")
(deftest pr2-eusmodel-validity-check
(if (not (boundp '*pr2*)) (pr2))
(eusmodel-validity-check-one *pr2*))

(deftest pr2-predefined-pose-test
(if (not (boundp '*pr2*)) (pr2))
(send *pr2* :reset-pose)
(send *pr2* :reset-pose :larm)
(send *pr2* :reset-pose :rarm)
)

(run-all-tests)
(exit)