mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-04 04:14:58 +00:00
changed comments to english
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
//#pragma once
|
//#pragma once
|
||||||
////*************************************************************************************
|
////*************************************************************************************
|
||||||
////*************************************************************************************
|
////*************************************************************************************
|
||||||
//// autor Martin Dekan a Peter Beno mail: dekdekan@gmail.com, peter.beno@stuba.sk
|
//// author Martin Dekan and Peter Beno mail: dekdekan@gmail.com, peter.beno@stuba.sk
|
||||||
////-------------------------------------------------------------------------------------
|
////-------------------------------------------------------------------------------------
|
||||||
//// co to je:
|
//// what it is:
|
||||||
//// trieda na pracu s robotom kobuki. mala by mat implementovane citanie dat
|
//// class for working with the kobuki robot. it should have implemented data reading
|
||||||
//// a posielanie prikazov...
|
//// and sending commands...
|
||||||
//// neobsahuje ziadnu logiku co s datami robit, to je na userovi aby spravil v callback funkcii
|
//// it does not contain any logic on what to do with the data, it is up to the user to do it in the callback function
|
||||||
// jedna sa vlastne len o implementaciu komunikacie s hardwareom, driver
|
//// it is basically just an implementation of communication with the hardware, driver
|
||||||
////*************************************************************************************
|
////*************************************************************************************
|
||||||
////*************************************************************************************
|
////*************************************************************************************
|
||||||
#ifndef KOBUKI_CLASS_123456789
|
#ifndef KOBUKI_CLASS_123456789
|
||||||
@@ -67,9 +67,9 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
//---zakladny balik
|
//---basic package
|
||||||
unsigned short timestamp;
|
unsigned short timestamp;
|
||||||
//narazniky
|
//bumpers
|
||||||
bool BumperLeft;
|
bool BumperLeft;
|
||||||
bool BumperCenter;
|
bool BumperCenter;
|
||||||
bool BumperRight;
|
bool BumperRight;
|
||||||
@@ -77,17 +77,17 @@ typedef struct
|
|||||||
bool CliffLeft;
|
bool CliffLeft;
|
||||||
bool CliffCenter;
|
bool CliffCenter;
|
||||||
bool CliffRight;
|
bool CliffRight;
|
||||||
// padnutie kolies
|
// wheel drop
|
||||||
bool WheelDropLeft;
|
bool WheelDropLeft;
|
||||||
bool WheelDropRight;
|
bool WheelDropRight;
|
||||||
//tocenie kolies
|
//wheel rotation
|
||||||
unsigned short EncoderRight;
|
unsigned short EncoderRight;
|
||||||
unsigned short EncoderLeft;
|
unsigned short EncoderLeft;
|
||||||
unsigned char PWMright;
|
unsigned char PWMright;
|
||||||
unsigned char PWMleft;
|
unsigned char PWMleft;
|
||||||
//gombiky
|
//buttons
|
||||||
unsigned char ButtonPress;// 0 nie, 1 2 4 pre button 0 1 2 (7 je ze vsetky tri)
|
unsigned char ButtonPress;// 0 no, 1 2 4 for button 0 1 2 (7 is all three)
|
||||||
//napajanie
|
//power
|
||||||
unsigned char Charger;
|
unsigned char Charger;
|
||||||
unsigned char Battery;
|
unsigned char Battery;
|
||||||
unsigned char overCurrent;
|
unsigned char overCurrent;
|
||||||
@@ -114,7 +114,7 @@ typedef struct
|
|||||||
unsigned short analogInputCh1;
|
unsigned short analogInputCh1;
|
||||||
unsigned short analogInputCh2;
|
unsigned short analogInputCh2;
|
||||||
unsigned short analogInputCh3;
|
unsigned short analogInputCh3;
|
||||||
//---struktura s datami ktore sa nam tam objavia iba na poziadanie
|
//---structure with data that appears only on request
|
||||||
TExtraRequestData extraInfo;
|
TExtraRequestData extraInfo;
|
||||||
}TKobukiData;
|
}TKobukiData;
|
||||||
|
|
||||||
@@ -127,11 +127,11 @@ public:
|
|||||||
CKobuki() {
|
CKobuki() {
|
||||||
stopVlakno = 0;
|
stopVlakno = 0;
|
||||||
std::cout << "kobuki instantiated" << std::endl;
|
std::cout << "kobuki instantiated" << std::endl;
|
||||||
odometry_log.open("odometry.txt");
|
odometry_log.open("odometry.txt");
|
||||||
};
|
};
|
||||||
virtual ~CKobuki() {
|
virtual ~CKobuki() {
|
||||||
stopVlakno = 1;
|
stopVlakno = 1;
|
||||||
close(HCom);
|
close(HCom);
|
||||||
pthread_cancel(threadHandle);
|
pthread_cancel(threadHandle);
|
||||||
odometry_log.close();
|
odometry_log.close();
|
||||||
};
|
};
|
||||||
@@ -144,8 +144,8 @@ public:
|
|||||||
long loop(void *user_data, TKobukiData &Kobuki_data);
|
long loop(void *user_data, TKobukiData &Kobuki_data);
|
||||||
|
|
||||||
void startCommunication(char *portname,bool CommandsEnabled,void *userDataL);
|
void startCommunication(char *portname,bool CommandsEnabled,void *userDataL);
|
||||||
int measure(); //vlaknova funkcia, ma v sebe nekonecne vlakno a vycitava udaje
|
int measure(); //thread function, contains an infinite loop and reads data
|
||||||
void setLed(int led1 = 0, int led2 = 0); //led1 zelena/cervena 2/1, //led2 zelena/cervena 2/1
|
void setLed(int led1 = 0, int led2 = 0); //led1 green/red 2/1, //led2 green/red 2/1
|
||||||
void setTranslationSpeed(int mmpersec);
|
void setTranslationSpeed(int mmpersec);
|
||||||
void setRotationSpeed(double radpersec);
|
void setRotationSpeed(double radpersec);
|
||||||
void setArcSpeed(int mmpersec,int radius);
|
void setArcSpeed(int mmpersec,int radius);
|
||||||
@@ -162,11 +162,10 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int HCom;
|
int HCom;
|
||||||
pthread_t threadHandle; // handle na vlakno
|
pthread_t threadHandle; // handle to the thread
|
||||||
int threadID; // id vlakna
|
int threadID; // thread id
|
||||||
int stopVlakno;
|
int stopVlakno;
|
||||||
src_callback_kobuki_data callbackFunction;
|
src_callback_kobuki_data callbackFunction;
|
||||||
void *userData;
|
void *userData;
|
||||||
@@ -176,12 +175,12 @@ private:
|
|||||||
unsigned char *readKobukiMessage();
|
unsigned char *readKobukiMessage();
|
||||||
int checkChecksum(unsigned char *data);
|
int checkChecksum(unsigned char *data);
|
||||||
|
|
||||||
//--spustenie merania v novom vlakne (vycitavanie bezi v novom vlakne. treba ho stopnut ak chceme poslat request)
|
//--start measurement in a new thread (reading runs in a new thread. it needs to be stopped if we want to send a request)
|
||||||
static void * KobukiProcess(void *param)
|
static void * KobukiProcess(void *param)
|
||||||
{
|
{
|
||||||
//std::cout << "Nase vlakno Kobuki process nastartovalo" << std::endl;
|
//std::cout << "Our thread Kobuki process started" << std::endl;
|
||||||
CKobuki *hoku = (CKobuki*)param;
|
CKobuki *hoku = (CKobuki*)param;
|
||||||
int vystup = hoku->measure();
|
int output = hoku->measure();
|
||||||
|
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
@@ -208,16 +207,16 @@ private:
|
|||||||
// utilities
|
// utilities
|
||||||
long double gyroToRad(signed short GyroAngle);
|
long double gyroToRad(signed short GyroAngle);
|
||||||
|
|
||||||
// plot p;
|
// plot p;
|
||||||
std::vector<float> vectorX;
|
std::vector<float> vectorX;
|
||||||
std::vector<float> vectorY;
|
std::vector<float> vectorY;
|
||||||
std::vector<float> vectorGyroTheta;
|
std::vector<float> vectorGyroTheta;
|
||||||
|
|
||||||
|
|
||||||
double displacement = 0;
|
double displacement = 0;
|
||||||
double integratedGyroTheta = 0;
|
double integratedGyroTheta = 0;
|
||||||
double gx = 0;
|
double gx = 0;
|
||||||
double gy = 0;
|
double gy = 0;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user