Skip to main content

Vision-triggered tool calls: the robot acts on what it sees

Time: 11:05 AM to 12:15 PM
This is the culmination of the entire week’s work. You are combining Day 3’s tool calls with Day 4’s vision so the robot can see, think, and act in a single loop.

The full stack

The new piece: describe_surroundings is a tool the LLM can call. When it needs visual information, it triggers a camera capture and VLM analysis, then uses the result to decide its next action.

Building the vision robot

This program extends Day 3’s llm_robot.py with camera support.

Step 1 — Add camera initialization

Set up the Pi camera alongside the robot hardware:

Step 2 — Add the describe_surroundings tool

This is the new tool. When GPT calls it, your code captures a photo and sends it to the vision API:
The tool result goes back to GPT, which then decides what to do next — maybe move, maybe speak, maybe call another tool.

Step 3 — Add it to the tool menu

Register the new tool in the TOOLS list so GPT knows it exists:
And add it to the ACTIONS dictionary:

Step 4 — Update the system prompt

Tell GPT it has a camera:
The prompt now explicitly tells GPT to use describe_surroundings when asked about the environment.

How it flows

When you say “what do you see?”, here is what happens: The key insight: GPT decides when to use the camera. It might respond to “tell me a joke” without looking, but respond to “what’s in front of you?” by calling describe_surroundings first.
The complete program is at ~/camp/day4/vision_robot.py — it extends llm_robot.py with camera support and the describe_surroundings tool.

Run the program

Or with voice:

Try these commands

Vision commands:
  • “What do you see?”
  • “Is there anything in front of me?”
  • “What color is that object?”
  • “Describe your surroundings”
  • “Can you read that sign?”
Vision + action combinations:
  • “Look around and tell me what you see”
  • “If the path is clear, move forward”
  • “What do you see? If it’s interesting, celebrate!”
Still works from Day 3:
  • “Make a square”
  • “Move forward for 3 seconds”
  • “Celebrate”
  • All 10 original tools still work

Available tools (updated)

The robot now has 11 tools — everything from Day 3 plus vision:

The big picture

This is the foundation of embodied AI: a model that perceives its environment and acts within it. Your robot now has all five layers:
  1. Movement — it can drive and steer
  2. Sensing — it reads distance, brightness, and audio
  3. Speech — it can speak and listen
  4. Language intelligence — it reasons with an LLM
  5. Vision — it sees and understands through a VLM
What would you need to add to make this fully autonomous?

Make it yours

1

Change what the robot looks for

Modify the describe_surroundings tool’s question parameter. Instead of general description, make it look for specific things: “Count how many people you see” or “Tell me if there’s food in this image.”
2

Add obstacle avoidance

Combine vision with the ultrasonic sensor. If the distance sensor reads less than 20cm, automatically call describe_surroundings to see what the obstacle is, then decide whether to go around it.
3

Vision-guided navigation

Create a loop where the robot drives forward, checks what it sees every 3 seconds, and stops if it sees a specific object (like a red cup or a person).

Day 4 wrap-up

Recap: The robot now sees, hears, thinks, speaks, and moves. All five layers are connected in a single program. Tomorrow is different. You will zoom out to discuss what all of this means for society — bias, surveillance, data privacy, and the dual-use problem. Then you will bring everything together in one final project: a robot reporter that tours the room and narrates what it sees.