7 from geometry_msgs.msg
import Point, Vector3
9 from kalman_filter
import Kalman
11 from people_msgs.msg
import People, Person, PositionMeasurementArray
17 return math.sqrt(math.pow(leg1.x - leg2.x, 2) +
18 math.pow(leg1.y - leg2.y, 2) +
19 math.pow(leg1.z - leg2.z, 2))
23 return Point((leg1.x + leg2.x) / 2,
24 (leg1.y + leg2.y) / 2,
25 (leg1.z + leg2.z) / 2)
29 return Vector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z)
33 return Vector3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z)
43 print(
'%.2f %.2f %.2f' % (v.x, v.y, v.z),)
47 gen.type = Marker.ARROW
63 ivel =
subtract(self.pos.pos, last.pos)
64 time = (self.pos.header.stamp - last.header.stamp).to_sec()
65 scale(ivel, 1.0 / time)
67 self.k.update([ivel.x, ivel.y, ivel.z])
70 return self.pos.header.stamp
73 return self.pos.object_id
79 v = Vector3(k[0], k[1], k[2])
83 gen.scale = [.1, .3, 0]
84 gen.color = [1, 1, 1, 1]
86 m = gen.marker(points=[self.pos.pos,
add(self.pos.pos, vel)])
87 m.header = self.pos.header
93 p.position = self.pos.pos
96 return self.pos.header.frame_id, p
102 self.
TIMEOUT = rospy.Duration(rospy.get_param(
'~timeout', 1.0))
103 self.
sub = rospy.Subscriber(
'/people_tracker_measurements',
104 PositionMeasurementArray,
106 self.
mpub = rospy.Publisher(
'/visualization_marker',
109 self.
ppub = rospy.Publisher(
'/people',
114 for pm
in msg.people:
115 if pm.object_id
in self.
people:
116 self.
people[pm.object_id].update(pm)
119 self.
people[pm.object_id] = p
122 rate = rospy.Rate(10)
123 while not rospy.is_shutdown():
125 now = rospy.Time.now()
126 for p
in self.people.values():
127 if now - p.age() > self.
TIMEOUT:
135 pl.header.frame_id =
None 137 for p
in self.people.values():
138 p.publish_markers(self.
mpub)
139 frame, person = p.get_person()
140 pl.header.frame_id = frame
141 pl.people.append(person)
143 self.ppub.publish(pl)
146 if __name__ ==
'__main__':
147 rospy.init_node(
'people_velocity_tracker')
def publish_markers(self, pub)