-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscriber.py
46 lines (35 loc) · 1.15 KB
/
subscriber.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import rclpy
from rclpy.node import Node
from std_msgs.msg import *
import rclpy
from rclpy.node import Node
import numpy as np
from geometry_msgs.msg import TransformStamped
class MinimalSubscriber(Node):
quat = np.array([0,0,0,0])
trans = np.array([0,0,0])
def __init__(self):
super().__init__('minimal_subscriber')
self.subscription = self.create_subscription(
TransformStamped,
'/vicon/px4_1/px4_1',
self.listener_callback,
10)
#self.subscription # prevent unused variable warning
def listener_callback(self, msg):
quat = msg.transform.rotation
trans = msg.transform.translation
print(quat)
print(trans)
#self.get_logger().info('I heard: "%s"' % msg.data)
def main(args=None):
rclpy.init(args=args)
minimal_subscriber = MinimalSubscriber()
rclpy.spin(minimal_subscriber)
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
minimal_subscriber.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()