#include "Telerobot.h" //import the Telerobot head file

 

int main(int argc, char *argv[])

{

Telerobot *t=new Telerobot; //create a telerobot object

t->robotConnect(); // connect the telerobot and your PC

t->initial(); //initialization the telerobot

t->ask();//gets the sensor feedback

 

while(t->Stop_flag==false) //check if mission shoud be canceled

{ if(t->Pause_flag==false) //check if mission should be paused

 {

 if(t->getSensor1()==true) t->moveForward(90); //if sensor1 is true

                                          robot moves forward with 90% speed

      else t->stop(); //else robot stops

      }

}

t->missionOver(); //mission over, buzzer pipes.

t->robotDisconnect(); //disconnect the telerobot

}

Tutorial: The first “hello world” program

Choose the system components for your first robot. You need:

1. Control unit.

2. Infrared sensor

3. Movement platform

4. Rear wheel

5. Lego brick

 Install the Movement platform and the rear wheel.

 

Install the infrared sensor and connect it to sensor channel 1.

“Hello world”.   This example teaches a user how to get standard of the telerobot system, how to build the robot hardware and how to write the task program. Although it is quite simple, this task shows all the solution phases of the task.

Task description: If there is an object in front of the telerobot, it moves. Else it stops. Robot works without connecting to GUI.

 

The task suggestion: pleas use an infrared sensor to detect if there is an object in front of it. Build a movement platform with two PWM motors and use it to control the robot movement.

I. Build the robot hardware

 Install the Movement platform and the rear wheel.

 

Build your movement platform:

 

 II. write the task program and save it as my_first_program.cpp

You can download this program form here…

Compile the program: with the following command in Linux console

 

g++ -L. –o my_first_program my_first_program.cpp –lTelerobotLibrary

 

III. Test the system before task begin.

 

Please type the command “CGUI” in Linux console to open the CGUI application.

For more information about CGUI, please read CGUI page.

 

Please turn on the telerobot.

Check the inputs channel. Put your hand in front of the sensor.  If sensor detects the object in front of it, the corresponding number of the input channel will be shown on the sensor field of the CGUI.

Check the outputs channel. Move the PWM2 slider, the left wheel will rotate. The speed of the rotation is adjustable through the slider.

 

 

IV. Test your program.

Execute your application through the Linux console and put your hand in front of the infrared sensor.

API

Logo der Universität Hamburg