Skip to content

Commit

Permalink
save image in euslisp, not use image_saver
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 committed Oct 18, 2019
1 parent 52158b5 commit 1368408
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions jsk_robot_common/jsk_robot_startup/lifelog/tweet.launch
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
<remap from="mux" to="tweet_image_mux" />
<param name="lazy" value="true" />
</node>
<!--
<node name="tweet_image_saver" pkg="image_view" type="image_saver"
machine="$(arg machine)">
<remap from="image" to="/tweet_image" />
<param name="save_all_image" value="false" />
<param name="filename_format" value="/tmp/tweet_image.jpg" />
<param name="image_transport" value="raw" />
</node>
-->
<node name="active_user" pkg="roseus"
type="roseus" args="$(find jsk_robot_startup)/lifelog/active_user.l"
machine="$(arg machine)"
Expand Down
26 changes: 13 additions & 13 deletions jsk_robot_common/jsk_robot_startup/lifelog/tweet_client.l
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
(setq *waking-target-second* *waking-tweet-second*)))

(defun tweet-string (twit-str &key (warning-time) (with-image) (image-wait 30) (speak t))
(let (prev-image-topic (save-wait 0))
(let (prev-image-topic img)
(when warning-time
(unless (numberp warning-time)
(setq warning-time 3))
Expand Down Expand Up @@ -73,18 +73,18 @@
(setq prev-image-topic (send (one-shot-subscribe "/tweet_image_mux/selected" std_msgs::String) :data)))

;; retrieve image
(call-empty-service "/tweet_image_saver/save" :wait t)
(ros::service-call "/tweet_image_mux/select" (instance topic_tools::muxselectrequest :init :topic prev-image-topic))

(ros::ros-info "tweeting ~A" twit-str)
;; waiting for 10 seconds for image saver
(while (and (not (probe-file "/tmp/tweet_image.jpg")) (< save-wait 10))
(incf save-wait 1)
(unix:sleep 1))
(ros::publish "/tweet"
(instance std_msgs::String :init
:data (format nil "~A ~A"
twit-str (format nil "/tmp/tweet_image.jpg")))))
;; (call-empty-service "/tweet_image_saver/save" :wait t)
(setq img (one-shot-subscribe "/tweet_image" sensor_msgs::Image :timeout 1000))
(if img
(progn
(write-image-file "/tmp/tweet_image.jpg" (ros::sensor_msgs/Image->image img))
(ros::ros-info "tweeting ~A" twit-str)
(ros::publish "/tweet"
(instance std_msgs::String :init
:data (format nil "~A ~A"
twit-str (format nil "/tmp/tweet_image.jpg")))))
(ros::ros-error "fail saving image and tweeting"))
(ros::service-call "/tweet_image_mux/select" (instance topic_tools::muxselectrequest :init :topic prev-image-topic)))
(t
(ros::publish "/tweet" (instance std_msgs::String :init :data twit-str))))
(when speak (speak-jp "ついーとしました" :wait t))))
Expand Down

0 comments on commit 1368408

Please sign in to comment.