Presentation is loading. Please wait.

Presentation is loading. Please wait.

Teaching Computer Science With Robotics Using Ada/Mindstorms 2.0 Barry Fagin, Laurence Merkle, Thomas Eggers US Air Force Academy Colorado Springs, CO.

Similar presentations


Presentation on theme: "Teaching Computer Science With Robotics Using Ada/Mindstorms 2.0 Barry Fagin, Laurence Merkle, Thomas Eggers US Air Force Academy Colorado Springs, CO."— Presentation transcript:

1

2 Teaching Computer Science With Robotics Using Ada/Mindstorms 2.0 Barry Fagin, Laurence Merkle, Thomas Eggers US Air Force Academy Colorado Springs, CO USA

3 Why Use Robotics to Teach Computer Science? Lego Mindstorms® Ada/Mindstorms 2.0 Why Ada? What Concepts Can Be Taught? How to Get Ada/Mindstorms 2.0 (it’s free) Future Plans Topics

4 Why Use Robotics? “Hot little hand” syndrome Value of experiential learning: learn by doing Robots are cool – it’s just plain fun!

5 Why is the time right for robotics? Used to be true that building robots was too costly and time-consuming for all but the specialized researcher Over time, technology tends to get better and cheaper. Now at the point where even children can build and program robots, using commercial products “Today’s technology, tomorrow’s toys”

6 The Lego Mindstorms RCX “brick”

7 Input ports The Lego Mindstorms RCX “brick”

8 Input ports Output ports The Lego Mindstorms RCX “brick”

9 Input ports Output ports Contains Hitachi microcontroller Robots built by connecting Lego bricks, motors, axles, wheels, etc. Programs downloaded from PC through I/R transmitter on serial port. The Lego Mindstorms RCX “brick”

10 A Mindstorms Robot

11 Ada/Mindstorms 2.0 Ada subset Ada/Mindstorms API Output_On(Output => Output_A) if counter = 0 then Ada compiler ada2nqc translator NQC Ada code Validated Ada code NQC code to RCX int COUNTER = 1; task main() { INITIALIZE_ROBOT () ;

12 Ada/Mindstorms 2.0 Ada subset Ada/Mindstorms API Output_On(Output => Output_A) if counter = 0 then Ada compiler ada2nqc translator NQC Ada code Validated Ada code NQC code to RCX Bundled with latest release of AdaGIDE compiler int COUNTER = 1; task main() { INITIALIZE_ROBOT () ;

13 Why Ada? No GUI for NQC, makes it harder for newcomers Leverage existing Ada compiler expertise Better environment for learning computer science. Students new to programming are likely to make mistakes that NQC can’t catch. (Still, NQC is a great piece of work!)

14 Advantages of Ada for Teaching Intro CS Strong typing -- type used to specify a sensor port (1..3) on the RCX. type Sensor_Port is (Sensor_1, Sensor_2, Sensor_3); procedure Clear_Sensor (Sensor : in Sensor_Port );

15 Advantages of Ada for Teaching Intro CS Named Association procedure Play_Tone (Frequency_In_Hertz : in Frequency; Tenths_Of_A_Second : in Natural ); Play_Tone(Frequency_In_Hertz => 440, Tenths_Of_A_Second => 20); Enables student to see meaning of each parameter

16 Some basic programming concepts easily demonstrated with an Ada/Mindstorms robot: Output_On_Reverse(Output => Output_A); Output_On_Reverse(Output => Output_C); Wait(Hundredths_Of_A_Second => Tenths_Of_A_Second * 10); Output_Off(Output => Output_A); Output_Off(Output => Output_C); Sequential control flow:

17 Some basic programming concepts easily demonstrated with an Ada/Mindstorms robot : Selection: --touch sensor pressed? if Get_Sensor_Value(Sensor => Sensor_1) = 1 then Go_Back(Tenths_Of_A_Second => 30); if counter = 0 then Turn(Direction => Right); counter := 1; else Turn(Direction => Left); counter := 0; end if; Go_Forward; end if;

18 Some basic programming concepts easily demonstrated with an Ada/Mindstorms robot: Iteration: (count-controlled) for I in loop Play_Tone(Freq => I * 100, Tenths_Of_A_Second => 10); Wait(10); end loop;

19 Some basic programming concepts easily demonstrated with an Ada/Mindstorms robot: Iteration: (event-controlled) loop … exit when Get_Sensor_Value(Sensor_1) = 1; end loop;

20 Some basic programming concepts easily demonstrated with an Ada/Mindstorms robot: User-defined procedures: procedure Shake is begin Output_On_Forward(Output => Output_A); Output_On_Reverse(Output => Output_B); Wait(Hundredths_Of_A_Second => 10); Output_On_Reverse(Output => Output_A); Output_On_Forward(Output => Output_B); Wait(Hundredths_Of_A_Second => 10); end Shake;

21 Arrays (new in 2.0) Limited support (due to NQC constraints) Integer arrays only, arrays and array elements cannot be passed as parameters Supply predefined type Integer_Array in lego.ads

22 Array example Turns : Integer_Array (1..Max_Index); Turn_Value : Integer; Num_Points : Integer := 0; begin Initialize_Robot; for Index in 1..Max_Index loop Get_Touch_Count(Touches => Turn_Value); Turns(Index) := Turn_Value; Num_Points := Num_Points + 1; exit when Turn_Value <= 0; end loop;

23 Array example for Index in 1..Num_Points loop Turn_Value := Turns(Index); Beep_A_Digit(Digit => Turn_Value); Wait(Hundredths_Of_A_Second => 50); if Turn_Value = Forward then … Gives a robot programmability, powerful accomplishment for an intro CS course

24 Planned for 3.0 tasks packages graphical simulator suggestions?

25 Demonstration Ada/Mindstorms used in experimental sections of intro CS course academic year. Data presently being written up for publication


Download ppt "Teaching Computer Science With Robotics Using Ada/Mindstorms 2.0 Barry Fagin, Laurence Merkle, Thomas Eggers US Air Force Academy Colorado Springs, CO."

Similar presentations


Ads by Google