logo

Général

Accueil

Présentation section

Matériel section

Trombinoscopes

Liens

Plan du site

Contactez-nous

SN 1

Aide spécifique Java

TP C++ Arduino

Les TP réseau Linux

Les TD Java

Les TP Java

TD C#

TP C#

Les Mini-projets

Stage en entreprise

IRIS 2

TP IPC linux / coldFire

TP PHP

Cours / TP XML

Projets

Cours

SN 1

IRIS 2

Statistiques

3 visiteurs

Record : 92

Pages vues :

Aujourd'hui : 53

Total : 172013

Valid XHTML 1.0 Transitional

separation

[Vous êtes ici ] ==> Accueil > Général > Matériel section > Robot WiFiBot > Commande du robot

separation

Generic solution to control the WIFIBOT with an external PC :
You need to create 2 threads, one for sending commands and the other for receiving.
For that you need to create a TCP/IP socket connecting to the WIFIBOT IP(192.168.0.230) with port 15000.
So to communicate with the WIFIBOT you need just to receive “buf2” and to send “buf” :

unsigned char buf[2], buf2[7];

There is the details of the communication :
Sending commands :

buf[0]=(unsigned char)(comg);//left motor board command
buf[1]=(unsigned char)(comd);//right motor board command

“comg” and “comd” is generated depending of the way we want the robot to move :
buffer

Receiving sensors values :
Example using C++ and MFC sockets :
Class : “MyClass” :

Exported from Notepad++
void InitSocket(void); void Close(void); Thread_Send(); Thread_Receive(); /* UINT Thread_Send (LPVOID p) UINT Thread_Receive (LPVOID p) */ CAsyncSocket so;//MFC socket bool running, running2 ; //to end the Thread Cstring ip;robot ip int port;//robot port unsigned char buf[2], buf2[7]; //send receive buffer unsigned char comg, comd; //motor board command void MyClass::InitSocket(void) { so.Create(); int status = so.Connect(ip,porttemp); running=true; running2=true; AfxBeginThread(Thread_Receive,this); AfxBeginThread(Thread_Send,this); } void MyClass::Close(void) { running2=false; running=false; so.Close(); } void MyClass::Thread_Send(void) { while(running) { buf[0]=(unsigned char)(comg);//left motor board command buf[1]=(unsigned char)(comd);//right motor board command so.Send(&buf, 2, 0); Sleep(60); //16 Hz } } UINT MyClass::Thread_Send (LPVOID p) { MyClass *me = (MyClass *)p; me-> Thread_Send (); return 0; } void MyClass::Thread_Receive(void) { while(running2) { int rcvnbr=so.Receive(&buf2,7,0); if (rcvnbr==7) { //Do what you want with the buffer } } } UINT MyClass::Thread_Receive (LPVOID p) { MyClass *me = (MyClass *)p; me-> Thread_Receive (); return 0; }

separation

ancre