Skip to main content

๐Ÿ†• Adding New Nodes & Packages

This guide explains how to create new ROS2 nodes and packages for the LIMO Pro + MyCobot + YOLO ecosystem, follow architectural best practices, integrate them into the workflow, and test them safely.


๐Ÿ“ฆ Creating a New Packageโ€‹

We use ROS2 Python packages for most nodes in this project.

cd ~/krish_ws/src
ros2 pkg create --build-type ament_python my_new_node

Structure:

my_new_node/
โ”œโ”€โ”€ package.xml
โ”œโ”€โ”€ setup.py
โ”œโ”€โ”€ resource/my_new_node
โ”œโ”€โ”€ my_new_node/__init__.py
โ”œโ”€โ”€ my_new_node/my_new_node.py
โ””โ”€โ”€ launch/

๐Ÿงฉ Node Architecture Guidelinesโ€‹

Keep it Modular

Each node should have one core responsibility (e.g., detection, navigation, arm control) and communicate via ROS2 topics/services/actions.

Required structure inside a node:

1. Initializationโ€‹

  • Node name
  • Parameters
  • Publishers/Subscribers/Action clients
  • Logging start message

2. Core Logicโ€‹

  • Main loop or callbacks
  • State handling (if applicable)

3. Shutdown Handlingโ€‹

  • Stop motors, close connections, save state

Example skeleton:

import rclpy
from rclpy.node import Node

class MyNewNode(Node):
def __init__(self):
super().__init__('my_new_node')
self.get_logger().info("Node initialized.")

def main_loop(self):
pass # Core logic here

def main(args=None):
rclpy.init(args=args)
node = MyNewNode()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()

๐Ÿ”— Integration Proceduresโ€‹

To integrate a new node:

1. Add to Launch Fileโ€‹

Use launch_ros.actions.Node in full_system.launch.py with proper TimerAction so it starts after dependencies are ready.

2. Respect Existing Topicsโ€‹

  • If publishing /target_pose, ensure format matches PoseStamped from object_detector.py.
  • Avoid name collisions with existing topics.

3. Parameterize IPs and Pathsโ€‹

  • For hardware nodes (like MyCobot), accept IP from --ros-args -p m5_ip:=....
  • Never hardcode file paths โ€” use ROS2 params.

4. Logging & Voice Feedbackโ€‹

  • Use self.get_logger().info() for state changes.
  • For user feedback, follow the say() function pattern in pick_node.py and mission_manager.py.

๐Ÿงช Testing New Nodesโ€‹

  • Use RViz2 and fake data to test without risking hardware.
  • If it's a detection node, feed it saved images.
  • If it's a navigation node, test in Gazebo before the real robot.

โœ… Pre-Merge Checklist for New Nodesโ€‹

  • โ˜ Package builds with colcon build --symlink-install
  • โ˜ Code follows Code Style Guidelines
  • โ˜ Node starts without errors or warnings
  • โ˜ Integration tested with full_system.launch.py
  • โ˜ Does not break Mission Manager or YOLO detection logic

๐Ÿ“– Read Next: Launch & Config File Creation


Next: Launch Configuration Files