This repository has been archived by the owner on Dec 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new version of python subscriber
- Loading branch information
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
mara_minimal_subscriber/scripts/mara_minimal_subscriber_v2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/python3 | ||
|
||
import rclpy | ||
from rclpy.node import Node | ||
from rclpy.qos import qos_profile_sensor_data | ||
from hrim_actuator_rotaryservo_msgs.msg import StateRotaryServo | ||
|
||
class MinimalSubscriber(Node): | ||
|
||
def __init__(self): | ||
# Initialize Node with name "mara_minimal_subscriber" | ||
super().__init__('mara_minimal_subscriber') | ||
|
||
# Subscribe to topic "/hrim_actuation_servomotor_000000000001/state_axis1" and link it to "minimal_callback" function | ||
self.create_subscription(StateRotaryServo, '/hrim_actuation_servomotor_000000000001/state_axis1', | ||
self.minimal_callback, | ||
qos_profile=qos_profile_sensor_data) # QoS profile for reading (joint) sensors | ||
|
||
|
||
def minimal_callback(self, msg): | ||
''' | ||
Function that will be called once a message is published to the topic we are subscribed | ||
''' | ||
self.get_logger().info('Position: {}'.format(msg.position)) | ||
|
||
|
||
def main(args=None): | ||
rclpy.init(args=args) | ||
|
||
node = MinimalSubscriber() | ||
rclpy.spin(node) | ||
|
||
node.destroy_node() | ||
rclpy.shutdown() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |