Vision-triggered tool calls: the robot acts on what it sees
Time: 11:05 AM to 12:15 PM
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’sllm_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:Step 3 — Add it to the tool menu
Register the new tool in theTOOLS list so GPT knows it exists:
ACTIONS dictionary:
Step 4 — Update the system prompt
Tell GPT it has a camera: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 callingdescribe_surroundings first.
Click to see the complete vision_robot.py program
Click to see the complete vision_robot.py program
~/camp/day4/vision_robot.py — it extends llm_robot.py with camera support and the describe_surroundings tool.Run the program
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?”
- “Look around and tell me what you see”
- “If the path is clear, move forward”
- “What do you see? If it’s interesting, celebrate!”
- “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:
- Movement — it can drive and steer
- Sensing — it reads distance, brightness, and audio
- Speech — it can speak and listen
- Language intelligence — it reasons with an LLM
- Vision — it sees and understands through a VLM
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).

