Java

Overview: 
Explore the programming term API.
Objectives: 

Understand what an API is and how they are used in programming.

Content: 

Simply put, an API or Application Programming Interface, is a library of pre-written computer programs that simplify the use of software or hardware features. When you look at a robot, there is a lot of low level programming needed to operate motors, read sensors, control valves, all at the binary level. There has to be different low level code for each different hardware component. For instance, two different models of motor may require different types of voltage input in order to properly move. It would be very tedious, error prone and time consuming if you had to write all of that low level code as well as the higher level instructions to perform the overall function of your robot.

To solve this problem, other programmers have written all of that low level code and provided it to you in the form of Java Object Libraries. You use these library objects in your program to handle all of the low level tasks for you, allowing you control the robot hardware at a much higher level. So rather than understanding all of the nuances and technical issues in controlling motor voltages, you can simply create a motor object (from the object library) and call the motor.SetSpeed() function to make the motor turn at your desired speed. The API is written so that you do not need to understand the specifics of how particular models of motors or servos (or other hardware) vary in their voltage level, but instead can focus on the actions you want the robot to complete. It is important to note, however, that sometimes the small differences in how hardware behaves at the low level (as controlled by the API), can result in surprising, undesired, or otherwise unexpected results when the robot is running. These problems can be difficult to track down, as we typically will not look into the specific contents of the API.

There are many functions and many devices available for each robot platform and the object library has many objects representing all of the features of the robot hardware. Taken together, all of these library objects are called an API. For the EV3, the API is called the leJOS API. For the Tetrix, the API is called the FTC SDK. On the RoboRio, the API is called the WpiLib.

The term API may also be used for subsets of the overall API. For instance, the WpiLib which is a large API, has a subset of objects termed the Vision API.

Here is the Wikipedia discussion of an API.

Navigation:

What is a programming language?

When we are programming, that is creating a program for a computer to execute, we will use a programming language. Like English or Spanish, a programming language is a written way to communicate with someone (or something). Computer languages allow you to encode the operations you wish to have the computer perform with a syntax (form) that is much easier for you to understand than the numeric language (binary) that computers understand.

What is Programming?

When used in the context of computers, programming generally means the process of creating the instructions that a computer will follow in solving a particular problem or completing some task. The product of programming is a "program", which is a package of instructions that can be executed by a computer.

Overview: 
Explore what it means to program and why we do it.
Objectives: 

Understand at a high level what programming is and what it means to "program".

Content: 

When used in the context of computers, programming generally means the process of creating the instructions that a computer will follow in solving a particular problem or completing some task. The product of programming is a "program", which is a package of instructions that can be executed by a computer. A program typically directs the computer to accept input of some type and produce output of some type. Programs are at the heart of all computing and are what you are using when you play games, edit documents, make calls on your phone, interact with web sites or make robots move.

Here is the Wikipedia description of programming.

A video describing programming.

Navigation:

STEM Robotics 201 Unit 1 Lession 2 - Diff #2

Differentiated item #2.

STEM Robotics 201 Unit 1 Lession 2 - Diff #1

Differentiated material??

Overview: 
Explore how programming languages make computers work and how we use those languages.
Objectives: 

Understand lower and higher levels of programming instructions. Understand compilers, compiling, linking and deployment.

Content: 

At the hardware level, computers understand one language, called machine language (also called object code). This is the set of instructions supported by the computer's processor hardware and is specific to each type of processor. This object code language is numeric in nature and expressed in binary, which is a numeric coding made up of only 1s and 0s. It is very tedious to program in binary, so higher level languages were created to make it easier to create programs. In a higher level language, you use syntax that is English like and easier to understand to express what you want the computer to do. It is the job of the higher level language to translate those written instructions into binary object code for the computer to execute. In fact, when a program is created by a higher level language it will contain only the binary instructions for the computer, not your source code.

Typically, the programmer writes instructions in the selected higher level language, Java in our case, and these instructions or source code are stored in text form in a file. This source file is then passed to a program called a compiler which translates the source language to object code in binary form and writes that to another file called the program. This file is an .exe file on Windows (for example). There may be an additional step called linking which is the process of combining the programmers instructions with libraries of instructions created by someone else. Finally the program file may be sent to another computer for execution. This is called deploying.

When the program is run by the computer, the computers operating system opens the program file, reads and executes the binary instructions it finds.

The exact steps and processes taken by each language to convert source code into an executable program may vary but will always follow this general set of steps. The process of translating from source code to a computer-usable program is called compilation or compiling. It is important to note that compilation is a one-time packaging of a certain set of source code into a program file. if the source code is modified by the programmer after compilation, the previously compiled program will use the same set of source code that existed at the time of compilation. In order to use whatever changes are made in the source code, the program must be recompiled.

 

Navigation:

How do programming languages make computers work?

At the hardware level, computers understand one language, called machine language (also called object code). This is the set of instructions supported by the computer's processor hardware and is specific to each type of processor. This object code language is numeric in nature and expressed in binary, which is a numeric coding made up of only 1s and 0s. It is very tedious to program in binary, so higher level languages were created to make it easier to create programs.

Overview: 
Explore what programming languages are and how we use them.
Objectives: 

Gain an understand what a programming language is. Understand the difference between text based and visual languages.

Content: 

When we are programming, that is creating a program for a computer to execute, we will use a programming language. Like English or Spanish, a programming language is a written way to communicate with someone (or something). Computer languages allow you to encode the operations you wish to have the computer perform with a syntax (form) that is much easier for you to understand than the numeric language (binary) that computers understand. There are many text based languages such as Basic, C, C++, C#, Java, JavaScript, Python and many more. Each language was created for various reasons to serve varied populations of programmers. In this course we will be studying the Java programming language.

Here is the Wikipedia description of a programming language.

When we say a language is text based, we mean that the language is expressed in written statements, which are typically entered into a text file and then processed for execution by the computer. Text based languages in general provide more capability in expressing what you want the computer to do at the price of being more complex to learn and use.

Note that there are also many visual programming tools (might be a stretch to call them languages) that seek to simplify programming by allowing the user to assemble programs by manipulating pictures instead of text. Such tools have visual objects that map to functions the computer can perform and programs are created by arranging such objects on a visual workspace. Such tools, in general, sacrifice some amount of capability for simplicity of learning and use.

Navigation:

Overview: 
What is computer programming? Why do we do it? How does programming apply to robots? In this unit we will explore these questions and set the stage for the following units.

Pages