You are on page 1of 35

Intel Do-It-Yourself Challenge

Robotics Hello World


Cdric Andreolli
www.Intel-Software-Academic-Program.com
paul.guermonprez@intel.com
Intel Software
2013-02-08

Agenda

Agenda
Introduction
Prerequisites
Working with Eclipse
Conclusion

Introduction

Introduction
Robotic can be very fun and exiting but you
might think that it's very difficult to start!
... YOU ARE WRONG
This course will present you some cheap
devices that you can use.
We will also explain how to configure your
development environment.

Prerequisites

Prerequisites
For this first course, you will need :

An computer with USB 2.0

Ubuntu 12.04 installed

A Phidget controller in this course, we recommand


you to use the Phidget Advanced Servo

Prerequisites
Prepare your Ubuntu
We are going to use Eclipse, our first program
will be in Java.
Open a terminal and run the command:
Intel:~/Downloads$ sudo apt-get install openjdk-7-jdk

This command will install the JDK (Java


Development Kit)

Prerequisites
Prepare your Ubuntu
Install libusb by typing the following command
in a terminal.
Intel:~/Downloads$ sudo apt-get install libusb-dev

Prerequisites
Get Eclipse
Download Eclipse for Java Developpers

Uncompress the file and Eclipse is ready!

Prerequisites
Install Phidget drivers
On http://www.phidgets.com go on the Drivers
page and download the drivers for your
Ubuntu version (x86 or x64)

And then

Prerequisites
Install Phidget drivers
In the terminal, retrieve the zip and
uncompress it.
intel:~/Downloads#cp libphidget_2.1.8.20130320.tar.gz ~/Applications
intel:~/Downloads#cd ~/Applications/
intel:~/Applications#tar xvfz libphidget_2.1.8.20130320.tar.gz
intel:~/Applications#cd libphidget-2.1.8.20130320

Use ./configure, make and make install to


install the driver.
intel:~/Applications/libphidget-2.1.8.20130320#sudo ./configure
intel:~/Applications/libphidget-2.1.8.20130320#sudo make
intel:~/Applications/libphidget-2.1.8.20130320#sudo make install

Prerequisites
Check that it works
On http://www.phidgets.com/docs/OS_-_Linux
download the Phidget Generic C Examples.

In the terminal, uncompress the file


intel:~/Downloads#tar xfvz phidget21-c-examples_2.1.8.20130320.tar.gz

Prerequisites
Check that it works
Go in the examples directory:
intel#cd phidget21-c-examples-2.1.8.20130320/

Compile the Hello World:


intel#gcc HelloWorld.c -o HelloWorld -lphidget21

Then test your program:


Intel#sudo ./HelloWorld
Opening...
Phidget Simple Playground (plug and unplug devices)
Press Enter to end anytime...
Hello Device Phidget Advanced Servo Controller 8-motor,
Serial Number: 177940
Closing...

Prerequisites
Check that it works
In the output, you should see a line that
describe your plugged device.
Hello Device Phidget Advanced Servo Controller 8-motor,
Serial Number: 177940

Sometimes, you need to unplug and plug the


device on another USB slot.

Prerequisites
Add udev rules
Using the command sudo can be complicated
(if you run your application in Eclipse for
example). To get ride of sudo, in the terminal,
type:
intel:~#cd Applications/libphidget-2.1.8.20130320/
intel:~/Applications/libphidget-2.1.8.20130320#sudo cp udev/99-phidgets.rules /etc/
udev/rules.d
[sudo] password for intel:
intel:~/Applications/libphidget-2.1.8.20130320#

Prerequisites
Get the Java Library
Our native library can be called in Java. But
we need to download the jar first. Go on
http://www.phidgets.com/docs/Programming_Resources

Download the files for Java

Prerequisites
Get the Java Library
Download the jar file:

You are now ready for controlling the device in


Java.

Working with Eclipse

Working with Eclipse


Open Eclipse
If open-jdk is correctly installed, you should
have any problem with running Eclipse.
Create a new Java Project
Click on File New Project... and select
Java Project.

Working with Eclipse


Set your project's name
Name your project Hello
World and click on
Finish

Working with Eclipse


Create a folder for the library
You can create a folder for your library. Right
click on your project and then New Folder.
You can name this folder lib

Working with Eclipse


Put the jar file in lib
You remember the jar file that we download
few steps ago ?
you can put it in the lib folder

In Eclipse, click select your project


and press F5

Working with Eclipse


Modify the classpath
In Eclipse, right-click on the project, select
Properties, then click on Java Build Path
and finally Libraries.

Working with Eclipse


Modify the classpath
Click on Add Jars... and select the library.
Then click on OK

Working with Eclipse


Create a class
Click on src New Class
Create the main method
by checking:
public static void main(String[] args)

Working with Eclipse


Plugin a motor on the card
The card must be powered, plugged to the
computer (USB) and a motor must be plugged
on the slot 0.

Working with Eclipse


In the main function

Include all the packages requested


by Eclipse.

Working with Eclipse


Let's write startMotor

Include all the packages requested


by Eclipse.

Working with Eclipse


Run the project
If your card is correctly detected and that udev
authorization are well set, the motor plugged
to the card should move.
If you have any problem, check your
installation.

Conclusion

Conclusion
Installation is easy
As you can see, the installation on Linux is
straight forward.
You only need to install the Phidget drivers to
make it work.
Phidget also provides small test applications
that can help you check your installation.

Conclusion
Using the card is easy
We need few lines of code to command the
servos.
Eclipse make the development easier.
Samples available
The samples that we used in this course are
available on
www.intel-software-academic-program.com .

License Creative Commons - By 3.0


You are free:
to Share to copy, distribute and transmit the work
to Remix to adapt the work
to make commercial use of the work
Under the following conditions:
Attribution You must attribute the work in the manner specified by the author or licensor (but not in
any way that suggests that they endorse you or your use of the work).
With the understanding that:
Waiver Any of the above conditions can be waived if you get permission from the copyright holder.
Public Domain Where the work or any of its elements is in the public domain under applicable law,
that status is in no way affected by the license.
Other Rights In no way are any of the following rights affected by the license:
Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations;
The author's moral rights;
Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights.

Notice For any reuse or distribution, you must make clear to others the license terms of this work.
The best way to do this is with a link to this web page.
http://creativecommons.org/licenses/by/3.0/

You might also like