logo

Général

Accueil

Présentation section

Matériel section

Trombinoscopes

Liens

Plan du site

Contactez-nous

CIEL 1

Langage C

Langage C++

Langage C#

Linux sur Raspberry

TP Arduino

UML/SysML

Mini-projets

Math

CIEL 2

UML

Rasberry

Système Num. 1

TP C Visual Studio

TP C++ Arduino

Aide spécifique Java

TP C/C++ MyRIO

TP Darwin-Op

Les TP réseau Linux

Les TD Java

Les TP Java

TD C#

TP C#

Les Mini-projets

Vidéo Mini-Projet

Stage en entreprise

Système Num. 2

TP C++/C#

RaspBerry

Projets

IRIS 2

TP IPC linux / coldFire

TP PHP

Cours / TP XML

Projets

S SI

1er S SI

1er SSI mini projet

1er S SI Liens

STI2D

SysML

Terminale SIN

Projet SIN

1er ETT

Projet 1er ETT

Terminale ETT

Questions BAC ETT

AP

Serfa

UML

C++

Statistiques

3 visiteurs

Record : 207

Pages vues :

Aujourd'hui : 101

Total : 226392

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