Upload
vankhanh
View
213
Download
0
Embed Size (px)
Citation preview
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
PraktikPraktikTelebotTelebot systemsystem
Lecturers
Manfred GroveHouxiang Zhang
TAMS, Department of InformaticsUniversity of Hamburg, Germany
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
kum: 4kum: 4 m environmentm environment
@Tams group
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 1
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 2
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Content of today’ s l● Program introduction
● Telebot program environment– Overview
– Example
● Your task
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
ecture
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 3
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Content of today’ s l● Program introduction
● Telebot program environment– Overview
– Example
● Your task
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
ecture
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 4
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
C++ Introduction● Structure of a program● Variables, data types● Constants● Operators
Y t h l i● You can get more help in – http://www.cplusplus.com/doc/tMore online documents● More online documents.– http://tams-www.informatik.uni-
hamburg.de/people/hzhang/projects/Te
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
tutorial/
elerobotDocument/index.htm
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 5
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Structure of a progra
#include <iostream>using namespace std;using namespace std;
int main () { "H ll W ld!" dl{ cout << "Hello World!" << endl;
return 0;}}
Please use g++ compilerPlease use g++ compiler.
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
am
Hello World!
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 6
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Variables & data typ● Global variables● Local variables● Constants● Operators
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
pes// operating with variables #include <iostream> using namespace std; int main (){// declaring variables: int a, b; int result; // process:a = 5; b = 2; a = a + 1;result = a - b; // print out the result: cout << result << endl;;// terminate the program: return 0;}
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 7
}
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Control Structures● If and else● Iteration structures (Loops)
– while loop
– do-while loop
– for loop
● The selective structure: switch
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 8
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Functions● Defining functions and methods● Calling functions and methods
The result is 8
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
// function example#include <iostream> using namespace std;g p ;int addition (int a, int b){
int r; r=a+b; return (r); ; ; ( );}
int main ()t a (){ int z;z = addition (5,3);cout << "The result is " << z << endl;cout The result is z endl; return 0;
}
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 9
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Object-oriented Prog#include <iostream>
● Class ● Object
using namespace std;class CLrect {float x,y;public:public:
CLrect(void);CLrect(float, float);
void set_values(float, float);float area() { return(x*y);};float area() { return(x y);};};
CLrect::CLrect(void)// Konstruktor 1{} // besser z B : x= 0{} // besser z.B.: x= 0
CLrect::CLrect(float a, float b) // Konstruktor 2
{ b }
Fläche: 12Fläche2:24
{ x= a; y= b; }
void CLrect::set_values(float a, float b){ x= a; y= b; }
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
gramming (OOP)
int main(){ CLrect R;
0 0; y= 0 0;
{ CLrect R;CLrect *R2 = new CLrect(3.0, 8.0);R.set_values(3.0, 4.0);cout << "Fläche: " << R.area() << endl;cout << "Fläche2= " << R2 >area() <<endl;0.0; y= 0.0; cout << "Fläche2= " << R2->area() <<endl;return 0; }
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 10
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Content of today’s le● Program introduction
● Telebot program environment– Overview
– Example
● Your task
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
ecture
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 11
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
How to program the ● First build your telebot
● Task description: – If there is an object in front of the
t l b t it If t it t Thtelebot, it moves. If not, it stops. The Robot works without connecting to the GUI.
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
Telebot?
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 12
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Building the mechan
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
nical system
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 13
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Programming the rob#i l d "T l b h" //i#include "Telerobot.h" //impoint main(int argc, char *argv[ ]){
Telerobot *t=new Telerobot; //createTelerobot t new Telerobot; //createt->robotConnect(); // connet->initial(); //initialt->ask(); //gets thwhile (!t->Stop_flag) //check
{ if (!t->Pause_flag) //che{ if (t->getSensor1()) t->mo
//if sens//if senselse t->stop(); //else ro};
t->checkGuiCommand();};
t->missionOver(); //missiot->robotDisconnect(); //discon
}
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
}
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
both T l b h d filort the Telerobot head file
e a telerobot objecte a telerobot objectect the telerobot and your PCization the telerobot
he sensor feedbackif mission shoud be canceledck if mission should be paused
oveForward(90); or1 is true robot moves forward with 90% speedor1 is true robot moves forward with 90% speed
obot stops
on over, buzzer pipes. nnect the telerobot
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 14
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Compiling the progra● Compile your code with g++
– g++ -L. –o destination_file_name co
– or
– g++ -L. –o destination_file_name co
● The API library can be found on th– http://tams-www.informatik.uni-
hamburg.de/people/hzhang/projectsDateien/Page751.htm
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
am
ode_file_name.cpp -lTelerobotLibrary
ode_file_name.cpp Telerobot.cpp
he TAMS web page.
s/TelerobotDocument/index-
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 15
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Correct use of sensor● Task: Move forward until an obst
Wrong !!Wrong !!
…..t->moveForward(50);while (!getSensor1())
…t->wh
while (!getSensor1()) ;
t->stop();……….
//// //t-t-…
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
rs in your programacle is found
CCorrect
…..>moveForward(50);hile (!getSensor1())
t->ask();
or t->moveForward(50);
>stop();>stop();……….
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 16
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Using analogue sens● Sensorchannels 6 and 7 can supp
you connect one of the optical sens
● For every method using digital sensusing analogue sensors on channelusing analogue sensors on channel
F l● For example:Digital: ask() Analogu
i h ( 0)moveRight(50)
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
ors (1)ly analogue values, whensors to them (8 Bit)
sors there is a corresponding method 6 and 76 and 7
ue: ask_Asensor()i h A ( 0) moveRight_Asensor(50)
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 17
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Using analogue sens● You can get the analogue values by
getAnalogueSensor6()and/or
getAnalogueSensor7()
Both return an (unsigned) char (1
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
ors (2)y calling the methods
byte)
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 18
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Writing standalone p● You don’t need MCGUI to run a
● If you are writing a standalone prog
! Delete all calls to checkGuiCommand()
! After creating the telebot-objeg jsetmyoutput(true)
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
programs program using the Telebot.
gram you should
(important !)
ect call the method
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 19
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Testing your soft cod● First check your hardware with CG
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
de with the TelebotGUI application
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 20
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Testing your soft cod
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
de with the Telebot
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 21
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Testing your soft cod● Execute your program on a Linux c
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
de with the Telebotconsole
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 22
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Content of today’s le● Program introduction
● Telebot program environment– Overview
– Example
● Your task
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
ecture
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 23
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Your task ( after a 15● Following a line
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
5-min-break)
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 24
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Execute your code on a Linux console ExecContr
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
ute your code on the MCGUI(Monitor and rol GUI)
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 25
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
How to use MCGUI?● Type in the execute code path● Load● Start the mission● Terminate the mission
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
?
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 26
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Implementation• Building the mechanical system• Programming• Testing
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 27
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Building the mechan
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
nical system
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 28
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Programming the rob
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
bot
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 29
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Do it on yDo it on y
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
your own…your own…
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 30
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
PraktikumPraktikumTelebotTelebot sensorssensors
Lecturers
Houxiang ZhangManfred Grove
TAMS, Department of InformaticsUniversity of Hamburg, Germany
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
m: 5 & 6m: 5 & 6s and actuatorss and actuators
@Tams group
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 31
Technical Aspects of Dept. Informatics, Faculty of Mathemati
University of
Thanks for yo
Any quAny qu
Dr. ZHANG, HouxiangInstitute TAMS Technical Aspects of Multimodal System
Multimodal Systemics, Informatics and Natural Sciencesf Hamburg
our attention!
uestions?uestions?
[email protected] http://tams-www.informatik.uni-hamburg.de/hzhang 32