Node template for Python and C++ nodes
All the nodes we start in this book will follow the same structure. As additional help to get started quickly, I have created a node template you can use to write the base of any Python or C++ node. I use these templates myself when creating new nodes, as the code can be quite repetitive.
You can copy and paste the templates either from this book directly, or download them from the GitHub repository: https://github.com/PacktPublishing/ROS-2-from-Scratch.
Template for a Python node
Use this code to start any new Python node:
#!/usr/bin/env python3 import rclpy from rclpy.node import Node class MyCustomNode(Node): # MODIFY NAME def __init__(self): super().__init__("node_name") # MODIFY NAME def main(args=None): rclpy.init(args=args) node = MyCustomNode() # MODIFY NAME rclpy.spin(node...