mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-05 12:54:57 +00:00
Compare commits
13 Commits
ec3e83ef7f
...
b86528595e
Author | SHA1 | Date | |
---|---|---|---|
b86528595e | |||
eef4f9c79c | |||
3c23d37be1 | |||
c2886d32c9 | |||
8158c85d6e | |||
e682969ec8 | |||
0dfc3b5c13 | |||
7f786d5197 | |||
60ba177dc2 | |||
e9f998b3e7 | |||
7eeaba482e | |||
e8db00120f | |||
c65f310e81 |
@@ -30,9 +30,6 @@ void setup()
|
||||
|
||||
int main()
|
||||
{
|
||||
// Unset the http_proxy environment variable
|
||||
|
||||
|
||||
setup();
|
||||
std::thread image (CapnSend);
|
||||
std::thread safety([&]() { robot.robotSafety(&message); });
|
||||
@@ -41,6 +38,7 @@ int main()
|
||||
while(true){
|
||||
parseMQTT(readMQTT());
|
||||
}
|
||||
|
||||
sendMqtt.join();
|
||||
safety.join();
|
||||
image.join();
|
||||
@@ -63,7 +61,7 @@ void parseMQTT(std::string message)
|
||||
{
|
||||
if (message == "up")
|
||||
{
|
||||
robot.forward(1024);
|
||||
robot.forward(350);
|
||||
}
|
||||
else if (message == "left")
|
||||
{
|
||||
@@ -75,7 +73,7 @@ void parseMQTT(std::string message)
|
||||
}
|
||||
else if (message == "down")
|
||||
{
|
||||
robot.forward(-800);
|
||||
robot.forward(-350);
|
||||
}
|
||||
else if (message == "stop")
|
||||
{
|
||||
@@ -283,9 +281,8 @@ void sendKobukiData(TKobukiData &data) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CapnSend() {
|
||||
VideoCapture cap(1); // Open the default camera
|
||||
VideoCapture cap("/dev/media3");
|
||||
if (!cap.isOpened()) {
|
||||
cerr << "Error: Could not open camera" << endl;
|
||||
return;
|
||||
@@ -305,8 +302,9 @@ void CapnSend() {
|
||||
auto* enc_msg = reinterpret_cast<unsigned char*>(buf.data());
|
||||
|
||||
// Publish the image data
|
||||
client.publishMessage("kobuki/cam-", string(enc_msg, enc_msg + buf.size()));
|
||||
client.publishMessage("kobuki/cam", string(enc_msg, enc_msg + buf.size()));
|
||||
cout << "Sent image" << endl;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(400)); // Send image every 1000ms
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // Send image every 1000ms
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user