Difference between revisions of "Roomba"

From CompSciWiki
Jump to: navigation, search
(table test)
(saving progress)
Line 26: Line 26:
  
 
The input parameters are:
 
The input parameters are:
* boolean hackingModel: This value will either be true or false depending on the type of roomba you are using.
+
* boolean hackingModel: There are two types of roombas that are available to you in this lab. One is called a hacking model and the other is the regular model. The only differance between the two is that the hacking model does not have a vacuum. Set this value to true if you are using the hacking model, and false otherwise.
 
* int port: This is the usb port your roomba will connect to. By default your roomba will be on port 0. If it is not do not worry, the function will print a list of available ports to the console.
 
* int port: This is the usb port your roomba will connect to. By default your roomba will be on port 0. If it is not do not worry, the function will print a list of available ports to the console.
  
Line 52: Line 52:
 
}}
 
}}
  
You are going to have a bad time. This is because when you run your code,,,,,
+
This code will not work. Please take a moment to figure out why before you continue.
 +
 
 +
The reason this code does not work is because the roombacomm object sends and recieves commands at real time. This means that you have to give the roomba some time to complete an instruction before moving on to the next one.
 +
 
 +
Now try this
 +
{{CodeBlock
 +
|Code=PImage img;
 +
    roombacomm.goForward();
 +
    roombacomm.pause(1000);
 +
    roombacomm.stop();
 +
}}
 +
 
  
 
=== Basic Movement ===
 
=== Basic Movement ===

Revision as of 18:05, 4 April 2012

COMP 1010 Home > Back to Extra Labs

Introduction

Welcome to the Comp 1010 extra labs. In this lab you will learn the basics about the roomba. We will cover basic movements, How to use the lights, how to make sound and play a simple melody, and how to read sensor data with the roomba.

Getting started

Setting up eclipse

If you are not familiar with eclipse please see the Introduction to Eclipse extra lab.

Run your first program

  • Import the Roomba project placed on your desktop.
  • Connect your computer to your roomba.
  • It should make a noise.

connectToRoomba

This function is given to you as part of the Rommba.java source code. Its purpose is to create a connection between your computer and the roomba.

 PImage img;
    public static RoombaCommSerial connectToRoomba(boolean hackingModel, int port) 

The input parameters are:

  • boolean hackingModel: There are two types of roombas that are available to you in this lab. One is called a hacking model and the other is the regular model. The only differance between the two is that the hacking model does not have a vacuum. Set this value to true if you are using the hacking model, and false otherwise.
  • int port: This is the usb port your roomba will connect to. By default your roomba will be on port 0. If it is not do not worry, the function will print a list of available ports to the console.

Output:

  • RoombaCommSerial: A RoombaCommSerial object will allow you to control the roomba. More on this later.

Trouble shooting

Problem tab

Ports

The roombacom object

The connectToRoomba function will return a RoombaCommSerial object which will be assigned to the variable roombacom. This object will maintain the state and connection to the roomba. With it you can send commands to the roomba and receive information back from the roomba. Now lets see how it works.

Wait a sec

Try running this code

 PImage img;
    roombacomm.goForward();
    roombacomm.stop(); 

This code will not work. Please take a moment to figure out why before you continue.

The reason this code does not work is because the roombacomm object sends and recieves commands at real time. This means that you have to give the roomba some time to complete an instruction before moving on to the next one.

Now try this

 PImage img;
    roombacomm.goForward();
    roombacomm.pause(1000);
    roombacomm.stop(); 


Basic Movement

Lights

Sound

Orange Apple 12,333.00
Bread Pie 500.00
Butter Ice cream 1.00
Orange Apple 12,333.00
Bread Pie 500.00
Butter Ice cream 1.00


Header 1 Header 2 Header 3
row 1, cell 1 row 1, cell 2 row 1, cell 3
row 2, cell 1 row 2, cell 2 row 2, cell 3
row 3, cell 1 row 3, cell 2 row 3, cell 3

Sensor Data

Exercise

And Beyond ...