Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed the Quick Start Guide from the guides folder.

  • Loading branch information...
commit e96f97a180c9f6e2def70f6c873441db9b00965d 1 parent 9bf330d
Brian Smith beesmith authored
BIN  guides/QuickStart/QSG-jar-depend.png
BIN  guides/QuickStart/QSG-library-project.png
BIN  guides/QuickStart/QSG-libs.png
170 guides/QuickStart/QuickStartGuide.md
Source Rendered
... ... @@ -1,170 +0,0 @@
1   -#Quick Start Guide
2   -
3   -1. Download the SDK.
4   -
5   - <!-- File in actual information on where to download the SDK libraries archive. -->
6   -
7   -2. Create an android project in Eclipse.
8   -
9   - The libraries are made to support andriod API level 8 (Android 2.2) or greater.
10   - Plus, you need set the Java language compliance level to 6.0(1.6).
11   -
12   -3. Place the libs folder from the SDK into your android project's folder.
13   -
14   - ![title](file://localhost/Users/brian/Documents/Codework/MOBILE-ANDROID-SDK/guides/QuickStart/QSG-libs.png)
15   -
16   -4. Set the dependency to RobotLibrary.jar.
17   -
18   - Set the dependency in the project's properties in the Properties->Java Build
19   - Path-> Libraries dialog.
20   -
21   - ![title](file://localhost/Users/brian/Documents/Codework/MOBILE-ANDROID-SDK/guides/QuickStart/QSG-jar-depend.png)
22   -
23   -5. Add the RobotUILibrary source library into the workspace.
24   -
25   - Import the library into workspace using Import->General->Existing projects
26   - into Workspace. You can have the importer copy the source into your
27   - workspace folder or you can place it into the workspace folder before
28   - importing. Once it is imported, you need to set the project dependent on
29   - RobotLibrary.jar, which is added using the Properties->Java Build ->Libraries
30   - dialog. You will need to add RobotUILibrary as library project to your
31   - application project from the projects Properties dialog.
32   -
33   - ![title](file://localhost/Users/brian/Documents/Codework/MOBILE-ANDROID-SDK/guides/QuickStart/QSG-library-project.png)
34   -
35   - RobotUILibrary is distributed as source, so you can
36   - customize the look of the resources to fit in with your
37   - applications.
38   -
39   -6. Add code to connect to a sphero.
40   -
41   - The RobotUILibrary includes an Activity called StartupActivity which will
42   - handle connectioning to a Sphero. When the activity exits, your are ready to
43   - send commands.
44   -
45   - To run the StartupActivity, add the following code to the main activity's onStart() method,
46   -
47   - Intent i = new Intent(this, StartupActivity.class);
48   - startActivityForResult(i, STARTUP_ACTIVITY);
49   -
50   - This will launch the StartupActivity using the intent, and sets an activity results
51   - identifier. The ``STARTUP_ACTIVITY`` constant is returned in the ``onActivityResult()`` method
52   - after the StartupActivity finishes as shown in the code below.
53   -
54   - private final static int STARTUP_ACTIVITY = 0;
55   -
56   - protected void onActivityResult(int requestCode, int resultCode, Intent data){
57   - super.onActivityResult(requestCode, resultCode, data);
58   - if(requestCode == STARTUP_ACTIVITY && resultCode == RESULT_OK){
59   - //Get the connected Robot
60   - final String robot_id = data.getStringExtra(StartupActivity.EXTRA_ROBOT_ID); // 1
61   - if(robot_id != null && !robot_id.equals("")){
62   - mRobot = RobotProvider.getDefaultProvider().findRobot(robot_id); // 2
63   - }
64   - //Start blinking
65   - blink(false); // 3
66   - }
67   - }
68   -
69   - (1) This line gets an identifier for the robot that was connected returned from the activity.
70   - (2) This line gets a Robot object for the robot identifier which is used to identifier the connected
71   - Sphero in other API calls. (The API supports connection to multiple Spheros.)
72   - (3) This line calls a method that will be used to blink Sphero's LED.
73   -
74   -7. Add code to blink the RGB LED.
75   -
76   - Now it is time to add code that sends a command to Sphero. In this case we will blink the
77   - RGB LED blue. Commands are encapsulated by subclasses of DeviceCommand and message to Sphero using
78   - DeviceMesssenger singleton. For convenience, DeviceCommand subclasses have class `sendCommand()`
79   - methods that will post messages to the DeviceMessenger singleton. Here is the code for the
80   - `blink()` method sends the SetRGBLEDCommand to blink LED.
81   -
82   - private void blink(final boolean lit){
83   -
84   - if(mRobot != null){
85   -
86   - //If not lit, send command to show blue light, or else, send command to show no light
87   - if(lit){
88   - RGBLEDOutputCommand.sendCommand(mRobot, 0, 0, 0); // 1
89   - }else{
90   - RGBLEDOutputCommand.sendCommand(mRobot, 0, 0, 255); // 2
91   - }
92   -
93   - //Send delayed message on a handler to run blink again
94   - final Handler handler = new Handler(); // 3
95   - handler.postDelayed(new Runnable() {
96   - public void run() {
97   - blink(!lit);
98   - }
99   - }, 1000);
100   - }
101   - }
102   -
103   - (1) This line will send a command to turn off the LED. `mRobot` is the Robot object that will receive the command, and last three parameters turn of the red, green, and blue components of the LED. A 0 value for the color component will set the LED components brightness off.
104   - (2) This line will send a command to turn on the blue LED at full brightness. 255 is full brightness, and is only set for the blue component of the LED.
105   - (3) This line creates a Handler that is used to post a delayed call to the `blink()` method after 1 second with the lit parameter inverted, so the next call toggles the LED on or off.
106   -
107   -8. Add to the AndroidManifest.xml file.
108   -
109   - Before running the application, you need to add an activity entry for the StartupActivity to the
110   - AndroidManifest.xml file. For convenience, you can copy this from the RobotUILibrary project's AndroidManifest.xml
111   - file. Add the following,
112   -
113   - <activity android:name="orbotix.robot.app.StartupActivity"
114   - android:theme="@android:style/Theme.Translucent"
115   - android:launchMode="singleTop"/>
116   -
117   - You will need to add permissions to use bluetooth too, so add the following line,
118   -
119   - <uses-permission android:name="android.permission.BLUETOOTH" />
120   -
121   - Also, add `android:launchMode="singleTask"` to the main activity.
122   -
123   -
124   -8. Run on a device.
125   -
126   -9. Changing the RGB LED command to a roll command.
127   -
128   - So, cool you got the LED to blink, but it's a ball that can drive with your Android device. So, how would you do that?
129   - Well, to make it go you send Sphero a RollCommand. RollCommand takes two parameter to make it go. One parameter is a
130   - heading in degrees from 0° to 360° and the other is a speed from 0.0 to 1.0. For example, a heading of 90° at a speed
131   - a speed of 0.5 will tell Sphero to turn clockwise 90° at half speed (1.0 is full speed). Once this command is issued
132   - Sphero will go forever at this heading and speed, so you will need to stop it some how. RollCommand has a `sendStop()`
133   - method for this.
134   -
135   - Now, it's time to modify the code. Let's send Sphero forward at full speed for 2 seconds. So, add the following method
136   - to the main activity.
137   -
138   - private void drive() {
139   - if(mRobot != null) {
140   - // Send a roll command to Sphero so it goes forward at full speed.
141   - RollCommand.sendCommand(mRobot, 0.0f, 1.0f); // 1
142   -
143   - // Send a delayed message on a handler
144   - final Handler handler = new Handler(); // 2
145   - handler.postDelayed(new Runnable() {
146   -
147   - @Override
148   - public void run() {
149   - // Send a stop to Sphero
150   - RollCommand.sendStop(mRobot); // 3
151   - }
152   - }, 2000);
153   -
154   - }
155   - }
156   -
157   - (1) This line sends the heading of 0° and the maximum speed of 1.0 to Sphero.
158   - (2) This line creates the handle that is used to send the delayed stop command.
159   - (3) This line uses the RollCommand to send the stop.
160   -
161   - Next add a call to `drive()` in the `onActivityResult()` below the call to `blink()`.
162   -
163   -10. Run again.
164   -
165   -11. Did you notice... Calibration and the necessity to set the 0° heading.
166   -
167   - Wait a minute did that really go forward. Isn't forward in the direction that I'm facing? Sphero really doesn't know
168   - what forward is to you or your Android device. So, it just picks a arbitrary direction for it's 0° heading. So, you
169   - have to tell it what should be 0°. This process of aiming Sphero is called calibration, and is the subject of the
170   - <!--Insert guide name and a link that covers calibration-->

0 comments on commit e96f97a

Please sign in to comment.
Something went wrong with that request. Please try again.