35
Intel Do-It-Yourself Challenge Robotics Hello World Cédric Andreolli www.Intel-Software-Academic-Program.com [email protected] Intel Software 2013-02-08

IntelAcademic DIY 02 HelloWorld

Embed Size (px)

Citation preview

  • Intel Do-It-Yourself ChallengeRobotics Hello World

    Cdric Andreolliwww.Intel-Software-Academic-Program.com

    [email protected] 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 UbuntuWe are going to use Eclipse, our first program will be in Java.Open a terminal and run the command:

    This command will install the JDK (Java Development Kit)

    Intel:~/Downloads$ sudo apt-get install openjdk-7-jdk

  • Prerequisites

    Prepare your UbuntuInstall libusb by typing the following command in a terminal.

    Intel:~/Downloads$ sudo apt-get install libusb-dev

  • Prerequisites

    Get EclipseDownload Eclipse for Java Developpers

    Uncompress the file and Eclipse is ready!

  • Prerequisites

    Install Phidget driversOn 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 driversIn the terminal, retrieve the zip and uncompress it.

    Use ./configure, make and make install to install the driver.

    intel:~/Downloads#cp libphidget_2.1.8.20130320.tar.gz ~/Applicationsintel:~/Downloads#cd ~/Applications/intel:~/Applications#tar xvfz libphidget_2.1.8.20130320.tar.gzintel:~/Applications#cd libphidget-2.1.8.20130320

    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 worksOn http://www.phidgets.com/docs/OS_-_Linux download the Phidget Generic C Examples.

    In the terminal, uncompress the fileintel:~/Downloads#tar xfvz phidget21-c-examples_2.1.8.20130320.tar.gz

  • Prerequisites

    Check that it worksGo in the examples directory:

    Compile the Hello World:

    Then test your program:

    intel#cd phidget21-c-examples-2.1.8.20130320/

    intel#gcc HelloWorld.c -o HelloWorld -lphidget21

    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 worksIn the output, you should see a line that describe your plugged device.

    Sometimes, you need to unplug and plug the device on another USB slot.

    Hello Device Phidget Advanced Servo Controller 8-motor, Serial Number: 177940

  • Prerequisites

    Add udev rulesUsing 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 LibraryOur native library can be called in Java. But we need to download the jar first. Go onhttp://www.phidgets.com/docs/Programming_Resources

    Download the files for Java

  • Prerequisites

    Get the Java LibraryDownload the jar file:

    You are now ready for controlling the device in Java.

  • Working with Eclipse

  • Working with Eclipse

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

  • Working with Eclipse

    Set your project's nameName your project Hello World and click on Finish

  • Working with Eclipse

    Create a folder for the libraryYou 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 libYou 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 classpathIn Eclipse, right-click on the project, select Properties, then click on Java Build Path and finally Libraries.

  • Working with Eclipse

    Modify the classpathClick on Add Jars... and select the library.

    Then click on OK

  • Working with Eclipse

    Create a classClick on src New Class

    Create the main method by checking: public static void main(String[] args)

  • Working with Eclipse

    Plugin a motor on the cardThe 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 projectIf 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 easyAs 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 easyWe need few lines of code to command the servos.Eclipse make the development easier.Samples availableThe 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/

    Slide 1Slide 2Slide 3Slide 4Slide 5Slide 6Slide 7Slide 8Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Slide 34Slide 35