bounding_box_sample.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 
4 import rospy
5 
6 from jsk_recognition_msgs.msg import BoundingBoxArray, BoundingBox
7 from tf.transformations import *
8 rospy.init_node("bbox_sample")
9 pub = rospy.Publisher("bbox", BoundingBoxArray)
10 r = rospy.Rate(24)
11 counter = 0
12 while not rospy.is_shutdown():
13  box_a = BoundingBox()
14  box_b = BoundingBox()
15  box_c = BoundingBox()
16  box_a.label = 2
17  box_b.label = 5
18  box_b.label = 10
19  box_arr = BoundingBoxArray()
20  now = rospy.Time.now()
21  box_a.header.stamp = now
22  box_b.header.stamp = now
23  box_c.header.stamp = now
24  box_arr.header.stamp = now
25  box_a.header.frame_id = "map"
26  box_b.header.frame_id = "map"
27  box_c.header.frame_id = "map"
28  box_arr.header.frame_id = "map"
29  q = quaternion_about_axis((counter % 100) * math.pi * 2 / 100.0, [0, 0, 1])
30  box_a.pose.orientation.x = q[0]
31  box_a.pose.orientation.y = q[1]
32  box_a.pose.orientation.z = q[2]
33  box_a.pose.orientation.w = q[3]
34  box_b.pose.orientation.w = 1
35  box_b.pose.position.y = 2
36  box_c.pose.position.y = 1
37  box_c.pose.position.z = -0.52
38  box_b.dimensions.x = (counter % 10 + 1) * 0.1
39  box_b.dimensions.y = ((counter + 1) % 10 + 1) * 0.1
40  box_b.dimensions.z = ((counter + 2) % 10 + 1) * 0.1
41  box_a.dimensions.x = 1
42  box_a.dimensions.y = 1
43  box_a.dimensions.z = 1
44  box_c.dimensions.x = 3
45  box_c.dimensions.y = 3
46  box_c.dimensions.z = 0.02
47  box_a.value = (counter % 100) / 100.0
48  box_b.value = 1 - (counter % 100) / 100.0
49  box_c.value = (counter % 300) / 100.0
50  box_arr.boxes.append(box_a)
51  box_arr.boxes.append(box_b)
52  box_arr.boxes.append(box_c)
53  pub.publish(box_arr)
54  r.sleep()
55  counter = counter + 1
56 
transformations
msg


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Dec 13 2024 03:49:56