Skip to main content

Intermediate AI Prompts for Chapter 3

Use these prompts with AI assistants to get help implementing perception nodes, configuring SLAM, managing TF2, and deploying Nav2.


Camera & Depth Processing​

Basic Camera Subscriber​

Write a ROS 2 Python node that subscribes to /camera/image_raw
and displays the image using OpenCV. Include proper error handling.

cv_bridge Conversion​

Show me how to convert a ROS Image message to OpenCV format using cv_bridge.
Handle different image encodings (bgr8, rgb8, mono8).

Edge Detection Pipeline​

Create a perception node that subscribes to camera images,
applies Canny edge detection, and publishes the result.
Include visualization code.

Depth Data Extraction​

Write code to extract distance measurements from a depth image
at specific pixel coordinates. Handle invalid depth values.

Region of Interest Processing​

How do I process only a specific region of interest (ROI) in a camera image?
Show me code to extract and process a rectangular region.

Image Encoding Issues​

I'm getting "cv_bridge encoding error" when converting images.
What encodings are available? How do I handle different formats?

Publishing Processed Images​

Show me the complete pattern for subscribing to an image,
processing it with OpenCV, and publishing the result as a new ROS Image message.

TF2 Coordinate Frames​

Broadcasting Static Transform​

Write code to broadcast a static transform from base_link to camera_link.
The camera is 0.1m forward and 0.2m up from base_link.

Dynamic Transform Broadcasting​

Create a node that broadcasts a dynamic transform that changes over time.
Show me how to update the transform in a timer callback.

Looking Up Transforms​

How do I look up the transform between two frames (e.g., map to base_link)?
Include error handling for when the transform doesn't exist.

Transform Point Between Frames​

I have a point in camera_frame coordinates. Show me how to transform it
to base_link frame using TF2.

TF2 Listener Setup​

What's the proper way to set up a TF2 listener in a ROS 2 node?
Show me the initialization and lookup pattern.

Debugging TF Issues​

My TF lookup fails with "frame does not exist". How do I debug this?
What commands can I use to visualize the TF tree?

Time Synchronization​

How do I handle time synchronization when looking up transforms?
What's the difference between lookup_transform with time=now vs time=0?

SLAM Toolbox​

Basic SLAM Launch​

Show me a launch file to start SLAM Toolbox with default parameters.
Include the necessary nodes and parameter files.

SLAM Parameter Tuning​

What SLAM Toolbox parameters should I tune for a large indoor environment?
Explain resolution, scan_buffer_size, and loop_closure parameters.

Saving Maps​

How do I save a map generated by SLAM Toolbox?
Show me the command and explain the output files.

Loading Existing Maps​

I have a saved map. How do I load it for localization-only mode?
What parameters need to change?

SLAM Not Updating​

My SLAM map isn't updating as the robot moves. What could be wrong?
What topics should I check? What parameters affect update rate?

Loop Closure Configuration​

How do I enable and tune loop closure in SLAM Toolbox?
What parameters control loop closure detection and correction?

SLAM Performance Optimization​

My SLAM is running slowly. How can I optimize performance?
What parameters affect computational cost?

Basic Nav2 Launch​

Create a launch file that starts Nav2 with a pre-built map.
Include all necessary nodes and configuration files.

Sending Navigation Goals​

Write a Python node that sends a navigation goal to Nav2.
Include code to monitor status and handle completion/failure.

Goal Pose Construction​

Show me how to construct a PoseStamped message for a navigation goal.
Include position (x, y) and orientation (quaternion).
Implement a complete NavigateToPose action client with:
- Goal sending
- Feedback monitoring
- Result handling
- Cancellation support

Multiple Waypoints​

How do I send the robot to multiple waypoints in sequence?
Show me code to navigate through a list of poses.
How do I check if navigation is in progress, succeeded, or failed?
Show me how to parse action status messages.

Canceling Navigation​

How do I cancel an in-progress navigation goal?
Show me the action client cancellation pattern.

Costmap Visualization​

Visualizing Costmaps in RViz2​

What RViz2 displays do I need to visualize global and local costmaps?
Show me the configuration for costmap visualization.

Understanding Costmap Colors​

What do the different colors in the costmap represent?
Explain the cost values and their meanings.

Costmap Not Showing​

I launched Nav2 but don't see costmaps in RViz2. What should I check?
What topics should be publishing?

Integration & Architecture​

Perception to Navigation Pipeline​

Design a system architecture that connects:
1. Camera perception node
2. Obstacle detection
3. Nav2 navigation
Show me the topic flow and node structure.

Multi-Sensor Fusion​

How do I integrate multiple sensors (camera + LIDAR) for navigation?
What's the architecture for sensor fusion with Nav2?

Perception Node Structure​

What's the best structure for a perception node that:
- Subscribes to multiple sensor topics
- Processes data
- Publishes results
Show me a template.

Debugging & Troubleshooting​

No Camera Images​

I'm not receiving camera images in my subscriber. How do I debug?
What commands check if images are being published?

Depth Data All Zeros​

My depth image subscriber gets all zero values. What could be wrong?
How do I verify depth camera is working in Gazebo?

TF Frame Not Found​

I get "frame 'X' does not exist in the tf tree" error.
How do I diagnose and fix TF frame issues?

SLAM Map Quality Poor​

My SLAM map is noisy and inaccurate. What parameters should I tune?
How do I improve map quality?

Robot Won't Navigate​

Nav2 is running but robot doesn't move toward goal. What should I check?
Walk me through systematic debugging steps.

Costmap Shows No Obstacles​

My costmap doesn't show obstacles detected by sensors.
What configuration could be wrong?
My robot oscillates back and forth instead of moving smoothly.
What local planner parameters should I adjust?

Performance Optimization​

Perception Node Performance​

My perception node is slow and dropping frames. How do I optimize?
What are common performance bottlenecks?

SLAM Computational Cost​

SLAM is using too much CPU. What parameters reduce computational cost
without sacrificing too much accuracy?

Real-Time Constraints​

How do I ensure my perception pipeline meets real-time constraints?
What techniques help maintain consistent frame rates?

Code Patterns​

Perception Node Template​

Give me a complete template for a perception node with:
- Multiple subscribers (camera, depth)
- Image processing
- Multiple publishers
- Proper error handling
- Logging

TF2 Broadcaster Template​

Provide a template for a node that broadcasts transforms with:
- Static transforms in __init__
- Dynamic transforms in timer callback
- Proper timestamp handling
Give me a reusable template for sending navigation goals with:
- Action client setup
- Goal construction
- Feedback callback
- Result handling
- Error recovery

Configuration Files​

SLAM Parameters Explained​

Explain each parameter in the SLAM Toolbox configuration file.
What does each one control? What are good starting values?
What are the most important Nav2 parameters to understand?
Explain global_costmap, local_costmap, and planner parameters.

Launch File Best Practices​

What are best practices for writing Nav2 launch files?
How should I organize parameters and node configurations?

Testing & Validation​

Testing Perception Nodes​

How do I test my perception node without a full robot setup?
Can I use rosbag files or test images?

Validating SLAM Output​

How do I validate that my SLAM map is accurate?
What metrics or checks should I use?
What's a good testing strategy for Nav2 navigation?
How do I test in simulation before real deployment?

Tips for Using These Prompts​

  • Add Context: Mention which lesson you're on and what you've tried
  • Share Error Messages: Include full error output for debugging help
  • Request Explanations: Ask "why" not just "how"
  • Iterate: Start simple, then ask for more advanced versions
  • Code Review: Ask AI to review your code for improvements

Next: Advanced AI Prompts (after completing Intermediate tier)