Courier Extension 1: Event Driven Programming
This is the fifth challenge within the Robotics with GoPiGo and Python Curriculum.
Your task is to design a robot program to deliver a selection of mail to the residents of GoPiGo Drive, a small cul-de-sac containing 3 houses.
Learn how to how to use and calibrate the color sensor.
3. Defining the Callback
Here’s the definition of the test_line function that is called by the button’s on_click() event:
def test_line(_):
output.clear_output() # [1]
with output: # [3]
test_line_follower() # [2]
This type of functions, that gets called when an event such as a button click happens, is referred to as a callback function.
This tells the robot to [comment #1] clear the output widget [ comment #2] run the test_line_follower()
test function that you wrote and [comment #3] direct any output generated by your test function to the output widget. In this instance, it displays output messages directly under the button panel.
For speed and convenience, we have followed exactly the same process to link all the other clickable buttons to the relevant functions in your template notebook for you.