commentaar naar engels

This commit is contained in:
ishak jmilou.ishak
2025-01-06 09:53:01 +01:00
parent b29a615681
commit bb1904b125

View File

@@ -68,7 +68,7 @@ int CKobuki::connect(char *comportT) {
HCom = open(comportT, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (HCom == -1) {
printf("Kobuki nepripojeny\n");
printf("Kobuki connected\n");
return HCom;
} else {
set_interface_attribs2(HCom, B115200,
@@ -89,7 +89,7 @@ int CKobuki::connect(char *comportT) {
tcsetattr(HCom, TCSANOW, &settings); // apply the settings*/
tcflush(HCom, TCOFLUSH);
printf("Kobuki pripojeny\n");
printf("Kobuki connected\n");
return HCom;
}
}
@@ -99,27 +99,26 @@ unsigned char *CKobuki::readKobukiMessage() {
ssize_t Pocet;
buffer[0] = 0;
unsigned char *null_buffer(0);
// citame kym nezachytime zaciatok spravy
// Read until the start of the message is detected
do {
Pocet = read(HCom, buffer, 1);
} while (buffer[0] != 0xAA);
// mame zaciatok spravy (asi)
// We have the start of the message (possibly)
if (Pocet == 1 && buffer[0] == 0xAA) {
// citame dalsi byte
// Read the next byte
do {
Pocet = read(HCom, buffer, 1);
} while (Pocet != 1); // On Linux: -1, on Windows: 0
} while (Pocet != 1); // na linuxe -1 na windowse 0
// a ak je to druhy byte hlavicky
// If it is the second byte of the header
if (Pocet == 1 && buffer[0] == 0x55) {
// precitame dlzku
// Read the length
Pocet = read(HCom, buffer, 1);
// ReadFile(hCom, buffer, 1, &Pocet, NULL);
if (Pocet == 1) {
// mame dlzku.. nastavime vektor a precitame ho cely
// We have the length; initialize a buffer and read the entire message
int readLenght = buffer[0];
unsigned char *outputBuffer =
(unsigned char *)calloc(readLenght + 4, sizeof(char));
@@ -134,7 +133,7 @@ unsigned char *CKobuki::readKobukiMessage() {
pct = pct + (Pocet == -1 ? 0 : Pocet);
} while (pct != (readLenght + 1));
// tu si mozeme ceknut co chodi zo serial intefejsu Kobukiho
// Here we can check what data is received from the Kobuki's serial interface
// for(int i=0;i<outputBuffer[0]+2;i++)
// {
// printf("%x ",outputBuffer[i]);
@@ -162,8 +161,8 @@ void CKobuki::setLed(int led1, int led2) {
pocet = write(HCom, &message, 8);
}
// tato funkcia nema moc sama o sebe vyznam, payload o tom, ze maju byt externe
// napajania aktivne musi byt aj tak v kazdej sprave...
// this function doesn't have much meaning by itself, the payload about them being external
// power supplies must be active in every message anyway...
void CKobuki::setPower(int value) {
if (value == 1) {
unsigned char message[8] = {0xaa, 0x55, 0x04, 0x0C, 0x02, 0xf0, 0x00, 0xAF};
@@ -267,13 +266,13 @@ int CKobuki::measure() {
while (stopVlakno == 0) {
unsigned char *message = readKobukiMessage();
if (message == NULL) {
// printf("vratil null message\n");
continue;
// printf("returned null message\n");
continue;
}
int ok = parser.parseKobukiMessage(parser.data, message);
// maximalne moze trvat callback funkcia 20 ms, ak by trvala viac, nestihame
// citat
// the maximum callback function can take 20 ms, if it takes longer, we won't be able to do it
// read
if (ok == 0) {
loop(userData, parser.data);
}
@@ -353,7 +352,7 @@ long CKobuki::loop(void *user_data, TKobukiData &Kobuki_data) {
totalLeft += dLeft;
totalRight += dRight;
// ak je suma novej a predchadzajucej vacsia ako 65536 tak to pretieklo?
// if the sum of the new and previous is greater than 65536 then it overflowed?
directionL = (prevLeftEncoder < Kobuki_data.EncoderLeft ? 1 : -1);
directionR = (prevRightEncoder < Kobuki_data.EncoderRight ? 1 : -1);
dTimestamp = (Kobuki_data.timestamp < prevTimestamp
@@ -387,7 +386,7 @@ long CKobuki::loop(void *user_data, TKobukiData &Kobuki_data) {
// tells the kobuki to go a few meters forward or backward, the sign decides
// the function compensates for walking straight with the controller, internally
// it uses setArcSpeed and uses encoder data as feedback
// it uses setArcSpeed and uses encoder data as feedback
void CKobuki::goStraight(long double distance) {
long double u_translation =
0; // controlled magnitude, speed of the robot in motion