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

add test to check float/double serialization/deserialization #722

Open
wants to merge 1 commit 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
4 changes: 3 additions & 1 deletion roseus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions roseus/srv/AddTwoDoubles.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
float64 a
float64 b
---
float64 sum
4 changes: 4 additions & 0 deletions roseus/srv/AddTwoFloats.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
float32 a
float32 b
---
float32 sum
20 changes: 20 additions & 0 deletions roseus/test/add-two-doubles-server.l
Original file line number Diff line number Diff line change
@@ -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))
20 changes: 20 additions & 0 deletions roseus/test/add-two-floats-server.l
Original file line number Diff line number Diff line change
@@ -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))
33 changes: 33 additions & 0 deletions roseus/test/test-add-two-doubles.l
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions roseus/test/test-add-two-doubles.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<launch>
<node name="a2i_server" pkg="roseus" type="roseus" args="$(find roseus)/test/add-two-doubles-server.l" />
<test test-name="add_two_doubles" pkg="roseus" type="roseus" args="$(find roseus)/test/test-add-two-doubles.l"
time-limit="120" />
</launch>
33 changes: 33 additions & 0 deletions roseus/test/test-add-two-floats.l
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions roseus/test/test-add-two-floats.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<launch>
<node name="a2i_server" pkg="roseus" type="roseus" args="$(find roseus)/test/add-two-floats-server.l" />
<test test-name="add_two_floats" pkg="roseus" type="roseus" args="$(find roseus)/test/test-add-two-floats.l"
time-limit="120" />
</launch>