From 4e9c55a370911ec69f3cf7459777920e0352d177 Mon Sep 17 00:00:00 2001 From: Shumpei Wakabayashi Date: Thu, 13 Jan 2022 23:36:25 +0900 Subject: [PATCH 1/2] add tf bbox sample --- .../src/display-tf-bounding-box-array.l | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 roseus_tutorials/src/display-tf-bounding-box-array.l diff --git a/roseus_tutorials/src/display-tf-bounding-box-array.l b/roseus_tutorials/src/display-tf-bounding-box-array.l new file mode 100755 index 000000000..6073d01fc --- /dev/null +++ b/roseus_tutorials/src/display-tf-bounding-box-array.l @@ -0,0 +1,42 @@ +#!/usr/bin/env roseus + +(ros::load-ros-manifest "jsk_recognition_msgs") +(defvar *base-frame-id* "/base_footprint") +(defvar *camera-frame-id* "/head_mount_kinect_rgb_optical_frame") + +(defun bounding-box-array-cb (msg) + (let ((bounding-box-list (send msg :boxes))) + (when bounding-box-list + (send *irtviewer* :draw-objects :flush nil) + (mapcar + #'(lambda (b) + (let* ((dims (ros::tf-point->pos (send b :dimensions))) + (bx (make-cube (elt dims 0) (elt dims 1) (elt dims 2))) + ;; Convert geoometry_msgs::Pose of BoundingBox to euslisp coordinates [mm] + (cam->obj-coords (ros::tf-pose->coords (send b :pose))) + ;; Get camera coordinates [mm] + (cam-coords (send *tfl* :lookup-transform + *base-frame-id* (send msg :header :frame_id) + (ros::time 0)))) + ;; Get BoundingBox world coordinates [mm] + (send bx :transform + (send (send cam-coords :copy-worldcoords) + :transform cam->obj-coords)) + (send bx :draw-on :flush nil :color #f(1 0 0)) + bx)) + bounding-box-list) + (send *irtviewer* :viewer :viewsurface :flush) + ))) + +(ros::roseus "bounding_box_array_subscriber") +(setq *tfl* (instance ros::transform-listener :init)) +(unless (boundp '*irtviewer*) (make-irtviewer)) + +(ros::subscribe "~input_box" jsk_recognition_msgs::BoundingBoxArray + #'bounding-box-array-cb 1) +(do-until-key + (x::window-main-one) + (ros::spin-once) + (ros::sleep) + ) + From 01d722f545e8313fcd83eb4e6ae669d2110b234d Mon Sep 17 00:00:00 2001 From: Shumpei Wakabayashi Date: Sat, 15 Jan 2022 23:14:55 +0900 Subject: [PATCH 2/2] add pr2 tf bbox sample --- roseus_tutorials/CMakeLists.txt | 2 +- roseus_tutorials/sample/euslisp/pr2-setting.l | 8 + .../sample/rviz/hsi_color_filter.rviz | 160 ++++++++++++++++++ .../sample/sample_hsi_color_filter.launch | 36 ++++ .../src/display-tf-bounding-box-array.l | 26 +-- 5 files changed, 221 insertions(+), 11 deletions(-) create mode 100755 roseus_tutorials/sample/euslisp/pr2-setting.l create mode 100644 roseus_tutorials/sample/rviz/hsi_color_filter.rviz create mode 100644 roseus_tutorials/sample/sample_hsi_color_filter.launch diff --git a/roseus_tutorials/CMakeLists.txt b/roseus_tutorials/CMakeLists.txt index b09d7b5a6..8a4b04b3a 100644 --- a/roseus_tutorials/CMakeLists.txt +++ b/roseus_tutorials/CMakeLists.txt @@ -12,7 +12,7 @@ catkin_package( # LIBRARIES # TODO ) -install(DIRECTORY launch src img config +install(DIRECTORY launch src sample img config DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS) diff --git a/roseus_tutorials/sample/euslisp/pr2-setting.l b/roseus_tutorials/sample/euslisp/pr2-setting.l new file mode 100755 index 000000000..d346f36e8 --- /dev/null +++ b/roseus_tutorials/sample/euslisp/pr2-setting.l @@ -0,0 +1,8 @@ +#!/usr/bin/env roseus +(require :pr2-interface "package://pr2eus/pr2-interface.l") +(setq *input-bbox-array* (ros::get-param "~/input_bbox_array" "/HSI_color_filter/boxes")) +(setq *base-frame-id* (ros::get-param "~base_frame_id" "/base_footprint")) +(setq *camera-frame-id* (ros::get-param "~camera_frame_id" ":head_mount_kinect_rgb_optical_frame_lk")) +(pr2-init) +(setq *robot* *pr2*) +(load "package://roseus_tutorials/src/display-tf-bounding-box-array.l") diff --git a/roseus_tutorials/sample/rviz/hsi_color_filter.rviz b/roseus_tutorials/sample/rviz/hsi_color_filter.rviz new file mode 100644 index 000000000..04da9377f --- /dev/null +++ b/roseus_tutorials/sample/rviz/hsi_color_filter.rviz @@ -0,0 +1,160 @@ +Panels: + - Class: rviz/Displays + Help Height: 78 + Name: Displays + Property Tree Widget: + Expanded: + - /Global Options1 + - /Status1 + Splitter Ratio: 0.5 + Tree Height: 728 + - Class: rviz/Selection + Name: Selection + - Class: rviz/Tool Properties + Expanded: + - /2D Pose Estimate1 + - /2D Nav Goal1 + - /Publish Point1 + Name: Tool Properties + Splitter Ratio: 0.5886790156364441 + - Class: rviz/Views + Expanded: + - /Current View1 + Name: Views + Splitter Ratio: 0.5 + - Class: rviz/Time + Experimental: false + Name: Time + SyncMode: 0 + SyncSource: PointCloud2 +Preferences: + PromptSaveOnExit: true +Toolbars: + toolButtonStyle: 2 +Visualization Manager: + Class: "" + Displays: + - Alpha: 0.5 + Cell Size: 1 + Class: rviz/Grid + Color: 160; 160; 164 + Enabled: true + Line Style: + Line Width: 0.029999999329447746 + Value: Lines + Name: Grid + Normal Cell Count: 0 + Offset: + X: 0 + Y: 0 + Z: 0 + Plane: XY + Plane Cell Count: 10 + Reference Frame: + Value: true + - Alpha: 1 + Autocompute Intensity Bounds: true + Autocompute Value Bounds: + Max Value: 10 + Min Value: -10 + Value: true + Axis: Z + Channel Name: intensity + Class: rviz/PointCloud2 + Color: 255; 255; 255 + Color Transformer: RGB8 + Decay Time: 0 + Enabled: true + Invert Rainbow: false + Max Color: 255; 255; 255 + Min Color: 0; 0; 0 + Name: PointCloud2 + Position Transformer: XYZ + Queue Size: 10 + Selectable: true + Size (Pixels): 3 + Size (m): 0.009999999776482582 + Style: Flat Squares + Topic: /kinect_head/depth_registered/points + Unreliable: false + Use Fixed Frame: true + Use rainbow: true + Value: true + - Class: jsk_rviz_plugin/BoundingBoxArray + Enabled: true + Name: BoundingBoxArray + Topic: /HSI_color_filter/boxes + Unreliable: false + Value: true + alpha: 0.800000011920929 + color: 25; 255; 0 + coloring: Auto + line width: 0.004999999888241291 + only edge: false + show coords: false + Enabled: true + Global Options: + Background Color: 48; 48; 48 + Default Light: true + Fixed Frame: base_footprint + Frame Rate: 30 + Name: root + Tools: + - Class: rviz/Interact + Hide Inactive Objects: true + - Class: rviz/MoveCamera + - Class: rviz/Select + - Class: rviz/FocusCamera + - Class: rviz/Measure + - Class: rviz/SetInitialPose + Theta std deviation: 0.2617993950843811 + Topic: /initialpose + X std deviation: 0.5 + Y std deviation: 0.5 + - Class: rviz/SetGoal + Topic: /move_base_simple/goal + - Class: rviz/PublishPoint + Single click: true + Topic: /clicked_point + Value: true + Views: + Current: + Class: rviz/Orbit + Distance: 1.8979061841964722 + Enable Stereo Rendering: + Stereo Eye Separation: 0.05999999865889549 + Stereo Focal Distance: 1 + Swap Stereo Eyes: false + Value: false + Focal Point: + X: 0.4162523150444031 + Y: 0.027002409100532532 + Z: 0.7402926087379456 + Focal Shape Fixed Size: true + Focal Shape Size: 0.05000000074505806 + Invert Z Axis: false + Name: Current View + Near Clip Distance: 0.009999999776482582 + Pitch: 0.4403988718986511 + Target Frame: + Value: Orbit (rviz) + Yaw: 3.178584575653076 + Saved: ~ +Window Geometry: + Displays: + collapsed: false + Height: 1025 + Hide Left Dock: false + Hide Right Dock: false + QMainWindow State: 000000ff00000000fd00000004000000000000015600000363fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000005c00fffffffb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000003d00000363000000c900fffffffb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000010f00000363fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fb0000000a00560069006500770073010000003d00000363000000a400fffffffb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000490000000a9fc0100000001fb0000000a00560069006500770073030000004e00000080000002e100000197000000030000073d0000003efc0100000002fb0000000800540069006d006501000000000000073d000002eb00fffffffb0000000800540069006d00650100000000000004500000000000000000000004cc0000036300000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + Selection: + collapsed: false + Time: + collapsed: false + Tool Properties: + collapsed: false + Views: + collapsed: false + Width: 1853 + X: 67 + Y: 27 diff --git a/roseus_tutorials/sample/sample_hsi_color_filter.launch b/roseus_tutorials/sample/sample_hsi_color_filter.launch new file mode 100644 index 000000000..085d1d42d --- /dev/null +++ b/roseus_tutorials/sample/sample_hsi_color_filter.launch @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + base_frame_id: $(arg base_frame_id) + input_bbox_array: $(arg input_bbox_array) + camera_frame_id: $(arg camera_frame_id) + + + + + + + diff --git a/roseus_tutorials/src/display-tf-bounding-box-array.l b/roseus_tutorials/src/display-tf-bounding-box-array.l index 6073d01fc..eb94cbde6 100755 --- a/roseus_tutorials/src/display-tf-bounding-box-array.l +++ b/roseus_tutorials/src/display-tf-bounding-box-array.l @@ -1,13 +1,19 @@ #!/usr/bin/env roseus (ros::load-ros-manifest "jsk_recognition_msgs") -(defvar *base-frame-id* "/base_footprint") -(defvar *camera-frame-id* "/head_mount_kinect_rgb_optical_frame") + +(setq *input-bbox-array* (ros::get-param "~/input_bbox_array" "/HSI_color_filter/boxes")) +(setq *base-frame-id* (ros::get-param "~base_frame_id" "/base_footprint")) +(setq *camera-frame-id* (ros::get-param "~camera_frame_id" ":head_mount_kinect_rgb_optical_frame_lk")) +;;(setq *robot* (ros::get-param "~robot" *pr2*)) (defun bounding-box-array-cb (msg) + (unless (send msg :boxes) + (return-from bounding-box-array-cb)) (let ((bounding-box-list (send msg :boxes))) (when bounding-box-list - (send *irtviewer* :draw-objects :flush nil) + (send *robot* :angle-vector (send *ri* :potentio-vector)) + (send *tfl* :wait-for-transform *base-frame-id* (send msg :header :frame_id) (ros::time 0) 10) (mapcar #'(lambda (b) (let* ((dims (ros::tf-point->pos (send b :dimensions))) @@ -15,24 +21,24 @@ ;; Convert geoometry_msgs::Pose of BoundingBox to euslisp coordinates [mm] (cam->obj-coords (ros::tf-pose->coords (send b :pose))) ;; Get camera coordinates [mm] - (cam-coords (send *tfl* :lookup-transform - *base-frame-id* (send msg :header :frame_id) + (base->cam-coords (send *tfl* :lookup-transform + *base-frame-id* (send b :header :frame_id) (ros::time 0)))) + ;;(base->cam-coords (send (send *robot* *camera-frame-id*) :copy-worldcoords))) ;; Get BoundingBox world coordinates [mm] (send bx :transform - (send (send cam-coords :copy-worldcoords) + (send (send base->cam-coords :copy-worldcoords) :transform cam->obj-coords)) - (send bx :draw-on :flush nil :color #f(1 0 0)) + (objects (list bx base->cam-coords *robot*)) bx)) bounding-box-list) - (send *irtviewer* :viewer :viewsurface :flush) ))) -(ros::roseus "bounding_box_array_subscriber") +(ros::roseus "display-tf-bounding-box") (setq *tfl* (instance ros::transform-listener :init)) (unless (boundp '*irtviewer*) (make-irtviewer)) -(ros::subscribe "~input_box" jsk_recognition_msgs::BoundingBoxArray +(ros::subscribe *input-bbox-array* jsk_recognition_msgs::BoundingBoxArray #'bounding-box-array-cb 1) (do-until-key (x::window-main-one)