mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
made it so we can read indiviual buttons
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
#include "KobukiParser.h"
|
||||
#include <iostream>
|
||||
//checkedValue const maken
|
||||
//bitwise operators nachecken met website van kobuki serial website
|
||||
//cliffsensor kan rauwe getallen zijn
|
||||
//moet checkenvalue gebruiken of moet kijken naar de payloadlength welke dingen er extra zijn
|
||||
int KobukiParser::parseKobukiMessage(TKobukiData &output, unsigned char *data) {
|
||||
int rtrnvalue = checkChecksum(data);
|
||||
if (rtrnvalue != 0) {
|
||||
@@ -127,7 +125,9 @@ void KobukiParser::parseBasicData(TKobukiData &output, unsigned char *data, int
|
||||
checkedValue++;
|
||||
output.PWMright = data[checkedValue];
|
||||
checkedValue++;
|
||||
output.ButtonPress = data[checkedValue];
|
||||
output.ButtonPress1 = data[checkedValue] & 0x01;
|
||||
output.ButtonPress2 = data[checkedValue] & 0x02;
|
||||
output.ButtonPress3 = data[checkedValue] & 0x04;
|
||||
checkedValue++;
|
||||
output.Charger = data[checkedValue];
|
||||
checkedValue++;
|
||||
|
@@ -19,7 +19,8 @@ struct TKobukiData {
|
||||
int CliffCenter, CliffLeft, CliffRight;
|
||||
int EncoderLeft, EncoderRight;
|
||||
int PWMleft, PWMright;
|
||||
int ButtonPress, Charger, Battery, overCurrent;
|
||||
int ButtonPress1, ButtonPress2, ButtonPress3;
|
||||
int Charger, Battery, overCurrent;
|
||||
int IRSensorRight, IRSensorCenter, IRSensorLeft;
|
||||
int GyroAngle, GyroAngleRate;
|
||||
int CliffSensorRight, CliffSensorCenter, CliffSensorLeft;
|
||||
|
@@ -15,11 +15,12 @@ int main()
|
||||
unsigned char *null_ptr(0);
|
||||
robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
|
||||
|
||||
std::thread safety([&robot]() { robot.robotSafety(); }); // use a lambda function to call the member function
|
||||
std::thread safety([&robot]()
|
||||
{ robot.robotSafety(); }); // use a lambda function to call the member function
|
||||
safety.detach();
|
||||
|
||||
thread movementThread(movement);
|
||||
movementThread.join(); //so the program doesnt quit
|
||||
movementThread.join(); // so the program doesnt quit
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -42,7 +43,6 @@ int movement()
|
||||
if (text == 1)
|
||||
{
|
||||
robot.forward(400);
|
||||
|
||||
}
|
||||
else if (text == 2)
|
||||
{
|
||||
@@ -98,7 +98,9 @@ void logToFile()
|
||||
outputFile << "EncoderRight: " << robotData.EncoderRight << "\n";
|
||||
outputFile << "PWMleft: " << robotData.PWMleft << "\n";
|
||||
outputFile << "PWMright: " << robotData.PWMright << "\n";
|
||||
outputFile << "ButtonPress: " << robotData.ButtonPress << "\n";
|
||||
outputFile << "ButtonPress: " << robotData.ButtonPress1 << "\n";
|
||||
outputFile << "ButtonPress: " << robotData.ButtonPress2 << "\n";
|
||||
outputFile << "ButtonPress: " << robotData.ButtonPress3 << "\n";
|
||||
outputFile << "Charger: " << robotData.Charger << "\n";
|
||||
outputFile << "Battery: " << robotData.Battery << "\n";
|
||||
outputFile << "overCurrent: " << robotData.overCurrent << "\n";
|
||||
|
Reference in New Issue
Block a user