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 #723

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
2 changes: 2 additions & 0 deletions roseus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ if(CATKIN_ENABLE_TESTING)
set_target_properties(simple_execute_ref_server PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/test)
add_rostest(test/test-talker-listener.test)
add_rostest(test/test-talker-listener-private-topic.test)
add_rostest(test/test-pub-sub-float.test)
add_rostest(test/test-pub-sub-double.test)
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)
Expand Down
20 changes: 20 additions & 0 deletions roseus/test/pub-double.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env roseus
;;;
;;;
(ros::load-ros-manifest "roseus")

(ros::roseus "pub_double")
(ros::advertise "double" std_msgs::float64 1)
(ros::rate 10)
(setq f 123456.654321)
(while (ros::ok)
(setq msg (instance std_msgs::float64 :init))
(send msg :data f)
(warning-message 3 "publish msg [~8,8f]~%" (send msg :data))
(ros::publish "double" msg)
(ros::sleep)
(setq f (* f 2))
)
(ros::roseus "shutdown")
(exit)

20 changes: 20 additions & 0 deletions roseus/test/pub-float.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env roseus
;;;
;;;
(ros::load-ros-manifest "roseus")

(ros::roseus "pub_float")
(ros::advertise "float" std_msgs::float32 1)
(ros::rate 10)
(setq f 123.321)
(while (ros::ok)
(setq msg (instance std_msgs::float32 :init))
(send msg :data f)
(warning-message 3 "publish msg [~8,8f]~%" (send msg :data))
(ros::publish "float" msg)
(ros::sleep)
(setq f (* f 2))
)
(ros::roseus "shutdown")
(exit)

4 changes: 4 additions & 0 deletions roseus/test/test-pub-sub-double.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<launch>
<node name="pub_double" pkg="roseus" type="roseus" args="$(find roseus)/test/pub-double.l" />
<test test-name="sub_double" pkg="roseus" type="roseus" args="$(find roseus)/test/test-sub-double.l" />
</launch>
4 changes: 4 additions & 0 deletions roseus/test/test-pub-sub-float.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<launch>
<node name="pub_float" pkg="roseus" type="roseus" args="$(find roseus)/test/pub-float.l" />
<test test-name="sub_float" pkg="roseus" type="roseus" args="$(find roseus)/test/test-sub-float.l" />
</launch>
41 changes: 41 additions & 0 deletions roseus/test/test-sub-double.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env roseus
;;;
;;;
(ros::load-ros-manifest "roseus")
(require :unittest "lib/llib/unittest.l")

(init-unit-test)


(ros::roseus "sub_double")
;; method call
(defclass double-cb-class
:super propertied-object
:slots (count prev-msg))
(defmethod double-cb-class
(:init
()
(setq count 0)
(setq prev-msg nil)
(ros::subscribe "double" std_msgs::float64 #'send self :double-cb))
(:double-cb
(msg)
(warning-message 2 "subscribe msg [~8,8f], ~A times bigger than previous data~%" (send msg :data) (if prev-msg (/ (send msg :data) (send prev-msg :data))))
(when prev-msg
(assert (eps= (/ (send msg :data) (send prev-msg :data)) 2.0))
)
(incf count)
(setq prev-msg msg)
)
(:count () count)
)

(deftest test-sub-double ()
(setq m (instance double-cb-class :init))

(while (< (send m :count) 10)
(ros::spin-once)
))

(run-all-tests)
(exit)
41 changes: 41 additions & 0 deletions roseus/test/test-sub-float.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env roseus
;;;
;;;
(ros::load-ros-manifest "roseus")
(require :unittest "lib/llib/unittest.l")

(init-unit-test)


(ros::roseus "sub_float")
;; method call
(defclass float-cb-class
:super propertied-object
:slots (count prev-msg))
(defmethod float-cb-class
(:init
()
(setq count 0)
(setq prev-msg nil)
(ros::subscribe "float" std_msgs::float32 #'send self :float-cb))
(:float-cb
(msg)
(warning-message 2 "subscribe msg [~8,8f], ~A times bigger than previous data~%" (send msg :data) (if prev-msg (/ (send msg :data) (send prev-msg :data))))
(when prev-msg
(assert (eps= (/ (send msg :data) (send prev-msg :data)) 2.0))
)
(incf count)
(setq prev-msg msg)
)
(:count () count)
)

(deftest test-sub-float ()
(setq m (instance float-cb-class :init))

(while (< (send m :count) 10)
(ros::spin-once)
))

(run-all-tests)
(exit)