static.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 import argparse
4 
5 from people_msgs.msg import People, Person
6 
7 import rospy
8 
9 
10 class VelocityTracker(object):
11  def __init__(self, x, y, vx, vy):
12  self.ppub = rospy.Publisher('/people', People, queue_size=10)
13  self.person = Person()
14  self.person.position.x = x
15  self.person.position.y = y
16  self.person.position.z = 0.5
17  self.person.velocity.x = vx
18  self.person.velocity.y = vy
19  self.person.name = 'static_test_person'
20  self.person.reliability = 0.90
21 
22  def spin(self):
23  rate = rospy.Rate(10)
24  while not rospy.is_shutdown():
25  pl = People()
26  pl.header.stamp = rospy.Time.now()
27  pl.header.frame_id = '/base_link'
28  pl.people.append(self.person)
29  self.ppub.publish(pl)
30  rate.sleep()
31 
32 
33 if __name__ == '__main__':
34  rospy.init_node('people_velocity_tracker')
35  parser = argparse.ArgumentParser()
36  parser.add_argument('x', type=float, help='x coordinate')
37  parser.add_argument('y', type=float, help='y coordinate')
38  parser.add_argument('vx', type=float, nargs='?', default=0.0, help='x velocity')
39  parser.add_argument('vy', type=float, nargs='?', default=0.0, help='y velocity')
40  args = parser.parse_args()
41 
42  vt = VelocityTracker(args.x, args.y, args.vx, args.vy)
43  vt.spin()
def spin(self)
Definition: static.py:22
def __init__(self, x, y, vx, vy)
Definition: static.py:11


people_velocity_tracker
Author(s): David V. Lu!!
autogenerated on Sun Feb 21 2021 03:56:52