Merge remote-tracking branch 'origin/main'

This commit is contained in:
Allan Cueff
2024-04-19 23:07:33 +02:00
2 changed files with 5 additions and 3 deletions

View File

@@ -332,7 +332,7 @@ void Localization::handleMessage(const std::string &message) {
if (contains(verb, "stop")) {
this->started = false;
}
if (contains(verb, "set position")) {
if (contains(verb, "set pos")) {
vector<string> position = split(data, ",");
this->setRobotPosition(stoi(position[0]), stoi(position[1]), stoi(position[2]));
}
@@ -349,4 +349,4 @@ void Localization::handleMessage(const std::string &message) {
void Localization::sendProximityAlert(int distance, int angle) {
this->sendMessage("all", "stop proximity", to_string(distance) + "," + to_string(angle));
}
}

View File

@@ -25,8 +25,9 @@ int main(int argc, char* argv[]) {
}
Localization localizer(-1, -1, -1, "127.0.0.1", port);
localizer.start();
localizer.sendMessage("strat", "ready", "1");
//LIDAR connection
sl::Result<sl::IChannel *> channel = sl::createSerialPortChannel("/dev/ttyUSB0", 115200);
sl::Result<sl::IChannel *> channel = sl::createSerialPortChannel("/dev/USB_LIDAR", 115200);
sl::ILidarDriver *drv = *sl::createLidarDriver();
auto res = drv->connect(*channel);
if (SL_IS_OK(res)) {
@@ -36,6 +37,7 @@ int main(int argc, char* argv[]) {
op_result = drv->getHealth(healthinfo);
if (SL_IS_OK(op_result)) {
localizer.setLidarHealth(true);
localizer.sendMessage("strat", "ready", "1");
}
signal(SIGINT, stop_loop);
while(true){