diff --git a/roseus/CMakeLists.txt b/roseus/CMakeLists.txt index e732689e3..12b752228 100644 --- a/roseus/CMakeLists.txt +++ b/roseus/CMakeLists.txt @@ -122,7 +122,7 @@ set_target_properties(eustf PROPERTIES PREFIX "" SUFFIX ".so") set_target_properties(roseus_c_util PROPERTIES PREFIX "" SUFFIX ".so") add_service_files( - FILES AddTwoInts.srv StringString.srv + FILES AddTwoInts.srv AddTwoFloats.srv AddTwoDoubles.srv StringString.srv ) add_message_files( FILES String.msg StringStamped.msg FixedArray.msg VariableArray.msg TestName.msg @@ -180,6 +180,8 @@ if(CATKIN_ENABLE_TESTING) add_rostest(test/test-add-two-ints.test) add_rostest(test/test-add-two-ints-server.test) add_rostest(test/test-add-two-ints-server-groupname.test) + add_rostest(test/test-add-two-floats.test) + add_rostest(test/test-add-two-doubles.test) add_rostest(test/test-service-callback.test) add_rostest(test/test-simple-client.test) add_rostest(test/test-simple-client-wait.test) diff --git a/roseus/srv/AddTwoDoubles.srv b/roseus/srv/AddTwoDoubles.srv new file mode 100644 index 000000000..5fcc8dca5 --- /dev/null +++ b/roseus/srv/AddTwoDoubles.srv @@ -0,0 +1,4 @@ +float64 a +float64 b +--- +float64 sum diff --git a/roseus/srv/AddTwoFloats.srv b/roseus/srv/AddTwoFloats.srv new file mode 100644 index 000000000..a9ecc19c6 --- /dev/null +++ b/roseus/srv/AddTwoFloats.srv @@ -0,0 +1,4 @@ +float32 a +float32 b +--- +float32 sum diff --git a/roseus/test/add-two-doubles-server.l b/roseus/test/add-two-doubles-server.l new file mode 100755 index 000000000..435268fcd --- /dev/null +++ b/roseus/test/add-two-doubles-server.l @@ -0,0 +1,20 @@ +#!/usr/bin/env roseus +;;; +;;; euslisp version of ros_tutorials/rospy_tutorials/005_add_two_ints +;;; +(ros::load-ros-manifest "roseus") + +;;; +(defun add-two-doubles (req) + (let ((m (send req :response))) + (ros::ros-info "Returning [~d + ~d = ~d]" + (send req :a) (send req :b) + (+ (send req :a) (send req :b))) + (send m :sum (+ (send req :a) (send req :b))) + m)) +;;; +;;; +(ros::roseus "add_two_doubles_server") +(ros::advertise-service "add_two_doubles" roseus::AddTwoDoubles #'add-two-doubles) +(do-until-key + (ros::spin-once)) diff --git a/roseus/test/add-two-floats-server.l b/roseus/test/add-two-floats-server.l new file mode 100755 index 000000000..16704fc2b --- /dev/null +++ b/roseus/test/add-two-floats-server.l @@ -0,0 +1,20 @@ +#!/usr/bin/env roseus +;;; +;;; euslisp version of ros_tutorials/rospy_tutorials/005_add_two_ints +;;; +(ros::load-ros-manifest "roseus") + +;;; +(defun add-two-floats (req) + (let ((m (send req :response))) + (ros::ros-info "Returning [~d + ~d = ~d]" + (send req :a) (send req :b) + (+ (send req :a) (send req :b))) + (send m :sum (+ (send req :a) (send req :b))) + m)) +;;; +;;; +(ros::roseus "add_two_floats_server") +(ros::advertise-service "add_two_floats" roseus::AddTwoFloats #'add-two-floats) +(do-until-key + (ros::spin-once)) diff --git a/roseus/test/test-add-two-doubles.l b/roseus/test/test-add-two-doubles.l new file mode 100755 index 000000000..b70b78c10 --- /dev/null +++ b/roseus/test/test-add-two-doubles.l @@ -0,0 +1,33 @@ +#!/usr/bin/env roseus +;;; +;;; euslisp version of ros_tutorials/rospy_tutorials/test_add_two_ints.py +;;; + +(setq sys::*gc-hook* #'(lambda (a b) (format t ";; gc ~A ~A~%" a b))) + +(require :unittest "lib/llib/unittest.l") +(ros::load-ros-manifest "roseus") +;;; +;;; +(init-unit-test) + +(deftest test-add-two-doubles + (ros::wait-for-service "add_two_doubles") + (dolist (test (list (cons 1.1 2.2) (cons 0.0 0.0) (cons -1.0 -2.0) + (cons 12312.12312 98023.98023))) + (print test) + (let ((a (car test)) (b (cdr test))) + (warning-message 2 "Requesting ~A(~A) + ~A(~A) -> ~A(~A)~%" a (class a) b (class b) (+ a b) (class (+ a b))) + (setq req (instance roseus::AddTwoDoublesRequest :init :a a :b b)) + (setq res (ros::service-call "add_two_doubles" req)) + (assert (eps= (+ (send req :a) (send req :b)) (send res :sum)) + (format nil "integration failure (~A+~A)=~A(~A)/=~A(~A)" + a b (+ a b) (class (+ a b)) (send res :sum) (class (send res :sum)))) + (sys::gc) + ))) + + +(ros::roseus "add_two_doubles_client") +(run-all-tests) + +(exit) diff --git a/roseus/test/test-add-two-doubles.test b/roseus/test/test-add-two-doubles.test new file mode 100644 index 000000000..b7351e6bd --- /dev/null +++ b/roseus/test/test-add-two-doubles.test @@ -0,0 +1,5 @@ + + + + diff --git a/roseus/test/test-add-two-floats.l b/roseus/test/test-add-two-floats.l new file mode 100755 index 000000000..07641490c --- /dev/null +++ b/roseus/test/test-add-two-floats.l @@ -0,0 +1,33 @@ +#!/usr/bin/env roseus +;;; +;;; euslisp version of ros_tutorials/rospy_tutorials/test_add_two_ints.py +;;; + +(setq sys::*gc-hook* #'(lambda (a b) (format t ";; gc ~A ~A~%" a b))) + +(require :unittest "lib/llib/unittest.l") +(ros::load-ros-manifest "roseus") +;;; +;;; +(init-unit-test) + +(deftest test-add-two-floats + (ros::wait-for-service "add_two_floats") + (dolist (test (list (cons 1.1 2.2) (cons 0.0 0.0) (cons -1.0 -2.0) + (cons 12312.12312 98023.98023))) + (print test) + (let ((a (car test)) (b (cdr test))) + (warning-message 2 "Requesting ~A(~A) + ~A(~A) -> ~A(~A)~%" a (class a) b (class b) (+ a b) (class (+ a b))) + (setq req (instance roseus::AddTwoFloatsRequest :init :a a :b b)) + (setq res (ros::service-call "add_two_floats" req)) + (assert (eps= (+ (send req :a) (send req :b)) (send res :sum)) + (format nil "integration failure (~A+~A)=~A(~A)/=~A(~A)" + a b (+ a b) (class (+ a b)) (send res :sum) (class (send res :sum)))) + (sys::gc) + ))) + + +(ros::roseus "add_two_floats_client") +(run-all-tests) + +(exit) diff --git a/roseus/test/test-add-two-floats.test b/roseus/test/test-add-two-floats.test new file mode 100644 index 000000000..5d6908e3a --- /dev/null +++ b/roseus/test/test-add-two-floats.test @@ -0,0 +1,5 @@ + + + +