Software Viva Guide
This file is for quick preparation before the presentation and viva.
It explains:
- what the software does
- how the code is structured
- how the robot behaves
- what to say when asked technical questions
1. One-line explanation
This project is a software-controlled robotic sorting system where a web application controls a robotic arm and conveyor, reads sensors, and runs automation/workflow logic to sort objects based on detection and color.
2. Main software objective
The software has three goals:
- Manual control
- allow the operator to move the robotic arm joints and motor from the browser
- Automation
- react to sensor input like ultrasonic detection
- run predefined workflows automatically
- Demo / sorting logic
- run a hardcoded demo loop:
- start conveyor
- detect object
- stop conveyor
- identify color
- execute the correct workflow or reject path
3. High-level architecture
There are 4 major software parts:
A. Frontend
What it does:
- shows the dashboard
- lets the user move sliders
- save positions
- create workflows
- create automations
- start/stop demo mode
- displays live state from the backend
Important point:
- the frontend is not the main control brain
- it is only the operator interface
B. Backend
What it does:
- main control brain of the whole system
- talks to both Arduinos over serial
- runs workflows
- runs automations
- runs hardcoded demo mode
- reads ultrasonic input from Arduino 1
- reads color result from camera CV pipeline
- updates LCD status through Arduino 1
- exposes API endpoints to the UI
Important point:
app.py is the central orchestrator
C. Persistent runtime state
What it does:
- stores live software state in
runtime_state.json
- persists:
- last commanded joints
- sensor state
- color state
- workflow execution
- automation state
- demo state
- command history
Why it exists:
- to avoid keeping important runtime state only in browser memory
- to survive page refresh or app restart
Important point:
- persisted state is used as software state, but not trusted as real physical feedback of arm pose
D. Computer vision color detection
What it does:
- uses webcam frames
- detects color using HSV ranges
- returns dominant color from the ROI
Important point:
- color detection is now camera-based, not Arduino color-sensor based
4. Hardware-software responsibility split
Arduino 1
Responsibilities:
- controls:
- reads ultrasonic sensor
- drives I2C LCD
- receives LCD text/status messages from backend
Arduino 2
Responsibilities:
- controls:
- Wrist Pitch
- Wrist Roll
- Gripper
- DC motor
Key design choice
Arduino firmware is kept relatively simple.
The complex decision-making is in Python backend:
- workflows
- automations
- demo logic
- branch by color
- sensor-driven control
That is intentional because Python is easier to modify quickly during development.
5. How commands flow in the system
Manual control flow
- User moves slider in UI
- Frontend sends
/send_command
app.py decides which Arduino should receive the command
- Serial command is sent
- runtime state is updated
- UI reflects updated backend state
Workflow flow
- User saves positions
- User builds workflow from steps
- Workflow is saved to
workflows.json
- User runs workflow
- Backend executes steps sequentially
Supported workflow step types:
Automation flow
- Arduino 1 sends ultrasonic distance
- Backend reads distance
- If rule condition matches:
- backend schedules automation
- After delay:
- motor stop / home / workflow run
Demo flow
The current hardcoded demo loop is:
- Start conveyor at
M:128
- Wait until ultrasonic distance is below
6 cm
- Wait
1000 ms
- Stop motor
- Check camera-detected color
- Branch:
RED -> run pd-red
GREEN -> run pd-green
- otherwise -> reverse motor
M:-200 for 1000 ms
- Restart conveyor
- Repeat until stopped
6. Important data files
positions.json
workflows.json
- stores workflows made from steps
automations.json
- stores ultrasonic trigger rules
runtime_state.json
- stores persistent runtime state
7. Why backend-owned state was needed
Earlier, frontend memory was behaving like the source of truth.
That caused a serious robotics problem:
- old commanded state could get reapplied even if physical arm pose had changed
So the design was corrected:
- backend owns runtime state
- frontend reads backend state
- persisted pose is treated as informational, not guaranteed physical truth
This is a good viva point because it shows safety-aware design thinking.
8. Why color detection was moved away from Arduino logic
Originally, there was an attempt to classify color directly around Arduino-side sensor logic.
That was changed because:
- camera-based CV was easier to tune
- backend-side classification is easier to change than reflashing firmware repeatedly
- it keeps Arduino simpler
So now:
- camera sees object
cv_detector.py classifies color
- backend stores that result
- demo logic uses that result
9. Most important files to mention in viva
If asked “which files matter most?”, answer:
Core control
UI
Firmware
Vision
10. Likely viva questions and safe answers
Q. Why did you use two Arduinos?
Because the system has multiple servos, a conveyor motor, an ultrasonic sensor, LCD, and serial coordination. Splitting responsibilities made pin usage and task separation simpler:
- Arduino 1 handles structural joints + ultrasonic + LCD
- Arduino 2 handles wrist/gripper + DC motor
Q. Why is Python backend needed?
Because the backend is the main control layer. It is easier to implement workflows, automations, state persistence, and demo branching in Python than in microcontroller firmware.
Q. Why not do everything on Arduino?
Because higher-level orchestration is easier, faster to modify, and more maintainable in Python. Arduino is used for low-level actuation and sensor interfacing.
Q. How is color detected?
Using a webcam and OpenCV-based HSV color detection in the software layer. The detected color is then used by the backend logic.
Q. How is object presence detected?
Using the HC-SR04 ultrasonic sensor connected to Arduino 1. The distance is streamed to the backend over serial.
Q. What happens when an object is detected in demo mode?
The conveyor is running. When distance goes below 6 cm, the backend waits 1000 ms, stops the motor, checks the camera-detected color, then runs the correct workflow or a reject motor action, and finally restarts the conveyor.
Q. Why do you store runtime state?
To make the UI and backend consistent, preserve execution state across refresh/restart, and avoid depending only on browser memory.
Q. Is persisted pose always equal to real robot pose?
No. Persisted pose is the last commanded software state. Without encoder feedback, physical pose is not guaranteed. That distinction is important for safety.
Q. What is the role of the LCD?
It gives local machine feedback directly on the robot side:
- distance state
- workflow execution
- demo state
- automation status
Q. What is future scope?
Full automatic color-based sorting with more reliable classification, richer workflow branching, and more autonomous pick-and-place behavior.
11. What your teammate must remember
If they remember only 5 points, remember these:
app.py is the brain
- two Arduinos split low-level hardware control
- ultrasonic detects object presence
- camera CV detects color
- hardcoded demo branches into red / green / reject actions
12. Short emergency answer
If someone asks suddenly, this answer is enough:
“Software-wise, the browser is only the interface. The main control logic is in the Flask backend, which talks to two Arduinos over serial, runs workflows and automations, reads ultrasonic input, gets color from OpenCV, and executes the sorting/demo logic. Runtime state is persisted so the system remains synchronized across sessions.”