sample_boundingbox_occlusion_rejector.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import rospy
4 from jsk_recognition_msgs.msg import BoundingBox, BoundingBoxArray
5 from sensor_msgs.msg import CameraInfo
6 from geometry_msgs.msg import PoseStamped
7 
8 candidate_pose = None
9 
11  global candidate_pose
12  candidate_pose = msg.pose
13 
14 def callback(msg):
15  if not candidate_pose:
16  return
17  target_array = BoundingBoxArray()
18  target_array.header.stamp = msg.header.stamp
19  target_array.header.frame_id = "world"
20  target = BoundingBox()
21  target.header.stamp = msg.header.stamp
22  target.header.frame_id = "world"
23  target.pose = candidate_pose
24  target.dimensions.x = 0.2
25  target.dimensions.y = 0.2
26  target.dimensions.z = 0.2
27  target_array.boxes = [target]
28  pub_target.publish(target_array)
29  candidate_array = BoundingBoxArray()
30  candidate_array.header.stamp = msg.header.stamp
31  candidate_array.header.frame_id = "world"
32  for x in [-0.2, -0.1, 0.0, 0.1, 0.2]:
33  for y in [-0.2, -0.1, 0.0, 0.1, 0.2]:
34  for z in [-0.2, -0.1, 0.0, 0.1, 0.2]:
35  candidate = BoundingBox()
36  candidate.header.stamp = msg.header.stamp
37  candidate.header.frame_id = "world"
38  candidate.pose.position.z = 2 + z
39  candidate.pose.position.x = x
40  candidate.pose.position.y = y
41  candidate.pose.orientation.w = 1.0
42  candidate.dimensions.x = 0.1
43  candidate.dimensions.y = 0.1
44  candidate.dimensions.z = 0.1
45  candidate_array.boxes.append(candidate)
46  pub_candidate.publish(candidate_array)
47 
48 
49 if __name__ == "__main__":
50  rospy.init_node("sample_boundingbox_occlusion_rejector")
51  pub_target = rospy.Publisher("~output/target_boxes", BoundingBoxArray)
52  pub_candidate = rospy.Publisher("~output/candidate_boxes", BoundingBoxArray)
53  sub = rospy.Subscriber("~input", CameraInfo, callback)
54  sub2 = rospy.Subscriber("~input/candidate_pose", PoseStamped, candidatePoseCallback)
55  rospy.spin()


jsk_pcl_ros
Author(s): Yohei Kakiuchi
autogenerated on Mon May 3 2021 03:03:47