Last active
September 2, 2021 09:34
-
-
Save sk413025/7166cd699f9cb95cc89084d625c570f7 to your computer and use it in GitHub Desktop.
example of basic rclpy
This file contains hidden or 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
| import rclpy | |
| import time | |
| import numpy as np | |
| from rclpy.node import Node | |
| from std_msgs.msg import Float32 | |
| def main(): | |
| rclpy.init() | |
| node = Node('my_node') | |
| rv_publisher = node.create_publisher(Float32, 'my_rv', 1) | |
| msg_rv = Float32() | |
| while(True): | |
| val = np.random.normal(1) | |
| print("Checking: ", type(val)) | |
| msg_rv.data = val | |
| rv_publisher.publish(msg_rv) | |
| time.sleep(0.1) | |
| node.destroy_node() | |
| rclpy.shutdown() | |
| if __name__ == '__main__': | |
| main() |
Author
sk413025
commented
Sep 2, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment