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()
|
int main()
|
||||||
{
|
{
|
||||||
// Unset the http_proxy environment variable
|
|
||||||
|
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
std::thread image (CapnSend);
|
std::thread image (CapnSend);
|
||||||
std::thread safety([&]() { robot.robotSafety(&message); });
|
std::thread safety([&]() { robot.robotSafety(&message); });
|
||||||
@@ -41,6 +38,7 @@ int main()
|
|||||||
while(true){
|
while(true){
|
||||||
parseMQTT(readMQTT());
|
parseMQTT(readMQTT());
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMqtt.join();
|
sendMqtt.join();
|
||||||
safety.join();
|
safety.join();
|
||||||
image.join();
|
image.join();
|
||||||
@@ -63,7 +61,7 @@ void parseMQTT(std::string message)
|
|||||||
{
|
{
|
||||||
if (message == "up")
|
if (message == "up")
|
||||||
{
|
{
|
||||||
robot.forward(1024);
|
robot.forward(350);
|
||||||
}
|
}
|
||||||
else if (message == "left")
|
else if (message == "left")
|
||||||
{
|
{
|
||||||
@@ -75,7 +73,7 @@ void parseMQTT(std::string message)
|
|||||||
}
|
}
|
||||||
else if (message == "down")
|
else if (message == "down")
|
||||||
{
|
{
|
||||||
robot.forward(-800);
|
robot.forward(-350);
|
||||||
}
|
}
|
||||||
else if (message == "stop")
|
else if (message == "stop")
|
||||||
{
|
{
|
||||||
@@ -283,9 +281,8 @@ void sendKobukiData(TKobukiData &data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CapnSend() {
|
void CapnSend() {
|
||||||
VideoCapture cap(1); // Open the default camera
|
VideoCapture cap("/dev/media3");
|
||||||
if (!cap.isOpened()) {
|
if (!cap.isOpened()) {
|
||||||
cerr << "Error: Could not open camera" << endl;
|
cerr << "Error: Could not open camera" << endl;
|
||||||
return;
|
return;
|
||||||
@@ -305,8 +302,9 @@ void CapnSend() {
|
|||||||
auto* enc_msg = reinterpret_cast<unsigned char*>(buf.data());
|
auto* enc_msg = reinterpret_cast<unsigned char*>(buf.data());
|
||||||
|
|
||||||
// Publish the image 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;
|
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