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

Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Aug 26, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Intel Do-It-Yourself ChallengeRobotics Hello World

Cédric Andreolliwww.Intel-Software-Academic-Program.com

[email protected] Software

2013-02-08

Page 2: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Agenda

Page 3: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Agenda

Introduction

Prerequisites

Working with Eclipse

Conclusion

Page 4: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Introduction

Page 5: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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.

Page 6: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Page 7: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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

Page 8: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Prepare your Ubuntu

We 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

Page 9: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Prepare your Ubuntu

Install libusb by typing the following command in a terminal.

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

Page 10: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Get Eclipse

Download Eclipse for Java Developpers

Uncompress the file and Eclipse is ready!

Page 11: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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

Page 12: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Install Phidget drivers

In 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

Page 13: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Check that it works

On 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

Page 14: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Check that it works

Go 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...

Page 15: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Check that it works

In 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

Page 16: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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#

Page 17: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Get the Java Library

Our 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

Page 18: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Prerequisites

Get the Java Library

Download the jar file:

You are now ready for controlling the device in Java.

Page 19: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Working with Eclipse

Page 20: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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.

Page 21: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Working with Eclipse

Set your project's name

Name your project Hello World and click on Finish

Page 22: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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”

Page 23: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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

Page 24: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Working with Eclipse

Modify the classpath

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

Page 25: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Working with Eclipse

Modify the classpath

Click on Add Jars... and select the library.

Then click on OK

Page 26: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Working with Eclipse

Create a class

Click on src → New → Class

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

Page 27: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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.

Page 28: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Working with Eclipse

In the main function

Include all the packages requested by Eclipse.

Page 29: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Working with Eclipse

Let's write startMotor

Include all the packages requested by Eclipse.

Page 30: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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.

Page 31: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

Conclusion

Page 32: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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.

Page 33: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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.

Page 34: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld
Page 35: Intel Do-It-Yourself Challenge Robotics Hello World · Compile the Hello World: Then test your program: intel#cd phidget21-c-examples-2.1.8.20130320/ intel#gcc HelloWorld.c -o HelloWorld

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/