Simulation and verification
A real robot costs money and can break; a program running on a screen cannot. Before connecting real motors and sensors, the behaviour of the system is checked in a simulator, where failing costs nothing.
Why simulate before building
Explain what a circuit or robotics simulator is and give two advantages of testing on it before building the physical assembly.
Explain what a circuit or robotics simulator is and give two advantages of testing on it before building the physical assembly.
In your own words, explain what it means to verify a program and how it differs from "just testing it briefly to see if it works".
In your own words, explain what it means to verify a program and how it differs from "just testing it briefly to see if it works".
The flowchart in the figure controls an automatic light depending on a sensor (LDR), but the contents of one block are missing. State what that block should do and…
The flowchart in the figure controls an automatic light depending on a sensor (LDR), but the contents of one block are missing. State what that block should do and describe what the system does when the sensor reading is 150 and when it is 800.
Designing test cases
Explain the difference between simulating a circuit on a computer and building it on a real breadboard: what is gained and lost with each method.
Explain the difference between simulating a circuit on a computer and building it on a real breadboard: what is gained and lost with each method.
A program must switch on a fan when the temperature exceeds $26\ ^\circ\text{C}$. Define three test cases (input value and expected result) to verify it, including the…
A program must switch on a fan when the temperature exceeds $26\ ^\circ\text{C}$. Define three test cases (input value and expected result) to verify it, including the boundary value of $26\ ^\circ\text{C}$, and justify why this boundary case is important.
In the simulator, your program works perfectly, but in the actual build, the motor does not rotate. Give three possible causes that a simulator does not detect and…
In the simulator, your program works perfectly, but in the actual build, the motor does not rotate. Give three possible causes that a simulator does not detect and explain how you would check each one on the workbench.
Verifying and validating: two different questions
Explain what a "boundary case" (or edge case) is when verifying a program and why they are so important. Give an example using a program that decides whether a mark…
Explain what a "boundary case" (or edge case) is when verifying a program and why they are so important. Give an example using a program that decides whether a mark passes from 5 upwards.
A program counts people entering a room (sensor A) and leaving it (sensor B). Design three test cases intended to catch typical errors: two people walking in together,…
A program counts people entering a room (sensor A) and leaving it (sensor B). Design three test cases intended to catch typical errors: two people walking in together, someone entering and leaving immediately, and a sensor triggering twice due to contact bounce.
In the simulation of an irrigation system for a school garden bed, you have programmed this control loop: REPEAT FOREVER: humidity = read_sensor() IF humidity < 30 %…
In the simulation of an irrigation system for a school garden bed, you have programmed this control loop:
REPEAT FOREVER:
humidity = read_sensor()
IF humidity < 30 % THEN:
activate_solenoid_valve()
wait(10 seconds)
deactivate_solenoid_valve()
END REPEAT
When running it in a simulator that models the physical absorption of water with an infiltration delay of 2 minutes, the solenoid valve opens and closes non-stop for dozens of consecutive cycles, waterlogging the soil.
- a) Justify why the program generates this behavior in the simulation despite including an explicit deactivation instruction.
- b) Redesign the algorithm (in pseudocode or a flowchart) to solve the problem without removing the sensor reading or changing the solenoid valve.
Debugging: finding and fixing the error
A mobile robot uses a front ultrasonic sensor (usable range: 2,0 cm to 400,0 cm) and must stop and turn if it detects an obstacle closer than 20,0 cm. Design a test…
A mobile robot uses a front ultrasonic sensor (usable range: 2,0 cm to 400,0 cm) and must stop and turn if it detects an obstacle closer than 20,0 cm. Design a test matrix to verify the code in the simulator before transferring it to the real robot. Your plan must contain at least 4 different test cases that include boundary values and reading anomalies. For each case, you must indicate: simulated numeric input value, expected behavior of the motors, and technical justification of why it is essential to check that specific case.
A team simulates a black line follower robot: on screen, the algorithm reacts in 0,02 s, the motors respond instantaneously, and the robot completes the circuit at 1,2…
A team simulates a black line follower robot: on screen, the algorithm reacts in 0,02 s, the motors respond instantaneously, and the robot completes the circuit at 1,2 m/s without any errors. However, when uploading the same program to the real robot with the same sensors, it oscillates sharply from side to side and ends up losing the line on the first curve.
- a) Identify and justify three real-world factors that the simulator omitted or idealized and that explain this discrepancy.
- b) Propose two technical modifications (one in the control software parameters and another in the physical assembly) to compensate for these real effects without replacing the sensors.