odom_rot.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 This script broadcasts a tf frame called odom_rot that spins about the z axis
4 at a slow rate but also allows its yaw to be set at the command line.
5 The yaw is listed on the command line in radians.
6 """
7 # Copyright (c) 2016, Fetch Robotics Inc.
8 # Author: Griswald Brooks
9 
10 import rospy
11 import tf
12 import threading
13 
14 class OdomTransform(object):
15  def __init__(self):
16  self.x = 1
17  self.y = 0
18  self.z = 0
19  self.roll = 0
20  self.pitch = 0
21  self.yaw = 0
22 
23 def updateTransform(odom_transform):
24  while not rospy.is_shutdown():
25  new_yaw = raw_input("Enter new yaw[" + str(odom_transform.yaw) + "]: ")
26 
27  try:
28  odom_transform.yaw = float(new_yaw)
29  except ValueError:
30  pass
31 
32 def main():
33 
34  # Create a node.
35  rospy.init_node("odom_rot")
36 
37  # Create transform object
38  odom_rot = OdomTransform()
39 
40  # Launch keyboard thread.
41  kb_th = threading.Thread(target=updateTransform, args=(odom_rot,))
42  kb_th.daemon = True
43  kb_th.start()
44 
45  # Setup broadcast rate.
46  r = rospy.Rate(100)
47 
48  # Broadcast odom_rot
50  while not rospy.is_shutdown():
51  br.sendTransform((odom_rot.x, odom_rot.y, odom_rot.z),
52  tf.transformations.quaternion_from_euler(odom_rot.roll, odom_rot.pitch, odom_rot.yaw),
53  rospy.Time.now(),
54  "odom_rot",
55  "odom")
56  # Increment yaw
57  odom_rot.yaw += 0.0001
58 
59  r.sleep()
60 
61 if __name__ == "__main__":
62 
63  main()
def __init__(self)
Definition: odom_rot.py:15
def updateTransform(odom_transform)
Definition: odom_rot.py:23
def main()
Definition: odom_rot.py:32


fetch_open_auto_dock
Author(s): Michael Ferguson, Griswald Brooks
autogenerated on Mon Feb 28 2022 22:21:37