From eab48ea5758a44fce219caf2d0ef1eccabb1bf27 Mon Sep 17 00:00:00 2001 From: Kei Okada Date: Tue, 26 Apr 2016 09:09:48 +0900 Subject: [PATCH 1/4] update jsk_travis to 0.4.5 --- .travis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis b/.travis index 4b6ba1f40..57b5e16fa 160000 --- a/.travis +++ b/.travis @@ -1 +1 @@ -Subproject commit 4b6ba1f40b50d7b3536a84c9b2b34cbc36f3e22f +Subproject commit 57b5e16fa32f14f65a4c2bee288523fdbcc17992 From e6d0f57e9a256b77373aa2eb9886c3aef39ddd18 Mon Sep 17 00:00:00 2001 From: Shunichi Nozawa Date: Tue, 26 Apr 2016 12:04:31 +0900 Subject: [PATCH 2/4] [pr2eus/robot-interface.l] Add robot-init function. Add documentation string for it. --- pr2eus/robot-interface.l | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/pr2eus/robot-interface.l b/pr2eus/robot-interface.l index 4628e3f37..02386a795 100644 --- a/pr2eus/robot-interface.l +++ b/pr2eus/robot-interface.l @@ -1683,4 +1683,45 @@ send-action [ send message to action server, it means robot will move ]" (ros::service-call (format nil "~A/~A/~A/set_parameters" node-name costmap-name inflation-name) req) )) +;; +;; robot-init +;; +(defun robot-init (&optional (robot-name (ros::get-param "/robot/type"))) + "Initialize robot-model and robot-interface instances respectively, such as *pr2* and *ri*. + Behavior: + 1. Without /robot/type and argument, or no interface file is found, robot instance and interface instance are not created and errors are invoked. + 2. If argument are specified and robot interface file is found, robot instance and interface with given name are created. + 3. If no argument is specified, /robot/type ROSPARAM is set, and robot interface file is found, robot instance and interface with given name are created. + Typical usage: + (robot-init) ;; With setting /robot/type ROSPARAM anywhere. + (robot-init (or (ros::get-param \"/robot/type\") \"pr2\")) ;; If /robot/type ROSPARAM is specified, use it. Otherwise, use \"pr2\" by default. + Configuring user-defined robot: + This function searches robot interface file from rospack plugins. + If user want to use their own robots from robot-init function, + please write export tag in [user_defined_rospackage]/package.xml as pr2eus/package.xml. + " + (let* (;; Check existence ros::rospack-plugins for robot-name-list and interface-file-list. + ;; For example, old deb environment before ros::rospack-plugins is committed. + (robot-name-list + (if (fboundp 'ros::rospack-plugins) + (mapcar #'cdr (ros::rospack-plugins "pr2eus" "robot-name")) + (piped-fork-returns-list "rospack plugins --attrib=robot-name pr2eus | cut -d\\ -f2"))) + (interface-file-list + (if (fboundp 'ros::rospack-plugins) + (mapcar #'cdr (ros::rospack-plugins "pr2eus" "interface-file")) + (piped-fork-returns-list "rospack plugins --attrib=interface-file pr2eus | cut -d\\ -f2"))) + (robot-name-interface-file-list + (assoc robot-name (mapcar #'(lambda (x y) (list x y)) + robot-name-list interface-file-list) + :test #'string=))) + (cond + ((or (not robot-name-interface-file-list) + (not (probe-file (cadr robot-name-interface-file-list)))) + (error ";; No such robot interface setting are defined ~A, or interface file found ~A!!~%" robot-name (cadr robot-name-interface-file-list)) + nil) + (t + (require (cadr robot-name-interface-file-list)) + (funcall (eval (read-from-string (format nil "#'~A-init" robot-name)))) + )))) + (provide :robot-interface "robot-interface.l") From d902a9cfac4c90a44cc86be29c5d9be36c41b6e3 Mon Sep 17 00:00:00 2001 From: Shunichi Nozawa Date: Tue, 26 Apr 2016 12:05:29 +0900 Subject: [PATCH 3/4] [package.xml] Add setting for robot-init to package.xml using export tag and rospack plugin functionality (http://wiki.ros.org/pluginlib). --- pr2eus/package.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pr2eus/package.xml b/pr2eus/package.xml index 407add00c..574b4fb46 100644 --- a/pr2eus/package.xml +++ b/pr2eus/package.xml @@ -35,5 +35,8 @@ dynamic_reconfigure sound_play + + + From 5c57e06d3211f3c356cdd09aa84d53366a1edd74 Mon Sep 17 00:00:00 2001 From: Shunichi Nozawa Date: Tue, 26 Apr 2016 12:06:47 +0900 Subject: [PATCH 4/4] [pr2eus/test/robot-init-test.*, pr2eus/CMakeLists.txt] Add robot-init function rostest. Add rostest execution for it in CMakeLists.txt. --- pr2eus/CMakeLists.txt | 1 + pr2eus/test/robot-init-test.l | 34 ++++++++++++++++++++++++++++++++ pr2eus/test/robot-init-test.test | 4 ++++ 3 files changed, 39 insertions(+) create mode 100644 pr2eus/test/robot-init-test.l create mode 100644 pr2eus/test/robot-init-test.test diff --git a/pr2eus/CMakeLists.txt b/pr2eus/CMakeLists.txt index 5a2f2c39b..ad4dd6588 100644 --- a/pr2eus/CMakeLists.txt +++ b/pr2eus/CMakeLists.txt @@ -36,6 +36,7 @@ if(CATKIN_ENABLE_TESTING) add_rostest(test/robot-no-clock.test) add_rostest(test/default-ri-test.test) add_rostest(test/speak-test.test) + add_rostest(test/robot-init-test.test) endif() generate_eusdoc(robot-interface.l) diff --git a/pr2eus/test/robot-init-test.l b/pr2eus/test/robot-init-test.l new file mode 100644 index 000000000..a08d42fb3 --- /dev/null +++ b/pr2eus/test/robot-init-test.l @@ -0,0 +1,34 @@ +#!/bin/env roseus + +;; robot-init test + +(require :unittest "lib/llib/unittest.l") + +(load "package://pr2eus/robot-interface.l") +(ros::roseus "test_robot_init") + +(init-unit-test) + +;;(deftest test-robot-init-without-param-and-argument () +;; (assert (not (robot-init)) "This should invoke error.")) + +(deftest test-robot-init-with-argument () + (assert (progn + (robot-init "pr2") + (and *ri* *pr2*)) + "This should return pr2 and ri.") + ) + +(deftest test-robot-init-without-argument-with-param () + (makunbound '*ri*) + (makunbound '*pr2*) + (ros::set-param "/robot/type" "pr2") + (assert (progn + (robot-init) + (and *ri* *pr2*)) + "This should return pr2 and ri.") + ) + +(run-all-tests) +(exit) + diff --git a/pr2eus/test/robot-init-test.test b/pr2eus/test/robot-init-test.test new file mode 100644 index 000000000..4b46ef1eb --- /dev/null +++ b/pr2eus/test/robot-init-test.test @@ -0,0 +1,4 @@ + + +