Skip to content

2.0 Introduction to CAIT Visual Programming

yelu728 edited this page Jan 5, 2021 · 19 revisions

Introduction to CAIT Visual Programming

CAIT's visual programming interface extends from Google's Blockly visual code editor. Google provides a great user's guide to Blockly. We will not cover these basic concepts here. Instead, we will talk about the basic constructs that every program written for CAIT shares and describe the different A.I. blocks you can use in your own project.

CAIT's primary design goal is to be intuitive, and any program written for it should closely resemble simple structured programming. For this reason, every program needs to have a least two blocks: a "setup" block and a "main" block. The "setup" block can only contain initialization blocks for various A.I. modules while the "main" block implements the program's logic flow. We employ a sequential programming model in CAIT. When a program executes, each of our A.I. blocks performs a specific task and waits for the result to return before moving on to the next block. The complexity of event handling and callbacks are virtually hidden within each block to offer users an intuitive way to express their logic.

CAIT also offers a conversion tool to convert the visual code into either Jupyter notebook format or straight Python code. The following describes the function of each custom block in CAIT. These blocks have a one to one correspondence with the converted Python code statements.

Now, let's dive in and create CAIT programs!

Basics

All CAIT programs must contain one "setup" block and one "main" block. You can find these blocks in the "Basics" category. The setup block is responsible for initializing the CAIT A.I. modules, while the main block is responsible for calling these A.I. modules to perform tasks. The screenshot below shows the structure of a bare CAIT program with only these 2 blocks.

Once you have these 2 blocks created in the workspace, you can drag and drop the CAIT A.I. blocks into them. Only initialize blocks can be placed inside the setup block. These blocks have the word "initialize" at the beginning of their names. For the main block, you can put any blocks except the initialize blocks in it. The screenshot below shows a typical CAIT program that uses the vision module to perform a task. It first initializes the vision module in the setup block, then uses the "Recognize Face" block to ask the vision module to perform face recognition. The result is stored in a variable called "person."

If you forgot to place the "Initialize vision" block in the setup block, an alert like the one below would be shown. Similarly, you will find initialize blocks for the Speech, NLP, control, and smart home modules.

Now that you understand how to construct a CAIT program, we will show you some more examples of using the different CAIT modules in the following tutorials. Click the links below for tutorials on different types of A.I. blocks that interest you.

Tutorials

  1. Dictionary and List data structure
  2. Vision Module
  3. Speech Module
  4. NLP Module
  5. Control Module
  6. Smart Home Module